1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
base.require('tracing.analysis.generic_object_view');
base.require('tracing.analysis.analyze_selection');
base.require('tracing.analysis.analysis_results');
base.exportTo('cc', function() {
var tsRound = tracing.analysis.tsRound;
var GenericObjectViewWithLabel = tracing.analysis.GenericObjectViewWithLabel;
function Selection() {
this.selectionToSetIfClicked = undefined;
};
Selection.prototype = {
/**
* When two things are picked in the UI, one must occasionally tie-break
* between them to decide what was really clicked. Things with higher
* specicifity will win.
*/
get specicifity() {
throw new Error('Not implemented');
},
/**
* If a selection is related to a specific layer, then this returns the
* layerId of that layer. If the selection is not related to a layer, for
* example if the device viewport is selected, then this returns undefined.
*/
get associatedLayerId() {
throw new Error('Not implemented');
},
/**
* If a selection is related to a specific render pass, then this returns
* the layerId of that layer. If the selection is not related to a layer,
* for example if the device viewport is selected, then this returns
* undefined.
*/
get associatedRenderPassId() {
throw new Error('Not implemented');
},
/**
* If the selected item(s) is visible on the pending tree in a way that
* should be highlighted, returns the quad for the item on the pending tree.
* Otherwise, returns undefined.
*/
get quadIfPending() {
throw new Error('Not implemented');
},
/**
* If the selected item(s) is visible on the active tree in a way that
* should be highlighted, returns the quad for the item on the active tree.
* Otherwise, returns undefined.
*/
get quadIfActive() {
throw new Error('Not implemented');
},
/**
* A stable string describing what is selected. Used to determine a stable
* color of the highlight quads for this selection.
*/
get title() {
throw new Error('Not implemented');
},
/**
* Called when the selection is made active in the layer view. Must return
* an HTMLElement that explains this selection in detail.
*/
createAnalysis: function() {
throw new Error('Not implemented');
},
/**
* Should try to create the equivalent selection in the provided LTHI,
* or undefined if it can't be done.
*/
findEquivalent: function(lthi) {
throw new Error('Not implemented');
}
};
/**
* @constructor
*/
function RenderPassSelection(renderPass, renderPassId) {
if (!renderPass || (renderPassId === undefined))
throw new Error('Render pass (with id) is required');
this.renderPass_ = renderPass;
this.renderPassId_ = renderPassId;
}
RenderPassSelection.prototype = {
__proto__: Selection.prototype,
get specicifity() {
return 1;
},
get associatedLayerId() {
return undefined;
},
get associatedRenderPassId() {
return this.renderPassId_;
},
get renderPass() {
return this.renderPass_;
},
createAnalysis: function() {
var dataView = new GenericObjectViewWithLabel();
dataView.label = 'RenderPass ' + this.renderPassId_;
dataView.object = this.renderPass_.args;
return dataView;
},
get title() {
return this.renderPass_.objectInstance.typeName;
}
};
/**
* @constructor
*/
function LayerSelection(layer) {
if (!layer)
throw new Error('Layer is required');
this.layer_ = layer;
}
LayerSelection.prototype = {
__proto__: Selection.prototype,
get specicifity() {
return 1;
},
get associatedLayerId() {
return this.layer_.layerId;
},
get associatedRenderPassId() {
return undefined;
},
get quadIfPending() {
return undefined;
},
get quadIfActive() {
return undefined;
},
get layer() {
return this.layer_;
},
createAnalysis: function() {
var dataView = new GenericObjectViewWithLabel();
dataView.label = 'Layer ' + this.layer_.layerId;
dataView.object = this.layer_.args;
return dataView;
},
get title() {
return this.layer_.objectInstance.typeName;
},
findEquivalent: function(lthi) {
var layer = lthi.activeTree.findLayerWithId(this.layer_.layerId) ||
lthi.pendingTree.findLayerWithId(this.layer_.layerId);
if (!layer)
return undefined;
return new LayerSelection(layer);
}
};
/**
* @constructor
*/
function TileSelection(tile) {
this.tile_ = tile;
}
TileSelection.prototype = {
__proto__: Selection.prototype,
get specicifity() {
return 2;
},
get associatedLayerId() {
return this.tile_.layerId;
},
get layerRect() {
return this.tile_.layerRect;
},
createAnalysis: function() {
var analysis = new GenericObjectViewWithLabel();
analysis.label = 'Tile ' + this.tile_.objectInstance.id + ' on layer ' +
this.tile_.layerId;
analysis.object = this.tile_.args;
return analysis;
},
get title() {
return this.tile_.objectInstance.typeName;
},
findEquivalent: function(lthi) {
var tileInstance = this.tile_.tileInstance;
if (lthi.ts < tileInstance.creationTs ||
lthi.ts >= tileInstance.deletionTs)
return undefined;
var tileSnapshot = tileInstance.getSnapshotAt(lthi.ts);
if (!tileSnapshot)
return undefined;
return new TileSelection(tileSnapshot);
}
};
/**
* @constructor
*/
function LayerRectSelection(layer, rectType, rect, opt_data) {
this.layer_ = layer;
this.rectType_ = rectType;
this.rect_ = rect;
this.data_ = opt_data !== undefined ? opt_data : rect;
}
LayerRectSelection.prototype = {
__proto__: Selection.prototype,
get specicifity() {
return 2;
},
get associatedLayerId() {
return this.layer_.layerId;
},
get layerRect() {
return this.rect_;
},
createAnalysis: function() {
var analysis = new GenericObjectViewWithLabel();
analysis.label = this.rectType_ + ' on layer ' + this.layer_.layerId;
analysis.object = this.data_;
return analysis;
},
get title() {
return this.rectType_;
},
findEquivalent: function(lthi) {
return undefined;
}
};
/**
* @constructor
*/
function RasterTaskSelection(rasterTask) {
this.rasterTask_ = rasterTask;
}
RasterTaskSelection.prototype = {
__proto__: Selection.prototype,
get specicifity() {
return 3;
},
get tile() {
return this.rasterTask_.args.data.tile_id;
},
get associatedLayerId() {
return this.tile.layerId;
},
get layerRect() {
return this.tile.layerRect;
},
createAnalysis: function() {
var sel = new tracing.Selection();
sel.push(this.rasterTask_);
var analysis = new tracing.analysis.AnalysisResults();
tracing.analysis.analyzeSelection(analysis, sel);
return analysis;
},
get title() {
return this.rasterTask_.title;
},
findEquivalent: function(lthi) {
// Raster tasks are only valid in one LTHI.
return undefined;
}
};
return {
Selection: Selection,
RenderPassSelection: RenderPassSelection,
LayerSelection: LayerSelection,
TileSelection: TileSelection,
LayerRectSelection: LayerRectSelection,
RasterTaskSelection: RasterTaskSelection
};
});
|