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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/layer_viewer/Layers3DView.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 /** 30 /**
31 * @implements {WebInspector.LayerView} 31 * @implements {LayerViewer.LayerView}
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.Layers3DView = class extends WebInspector.VBox { 34 LayerViewer.Layers3DView = class extends UI.VBox {
35 /** 35 /**
36 * @param {!WebInspector.LayerViewHost} layerViewHost 36 * @param {!LayerViewer.LayerViewHost} layerViewHost
37 */ 37 */
38 constructor(layerViewHost) { 38 constructor(layerViewHost) {
39 super(true); 39 super(true);
40 this.registerRequiredCSS('layer_viewer/layers3DView.css'); 40 this.registerRequiredCSS('layer_viewer/layers3DView.css');
41 this.contentElement.classList.add('layers-3d-view'); 41 this.contentElement.classList.add('layers-3d-view');
42 this._failBanner = new WebInspector.VBox(); 42 this._failBanner = new UI.VBox();
43 this._failBanner.element.classList.add('full-widget-dimmed-banner'); 43 this._failBanner.element.classList.add('full-widget-dimmed-banner');
44 this._failBanner.element.createTextChild(WebInspector.UIString('Layer inform ation is not yet available.')); 44 this._failBanner.element.createTextChild(Common.UIString('Layer information is not yet available.'));
45 45
46 this._layerViewHost = layerViewHost; 46 this._layerViewHost = layerViewHost;
47 this._layerViewHost.registerView(this); 47 this._layerViewHost.registerView(this);
48 48
49 this._transformController = new WebInspector.TransformController(this.conten tElement); 49 this._transformController = new LayerViewer.TransformController(this.content Element);
50 this._transformController.addEventListener( 50 this._transformController.addEventListener(
51 WebInspector.TransformController.Events.TransformChanged, this._update, this); 51 LayerViewer.TransformController.Events.TransformChanged, this._update, t his);
52 this._initToolbar(); 52 this._initToolbar();
53 53
54 this._canvasElement = this.contentElement.createChild('canvas'); 54 this._canvasElement = this.contentElement.createChild('canvas');
55 this._canvasElement.tabIndex = 0; 55 this._canvasElement.tabIndex = 0;
56 this._canvasElement.addEventListener('dblclick', this._onDoubleClick.bind(th is), false); 56 this._canvasElement.addEventListener('dblclick', this._onDoubleClick.bind(th is), false);
57 this._canvasElement.addEventListener('mousedown', this._onMouseDown.bind(thi s), false); 57 this._canvasElement.addEventListener('mousedown', this._onMouseDown.bind(thi s), false);
58 this._canvasElement.addEventListener('mouseup', this._onMouseUp.bind(this), false); 58 this._canvasElement.addEventListener('mouseup', this._onMouseUp.bind(this), false);
59 this._canvasElement.addEventListener('mouseleave', this._onMouseMove.bind(th is), false); 59 this._canvasElement.addEventListener('mouseleave', this._onMouseMove.bind(th is), false);
60 this._canvasElement.addEventListener('mousemove', this._onMouseMove.bind(thi s), false); 60 this._canvasElement.addEventListener('mousemove', this._onMouseMove.bind(thi s), false);
61 this._canvasElement.addEventListener('contextmenu', this._onContextMenu.bind (this), false); 61 this._canvasElement.addEventListener('contextmenu', this._onContextMenu.bind (this), false);
62 62
63 this._lastSelection = {}; 63 this._lastSelection = {};
64 this._layerTree = null; 64 this._layerTree = null;
65 65
66 this._textureManager = new WebInspector.LayerTextureManager(this._update.bin d(this)); 66 this._textureManager = new LayerViewer.LayerTextureManager(this._update.bind (this));
67 67
68 /** @type Array.<!WebGLTexture|undefined> */ 68 /** @type Array.<!WebGLTexture|undefined> */
69 this._chromeTextures = []; 69 this._chromeTextures = [];
70 this._rects = []; 70 this._rects = [];
71 71
72 this._layerViewHost.showInternalLayersSetting().addChangeListener(this._upda te, this); 72 this._layerViewHost.showInternalLayersSetting().addChangeListener(this._upda te, this);
73 } 73 }
74 74
75 /** 75 /**
76 * @param {?WebInspector.LayerTreeBase} layerTree 76 * @param {?SDK.LayerTreeBase} layerTree
77 * @override 77 * @override
78 */ 78 */
79 setLayerTree(layerTree) { 79 setLayerTree(layerTree) {
80 this._layerTree = layerTree; 80 this._layerTree = layerTree;
81 this._layerTexture = null; 81 this._layerTexture = null;
82 delete this._oldTextureScale; 82 delete this._oldTextureScale;
83 if (this._showPaints()) 83 if (this._showPaints())
84 this._textureManager.setLayerTree(layerTree); 84 this._textureManager.setLayerTree(layerTree);
85 this._update(); 85 this._update();
86 } 86 }
87 87
88 /** 88 /**
89 * @param {!WebInspector.Layer} layer 89 * @param {!SDK.Layer} layer
90 * @param {string=} imageURL 90 * @param {string=} imageURL
91 */ 91 */
92 showImageForLayer(layer, imageURL) { 92 showImageForLayer(layer, imageURL) {
93 if (!imageURL) { 93 if (!imageURL) {
94 this._layerTexture = null; 94 this._layerTexture = null;
95 this._update(); 95 this._update();
96 return; 96 return;
97 } 97 }
98 WebInspector.loadImage(imageURL).then(image => { 98 UI.loadImage(imageURL).then(image => {
99 var texture = image && WebInspector.LayerTextureManager._createTextureForI mage(this._gl, image); 99 var texture = image && LayerViewer.LayerTextureManager._createTextureForIm age(this._gl, image);
100 this._layerTexture = texture ? {layer: layer, texture: texture} : null; 100 this._layerTexture = texture ? {layer: layer, texture: texture} : null;
101 this._update(); 101 this._update();
102 }); 102 });
103 } 103 }
104 104
105 /** 105 /**
106 * @override 106 * @override
107 */ 107 */
108 onResize() { 108 onResize() {
109 this._resizeCanvas(); 109 this._resizeCanvas();
(...skipping 12 matching lines...) Expand all
122 */ 122 */
123 wasShown() { 123 wasShown() {
124 this._textureManager.resume(); 124 this._textureManager.resume();
125 if (!this._needsUpdate) 125 if (!this._needsUpdate)
126 return; 126 return;
127 this._resizeCanvas(); 127 this._resizeCanvas();
128 this._update(); 128 this._update();
129 } 129 }
130 130
131 /** 131 /**
132 * @param {!WebInspector.Layer} layer 132 * @param {!SDK.Layer} layer
133 */ 133 */
134 updateLayerSnapshot(layer) { 134 updateLayerSnapshot(layer) {
135 this._textureManager.layerNeedsUpdate(layer); 135 this._textureManager.layerNeedsUpdate(layer);
136 } 136 }
137 137
138 /** 138 /**
139 * @param {!WebInspector.Layers3DView.OutlineType} type 139 * @param {!LayerViewer.Layers3DView.OutlineType} type
140 * @param {?WebInspector.LayerView.Selection} selection 140 * @param {?LayerViewer.LayerView.Selection} selection
141 */ 141 */
142 _setOutline(type, selection) { 142 _setOutline(type, selection) {
143 this._lastSelection[type] = selection; 143 this._lastSelection[type] = selection;
144 this._update(); 144 this._update();
145 } 145 }
146 146
147 /** 147 /**
148 * @param {?WebInspector.LayerView.Selection} selection 148 * @param {?LayerViewer.LayerView.Selection} selection
149 * @override 149 * @override
150 */ 150 */
151 hoverObject(selection) { 151 hoverObject(selection) {
152 this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered, selection); 152 this._setOutline(LayerViewer.Layers3DView.OutlineType.Hovered, selection);
153 } 153 }
154 154
155 /** 155 /**
156 * @param {?WebInspector.LayerView.Selection} selection 156 * @param {?LayerViewer.LayerView.Selection} selection
157 * @override 157 * @override
158 */ 158 */
159 selectObject(selection) { 159 selectObject(selection) {
160 this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered, null); 160 this._setOutline(LayerViewer.Layers3DView.OutlineType.Hovered, null);
161 this._setOutline(WebInspector.Layers3DView.OutlineType.Selected, selection); 161 this._setOutline(LayerViewer.Layers3DView.OutlineType.Selected, selection);
162 } 162 }
163 163
164 /** 164 /**
165 * @param {!WebInspector.LayerView.Selection} selection 165 * @param {!LayerViewer.LayerView.Selection} selection
166 * @return {!Promise<?WebInspector.SnapshotWithRect>} 166 * @return {!Promise<?SDK.SnapshotWithRect>}
167 */ 167 */
168 snapshotForSelection(selection) { 168 snapshotForSelection(selection) {
169 if (selection.type() === WebInspector.LayerView.Selection.Type.Snapshot) { 169 if (selection.type() === LayerViewer.LayerView.Selection.Type.Snapshot) {
170 var snapshotWithRect = /** @type {!WebInspector.LayerView.SnapshotSelectio n} */ (selection).snapshot(); 170 var snapshotWithRect = /** @type {!LayerViewer.LayerView.SnapshotSelection } */ (selection).snapshot();
171 snapshotWithRect.snapshot.addReference(); 171 snapshotWithRect.snapshot.addReference();
172 return /** @type {!Promise<?WebInspector.SnapshotWithRect>} */ (Promise.re solve(snapshotWithRect)); 172 return /** @type {!Promise<?SDK.SnapshotWithRect>} */ (Promise.resolve(sna pshotWithRect));
173 } 173 }
174 if (selection.layer()) { 174 if (selection.layer()) {
175 var promise = selection.layer().snapshots()[0]; 175 var promise = selection.layer().snapshots()[0];
176 if (promise) 176 if (promise)
177 return promise; 177 return promise;
178 } 178 }
179 return /** @type {!Promise<?WebInspector.SnapshotWithRect>} */ (Promise.reso lve(null)); 179 return /** @type {!Promise<?SDK.SnapshotWithRect>} */ (Promise.resolve(null) );
180 } 180 }
181 181
182 /** 182 /**
183 * @param {!Element} canvas 183 * @param {!Element} canvas
184 * @return {?WebGLRenderingContext} 184 * @return {?WebGLRenderingContext}
185 */ 185 */
186 _initGL(canvas) { 186 _initGL(canvas) {
187 var gl = canvas.getContext('webgl'); 187 var gl = canvas.getContext('webgl');
188 if (!gl) 188 if (!gl)
189 return null; 189 return null;
(...skipping 10 matching lines...) Expand all
200 */ 200 */
201 _createShader(type, script) { 201 _createShader(type, script) {
202 var shader = this._gl.createShader(type); 202 var shader = this._gl.createShader(type);
203 this._gl.shaderSource(shader, script); 203 this._gl.shaderSource(shader, script);
204 this._gl.compileShader(shader); 204 this._gl.compileShader(shader);
205 this._gl.attachShader(this._shaderProgram, shader); 205 this._gl.attachShader(this._shaderProgram, shader);
206 } 206 }
207 207
208 _initShaders() { 208 _initShaders() {
209 this._shaderProgram = this._gl.createProgram(); 209 this._shaderProgram = this._gl.createProgram();
210 this._createShader(this._gl.FRAGMENT_SHADER, WebInspector.Layers3DView.Fragm entShader); 210 this._createShader(this._gl.FRAGMENT_SHADER, LayerViewer.Layers3DView.Fragme ntShader);
211 this._createShader(this._gl.VERTEX_SHADER, WebInspector.Layers3DView.VertexS hader); 211 this._createShader(this._gl.VERTEX_SHADER, LayerViewer.Layers3DView.VertexSh ader);
212 this._gl.linkProgram(this._shaderProgram); 212 this._gl.linkProgram(this._shaderProgram);
213 this._gl.useProgram(this._shaderProgram); 213 this._gl.useProgram(this._shaderProgram);
214 214
215 this._shaderProgram.vertexPositionAttribute = this._gl.getAttribLocation(thi s._shaderProgram, 'aVertexPosition'); 215 this._shaderProgram.vertexPositionAttribute = this._gl.getAttribLocation(thi s._shaderProgram, 'aVertexPosition');
216 this._gl.enableVertexAttribArray(this._shaderProgram.vertexPositionAttribute ); 216 this._gl.enableVertexAttribArray(this._shaderProgram.vertexPositionAttribute );
217 this._shaderProgram.vertexColorAttribute = this._gl.getAttribLocation(this._ shaderProgram, 'aVertexColor'); 217 this._shaderProgram.vertexColorAttribute = this._gl.getAttribLocation(this._ shaderProgram, 'aVertexColor');
218 this._gl.enableVertexAttribArray(this._shaderProgram.vertexColorAttribute); 218 this._gl.enableVertexAttribArray(this._shaderProgram.vertexColorAttribute);
219 this._shaderProgram.textureCoordAttribute = this._gl.getAttribLocation(this. _shaderProgram, 'aTextureCoord'); 219 this._shaderProgram.textureCoordAttribute = this._gl.getAttribLocation(this. _shaderProgram, 'aTextureCoord');
220 this._gl.enableVertexAttribArray(this._shaderProgram.textureCoordAttribute); 220 this._gl.enableVertexAttribArray(this._shaderProgram.textureCoordAttribute);
221 221
(...skipping 26 matching lines...) Expand all
248 10 / viewScale); // 1/viewScale is 1:1 in terms of pixels, so allow zoo ming to 10x of native size 248 10 / viewScale); // 1/viewScale is 1:1 in terms of pixels, so allow zoo ming to 10x of native size
249 var scale = this._transformController.scale(); 249 var scale = this._transformController.scale();
250 var rotateX = this._transformController.rotateX(); 250 var rotateX = this._transformController.rotateX();
251 var rotateY = this._transformController.rotateY(); 251 var rotateY = this._transformController.rotateY();
252 252
253 this._scale = scale * viewScale; 253 this._scale = scale * viewScale;
254 var textureScale = Number.constrain(this._scale, 0.1, 1); 254 var textureScale = Number.constrain(this._scale, 0.1, 1);
255 if (textureScale !== this._oldTextureScale) { 255 if (textureScale !== this._oldTextureScale) {
256 this._oldTextureScale = textureScale; 256 this._oldTextureScale = textureScale;
257 this._textureManager.setScale(textureScale); 257 this._textureManager.setScale(textureScale);
258 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.ScaleChange d, textureScale); 258 this.dispatchEventToListeners(LayerViewer.Layers3DView.Events.ScaleChanged , textureScale);
259 } 259 }
260 var scaleAndRotationMatrix = new WebKitCSSMatrix() 260 var scaleAndRotationMatrix = new WebKitCSSMatrix()
261 .scale(scale, scale, scale) 261 .scale(scale, scale, scale)
262 .translate(canvasWidth / 2, canvasHeight / 2, 0) 262 .translate(canvasWidth / 2, canvasHeight / 2, 0)
263 .rotate(rotateX, rotateY, 0) 263 .rotate(rotateX, rotateY, 0)
264 .scale(viewScale, viewScale, viewScale) 264 .scale(viewScale, viewScale, viewScale)
265 .translate(-baseWidth / 2, -baseHeight / 2, 0); 265 .translate(-baseWidth / 2, -baseHeight / 2, 0);
266 266
267 var bounds; 267 var bounds;
268 for (var i = 0; i < this._rects.length; ++i) 268 for (var i = 0; i < this._rects.length; ++i)
269 bounds = 269 bounds =
270 WebInspector.Geometry.boundsForTransformedPoints(scaleAndRotationMatri x, this._rects[i].vertices, bounds); 270 Common.Geometry.boundsForTransformedPoints(scaleAndRotationMatrix, thi s._rects[i].vertices, bounds);
271 271
272 this._transformController.clampOffsets( 272 this._transformController.clampOffsets(
273 (paddingX - bounds.maxX) / window.devicePixelRatio, 273 (paddingX - bounds.maxX) / window.devicePixelRatio,
274 (canvasWidth - paddingX - bounds.minX) / window.devicePixelRatio, 274 (canvasWidth - paddingX - bounds.minX) / window.devicePixelRatio,
275 (paddingY - bounds.maxY) / window.devicePixelRatio, 275 (paddingY - bounds.maxY) / window.devicePixelRatio,
276 (canvasHeight - paddingY - bounds.minY) / window.devicePixelRatio); 276 (canvasHeight - paddingY - bounds.minY) / window.devicePixelRatio);
277 var offsetX = this._transformController.offsetX() * window.devicePixelRatio; 277 var offsetX = this._transformController.offsetX() * window.devicePixelRatio;
278 var offsetY = this._transformController.offsetY() * window.devicePixelRatio; 278 var offsetY = this._transformController.offsetY() * window.devicePixelRatio;
279 // Multiply to translation matrix on the right rather than translate (which would implicitly multiply on the left). 279 // Multiply to translation matrix on the right rather than translate (which would implicitly multiply on the left).
280 this._projectionMatrix = new WebKitCSSMatrix().translate(offsetX, offsetY, 0 ).multiply(scaleAndRotationMatrix); 280 this._projectionMatrix = new WebKitCSSMatrix().translate(offsetX, offsetY, 0 ).multiply(scaleAndRotationMatrix);
(...skipping 19 matching lines...) Expand all
300 _initWhiteTexture() { 300 _initWhiteTexture() {
301 this._whiteTexture = this._gl.createTexture(); 301 this._whiteTexture = this._gl.createTexture();
302 this._gl.bindTexture(this._gl.TEXTURE_2D, this._whiteTexture); 302 this._gl.bindTexture(this._gl.TEXTURE_2D, this._whiteTexture);
303 var whitePixel = new Uint8Array([255, 255, 255, 255]); 303 var whitePixel = new Uint8Array([255, 255, 255, 255]);
304 this._gl.texImage2D( 304 this._gl.texImage2D(
305 this._gl.TEXTURE_2D, 0, this._gl.RGBA, 1, 1, 0, this._gl.RGBA, this._gl. UNSIGNED_BYTE, whitePixel); 305 this._gl.TEXTURE_2D, 0, this._gl.RGBA, 1, 1, 0, this._gl.RGBA, this._gl. UNSIGNED_BYTE, whitePixel);
306 } 306 }
307 307
308 _initChromeTextures() { 308 _initChromeTextures() {
309 /** 309 /**
310 * @this {WebInspector.Layers3DView} 310 * @this {LayerViewer.Layers3DView}
311 * @param {!WebInspector.Layers3DView.ChromeTexture} index 311 * @param {!LayerViewer.Layers3DView.ChromeTexture} index
312 * @param {string} url 312 * @param {string} url
313 */ 313 */
314 function loadChromeTexture(index, url) { 314 function loadChromeTexture(index, url) {
315 WebInspector.loadImage(url).then(image => { 315 UI.loadImage(url).then(image => {
316 this._chromeTextures[index] = 316 this._chromeTextures[index] =
317 image && WebInspector.LayerTextureManager._createTextureForImage(thi s._gl, image) || undefined; 317 image && LayerViewer.LayerTextureManager._createTextureForImage(this ._gl, image) || undefined;
318 }); 318 });
319 } 319 }
320 loadChromeTexture.call(this, WebInspector.Layers3DView.ChromeTexture.Left, ' Images/chromeLeft.png'); 320 loadChromeTexture.call(this, LayerViewer.Layers3DView.ChromeTexture.Left, 'I mages/chromeLeft.png');
321 loadChromeTexture.call(this, WebInspector.Layers3DView.ChromeTexture.Middle, 'Images/chromeMiddle.png'); 321 loadChromeTexture.call(this, LayerViewer.Layers3DView.ChromeTexture.Middle, 'Images/chromeMiddle.png');
322 loadChromeTexture.call(this, WebInspector.Layers3DView.ChromeTexture.Right, 'Images/chromeRight.png'); 322 loadChromeTexture.call(this, LayerViewer.Layers3DView.ChromeTexture.Right, ' Images/chromeRight.png');
323 } 323 }
324 324
325 /** 325 /**
326 * @return {?WebGLRenderingContext} 326 * @return {?WebGLRenderingContext}
327 */ 327 */
328 _initGLIfNecessary() { 328 _initGLIfNecessary() {
329 if (this._gl) 329 if (this._gl)
330 return this._gl; 330 return this._gl;
331 this._gl = this._initGL(this._canvasElement); 331 this._gl = this._initGL(this._canvasElement);
332 if (!this._gl) 332 if (!this._gl)
333 return null; 333 return null;
334 this._initShaders(); 334 this._initShaders();
335 this._initWhiteTexture(); 335 this._initWhiteTexture();
336 this._initChromeTextures(); 336 this._initChromeTextures();
337 this._textureManager.setContext(this._gl); 337 this._textureManager.setContext(this._gl);
338 return this._gl; 338 return this._gl;
339 } 339 }
340 340
341 _calculateDepthsAndVisibility() { 341 _calculateDepthsAndVisibility() {
342 this._depthByLayerId = {}; 342 this._depthByLayerId = {};
343 var depth = 0; 343 var depth = 0;
344 var showInternalLayers = this._layerViewHost.showInternalLayersSetting().get (); 344 var showInternalLayers = this._layerViewHost.showInternalLayersSetting().get ();
345 var root = showInternalLayers ? this._layerTree.root() : (this._layerTree.co ntentRoot() || this._layerTree.root()); 345 var root = showInternalLayers ? this._layerTree.root() : (this._layerTree.co ntentRoot() || this._layerTree.root());
346 var queue = [root]; 346 var queue = [root];
347 this._depthByLayerId[root.id()] = 0; 347 this._depthByLayerId[root.id()] = 0;
348 /** @type {!Set<!WebInspector.Layer>} */ 348 /** @type {!Set<!SDK.Layer>} */
349 this._visibleLayers = new Set(); 349 this._visibleLayers = new Set();
350 while (queue.length > 0) { 350 while (queue.length > 0) {
351 var layer = queue.shift(); 351 var layer = queue.shift();
352 if (showInternalLayers || layer.drawsContent()) 352 if (showInternalLayers || layer.drawsContent())
353 this._visibleLayers.add(layer); 353 this._visibleLayers.add(layer);
354 var children = layer.children(); 354 var children = layer.children();
355 for (var i = 0; i < children.length; ++i) { 355 for (var i = 0; i < children.length; ++i) {
356 this._depthByLayerId[children[i].id()] = ++depth; 356 this._depthByLayerId[children[i].id()] = ++depth;
357 queue.push(children[i]); 357 queue.push(children[i]);
358 } 358 }
359 } 359 }
360 this._maxDepth = depth; 360 this._maxDepth = depth;
361 } 361 }
362 362
363 /** 363 /**
364 * @param {!WebInspector.Layer} layer 364 * @param {!SDK.Layer} layer
365 * @return {number} 365 * @return {number}
366 */ 366 */
367 _depthForLayer(layer) { 367 _depthForLayer(layer) {
368 return this._depthByLayerId[layer.id()] * WebInspector.Layers3DView.LayerSpa cing; 368 return this._depthByLayerId[layer.id()] * LayerViewer.Layers3DView.LayerSpac ing;
369 } 369 }
370 370
371 /** 371 /**
372 * @param {!WebInspector.Layer} layer 372 * @param {!SDK.Layer} layer
373 * @param {number} index 373 * @param {number} index
374 * @return {number} 374 * @return {number}
375 */ 375 */
376 _calculateScrollRectDepth(layer, index) { 376 _calculateScrollRectDepth(layer, index) {
377 return this._depthForLayer(layer) + index * WebInspector.Layers3DView.Scroll RectSpacing + 1; 377 return this._depthForLayer(layer) + index * LayerViewer.Layers3DView.ScrollR ectSpacing + 1;
378 } 378 }
379 379
380 /** 380 /**
381 * @param {!WebInspector.Layer} layer 381 * @param {!SDK.Layer} layer
382 */ 382 */
383 _updateDimensionsForAutoscale(layer) { 383 _updateDimensionsForAutoscale(layer) {
384 // We don't want to be precise, but rather pick something least affected by 384 // We don't want to be precise, but rather pick something least affected by
385 // animationtransforms, so that we don't change scale too often. So let's 385 // animationtransforms, so that we don't change scale too often. So let's
386 // disregard transforms, scrolling and relative layer positioning and choose 386 // disregard transforms, scrolling and relative layer positioning and choose
387 // the largest dimensions of all layers. 387 // the largest dimensions of all layers.
388 this._dimensionsForAutoscale.width = Math.max(layer.width(), this._dimension sForAutoscale.width); 388 this._dimensionsForAutoscale.width = Math.max(layer.width(), this._dimension sForAutoscale.width);
389 this._dimensionsForAutoscale.height = Math.max(layer.height(), this._dimensi onsForAutoscale.height); 389 this._dimensionsForAutoscale.height = Math.max(layer.height(), this._dimensi onsForAutoscale.height);
390 } 390 }
391 391
392 /** 392 /**
393 * @param {!WebInspector.Layer} layer 393 * @param {!SDK.Layer} layer
394 */ 394 */
395 _calculateLayerRect(layer) { 395 _calculateLayerRect(layer) {
396 if (!this._visibleLayers.has(layer)) 396 if (!this._visibleLayers.has(layer))
397 return; 397 return;
398 var selection = new WebInspector.LayerView.LayerSelection(layer); 398 var selection = new LayerViewer.LayerView.LayerSelection(layer);
399 var rect = new WebInspector.Layers3DView.Rectangle(selection); 399 var rect = new LayerViewer.Layers3DView.Rectangle(selection);
400 rect.setVertices(layer.quad(), this._depthForLayer(layer)); 400 rect.setVertices(layer.quad(), this._depthForLayer(layer));
401 this._appendRect(rect); 401 this._appendRect(rect);
402 this._updateDimensionsForAutoscale(layer); 402 this._updateDimensionsForAutoscale(layer);
403 } 403 }
404 404
405 /** 405 /**
406 * @param {!WebInspector.Layers3DView.Rectangle} rect 406 * @param {!LayerViewer.Layers3DView.Rectangle} rect
407 */ 407 */
408 _appendRect(rect) { 408 _appendRect(rect) {
409 var selection = rect.relatedObject; 409 var selection = rect.relatedObject;
410 var isSelected = WebInspector.LayerView.Selection.isEqual( 410 var isSelected = LayerViewer.LayerView.Selection.isEqual(
411 this._lastSelection[WebInspector.Layers3DView.OutlineType.Selected], sel ection); 411 this._lastSelection[LayerViewer.Layers3DView.OutlineType.Selected], sele ction);
412 var isHovered = WebInspector.LayerView.Selection.isEqual( 412 var isHovered = LayerViewer.LayerView.Selection.isEqual(
413 this._lastSelection[WebInspector.Layers3DView.OutlineType.Hovered], sele ction); 413 this._lastSelection[LayerViewer.Layers3DView.OutlineType.Hovered], selec tion);
414 if (isSelected) { 414 if (isSelected) {
415 rect.borderColor = WebInspector.Layers3DView.SelectedBorderColor; 415 rect.borderColor = LayerViewer.Layers3DView.SelectedBorderColor;
416 } else if (isHovered) { 416 } else if (isHovered) {
417 rect.borderColor = WebInspector.Layers3DView.HoveredBorderColor; 417 rect.borderColor = LayerViewer.Layers3DView.HoveredBorderColor;
418 var fillColor = rect.fillColor || [255, 255, 255, 1]; 418 var fillColor = rect.fillColor || [255, 255, 255, 1];
419 var maskColor = WebInspector.Layers3DView.HoveredImageMaskColor; 419 var maskColor = LayerViewer.Layers3DView.HoveredImageMaskColor;
420 rect.fillColor = [ 420 rect.fillColor = [
421 fillColor[0] * maskColor[0] / 255, fillColor[1] * maskColor[1] / 255, fi llColor[2] * maskColor[2] / 255, 421 fillColor[0] * maskColor[0] / 255, fillColor[1] * maskColor[1] / 255, fi llColor[2] * maskColor[2] / 255,
422 fillColor[3] * maskColor[3] 422 fillColor[3] * maskColor[3]
423 ]; 423 ];
424 } else { 424 } else {
425 rect.borderColor = WebInspector.Layers3DView.BorderColor; 425 rect.borderColor = LayerViewer.Layers3DView.BorderColor;
426 } 426 }
427 rect.lineWidth = isSelected ? WebInspector.Layers3DView.SelectedBorderWidth : WebInspector.Layers3DView.BorderWidth; 427 rect.lineWidth = isSelected ? LayerViewer.Layers3DView.SelectedBorderWidth : LayerViewer.Layers3DView.BorderWidth;
428 this._rects.push(rect); 428 this._rects.push(rect);
429 } 429 }
430 430
431 /** 431 /**
432 * @param {!WebInspector.Layer} layer 432 * @param {!SDK.Layer} layer
433 */ 433 */
434 _calculateLayerScrollRects(layer) { 434 _calculateLayerScrollRects(layer) {
435 var scrollRects = layer.scrollRects(); 435 var scrollRects = layer.scrollRects();
436 for (var i = 0; i < scrollRects.length; ++i) { 436 for (var i = 0; i < scrollRects.length; ++i) {
437 var selection = new WebInspector.LayerView.ScrollRectSelection(layer, i); 437 var selection = new LayerViewer.LayerView.ScrollRectSelection(layer, i);
438 var rect = new WebInspector.Layers3DView.Rectangle(selection); 438 var rect = new LayerViewer.Layers3DView.Rectangle(selection);
439 rect.calculateVerticesFromRect(layer, scrollRects[i].rect, this._calculate ScrollRectDepth(layer, i)); 439 rect.calculateVerticesFromRect(layer, scrollRects[i].rect, this._calculate ScrollRectDepth(layer, i));
440 rect.fillColor = WebInspector.Layers3DView.ScrollRectBackgroundColor; 440 rect.fillColor = LayerViewer.Layers3DView.ScrollRectBackgroundColor;
441 this._appendRect(rect); 441 this._appendRect(rect);
442 } 442 }
443 } 443 }
444 444
445 /** 445 /**
446 * @param {!WebInspector.Layer} layer 446 * @param {!SDK.Layer} layer
447 */ 447 */
448 _calculateLayerTileRects(layer) { 448 _calculateLayerTileRects(layer) {
449 var tiles = this._textureManager.tilesForLayer(layer); 449 var tiles = this._textureManager.tilesForLayer(layer);
450 for (var i = 0; i < tiles.length; ++i) { 450 for (var i = 0; i < tiles.length; ++i) {
451 var tile = tiles[i]; 451 var tile = tiles[i];
452 if (!tile.texture) 452 if (!tile.texture)
453 continue; 453 continue;
454 var selection = new WebInspector.LayerView.SnapshotSelection(layer, {rect: tile.rect, snapshot: tile.snapshot}); 454 var selection = new LayerViewer.LayerView.SnapshotSelection(layer, {rect: tile.rect, snapshot: tile.snapshot});
455 var rect = new WebInspector.Layers3DView.Rectangle(selection); 455 var rect = new LayerViewer.Layers3DView.Rectangle(selection);
456 rect.calculateVerticesFromRect(layer, tile.rect, this._depthForLayer(layer ) + 1); 456 rect.calculateVerticesFromRect(layer, tile.rect, this._depthForLayer(layer ) + 1);
457 rect.texture = tile.texture; 457 rect.texture = tile.texture;
458 this._appendRect(rect); 458 this._appendRect(rect);
459 } 459 }
460 } 460 }
461 461
462 _calculateRects() { 462 _calculateRects() {
463 this._rects = []; 463 this._rects = [];
464 this._dimensionsForAutoscale = {width: 0, height: 0}; 464 this._dimensionsForAutoscale = {width: 0, height: 0};
465 this._layerTree.forEachLayer(this._calculateLayerRect.bind(this)); 465 this._layerTree.forEachLayer(this._calculateLayerRect.bind(this));
466 466
467 if (this._showSlowScrollRectsSetting.get()) 467 if (this._showSlowScrollRectsSetting.get())
468 this._layerTree.forEachLayer(this._calculateLayerScrollRects.bind(this)); 468 this._layerTree.forEachLayer(this._calculateLayerScrollRects.bind(this));
469 469
470 if (this._layerTexture && this._visibleLayers.has(this._layerTexture.layer)) { 470 if (this._layerTexture && this._visibleLayers.has(this._layerTexture.layer)) {
471 var layer = this._layerTexture.layer; 471 var layer = this._layerTexture.layer;
472 var selection = new WebInspector.LayerView.LayerSelection(layer); 472 var selection = new LayerViewer.LayerView.LayerSelection(layer);
473 var rect = new WebInspector.Layers3DView.Rectangle(selection); 473 var rect = new LayerViewer.Layers3DView.Rectangle(selection);
474 rect.setVertices(layer.quad(), this._depthForLayer(layer)); 474 rect.setVertices(layer.quad(), this._depthForLayer(layer));
475 rect.texture = this._layerTexture.texture; 475 rect.texture = this._layerTexture.texture;
476 this._appendRect(rect); 476 this._appendRect(rect);
477 } else if (this._showPaints()) { 477 } else if (this._showPaints()) {
478 this._layerTree.forEachLayer(this._calculateLayerTileRects.bind(this)); 478 this._layerTree.forEachLayer(this._calculateLayerTileRects.bind(this));
479 } 479 }
480 } 480 }
481 481
482 /** 482 /**
483 * @param {!Array.<number>} color 483 * @param {!Array.<number>} color
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 */ 537 */
538 _drawTexture(vertices, texture, color) { 538 _drawTexture(vertices, texture, color) {
539 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, color, texture); 539 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, color, texture);
540 } 540 }
541 541
542 _drawViewportAndChrome() { 542 _drawViewportAndChrome() {
543 var viewport = this._layerTree.viewportSize(); 543 var viewport = this._layerTree.viewportSize();
544 if (!viewport) 544 if (!viewport)
545 return; 545 return;
546 546
547 var drawChrome = !WebInspector.moduleSetting('frameViewerHideChromeWindow'). get() && 547 var drawChrome = !Common.moduleSetting('frameViewerHideChromeWindow').get() &&
548 this._chromeTextures.length >= 3 && this._chromeTextures.indexOf(undefin ed) < 0; 548 this._chromeTextures.length >= 3 && this._chromeTextures.indexOf(undefin ed) < 0;
549 var z = (this._maxDepth + 1) * WebInspector.Layers3DView.LayerSpacing; 549 var z = (this._maxDepth + 1) * LayerViewer.Layers3DView.LayerSpacing;
550 var borderWidth = Math.ceil(WebInspector.Layers3DView.ViewportBorderWidth * this._scale); 550 var borderWidth = Math.ceil(LayerViewer.Layers3DView.ViewportBorderWidth * t his._scale);
551 var vertices = [viewport.width, 0, z, viewport.width, viewport.height, z, 0, viewport.height, z, 0, 0, z]; 551 var vertices = [viewport.width, 0, z, viewport.width, viewport.height, z, 0, viewport.height, z, 0, 0, z];
552 this._gl.lineWidth(borderWidth); 552 this._gl.lineWidth(borderWidth);
553 this._drawRectangle( 553 this._drawRectangle(
554 vertices, drawChrome ? this._gl.LINE_STRIP : this._gl.LINE_LOOP, WebInsp ector.Layers3DView.ViewportBorderColor); 554 vertices, drawChrome ? this._gl.LINE_STRIP : this._gl.LINE_LOOP, LayerVi ewer.Layers3DView.ViewportBorderColor);
555 555
556 if (!drawChrome) 556 if (!drawChrome)
557 return; 557 return;
558 558
559 var borderAdjustment = WebInspector.Layers3DView.ViewportBorderWidth / 2; 559 var borderAdjustment = LayerViewer.Layers3DView.ViewportBorderWidth / 2;
560 var viewportWidth = this._layerTree.viewportSize().width + 2 * borderAdjustm ent; 560 var viewportWidth = this._layerTree.viewportSize().width + 2 * borderAdjustm ent;
561 var chromeHeight = this._chromeTextures[0].image.naturalHeight; 561 var chromeHeight = this._chromeTextures[0].image.naturalHeight;
562 var middleFragmentWidth = 562 var middleFragmentWidth =
563 viewportWidth - this._chromeTextures[0].image.naturalWidth - this._chrom eTextures[2].image.naturalWidth; 563 viewportWidth - this._chromeTextures[0].image.naturalWidth - this._chrom eTextures[2].image.naturalWidth;
564 var x = -borderAdjustment; 564 var x = -borderAdjustment;
565 var y = -chromeHeight; 565 var y = -chromeHeight;
566 for (var i = 0; i < this._chromeTextures.length; ++i) { 566 for (var i = 0; i < this._chromeTextures.length; ++i) {
567 var width = i === WebInspector.Layers3DView.ChromeTexture.Middle ? middleF ragmentWidth : 567 var width = i === LayerViewer.Layers3DView.ChromeTexture.Middle ? middleFr agmentWidth :
568 this._c hromeTextures[i].image.naturalWidth; 568 this._c hromeTextures[i].image.naturalWidth;
569 if (width < 0 || x + width > viewportWidth) 569 if (width < 0 || x + width > viewportWidth)
570 break; 570 break;
571 vertices = [x, y, z, x + width, y, z, x + width, y + chromeHeight, z, x, y + chromeHeight, z]; 571 vertices = [x, y, z, x + width, y, z, x + width, y + chromeHeight, z, x, y + chromeHeight, z];
572 this._drawTexture(vertices, /** @type {!WebGLTexture} */ (this._chromeText ures[i])); 572 this._drawTexture(vertices, /** @type {!WebGLTexture} */ (this._chromeText ures[i]));
573 x += width; 573 x += width;
574 } 574 }
575 } 575 }
576 576
577 /** 577 /**
578 * @param {!WebInspector.Layers3DView.Rectangle} rect 578 * @param {!LayerViewer.Layers3DView.Rectangle} rect
579 */ 579 */
580 _drawViewRect(rect) { 580 _drawViewRect(rect) {
581 var vertices = rect.vertices; 581 var vertices = rect.vertices;
582 if (rect.texture) 582 if (rect.texture)
583 this._drawTexture(vertices, rect.texture, rect.fillColor || undefined); 583 this._drawTexture(vertices, rect.texture, rect.fillColor || undefined);
584 else if (rect.fillColor) 584 else if (rect.fillColor)
585 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, rect.fillColor); 585 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, rect.fillColor);
586 this._gl.lineWidth(rect.lineWidth); 586 this._gl.lineWidth(rect.lineWidth);
587 if (rect.borderColor) 587 if (rect.borderColor)
588 this._drawRectangle(vertices, this._gl.LINE_LOOP, rect.borderColor); 588 this._drawRectangle(vertices, this._gl.LINE_LOOP, rect.borderColor);
(...skipping 28 matching lines...) Expand all
617 617
618 this._rects.forEach(this._drawViewRect.bind(this)); 618 this._rects.forEach(this._drawViewRect.bind(this));
619 this._drawViewportAndChrome(); 619 this._drawViewportAndChrome();
620 } 620 }
621 621
622 /** 622 /**
623 * @return {!Node} 623 * @return {!Node}
624 */ 624 */
625 _webglDisabledBanner() { 625 _webglDisabledBanner() {
626 var fragment = this.contentElement.ownerDocument.createDocumentFragment(); 626 var fragment = this.contentElement.ownerDocument.createDocumentFragment();
627 fragment.createChild('div').textContent = WebInspector.UIString('Can\'t disp lay layers,'); 627 fragment.createChild('div').textContent = Common.UIString('Can\'t display la yers,');
628 fragment.createChild('div').textContent = WebInspector.UIString('WebGL suppo rt is disabled in your browser.'); 628 fragment.createChild('div').textContent = Common.UIString('WebGL support is disabled in your browser.');
629 fragment.appendChild(WebInspector.formatLocalized( 629 fragment.appendChild(UI.formatLocalized(
630 'Check %s for possible reasons.', [WebInspector.linkifyURLAsNode('about: gpu', undefined, undefined, true)])); 630 'Check %s for possible reasons.', [UI.linkifyURLAsNode('about:gpu', unde fined, undefined, true)]));
631 return fragment; 631 return fragment;
632 } 632 }
633 633
634 /** 634 /**
635 * @param {!Event} event 635 * @param {!Event} event
636 * @return {?WebInspector.LayerView.Selection} 636 * @return {?LayerViewer.LayerView.Selection}
637 */ 637 */
638 _selectionFromEventPoint(event) { 638 _selectionFromEventPoint(event) {
639 if (!this._layerTree) 639 if (!this._layerTree)
640 return null; 640 return null;
641 var closestIntersectionPoint = Infinity; 641 var closestIntersectionPoint = Infinity;
642 var closestObject = null; 642 var closestObject = null;
643 var projectionMatrix = new WebKitCSSMatrix().scale(1, -1, -1).translate(-1, -1, 0).multiply(this._projectionMatrix); 643 var projectionMatrix = new WebKitCSSMatrix().scale(1, -1, -1).translate(-1, -1, 0).multiply(this._projectionMatrix);
644 var x0 = (event.clientX - this._canvasElement.totalOffsetLeft()) * window.de vicePixelRatio; 644 var x0 = (event.clientX - this._canvasElement.totalOffsetLeft()) * window.de vicePixelRatio;
645 var y0 = -(event.clientY - this._canvasElement.totalOffsetTop()) * window.de vicePixelRatio; 645 var y0 = -(event.clientY - this._canvasElement.totalOffsetTop()) * window.de vicePixelRatio;
646 646
647 /** 647 /**
648 * @param {!WebInspector.Layers3DView.Rectangle} rect 648 * @param {!LayerViewer.Layers3DView.Rectangle} rect
649 */ 649 */
650 function checkIntersection(rect) { 650 function checkIntersection(rect) {
651 if (!rect.relatedObject) 651 if (!rect.relatedObject)
652 return; 652 return;
653 var t = rect.intersectWithLine(projectionMatrix, x0, y0); 653 var t = rect.intersectWithLine(projectionMatrix, x0, y0);
654 if (t < closestIntersectionPoint) { 654 if (t < closestIntersectionPoint) {
655 closestIntersectionPoint = t; 655 closestIntersectionPoint = t;
656 closestObject = rect.relatedObject; 656 closestObject = rect.relatedObject;
657 } 657 }
658 } 658 }
659 659
660 this._rects.forEach(checkIntersection); 660 this._rects.forEach(checkIntersection);
661 return closestObject; 661 return closestObject;
662 } 662 }
663 663
664 /** 664 /**
665 * @param {string} caption 665 * @param {string} caption
666 * @param {string} name 666 * @param {string} name
667 * @param {boolean} value 667 * @param {boolean} value
668 * @param {!WebInspector.Toolbar} toolbar 668 * @param {!UI.Toolbar} toolbar
669 * @return {!WebInspector.Setting} 669 * @return {!Common.Setting}
670 */ 670 */
671 _createVisibilitySetting(caption, name, value, toolbar) { 671 _createVisibilitySetting(caption, name, value, toolbar) {
672 var checkbox = new WebInspector.ToolbarCheckbox(WebInspector.UIString(captio n)); 672 var checkbox = new UI.ToolbarCheckbox(Common.UIString(caption));
673 toolbar.appendToolbarItem(checkbox); 673 toolbar.appendToolbarItem(checkbox);
674 var setting = WebInspector.settings.createSetting(name, value); 674 var setting = Common.settings.createSetting(name, value);
675 WebInspector.SettingsUI.bindCheckbox(checkbox.inputElement, setting); 675 UI.SettingsUI.bindCheckbox(checkbox.inputElement, setting);
676 setting.addChangeListener(this._update, this); 676 setting.addChangeListener(this._update, this);
677 return setting; 677 return setting;
678 } 678 }
679 679
680 _initToolbar() { 680 _initToolbar() {
681 this._panelToolbar = this._transformController.toolbar(); 681 this._panelToolbar = this._transformController.toolbar();
682 this.contentElement.appendChild(this._panelToolbar.element); 682 this.contentElement.appendChild(this._panelToolbar.element);
683 this._showSlowScrollRectsSetting = 683 this._showSlowScrollRectsSetting =
684 this._createVisibilitySetting('Slow scroll rects', 'frameViewerShowSlowS crollRects', true, this._panelToolbar); 684 this._createVisibilitySetting('Slow scroll rects', 'frameViewerShowSlowS crollRects', true, this._panelToolbar);
685 this._showPaintsSetting = 685 this._showPaintsSetting =
686 this._createVisibilitySetting('Paints', 'frameViewerShowPaints', true, t his._panelToolbar); 686 this._createVisibilitySetting('Paints', 'frameViewerShowPaints', true, t his._panelToolbar);
687 this._showPaintsSetting.addChangeListener(this._updatePaints, this); 687 this._showPaintsSetting.addChangeListener(this._updatePaints, this);
688 WebInspector.moduleSetting('frameViewerHideChromeWindow').addChangeListener( this._update, this); 688 Common.moduleSetting('frameViewerHideChromeWindow').addChangeListener(this._ update, this);
689 } 689 }
690 690
691 /** 691 /**
692 * @param {!Event} event 692 * @param {!Event} event
693 */ 693 */
694 _onContextMenu(event) { 694 _onContextMenu(event) {
695 var contextMenu = new WebInspector.ContextMenu(event); 695 var contextMenu = new UI.ContextMenu(event);
696 contextMenu.appendItem( 696 contextMenu.appendItem(
697 WebInspector.UIString('Reset View'), this._transformController.resetAndN otify.bind(this._transformController), 697 Common.UIString('Reset View'), this._transformController.resetAndNotify. bind(this._transformController),
698 false); 698 false);
699 var selection = this._selectionFromEventPoint(event); 699 var selection = this._selectionFromEventPoint(event);
700 if (selection && selection.type() === WebInspector.LayerView.Selection.Type. Snapshot) 700 if (selection && selection.type() === LayerViewer.LayerView.Selection.Type.S napshot)
701 contextMenu.appendItem( 701 contextMenu.appendItem(
702 WebInspector.UIString('Show Paint Profiler'), 702 Common.UIString('Show Paint Profiler'),
703 this.dispatchEventToListeners.bind( 703 this.dispatchEventToListeners.bind(
704 this, WebInspector.Layers3DView.Events.PaintProfilerRequested, sel ection.snapshot()), 704 this, LayerViewer.Layers3DView.Events.PaintProfilerRequested, sele ction.snapshot()),
705 false); 705 false);
706 this._layerViewHost.showContextMenu(contextMenu, selection); 706 this._layerViewHost.showContextMenu(contextMenu, selection);
707 } 707 }
708 708
709 /** 709 /**
710 * @param {!Event} event 710 * @param {!Event} event
711 */ 711 */
712 _onMouseMove(event) { 712 _onMouseMove(event) {
713 if (event.which) 713 if (event.which)
714 return; 714 return;
(...skipping 18 matching lines...) Expand all
733 this._layerViewHost.selectObject(this._selectionFromEventPoint(event)); 733 this._layerViewHost.selectObject(this._selectionFromEventPoint(event));
734 delete this._mouseDownX; 734 delete this._mouseDownX;
735 delete this._mouseDownY; 735 delete this._mouseDownY;
736 } 736 }
737 737
738 /** 738 /**
739 * @param {!Event} event 739 * @param {!Event} event
740 */ 740 */
741 _onDoubleClick(event) { 741 _onDoubleClick(event) {
742 var selection = this._selectionFromEventPoint(event); 742 var selection = this._selectionFromEventPoint(event);
743 if (selection && (selection.type() === WebInspector.LayerView.Selection.Type .Snapshot || selection.layer())) 743 if (selection && (selection.type() === LayerViewer.LayerView.Selection.Type. Snapshot || selection.layer()))
744 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.PaintProfil erRequested, selection); 744 this.dispatchEventToListeners(LayerViewer.Layers3DView.Events.PaintProfile rRequested, selection);
745 event.stopPropagation(); 745 event.stopPropagation();
746 } 746 }
747 747
748 _updatePaints() { 748 _updatePaints() {
749 if (this._showPaints()) { 749 if (this._showPaints()) {
750 this._textureManager.setLayerTree(this._layerTree); 750 this._textureManager.setLayerTree(this._layerTree);
751 this._textureManager.forceUpdate(); 751 this._textureManager.forceUpdate();
752 } else { 752 } else {
753 this._textureManager.reset(); 753 this._textureManager.reset();
754 } 754 }
755 this._update(); 755 this._update();
756 } 756 }
757 757
758 /** 758 /**
759 * @return {boolean} 759 * @return {boolean}
760 */ 760 */
761 _showPaints() { 761 _showPaints() {
762 return this._showPaintsSetting.get(); 762 return this._showPaintsSetting.get();
763 } 763 }
764 }; 764 };
765 765
766 /** @typedef {{borderColor: !Array<number>, borderWidth: number}} */ 766 /** @typedef {{borderColor: !Array<number>, borderWidth: number}} */
767 WebInspector.Layers3DView.LayerStyle; 767 LayerViewer.Layers3DView.LayerStyle;
768 768
769 /** 769 /**
770 * @enum {string} 770 * @enum {string}
771 */ 771 */
772 WebInspector.Layers3DView.OutlineType = { 772 LayerViewer.Layers3DView.OutlineType = {
773 Hovered: 'hovered', 773 Hovered: 'hovered',
774 Selected: 'selected' 774 Selected: 'selected'
775 }; 775 };
776 776
777 /** 777 /**
778 * @enum {string} 778 * @enum {string}
779 */ 779 */
780 /** @enum {symbol} */ 780 /** @enum {symbol} */
781 WebInspector.Layers3DView.Events = { 781 LayerViewer.Layers3DView.Events = {
782 PaintProfilerRequested: Symbol('PaintProfilerRequested'), 782 PaintProfilerRequested: Symbol('PaintProfilerRequested'),
783 ScaleChanged: Symbol('ScaleChanged') 783 ScaleChanged: Symbol('ScaleChanged')
784 }; 784 };
785 785
786 /** 786 /**
787 * @enum {number} 787 * @enum {number}
788 */ 788 */
789 WebInspector.Layers3DView.ChromeTexture = { 789 LayerViewer.Layers3DView.ChromeTexture = {
790 Left: 0, 790 Left: 0,
791 Middle: 1, 791 Middle: 1,
792 Right: 2 792 Right: 2
793 }; 793 };
794 794
795 /** 795 /**
796 * @enum {string} 796 * @enum {string}
797 */ 797 */
798 WebInspector.Layers3DView.ScrollRectTitles = { 798 LayerViewer.Layers3DView.ScrollRectTitles = {
799 RepaintsOnScroll: WebInspector.UIString('repaints on scroll'), 799 RepaintsOnScroll: Common.UIString('repaints on scroll'),
800 TouchEventHandler: WebInspector.UIString('touch event listener'), 800 TouchEventHandler: Common.UIString('touch event listener'),
801 WheelEventHandler: WebInspector.UIString('mousewheel event listener') 801 WheelEventHandler: Common.UIString('mousewheel event listener')
802 }; 802 };
803 803
804 WebInspector.Layers3DView.FragmentShader = '' + 804 LayerViewer.Layers3DView.FragmentShader = '' +
805 'precision mediump float;\n' + 805 'precision mediump float;\n' +
806 'varying vec4 vColor;\n' + 806 'varying vec4 vColor;\n' +
807 'varying vec2 vTextureCoord;\n' + 807 'varying vec2 vTextureCoord;\n' +
808 'uniform sampler2D uSampler;\n' + 808 'uniform sampler2D uSampler;\n' +
809 'void main(void)\n' + 809 'void main(void)\n' +
810 '{\n' + 810 '{\n' +
811 ' gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord. t)) * vColor;\n' + 811 ' gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord. t)) * vColor;\n' +
812 '}'; 812 '}';
813 813
814 WebInspector.Layers3DView.VertexShader = '' + 814 LayerViewer.Layers3DView.VertexShader = '' +
815 'attribute vec3 aVertexPosition;\n' + 815 'attribute vec3 aVertexPosition;\n' +
816 'attribute vec2 aTextureCoord;\n' + 816 'attribute vec2 aTextureCoord;\n' +
817 'attribute vec4 aVertexColor;\n' + 817 'attribute vec4 aVertexColor;\n' +
818 'uniform mat4 uPMatrix;\n' + 818 'uniform mat4 uPMatrix;\n' +
819 'varying vec2 vTextureCoord;\n' + 819 'varying vec2 vTextureCoord;\n' +
820 'varying vec4 vColor;\n' + 820 'varying vec4 vColor;\n' +
821 'void main(void)\n' + 821 'void main(void)\n' +
822 '{\n' + 822 '{\n' +
823 'gl_Position = uPMatrix * vec4(aVertexPosition, 1.0);\n' + 823 'gl_Position = uPMatrix * vec4(aVertexPosition, 1.0);\n' +
824 'vColor = aVertexColor;\n' + 824 'vColor = aVertexColor;\n' +
825 'vTextureCoord = aTextureCoord;\n' + 825 'vTextureCoord = aTextureCoord;\n' +
826 '}'; 826 '}';
827 827
828 WebInspector.Layers3DView.HoveredBorderColor = [0, 0, 255, 1]; 828 LayerViewer.Layers3DView.HoveredBorderColor = [0, 0, 255, 1];
829 WebInspector.Layers3DView.SelectedBorderColor = [0, 255, 0, 1]; 829 LayerViewer.Layers3DView.SelectedBorderColor = [0, 255, 0, 1];
830 WebInspector.Layers3DView.BorderColor = [0, 0, 0, 1]; 830 LayerViewer.Layers3DView.BorderColor = [0, 0, 0, 1];
831 WebInspector.Layers3DView.ViewportBorderColor = [160, 160, 160, 1]; 831 LayerViewer.Layers3DView.ViewportBorderColor = [160, 160, 160, 1];
832 WebInspector.Layers3DView.ScrollRectBackgroundColor = [178, 100, 100, 0.6]; 832 LayerViewer.Layers3DView.ScrollRectBackgroundColor = [178, 100, 100, 0.6];
833 WebInspector.Layers3DView.HoveredImageMaskColor = [200, 200, 255, 1]; 833 LayerViewer.Layers3DView.HoveredImageMaskColor = [200, 200, 255, 1];
834 WebInspector.Layers3DView.BorderWidth = 1; 834 LayerViewer.Layers3DView.BorderWidth = 1;
835 WebInspector.Layers3DView.SelectedBorderWidth = 2; 835 LayerViewer.Layers3DView.SelectedBorderWidth = 2;
836 WebInspector.Layers3DView.ViewportBorderWidth = 3; 836 LayerViewer.Layers3DView.ViewportBorderWidth = 3;
837 837
838 WebInspector.Layers3DView.LayerSpacing = 20; 838 LayerViewer.Layers3DView.LayerSpacing = 20;
839 WebInspector.Layers3DView.ScrollRectSpacing = 4; 839 LayerViewer.Layers3DView.ScrollRectSpacing = 4;
840 840
841 /** 841 /**
842 * @unrestricted 842 * @unrestricted
843 */ 843 */
844 WebInspector.LayerTextureManager = class { 844 LayerViewer.LayerTextureManager = class {
845 /** 845 /**
846 * @param {function()} textureUpdatedCallback 846 * @param {function()} textureUpdatedCallback
847 */ 847 */
848 constructor(textureUpdatedCallback) { 848 constructor(textureUpdatedCallback) {
849 this._textureUpdatedCallback = textureUpdatedCallback; 849 this._textureUpdatedCallback = textureUpdatedCallback;
850 this._throttler = new WebInspector.Throttler(0); 850 this._throttler = new Common.Throttler(0);
851 this._scale = 0; 851 this._scale = 0;
852 this._active = false; 852 this._active = false;
853 this.reset(); 853 this.reset();
854 } 854 }
855 855
856 /** 856 /**
857 * @param {!Image} image 857 * @param {!Image} image
858 * @param {!WebGLRenderingContext} gl 858 * @param {!WebGLRenderingContext} gl
859 * @return {!WebGLTexture} texture 859 * @return {!WebGLTexture} texture
860 */ 860 */
861 static _createTextureForImage(gl, image) { 861 static _createTextureForImage(gl, image) {
862 var texture = gl.createTexture(); 862 var texture = gl.createTexture();
863 texture.image = image; 863 texture.image = image;
864 gl.bindTexture(gl.TEXTURE_2D, texture); 864 gl.bindTexture(gl.TEXTURE_2D, texture);
865 gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1); 865 gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
866 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture. image); 866 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture. image);
867 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); 867 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
868 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); 868 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
869 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); 869 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
870 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); 870 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
871 gl.bindTexture(gl.TEXTURE_2D, null); 871 gl.bindTexture(gl.TEXTURE_2D, null);
872 return texture; 872 return texture;
873 } 873 }
874 874
875 reset() { 875 reset() {
876 if (this._tilesByLayer) 876 if (this._tilesByLayer)
877 this.setLayerTree(null); 877 this.setLayerTree(null);
878 878
879 /** @type {!Map<!WebInspector.Layer, !Array<!WebInspector.LayerTextureManage r.Tile>>} */ 879 /** @type {!Map<!SDK.Layer, !Array<!LayerViewer.LayerTextureManager.Tile>>} */
880 this._tilesByLayer = new Map(); 880 this._tilesByLayer = new Map();
881 /** @type {!Array<!WebInspector.Layer>} */ 881 /** @type {!Array<!SDK.Layer>} */
882 this._queue = []; 882 this._queue = [];
883 } 883 }
884 884
885 /** 885 /**
886 * @param {!WebGLRenderingContext} glContext 886 * @param {!WebGLRenderingContext} glContext
887 */ 887 */
888 setContext(glContext) { 888 setContext(glContext) {
889 this._gl = glContext; 889 this._gl = glContext;
890 if (this._scale) 890 if (this._scale)
891 this._updateTextures(); 891 this._updateTextures();
892 } 892 }
893 893
894 suspend() { 894 suspend() {
895 this._active = false; 895 this._active = false;
896 } 896 }
897 897
898 resume() { 898 resume() {
899 this._active = true; 899 this._active = true;
900 if (this._queue.length) 900 if (this._queue.length)
901 this._update(); 901 this._update();
902 } 902 }
903 903
904 /** 904 /**
905 * @param {?WebInspector.LayerTreeBase} layerTree 905 * @param {?SDK.LayerTreeBase} layerTree
906 */ 906 */
907 setLayerTree(layerTree) { 907 setLayerTree(layerTree) {
908 var newLayers = new Set(); 908 var newLayers = new Set();
909 var oldLayers = Array.from(this._tilesByLayer.keys()); 909 var oldLayers = Array.from(this._tilesByLayer.keys());
910 if (layerTree) { 910 if (layerTree) {
911 layerTree.forEachLayer(layer => { 911 layerTree.forEachLayer(layer => {
912 if (!layer.drawsContent()) 912 if (!layer.drawsContent())
913 return; 913 return;
914 newLayers.add(layer); 914 newLayers.add(layer);
915 if (!this._tilesByLayer.has(layer)) { 915 if (!this._tilesByLayer.has(layer)) {
916 this._tilesByLayer.set(layer, []); 916 this._tilesByLayer.set(layer, []);
917 this.layerNeedsUpdate(layer); 917 this.layerNeedsUpdate(layer);
918 } 918 }
919 }); 919 });
920 } 920 }
921 if (!oldLayers.length) 921 if (!oldLayers.length)
922 this.forceUpdate(); 922 this.forceUpdate();
923 for (var layer of oldLayers) { 923 for (var layer of oldLayers) {
924 if (newLayers.has(layer)) 924 if (newLayers.has(layer))
925 continue; 925 continue;
926 this._tilesByLayer.get(layer).forEach(tile => tile.dispose()); 926 this._tilesByLayer.get(layer).forEach(tile => tile.dispose());
927 this._tilesByLayer.delete(layer); 927 this._tilesByLayer.delete(layer);
928 } 928 }
929 } 929 }
930 930
931 /** 931 /**
932 * @param {!WebInspector.Layer} layer 932 * @param {!SDK.Layer} layer
933 * @param {!Array<!WebInspector.SnapshotWithRect>} snapshots 933 * @param {!Array<!SDK.SnapshotWithRect>} snapshots
934 * @return {!Promise} 934 * @return {!Promise}
935 */ 935 */
936 _setSnapshotsForLayer(layer, snapshots) { 936 _setSnapshotsForLayer(layer, snapshots) {
937 var oldSnapshotsToTiles = new Map((this._tilesByLayer.get(layer) || []).map( tile => [tile.snapshot, tile])); 937 var oldSnapshotsToTiles = new Map((this._tilesByLayer.get(layer) || []).map( tile => [tile.snapshot, tile]));
938 var newTiles = []; 938 var newTiles = [];
939 var reusedTiles = []; 939 var reusedTiles = [];
940 for (var snapshot of snapshots) { 940 for (var snapshot of snapshots) {
941 var oldTile = oldSnapshotsToTiles.get(snapshot); 941 var oldTile = oldSnapshotsToTiles.get(snapshot);
942 if (oldTile) { 942 if (oldTile) {
943 reusedTiles.push(oldTile); 943 reusedTiles.push(oldTile);
944 oldSnapshotsToTiles.delete(oldTile); 944 oldSnapshotsToTiles.delete(oldTile);
945 } else { 945 } else {
946 newTiles.push(new WebInspector.LayerTextureManager.Tile(snapshot)); 946 newTiles.push(new LayerViewer.LayerTextureManager.Tile(snapshot));
947 } 947 }
948 } 948 }
949 this._tilesByLayer.set(layer, reusedTiles.concat(newTiles)); 949 this._tilesByLayer.set(layer, reusedTiles.concat(newTiles));
950 for (var tile of oldSnapshotsToTiles.values()) 950 for (var tile of oldSnapshotsToTiles.values())
951 tile.dispose(); 951 tile.dispose();
952 if (!this._gl || !this._scale) 952 if (!this._gl || !this._scale)
953 return Promise.resolve(); 953 return Promise.resolve();
954 return Promise.all(newTiles.map(tile => tile.update(this._gl, this._scale))) .then(this._textureUpdatedCallback); 954 return Promise.all(newTiles.map(tile => tile.update(this._gl, this._scale))) .then(this._textureUpdatedCallback);
955 } 955 }
956 956
957 /** 957 /**
958 * @param {number} scale 958 * @param {number} scale
959 */ 959 */
960 setScale(scale) { 960 setScale(scale) {
961 if (this._scale && this._scale >= scale) 961 if (this._scale && this._scale >= scale)
962 return; 962 return;
963 this._scale = scale; 963 this._scale = scale;
964 this._updateTextures(); 964 this._updateTextures();
965 } 965 }
966 966
967 /** 967 /**
968 * @param {!WebInspector.Layer} layer 968 * @param {!SDK.Layer} layer
969 * @return {!Array<!WebInspector.LayerTextureManager.Tile>} 969 * @return {!Array<!LayerViewer.LayerTextureManager.Tile>}
970 */ 970 */
971 tilesForLayer(layer) { 971 tilesForLayer(layer) {
972 return this._tilesByLayer.get(layer) || []; 972 return this._tilesByLayer.get(layer) || [];
973 } 973 }
974 974
975 /** 975 /**
976 * @param {!WebInspector.Layer} layer 976 * @param {!SDK.Layer} layer
977 */ 977 */
978 layerNeedsUpdate(layer) { 978 layerNeedsUpdate(layer) {
979 if (this._queue.indexOf(layer) < 0) 979 if (this._queue.indexOf(layer) < 0)
980 this._queue.push(layer); 980 this._queue.push(layer);
981 if (this._active) 981 if (this._active)
982 this._throttler.schedule(this._update.bind(this)); 982 this._throttler.schedule(this._update.bind(this));
983 } 983 }
984 984
985 forceUpdate() { 985 forceUpdate() {
986 this._queue.forEach(layer => this._updateLayer(layer)); 986 this._queue.forEach(layer => this._updateLayer(layer));
987 this._queue = []; 987 this._queue = [];
988 this._throttler.flush(); 988 this._throttler.flush();
989 } 989 }
990 990
991 /** 991 /**
992 * @return {!Promise} 992 * @return {!Promise}
993 */ 993 */
994 _update() { 994 _update() {
995 var layer = this._queue.shift(); 995 var layer = this._queue.shift();
996 if (!layer) 996 if (!layer)
997 return Promise.resolve(); 997 return Promise.resolve();
998 if (this._queue.length) 998 if (this._queue.length)
999 this._throttler.schedule(this._update.bind(this)); 999 this._throttler.schedule(this._update.bind(this));
1000 return this._updateLayer(layer); 1000 return this._updateLayer(layer);
1001 } 1001 }
1002 1002
1003 /** 1003 /**
1004 * @param {!WebInspector.Layer} layer 1004 * @param {!SDK.Layer} layer
1005 * @return {!Promise} 1005 * @return {!Promise}
1006 */ 1006 */
1007 _updateLayer(layer) { 1007 _updateLayer(layer) {
1008 return Promise.all(layer.snapshots()) 1008 return Promise.all(layer.snapshots())
1009 .then(snapshots => this._setSnapshotsForLayer(layer, snapshots.filter(sn apshot => !!snapshot))); 1009 .then(snapshots => this._setSnapshotsForLayer(layer, snapshots.filter(sn apshot => !!snapshot)));
1010 } 1010 }
1011 1011
1012 _updateTextures() { 1012 _updateTextures() {
1013 if (!this._gl) 1013 if (!this._gl)
1014 return; 1014 return;
1015 if (!this._scale) 1015 if (!this._scale)
1016 return; 1016 return;
1017 1017
1018 for (var tiles of this._tilesByLayer.values()) { 1018 for (var tiles of this._tilesByLayer.values()) {
1019 for (var tile of tiles) { 1019 for (var tile of tiles) {
1020 var promise = tile.updateScale(this._gl, this._scale); 1020 var promise = tile.updateScale(this._gl, this._scale);
1021 if (promise) 1021 if (promise)
1022 promise.then(this._textureUpdatedCallback); 1022 promise.then(this._textureUpdatedCallback);
1023 } 1023 }
1024 } 1024 }
1025 } 1025 }
1026 }; 1026 };
1027 1027
1028 /** 1028 /**
1029 * @unrestricted 1029 * @unrestricted
1030 */ 1030 */
1031 WebInspector.Layers3DView.Rectangle = class { 1031 LayerViewer.Layers3DView.Rectangle = class {
1032 /** 1032 /**
1033 * @param {?WebInspector.LayerView.Selection} relatedObject 1033 * @param {?LayerViewer.LayerView.Selection} relatedObject
1034 */ 1034 */
1035 constructor(relatedObject) { 1035 constructor(relatedObject) {
1036 this.relatedObject = relatedObject; 1036 this.relatedObject = relatedObject;
1037 /** @type {number} */ 1037 /** @type {number} */
1038 this.lineWidth = 1; 1038 this.lineWidth = 1;
1039 /** @type {?Array.<number>} */ 1039 /** @type {?Array.<number>} */
1040 this.borderColor = null; 1040 this.borderColor = null;
1041 /** @type {?Array.<number>} */ 1041 /** @type {?Array.<number>} */
1042 this.fillColor = null; 1042 this.fillColor = null;
1043 /** @type {?WebGLTexture} */ 1043 /** @type {?WebGLTexture} */
(...skipping 30 matching lines...) Expand all
1074 var firstSidePointY = y0 + ratioX * (y1 - y0); 1074 var firstSidePointY = y0 + ratioX * (y1 - y0);
1075 // Point on the third quad side clockwise 1075 // Point on the third quad side clockwise
1076 var thirdSidePointX = x3 + ratioX * (x2 - x3); 1076 var thirdSidePointX = x3 + ratioX * (x2 - x3);
1077 var thirdSidePointY = y3 + ratioX * (y2 - y3); 1077 var thirdSidePointY = y3 + ratioX * (y2 - y3);
1078 var x = firstSidePointX + ratioY * (thirdSidePointX - firstSidePointX); 1078 var x = firstSidePointX + ratioY * (thirdSidePointX - firstSidePointX);
1079 var y = firstSidePointY + ratioY * (thirdSidePointY - firstSidePointY); 1079 var y = firstSidePointY + ratioY * (thirdSidePointY - firstSidePointY);
1080 return [x, y]; 1080 return [x, y];
1081 } 1081 }
1082 1082
1083 /** 1083 /**
1084 * @param {!WebInspector.Layer} layer 1084 * @param {!SDK.Layer} layer
1085 * @param {!Protocol.DOM.Rect} rect 1085 * @param {!Protocol.DOM.Rect} rect
1086 * @param {number} z 1086 * @param {number} z
1087 */ 1087 */
1088 calculateVerticesFromRect(layer, rect, z) { 1088 calculateVerticesFromRect(layer, rect, z) {
1089 var quad = layer.quad(); 1089 var quad = layer.quad();
1090 var rx1 = rect.x / layer.width(); 1090 var rx1 = rect.x / layer.width();
1091 var rx2 = (rect.x + rect.width) / layer.width(); 1091 var rx2 = (rect.x + rect.width) / layer.width();
1092 var ry1 = rect.y / layer.height(); 1092 var ry1 = rect.y / layer.height();
1093 var ry2 = (rect.y + rect.height) / layer.height(); 1093 var ry2 = (rect.y + rect.height) / layer.height();
1094 var rectQuad = this._calculatePointOnQuad(quad, rx1, ry1) 1094 var rectQuad = this._calculatePointOnQuad(quad, rx1, ry1)
1095 .concat(this._calculatePointOnQuad(quad, rx2, ry1)) 1095 .concat(this._calculatePointOnQuad(quad, rx2, ry1))
1096 .concat(this._calculatePointOnQuad(quad, rx2, ry2)) 1096 .concat(this._calculatePointOnQuad(quad, rx2, ry2))
1097 .concat(this._calculatePointOnQuad(quad, rx1, ry2)); 1097 .concat(this._calculatePointOnQuad(quad, rx1, ry2));
1098 this.setVertices(rectQuad, z); 1098 this.setVertices(rectQuad, z);
1099 } 1099 }
1100 1100
1101 /** 1101 /**
1102 * Intersects quad with given transform matrix and line l(t) = (x0, y0, t) 1102 * Intersects quad with given transform matrix and line l(t) = (x0, y0, t)
1103 * @param {!CSSMatrix} matrix 1103 * @param {!CSSMatrix} matrix
1104 * @param {number} x0 1104 * @param {number} x0
1105 * @param {number} y0 1105 * @param {number} y0
1106 * @return {(number|undefined)} 1106 * @return {(number|undefined)}
1107 */ 1107 */
1108 intersectWithLine(matrix, x0, y0) { 1108 intersectWithLine(matrix, x0, y0) {
1109 var i; 1109 var i;
1110 // Vertices of the quad with transform matrix applied 1110 // Vertices of the quad with transform matrix applied
1111 var points = []; 1111 var points = [];
1112 for (i = 0; i < 4; ++i) 1112 for (i = 0; i < 4; ++i)
1113 points[i] = WebInspector.Geometry.multiplyVectorByMatrixAndNormalize( 1113 points[i] = Common.Geometry.multiplyVectorByMatrixAndNormalize(
1114 new WebInspector.Geometry.Vector(this.vertices[i * 3], this.vertices[i * 3 + 1], this.vertices[i * 3 + 2]), 1114 new Common.Geometry.Vector(this.vertices[i * 3], this.vertices[i * 3 + 1], this.vertices[i * 3 + 2]),
1115 matrix); 1115 matrix);
1116 // Calculating quad plane normal 1116 // Calculating quad plane normal
1117 var normal = WebInspector.Geometry.crossProduct( 1117 var normal = Common.Geometry.crossProduct(
1118 WebInspector.Geometry.subtract(points[1], points[0]), WebInspector.Geome try.subtract(points[2], points[1])); 1118 Common.Geometry.subtract(points[1], points[0]), Common.Geometry.subtract (points[2], points[1]));
1119 // General form of the equation of the quad plane: A * x + B * y + C * z + D = 0 1119 // General form of the equation of the quad plane: A * x + B * y + C * z + D = 0
1120 var A = normal.x; 1120 var A = normal.x;
1121 var B = normal.y; 1121 var B = normal.y;
1122 var C = normal.z; 1122 var C = normal.z;
1123 var D = -(A * points[0].x + B * points[0].y + C * points[0].z); 1123 var D = -(A * points[0].x + B * points[0].y + C * points[0].z);
1124 // Finding t from the equation 1124 // Finding t from the equation
1125 var t = -(D + A * x0 + B * y0) / C; 1125 var t = -(D + A * x0 + B * y0) / C;
1126 // Point of the intersection 1126 // Point of the intersection
1127 var pt = new WebInspector.Geometry.Vector(x0, y0, t); 1127 var pt = new Common.Geometry.Vector(x0, y0, t);
1128 // Vectors from the intersection point to vertices of the quad 1128 // Vectors from the intersection point to vertices of the quad
1129 var tVects = points.map(WebInspector.Geometry.subtract.bind(null, pt)); 1129 var tVects = points.map(Common.Geometry.subtract.bind(null, pt));
1130 // Intersection point lies inside of the polygon if scalar products of norma l of the plane and 1130 // Intersection point lies inside of the polygon if scalar products of norma l of the plane and
1131 // cross products of successive tVects are all nonstrictly above or all nons trictly below zero 1131 // cross products of successive tVects are all nonstrictly above or all nons trictly below zero
1132 for (i = 0; i < tVects.length; ++i) { 1132 for (i = 0; i < tVects.length; ++i) {
1133 var product = WebInspector.Geometry.scalarProduct( 1133 var product = Common.Geometry.scalarProduct(
1134 normal, WebInspector.Geometry.crossProduct(tVects[i], tVects[(i + 1) % tVects.length])); 1134 normal, Common.Geometry.crossProduct(tVects[i], tVects[(i + 1) % tVect s.length]));
1135 if (product < 0) 1135 if (product < 0)
1136 return undefined; 1136 return undefined;
1137 } 1137 }
1138 return t; 1138 return t;
1139 } 1139 }
1140 }; 1140 };
1141 1141
1142 1142
1143 /** 1143 /**
1144 * @unrestricted 1144 * @unrestricted
1145 */ 1145 */
1146 WebInspector.LayerTextureManager.Tile = class { 1146 LayerViewer.LayerTextureManager.Tile = class {
1147 /** 1147 /**
1148 * @param {!WebInspector.SnapshotWithRect} snapshotWithRect 1148 * @param {!SDK.SnapshotWithRect} snapshotWithRect
1149 */ 1149 */
1150 constructor(snapshotWithRect) { 1150 constructor(snapshotWithRect) {
1151 this.snapshot = snapshotWithRect.snapshot; 1151 this.snapshot = snapshotWithRect.snapshot;
1152 this.rect = snapshotWithRect.rect; 1152 this.rect = snapshotWithRect.rect;
1153 this.scale = 0; 1153 this.scale = 0;
1154 /** @type {?WebGLTexture} */ 1154 /** @type {?WebGLTexture} */
1155 this.texture = null; 1155 this.texture = null;
1156 } 1156 }
1157 1157
1158 dispose() { 1158 dispose() {
(...skipping 17 matching lines...) Expand all
1176 1176
1177 /** 1177 /**
1178 * @param {!WebGLRenderingContext} glContext 1178 * @param {!WebGLRenderingContext} glContext
1179 * @param {number} scale 1179 * @param {number} scale
1180 * @return {!Promise} 1180 * @return {!Promise}
1181 */ 1181 */
1182 update(glContext, scale) { 1182 update(glContext, scale) {
1183 this._gl = glContext; 1183 this._gl = glContext;
1184 this.scale = scale; 1184 this.scale = scale;
1185 return this.snapshot.replay(null, null, scale) 1185 return this.snapshot.replay(null, null, scale)
1186 .then(imageURL => imageURL && WebInspector.loadImage(imageURL)) 1186 .then(imageURL => imageURL && UI.loadImage(imageURL))
1187 .then(image => { 1187 .then(image => {
1188 this.texture = image && WebInspector.LayerTextureManager._createTextur eForImage(glContext, image); 1188 this.texture = image && LayerViewer.LayerTextureManager._createTexture ForImage(glContext, image);
1189 }); 1189 });
1190 } 1190 }
1191 }; 1191 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698