Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: tools/cc-frame-viewer/src/lthi_view.js

Issue 12287014: [cc-frame-viewer] Show layers and levels of detail (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/cc-frame-viewer/src/lthi_view.css ('k') | tools/cc-frame-viewer/src/model.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 'use strict'; 5 'use strict';
6 6
7 base.require('ui'); 7 base.require('ui');
8 base.require('ui.list_view'); 8 base.require('ui.list_view');
9 base.require('quad_view_viewport'); 9 base.require('quad_view_viewport');
10 base.require('tree_quad_view'); 10 base.require('tree_quad_view');
11 base.require('layer_tree_impl_view');
11 base.requireStylesheet('lthi_view'); 12 base.requireStylesheet('lthi_view');
12 13
13 base.exportTo('ccfv', function() { 14 base.exportTo('ccfv', function() {
14 15
15 var TreeQuadView = ccfv.TreeQuadView; 16 var TreeQuadView = ccfv.TreeQuadView;
16 17
17 var LTHIView = ui.define('x-lthi-view'); 18 var LTHIView = ui.define('x-lthi-view');
18 19
19 LTHIView.prototype = { 20 LTHIView.prototype = {
20 __proto__: HTMLUnknownElement.prototype, 21 __proto__: HTMLUnknownElement.prototype,
21 22
22 decorate: function() { 23 decorate: function() {
23 this.lthi_ = undefined; 24 this.lthi_ = undefined;
24 this.trees_ = document.createElement('x-trees'); 25 this.quadViews_ = document.createElement('x-quad-views');
25 26
26 this.viewport_ = undefined; 27 this.viewport_ = undefined;
27 28
28 var optionsEl = document.createElement('x-frame-view-options'); 29 var optionsEl = document.createElement('x-lthi-view-options');
29 30
30 this.colorMapSelector_ = document.createElement('select'); 31 this.colorMapSelector_ = document.createElement('select');
31 this.colorMapSelector_.addEventListener( 32 this.colorMapSelector_.addEventListener(
32 'change', this.onColorMapChanged_.bind(this)); 33 'change', this.onColorMapChanged_.bind(this));
33 ccfv.ALL_TILE_COLOR_MAPS.forEach(function(colorMap) { 34 ccfv.ALL_TILE_COLOR_MAPS.forEach(function(colorMap) {
34 var mapOption = document.createElement('option'); 35 var mapOption = document.createElement('option');
35 mapOption.textContent = colorMap.title; 36 mapOption.textContent = colorMap.title;
36 mapOption.colorMap = colorMap; 37 mapOption.colorMap = colorMap;
37 this.colorMapSelector_.appendChild(mapOption); 38 this.colorMapSelector_.appendChild(mapOption);
38 }.bind(this)); 39 }.bind(this));
39 optionsEl.appendChild(ui.createSpan('Color map:')); 40 optionsEl.appendChild(ui.createSpan('Color map:'));
40 optionsEl.appendChild(this.colorMapSelector_); 41 optionsEl.appendChild(this.colorMapSelector_);
41 42
42 this.scaleSelector_ = document.createElement('select'); 43 this.scaleSelector_ = document.createElement('select');
43 this.scaleSelector_.addEventListener( 44 this.scaleSelector_.addEventListener(
44 'change', this.onScaleChanged_.bind(this)); 45 'change', this.onScaleChanged_.bind(this));
45 [1/32., 1/16., 1/8., 1/4, 1/2, 1].forEach(function(scale) { 46 [1/32., 1/16., 1/8., 1/4, 1/2, 1].forEach(function(scale) {
46 var mapOption = document.createElement('option'); 47 var mapOption = document.createElement('option');
47 mapOption.textContent = Math.floor(scale * 100) + '%'; 48 mapOption.textContent = Math.floor(scale * 100) + '%';
48 mapOption.scale = scale; 49 mapOption.scale = scale;
49 this.scaleSelector_.appendChild(mapOption); 50 this.scaleSelector_.appendChild(mapOption);
50 }.bind(this)); 51 }.bind(this));
51 this.scaleSelector_.selectedIndex = 3; 52 this.scaleSelector_.selectedIndex = 3;
52 optionsEl.appendChild(ui.createSpan('Scale:')); 53 optionsEl.appendChild(ui.createSpan('Scale:'));
53 optionsEl.appendChild(this.scaleSelector_); 54 optionsEl.appendChild(this.scaleSelector_);
54 55
56 this.treePerContentScale_ = document.createElement('input');
57 this.treePerContentScale_.type = 'checkbox';
58 this.treePerContentScale_.textContent = 'bar';
59 this.treePerContentScale_.addEventListener(
60 'change', this.onTreePerContentScaleChanged_.bind(this));
61 optionsEl.appendChild(
62 ui.createLabel('Split apart scale:', this.treePerContentScale_));
63
55 this.headerTextEl_ = document.createElement('span'); 64 this.headerTextEl_ = document.createElement('span');
56 optionsEl.appendChild(ui.createSpan('Details:')); 65 optionsEl.appendChild(ui.createSpan('Details:'));
57 optionsEl.appendChild(this.headerTextEl_); 66 optionsEl.appendChild(this.headerTextEl_);
58 67
59
60 this.activeTreeQuadView_ = new TreeQuadView();
61 this.pendingTreeQuadView_ = new TreeQuadView();
62 this.inactiveTileView_ = new InactiveTileView(); 68 this.inactiveTileView_ = new InactiveTileView();
63 69
64 this.onSelectionChanged_ = this.onSelectionChanged_.bind(this); 70 this.onSelectionChanged_ = this.onSelectionChanged_.bind(this);
65 this.activeTreeQuadView_.addEventListener('selection-changed', 71
66 this.onSelectionChanged_);
67 this.pendingTreeQuadView_.addEventListener('selection-changed',
68 this.onSelectionChanged_);
69 this.inactiveTileView_.addEventListener('selection-changed', 72 this.inactiveTileView_.addEventListener('selection-changed',
70 this.onSelectionChanged_); 73 this.onSelectionChanged_);
71 74
72 this.trees_.appendChild(this.activeTreeQuadView_); 75 this.activeLayerTreeImplView_ = new ccfv.LayerTreeImplView();
73 this.trees_.appendChild(this.pendingTreeQuadView_); 76 this.activeLayerTreeImplView_.header = 'Active layers';
77
74 this.appendChild(optionsEl); 78 this.appendChild(optionsEl);
75 this.appendChild(this.trees_); 79 this.appendChild(this.quadViews_);
76 this.appendChild(this.inactiveTileView_); 80 this.appendChild(this.inactiveTileView_);
81 this.appendChild(this.activeLayerTreeImplView_);
77 }, 82 },
78 83
79 get lthi() { 84 get lthi() {
80 return this.lthi_; 85 return this.lthi_;
81 }, 86 },
82 87
83 set lthi(lthi) { 88 set lthi(lthi) {
84 this.lthi_ = lthi; 89 this.lthi_ = lthi;
85 this.updateChildren_(); 90 this.updateChildren_();
86 }, 91 },
87 92
88 onColorMapChanged_: function() { 93 onColorMapChanged_: function() {
89 this.activeTreeQuadView_.colorMap = 94 for (var i = 0; i < this.quadViews_.children.length; i++) {
90 this.colorMapSelector_.selectedOptions[0].colorMap; 95 this.quadViews_.children[i].colorMap =
91 this.pendingTreeQuadView_.colorMap = 96 this.colorMapSelector_.selectedOptions[0].colorMap;
92 this.colorMapSelector_.selectedOptions[0].colorMap; 97 }
93 }, 98 },
94 99
95 onScaleChanged_: function() { 100 onScaleChanged_: function() {
96 if (this.viewport_.scale) 101 if (this.viewport_.scale)
97 this.viewport_.scale = this.scaleSelector_.selectedOptions[0].scale; 102 this.viewport_.scale = this.scaleSelector_.selectedOptions[0].scale;
98 }, 103 },
99 104
105 onTreePerContentScaleChanged_: function() {
106 this.updateChildren_();
107 },
108
100 updateChildren_: function() { 109 updateChildren_: function() {
101 var lthi = this.lthi_; 110 var lthi = this.lthi_;
102 if (!lthi) { 111 if (!lthi) {
103 this.activeTreeQuadView_.tree = undefined; 112 for (var i = 0; i < this.quadViews_.children.length; i++) {
104 this.pendingTreeQuadView_.tree = undefined; 113 this.quadViews_.children[i].tree = undefined;
114 this.quadViews_.children[i].removeEventListener('selection-changed',
115 this.onSelectionChanged_);
116 }
117 this.quadViews_.textContent = '';
105 this.viewport_ = undefined; 118 this.viewport_ = undefined;
119 this.activeLayerTreeImplView_.layerTreeImpl = undefined;
106 return; 120 return;
107 } 121 }
108 122
123 this.quadViews_.textContent = '';
124
109 var bbox = lthi.history.allTilesBBox; 125 var bbox = lthi.history.allTilesBBox;
110 if (!this.viewport_) { 126 if (bbox.isEmpty)
111 if (!bbox.isEmpty) { 127 return;
112 this.viewport_ = new ccfv.QuadViewViewport( 128
113 bbox); 129 this.viewport_ = new ccfv.QuadViewViewport(
114 this.viewport_.scale = this.scaleSelector_.selectedOptions[0].scale; 130 bbox);
115 this.activeTreeQuadView_.viewport = this.viewport_; 131 this.viewport_.scale = this.scaleSelector_.selectedOptions[0].scale;
116 this.pendingTreeQuadView_.viewport = this.viewport_; 132
117 } else { 133
118 return; 134 // Make the trees.
119 } 135 var quadViews;
136 function makeForTree(tree, treePrefix) {
137 var tilesByContentsScale = {};
138 tree.tiles.forEach(function(tile) {
139 var cs = tile.history.contentsScale;
140 if (tilesByContentsScale[cs] === undefined)
141 tilesByContentsScale[cs] = [];
142 tilesByContentsScale[cs].push(tile);
143 }, this);
144 base.dictionaryKeys(tilesByContentsScale).forEach(function(cs) {
145 var qv = new TreeQuadView();
146 var csRounded = Math.floor(cs * 10) / 10;
147 qv.headerPrefix = treePrefix + ' @ cs=' + csRounded;
148 qv.which_tree = tree.which_tree;
149 qv.tiles = tilesByContentsScale[cs];
150 quadViews.push(qv);
151 }, this);
120 } 152 }
121 153
122 this.activeTreeQuadView_.which_tree = lthi.activeTree.which_tree; 154 if (this.treePerContentScale_.checked) {
123 this.activeTreeQuadView_.tiles = lthi.activeTree.tiles;
124 this.activeTreeQuadView_.headerText =
125 'Active Tree: ' + lthi.activeTree.tiles.length + ' live tiles';
126 this.activeTreeQuadView_.deviceViewportSizeForFrame =
127 lthi.deviceViewportSize;
128 155
129 this.pendingTreeQuadView_.which_tree = lthi.pendingTree.which_tree; 156 quadViews = [];
130 this.pendingTreeQuadView_.tiles = lthi.pendingTree.tiles; 157 makeForTree(lthi.activeTree, 'Active Tree Tiles');
131 this.pendingTreeQuadView_.headerText = 158 makeForTree(lthi.pendingTree, 'Pending Tree Tiles');
132 'Pending Tree: ' + lthi.pendingTree.tiles.length + ' live tiles'; 159 } else {
133 this.pendingTreeQuadView_.deviceViewportSizeForFrame = 160 var aQuadView = new TreeQuadView();
134 lthi.deviceViewportSize; 161 aQuadView.headerPrefix = 'Active Tree Tiles';
162 aQuadView.which_tree = lthi.activeTree.which_tree;
163 aQuadView.tiles = lthi.activeTree.tiles;
164
165 var pQuadView = new TreeQuadView();
166 pQuadView.headerPrefix = 'Pending Tree Tiles';
167 pQuadView.which_tree = lthi.pendingTree.which_tree;
168 pQuadView.tiles = lthi.pendingTree.tiles;
169
170 quadViews = [aQuadView, pQuadView];
171 }
172
173 quadViews.forEach(function(qv) {
174 qv.viewport = this.viewport_;
175 qv.addEventListener('selection-changed',
176 this.onSelectionChanged_);
177 this.quadViews_.appendChild(qv);
178 qv.deviceViewportSizeForFrame = lthi.deviceViewportSize;
179 qv.headerText =
180 qv.headerPrefix + ': ' + qv.tiles.length + ' tiles';
181 qv.colorMap = this.colorMapSelector_.selectedOptions[0].colorMap;
182 }, this);
183
184
135 185
136 this.headerTextEl_.textContent = lthi.inactiveTiles.length + 186 this.headerTextEl_.textContent = lthi.inactiveTiles.length +
137 ' inactive tiles'; 187 ' inactive tiles';
138 this.inactiveTileView_.tiles = lthi.inactiveTiles; 188 this.inactiveTileView_.tiles = lthi.inactiveTiles;
189
190
191 this.activeLayerTreeImplView_.layerTreeImpl = this.lthi_.activeTree;
139 }, 192 },
140 193
141 onSelectionChanged_: function(e) { 194 onSelectionChanged_: function(e) {
142 var e2 = new base.Event('selection-changed'); 195 var e2 = new base.Event('selection-changed');
143 e2.selection = e.selection; 196 e2.selection = e.selection;
144 this.dispatchEvent(e2); 197 this.dispatchEvent(e2);
145 return true; 198 return true;
146 } 199 }
147 }; 200 };
148 201
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 this.dispatchEvent(e); 306 this.dispatchEvent(e);
254 } 307 }
255 } 308 }
256 309
257 return { 310 return {
258 LTHIView: LTHIView, 311 LTHIView: LTHIView,
259 InactiveTileView: InactiveTileView, 312 InactiveTileView: InactiveTileView,
260 } 313 }
261 }); 314 });
262 315
OLDNEW
« no previous file with comments | « tools/cc-frame-viewer/src/lthi_view.css ('k') | tools/cc-frame-viewer/src/model.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698