Chris Craik | beca7ae | 2015-04-07 13:29:55 -0700 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <!-- |
| 3 | Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 4 | Use of this source code is governed by a BSD-style license that can be |
| 5 | found in the LICENSE file. |
| 6 | --> |
| 7 | |
| 8 | <link rel="import" href="/core/analysis/analysis_sub_view.html"> |
| 9 | <link rel="import" href="/core/analysis/multi_event_sub_view.html"> |
Chris Craik | 44c2820 | 2015-05-12 17:25:16 -0700 | [diff] [blame^] | 10 | <link rel="import" href="/core/analysis/flow_classifier.html"> |
| 11 | <link rel="import" href="/core/analysis/related_flows.html"> |
Chris Craik | beca7ae | 2015-04-07 13:29:55 -0700 | [diff] [blame] | 12 | |
| 13 | <polymer-element name="tv-c-a-multi-thread-slice-sub-view" |
| 14 | extends="tracing-analysis-sub-view"> |
| 15 | <template> |
| 16 | <style> |
| 17 | :host { |
| 18 | display: flex; |
| 19 | } |
| 20 | #content { |
| 21 | display: flex; |
| 22 | flex: 1 1 auto; |
| 23 | } |
Chris Craik | 44c2820 | 2015-05-12 17:25:16 -0700 | [diff] [blame^] | 24 | #content > tv-c-a-related-flows { |
| 25 | margin-left: 8px; |
| 26 | } |
Chris Craik | beca7ae | 2015-04-07 13:29:55 -0700 | [diff] [blame] | 27 | </style> |
| 28 | <div id="content"></div> |
| 29 | </template> |
| 30 | |
| 31 | <script> |
| 32 | 'use strict'; |
| 33 | |
| 34 | Polymer({ |
| 35 | created: function() { |
| 36 | this.selection_ = undefined; |
| 37 | }, |
| 38 | |
| 39 | get selection() { |
| 40 | return this.selection_; |
| 41 | }, |
| 42 | |
| 43 | set selection(selection) { |
| 44 | this.selection_ = selection; |
| 45 | |
| 46 | // TODO(nduca): This is a gross hack for cc Frame Viewer, but its only |
| 47 | // the frame viewer that needs this feature, so ~shrug~. |
| 48 | if (window.RasterTaskView !== undefined) { // May not have been imported. |
| 49 | if (tv.e.cc.RasterTaskSelection.supports(selection)) { |
| 50 | var ltvSelection = new tv.e.cc.RasterTaskSelection(selection); |
| 51 | |
| 52 | var ltv = new tv.e.cc.LayerTreeHostImplSnapshotView(); |
| 53 | ltv.objectSnapshot = ltvSelection.containingSnapshot; |
| 54 | ltv.selection = ltvSelection; |
| 55 | ltv.extraHighlightsByLayerId = ltvSelection.extraHighlightsByLayerId; |
| 56 | |
| 57 | this.$.content.textContent = ''; |
| 58 | this.$.content.appendChild(ltv); |
| 59 | |
| 60 | this.requiresTallView_ = true; |
| 61 | return; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | this.$.content.textContent = ''; |
| 66 | |
| 67 | var mesv = document.createElement('tv-c-a-multi-event-sub-view'); |
| 68 | mesv.selection = selection; |
| 69 | this.$.content.appendChild(mesv); |
Chris Craik | 44c2820 | 2015-05-12 17:25:16 -0700 | [diff] [blame^] | 70 | |
| 71 | var fc = new tv.c.analysis.FlowClassifier(); |
| 72 | selection.forEach(function(slice) { |
| 73 | slice.inFlowEvents.forEach(function(flow) { |
| 74 | fc.addInFlow(flow); |
| 75 | }); |
| 76 | slice.outFlowEvents.forEach(function(flow) { |
| 77 | fc.addOutFlow(flow); |
| 78 | }); |
| 79 | }); |
| 80 | if (fc.hasEvents) { |
| 81 | var rflows = document.createElement('tv-c-a-related-flows'); |
| 82 | rflows.setFlows( |
| 83 | fc.inFlowEvents, fc.outFlowEvents, fc.internalFlowEvents); |
| 84 | this.$.content.appendChild(rflows); |
| 85 | } |
Chris Craik | beca7ae | 2015-04-07 13:29:55 -0700 | [diff] [blame] | 86 | }, |
| 87 | |
| 88 | get requiresTallView() { |
| 89 | if (this.$.content.children.length === 0) |
| 90 | return false; |
| 91 | var childTagName = this.$.content.children[0].tagName; |
| 92 | if (childTagName === 'TV-C-A-MULTI-EVENT-SUB-VIEW') |
| 93 | return false; |
| 94 | |
| 95 | // Using raster task view. |
| 96 | return true; |
| 97 | } |
| 98 | }); |
| 99 | </script> |
Chris Craik | 44c2820 | 2015-05-12 17:25:16 -0700 | [diff] [blame^] | 100 | </polymer-element> |