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.
8 <link rel="import" href="/tracing/analysis/generic_object_view.html">
13 tv.exportTo('cc', function() {
14 var tsRound = tracing.analysis.tsRound;
16 var GenericObjectViewWithLabel = tracing.analysis.GenericObjectViewWithLabel;
18 function Selection() {
19 this.selectionToSetIfClicked = undefined;
21 Selection.prototype = {
23 * When two things are picked in the UI, one must occasionally tie-break
24 * between them to decide what was really clicked. Things with higher
25 * specicifity will win.
28 throw new Error('Not implemented');
32 * If a selection is related to a specific layer, then this returns the
33 * layerId of that layer. If the selection is not related to a layer, for
34 * example if the device viewport is selected, then this returns undefined.
36 get associatedLayerId() {
37 throw new Error('Not implemented');
41 * If a selection is related to a specific render pass, then this returns
42 * the layerId of that layer. If the selection is not related to a layer,
43 * for example if the device viewport is selected, then this returns
46 get associatedRenderPassId() {
47 throw new Error('Not implemented');
51 get highlightsByLayerId() {
56 * Called when the selection is made active in the layer view. Must return
57 * an HTMLElement that explains this selection in detail.
59 createAnalysis: function() {
60 throw new Error('Not implemented');
64 * Should try to create the equivalent selection in the provided LTHI,
65 * or undefined if it can't be done.
67 findEquivalent: function(lthi) {
68 throw new Error('Not implemented');
75 function RenderPassSelection(renderPass, renderPassId) {
76 if (!renderPass || (renderPassId === undefined))
77 throw new Error('Render pass (with id) is required');
78 this.renderPass_ = renderPass;
79 this.renderPassId_ = renderPassId;
82 RenderPassSelection.prototype = {
83 __proto__: Selection.prototype,
89 get associatedLayerId() {
93 get associatedRenderPassId() {
94 return this.renderPassId_;
98 return this.renderPass_;
101 createAnalysis: function() {
102 var dataView = new GenericObjectViewWithLabel();
103 dataView.label = 'RenderPass ' + this.renderPassId_;
104 dataView.object = this.renderPass_.args;
109 return this.renderPass_.objectInstance.typeName;
116 function LayerSelection(layer) {
118 throw new Error('Layer is required');
122 LayerSelection.prototype = {
123 __proto__: Selection.prototype,
129 get associatedLayerId() {
130 return this.layer_.layerId;
133 get associatedRenderPassId() {
141 createAnalysis: function() {
142 var dataView = new GenericObjectViewWithLabel();
143 dataView.label = 'Layer ' + this.layer_.layerId;
144 if (this.layer_.usingGpuRasterization)
145 dataView.label += ' (GPU-rasterized)';
146 dataView.object = this.layer_.args;
151 return this.layer_.objectInstance.typeName;
154 findEquivalent: function(lthi) {
155 var layer = lthi.activeTree.findLayerWithId(this.layer_.layerId) ||
156 lthi.pendingTree.findLayerWithId(this.layer_.layerId);
159 return new LayerSelection(layer);
166 function TileSelection(tile, opt_data) {
168 this.data_ = opt_data || {};
171 TileSelection.prototype = {
172 __proto__: Selection.prototype,
178 get associatedLayerId() {
179 return this.tile_.layerId;
182 get highlightsByLayerId() {
184 highlights[this.tile_.layerId] = [
186 colorKey: this.tile_.objectInstance.typeName,
187 rect: this.tile_.layerRect
193 createAnalysis: function() {
194 var analysis = new GenericObjectViewWithLabel();
195 analysis.label = 'Tile ' + this.tile_.objectInstance.id + ' on layer ' +
199 moreInfo: this.data_,
200 tileArgs: this.tile_.args,
203 analysis.object = this.tile_.args;
208 findEquivalent: function(lthi) {
209 var tileInstance = this.tile_.tileInstance;
210 if (lthi.ts < tileInstance.creationTs ||
211 lthi.ts >= tileInstance.deletionTs)
213 var tileSnapshot = tileInstance.getSnapshotAt(lthi.ts);
216 return new TileSelection(tileSnapshot);
223 function LayerRectSelection(layer, rectType, rect, opt_data) {
225 this.rectType_ = rectType;
227 this.data_ = opt_data !== undefined ? opt_data : rect;
230 LayerRectSelection.prototype = {
231 __proto__: Selection.prototype,
237 get associatedLayerId() {
238 return this.layer_.layerId;
242 get highlightsByLayerId() {
244 highlights[this.layer_.layerId] = [
246 colorKey: this.rectType_,
253 createAnalysis: function() {
254 var analysis = new GenericObjectViewWithLabel();
255 analysis.label = this.rectType_ + ' on layer ' + this.layer_.layerId;
256 analysis.object = this.data_;
260 findEquivalent: function(lthi) {
268 function AnimationRectSelection(layer, rect) {
273 AnimationRectSelection.prototype = {
274 __proto__: Selection.prototype,
280 get associatedLayerId() {
281 return this.layer_.layerId;
284 createAnalysis: function() {
285 var analysis = new GenericObjectViewWithLabel();
286 analysis.label = 'Animation Bounds of layer ' + this.layer_.layerId;
287 analysis.object = this.rect_;
293 Selection: Selection,
294 RenderPassSelection: RenderPassSelection,
295 LayerSelection: LayerSelection,
296 TileSelection: TileSelection,
297 LayerRectSelection: LayerRectSelection,
298 AnimationRectSelection: AnimationRectSelection,