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

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

Issue 1463143005: DevTools: avoid layout thrashing on Layers panel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: extracted reveal() change Created 5 years 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/LayerViewHost.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 */ 183 */
184 function onTextureCreated(texture) 184 function onTextureCreated(texture)
185 { 185 {
186 this._layerTexture = texture ? {layerId: layer.id(), texture: textur e} : null; 186 this._layerTexture = texture ? {layerId: layer.id(), texture: textur e} : null;
187 this._update(); 187 this._update();
188 } 188 }
189 }, 189 },
190 190
191 onResize: function() 191 onResize: function()
192 { 192 {
193 this._resizeCanvas();
193 this._update(); 194 this._update();
194 }, 195 },
195 196
196 wasShown: function() 197 wasShown: function()
197 { 198 {
198 if (this._needsUpdate) 199 if (!this._needsUpdate)
199 this._update(); 200 return;
201 this._resizeCanvas();
202 this._update();
200 }, 203 },
201 204
202 /** 205 /**
203 * @param {!WebInspector.Layers3DView.OutlineType} type 206 * @param {!WebInspector.Layers3DView.OutlineType} type
204 * @param {?WebInspector.LayerView.Selection} selection 207 * @param {?WebInspector.LayerView.Selection} selection
205 */ 208 */
206 _setOutline: function(type, selection) 209 _setOutline: function(type, selection)
207 { 210 {
208 this._lastSelection[type] = selection; 211 this._lastSelection[type] = selection;
209 this._update(); 212 this._update();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 this._gl.enableVertexAttribArray(this._shaderProgram.textureCoordAttribu te); 275 this._gl.enableVertexAttribArray(this._shaderProgram.textureCoordAttribu te);
273 276
274 this._shaderProgram.pMatrixUniform = this._gl.getUniformLocation(this._s haderProgram, "uPMatrix"); 277 this._shaderProgram.pMatrixUniform = this._gl.getUniformLocation(this._s haderProgram, "uPMatrix");
275 this._shaderProgram.samplerUniform = this._gl.getUniformLocation(this._s haderProgram, "uSampler"); 278 this._shaderProgram.samplerUniform = this._gl.getUniformLocation(this._s haderProgram, "uSampler");
276 }, 279 },
277 280
278 _resizeCanvas: function() 281 _resizeCanvas: function()
279 { 282 {
280 this._canvasElement.width = this._canvasElement.offsetWidth * window.dev icePixelRatio; 283 this._canvasElement.width = this._canvasElement.offsetWidth * window.dev icePixelRatio;
281 this._canvasElement.height = this._canvasElement.offsetHeight * window.d evicePixelRatio; 284 this._canvasElement.height = this._canvasElement.offsetHeight * window.d evicePixelRatio;
282 this._gl.viewportWidth = this._canvasElement.width;
283 this._gl.viewportHeight = this._canvasElement.height;
284 }, 285 },
285 286
286 _updateTransformAndConstraints: function() 287 _updateTransformAndConstraints: function()
287 { 288 {
288 var paddingFraction = 0.1; 289 var paddingFraction = 0.1;
289 var viewport = this._layerTree.viewportSize(); 290 var viewport = this._layerTree.viewportSize();
290 var root = this._layerTree.root(); 291 var root = this._layerTree.root();
291 var baseWidth = viewport ? viewport.width : this._dimensionsForAutoscale .width; 292 var baseWidth = viewport ? viewport.width : this._dimensionsForAutoscale .width;
292 var baseHeight = viewport ? viewport.height : this._dimensionsForAutosca le.height; 293 var baseHeight = viewport ? viewport.height : this._dimensionsForAutosca le.height;
293 var canvasWidth = this._canvasElement.width; 294 var canvasWidth = this._canvasElement.width;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 var children = layer.children(); 388 var children = layer.children();
388 for (var i = 0; i < children.length; ++i) { 389 for (var i = 0; i < children.length; ++i) {
389 this._depthByLayerId[children[i].id()] = ++depth; 390 this._depthByLayerId[children[i].id()] = ++depth;
390 queue.push(children[i]); 391 queue.push(children[i]);
391 } 392 }
392 } 393 }
393 this._maxDepth = depth; 394 this._maxDepth = depth;
394 }, 395 },
395 396
396 /** 397 /**
397 * @param {!WebInspector.Layers3DView.OutlineType} type
398 * @param {!WebInspector.LayerView.Selection} selection
399 */
400 _isSelectionActive: function(type, selection)
401 {
402 return this._lastSelection[type] && this._lastSelection[type].isEqual(se lection);
403 },
404
405 /**
406 * @param {!WebInspector.Layer} layer 398 * @param {!WebInspector.Layer} layer
407 * @return {number} 399 * @return {number}
408 */ 400 */
409 _depthForLayer: function(layer) 401 _depthForLayer: function(layer)
410 { 402 {
411 return this._depthByLayerId[layer.id()] * WebInspector.Layers3DView.Laye rSpacing; 403 return this._depthByLayerId[layer.id()] * WebInspector.Layers3DView.Laye rSpacing;
412 }, 404 },
413 405
414 /** 406 /**
415 * @param {!WebInspector.Layer} layer 407 * @param {!WebInspector.Layer} layer
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 this._appendRect(rect); 439 this._appendRect(rect);
448 this._updateDimensionsForAutoscale(layer); 440 this._updateDimensionsForAutoscale(layer);
449 }, 441 },
450 442
451 /** 443 /**
452 * @param {!WebInspector.Layers3DView.Rectangle} rect 444 * @param {!WebInspector.Layers3DView.Rectangle} rect
453 */ 445 */
454 _appendRect: function(rect) 446 _appendRect: function(rect)
455 { 447 {
456 var selection = rect.relatedObject; 448 var selection = rect.relatedObject;
457 var isSelected = this._isSelectionActive(WebInspector.Layers3DView.Outli neType.Selected, selection); 449 var isSelected = WebInspector.LayerView.Selection.isEqual(this._lastSele ction[WebInspector.Layers3DView.OutlineType.Selected], selection);
458 var isHovered = this._isSelectionActive(WebInspector.Layers3DView.Outlin eType.Hovered, selection); 450 var isHovered = WebInspector.LayerView.Selection.isEqual(this._lastSelec tion[WebInspector.Layers3DView.OutlineType.Hovered], selection);
459 if (isSelected) { 451 if (isSelected) {
460 rect.borderColor = WebInspector.Layers3DView.SelectedBorderColor; 452 rect.borderColor = WebInspector.Layers3DView.SelectedBorderColor;
461 } else if (isHovered) { 453 } else if (isHovered) {
462 rect.borderColor = WebInspector.Layers3DView.HoveredBorderColor; 454 rect.borderColor = WebInspector.Layers3DView.HoveredBorderColor;
463 var fillColor = rect.fillColor || [255, 255, 255, 1]; 455 var fillColor = rect.fillColor || [255, 255, 255, 1];
464 var maskColor = WebInspector.Layers3DView.HoveredImageMaskColor; 456 var maskColor = WebInspector.Layers3DView.HoveredImageMaskColor;
465 rect.fillColor = [fillColor[0] * maskColor[0] / 255, fillColor[1] * maskColor[1] / 255, fillColor[2] * maskColor[2] / 255, fillColor[3] * maskColor[ 3]]; 457 rect.fillColor = [fillColor[0] * maskColor[0] / 255, fillColor[1] * maskColor[1] / 255, fillColor[2] * maskColor[2] / 255, fillColor[3] * maskColor[ 3]];
466 } else { 458 } else {
467 rect.borderColor = WebInspector.Layers3DView.BorderColor; 459 rect.borderColor = WebInspector.Layers3DView.BorderColor;
468 } 460 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 return; 649 return;
658 } 650 }
659 var gl = this._initGLIfNecessary(); 651 var gl = this._initGLIfNecessary();
660 if (!gl) { 652 if (!gl) {
661 this._failBanner.element.removeChildren(); 653 this._failBanner.element.removeChildren();
662 this._failBanner.element.appendChild(this._webglDisabledBanner()); 654 this._failBanner.element.appendChild(this._webglDisabledBanner());
663 this._failBanner.show(this.element); 655 this._failBanner.show(this.element);
664 return; 656 return;
665 } 657 }
666 this._failBanner.detach(); 658 this._failBanner.detach();
659 this._gl.viewportWidth = this._canvasElement.width;
660 this._gl.viewportHeight = this._canvasElement.height;
667 661
668 this._resizeCanvas();
669 this._calculateDepthsAndVisibility(); 662 this._calculateDepthsAndVisibility();
670 this._calculateRects(); 663 this._calculateRects();
671 this._updateTransformAndConstraints(); 664 this._updateTransformAndConstraints();
672 665
673 this._textureManager.setScale(Number.constrain(0.1, 1, this._scale)); 666 this._textureManager.setScale(Number.constrain(0.1, 1, this._scale));
674 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); 667 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
675 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 668 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
676 669
677 this._rects.forEach(this._drawViewRect.bind(this)); 670 this._rects.forEach(this._drawViewRect.bind(this));
678 this._drawViewportAndChrome(); 671 this._drawViewportAndChrome();
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 */ 1089 */
1097 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent) 1090 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent)
1098 { 1091 {
1099 this.snapshot = snapshot; 1092 this.snapshot = snapshot;
1100 this.rect = rect; 1093 this.rect = rect;
1101 this.traceEvent = traceEvent; 1094 this.traceEvent = traceEvent;
1102 this.scale = 0; 1095 this.scale = 0;
1103 /** @type {?WebGLTexture} */ 1096 /** @type {?WebGLTexture} */
1104 this.texture = null; 1097 this.texture = null;
1105 } 1098 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/timeline/LayerViewHost.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698