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

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

Issue 711423002: DevTools: better visual feedback for hovered objects is Layers3DView (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed review comments, fixed test Created 6 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 | Annotate | Revision Log
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 this._canvasElement = this.element.createChild("canvas"); 45 this._canvasElement = this.element.createChild("canvas");
46 this._canvasElement.tabIndex = 0; 46 this._canvasElement.tabIndex = 0;
47 this._canvasElement.addEventListener("dblclick", this._onDoubleClick.bind(th is), false); 47 this._canvasElement.addEventListener("dblclick", this._onDoubleClick.bind(th is), false);
48 this._canvasElement.addEventListener("mousedown", this._onMouseDown.bind(thi s), false); 48 this._canvasElement.addEventListener("mousedown", this._onMouseDown.bind(thi s), false);
49 this._canvasElement.addEventListener("mouseup", this._onMouseUp.bind(this), false); 49 this._canvasElement.addEventListener("mouseup", this._onMouseUp.bind(this), false);
50 this._canvasElement.addEventListener("mouseleave", this._onMouseMove.bind(th is), false); 50 this._canvasElement.addEventListener("mouseleave", this._onMouseMove.bind(th is), false);
51 this._canvasElement.addEventListener("mousemove", this._onMouseMove.bind(thi s), false); 51 this._canvasElement.addEventListener("mousemove", this._onMouseMove.bind(thi s), false);
52 this._canvasElement.addEventListener("contextmenu", this._onContextMenu.bind (this), false); 52 this._canvasElement.addEventListener("contextmenu", this._onContextMenu.bind (this), false);
53 53
54 this._lastActiveObject = {}; 54 this._lastSelection = {};
55 this._picturesForLayer = {}; 55 this._picturesForLayer = {};
56 this._scrollRectQuadsForLayer = {}; 56 this._scrollRectQuadsForLayer = {};
57 this._isVisible = {}; 57 this._isVisible = {};
58 this._layerTree = null; 58 this._layerTree = null;
59 this._textureManager = new WebInspector.LayerTextureManager(); 59 this._textureManager = new WebInspector.LayerTextureManager();
60 this._textureManager.addEventListener(WebInspector.LayerTextureManager.Event s.TextureUpdated, this._update, this); 60 this._textureManager.addEventListener(WebInspector.LayerTextureManager.Event s.TextureUpdated, this._update, this);
61 /** @type Array.<!WebGLTexture|undefined> */ 61 /** @type Array.<!WebGLTexture|undefined> */
62 this._chromeTextures = []; 62 this._chromeTextures = [];
63 63
64 WebInspector.settings.showPaintRects.addChangeListener(this._update, this); 64 WebInspector.settings.showPaintRects.addChangeListener(this._update, this);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 "uniform mat4 uPMatrix;\n" + 123 "uniform mat4 uPMatrix;\n" +
124 "varying vec2 vTextureCoord;\n" + 124 "varying vec2 vTextureCoord;\n" +
125 "varying vec4 vColor;\n" + 125 "varying vec4 vColor;\n" +
126 "void main(void)\n" + 126 "void main(void)\n" +
127 "{\n" + 127 "{\n" +
128 "gl_Position = uPMatrix * vec4(aVertexPosition, 1.0);\n" + 128 "gl_Position = uPMatrix * vec4(aVertexPosition, 1.0);\n" +
129 "vColor = aVertexColor;\n" + 129 "vColor = aVertexColor;\n" +
130 "vTextureCoord = aTextureCoord;\n" + 130 "vTextureCoord = aTextureCoord;\n" +
131 "}"; 131 "}";
132 132
133 WebInspector.Layers3DView.SelectedBackgroundColor = [20, 40, 110, 0.66];
134 WebInspector.Layers3DView.BackgroundColor = [0, 0, 0, 0];
135 WebInspector.Layers3DView.HoveredBorderColor = [0, 0, 255, 1]; 133 WebInspector.Layers3DView.HoveredBorderColor = [0, 0, 255, 1];
136 WebInspector.Layers3DView.SelectedBorderColor = [0, 255, 0, 1]; 134 WebInspector.Layers3DView.SelectedBorderColor = [0, 255, 0, 1];
137 WebInspector.Layers3DView.BorderColor = [0, 0, 0, 1]; 135 WebInspector.Layers3DView.BorderColor = [0, 0, 0, 1];
138 WebInspector.Layers3DView.ViewportBorderColor = [160, 160, 160, 1]; 136 WebInspector.Layers3DView.ViewportBorderColor = [160, 160, 160, 1];
139 WebInspector.Layers3DView.ScrollRectBackgroundColor = [178, 0, 0, 0.4]; 137 WebInspector.Layers3DView.ScrollRectBackgroundColor = [178, 100, 100, 0.6];
140 WebInspector.Layers3DView.SelectedScrollRectBackgroundColor = [178, 0, 0, 0.6]; 138 WebInspector.Layers3DView.HoveredImageMaskColor = [200, 200, 255, 1];
141 WebInspector.Layers3DView.ScrollRectBorderColor = [178, 0, 0, 1];
142 WebInspector.Layers3DView.BorderWidth = 1; 139 WebInspector.Layers3DView.BorderWidth = 1;
143 WebInspector.Layers3DView.SelectedBorderWidth = 2; 140 WebInspector.Layers3DView.SelectedBorderWidth = 2;
144 WebInspector.Layers3DView.ViewportBorderWidth = 3; 141 WebInspector.Layers3DView.ViewportBorderWidth = 3;
145 142
146 WebInspector.Layers3DView.LayerSpacing = 20; 143 WebInspector.Layers3DView.LayerSpacing = 20;
147 WebInspector.Layers3DView.ScrollRectSpacing = 4; 144 WebInspector.Layers3DView.ScrollRectSpacing = 4;
148 145
149 WebInspector.Layers3DView.prototype = { 146 WebInspector.Layers3DView.prototype = {
150 /** 147 /**
151 * @param {?WebInspector.LayerTreeBase} layerTree 148 * @param {?WebInspector.LayerTreeBase} layerTree
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 }, 190 },
194 191
195 wasShown: function() 192 wasShown: function()
196 { 193 {
197 if (this._needsUpdate) 194 if (this._needsUpdate)
198 this._update(); 195 this._update();
199 }, 196 },
200 197
201 /** 198 /**
202 * @param {!WebInspector.Layers3DView.OutlineType} type 199 * @param {!WebInspector.Layers3DView.OutlineType} type
203 * @param {?WebInspector.Layers3DView.ActiveObject} activeObject 200 * @param {?WebInspector.Layers3DView.Selection} selection
204 */ 201 */
205 _setOutline: function(type, activeObject) 202 _setOutline: function(type, selection)
206 { 203 {
207 this._lastActiveObject[type] = activeObject; 204 this._lastSelection[type] = selection;
208 this._update(); 205 this._update();
209 }, 206 },
210 207
211 /** 208 /**
212 * @param {?WebInspector.Layers3DView.ActiveObject} activeObject 209 * @param {?WebInspector.Layers3DView.Selection} selection
213 */ 210 */
214 hoverObject: function(activeObject) 211 hoverObject: function(selection)
215 { 212 {
216 this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered, activeOb ject); 213 this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered, selectio n);
217 }, 214 },
218 215
219 /** 216 /**
220 * @param {?WebInspector.Layers3DView.ActiveObject} activeObject 217 * @param {?WebInspector.Layers3DView.Selection} selection
221 */ 218 */
222 selectObject: function(activeObject) 219 selectObject: function(selection)
223 { 220 {
224 this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered, null); 221 this._setOutline(WebInspector.Layers3DView.OutlineType.Hovered, null);
225 this._setOutline(WebInspector.Layers3DView.OutlineType.Selected, activeO bject); 222 this._setOutline(WebInspector.Layers3DView.OutlineType.Selected, selecti on);
226 }, 223 },
227 224
228 /** 225 /**
229 * @param {!Element} canvas 226 * @param {!Element} canvas
230 * @return {!WebGLRenderingContext} 227 * @return {!WebGLRenderingContext}
231 */ 228 */
232 _initGL: function(canvas) 229 _initGL: function(canvas)
233 { 230 {
234 var gl = canvas.getContext("webgl"); 231 var gl = canvas.getContext("webgl");
235 gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); 232 gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 }, 360 },
364 361
365 _calculateDepths: function() 362 _calculateDepths: function()
366 { 363 {
367 this._depthByLayerId = {}; 364 this._depthByLayerId = {};
368 this._isVisible = {}; 365 this._isVisible = {};
369 var depth = 0; 366 var depth = 0;
370 var root = this._layerTree.root(); 367 var root = this._layerTree.root();
371 var queue = [root]; 368 var queue = [root];
372 this._depthByLayerId[root.id()] = 0; 369 this._depthByLayerId[root.id()] = 0;
373 this._isVisible[root.id()] = this._layerTree.root() === root; 370 this._isVisible[root.id()] = !this._layerTree.contentRoot();
374 while (queue.length > 0) { 371 while (queue.length > 0) {
375 var layer = queue.shift(); 372 var layer = queue.shift();
376 var children = layer.children(); 373 var children = layer.children();
377 for (var i = 0; i < children.length; ++i) { 374 for (var i = 0; i < children.length; ++i) {
378 this._depthByLayerId[children[i].id()] = ++depth; 375 this._depthByLayerId[children[i].id()] = ++depth;
379 this._isVisible[children[i].id()] = children[i] === this._layerT ree.contentRoot() || this._isVisible[layer.id()]; 376 this._isVisible[children[i].id()] = children[i] === this._layerT ree.contentRoot() || this._isVisible[layer.id()];
380 queue.push(children[i]); 377 queue.push(children[i]);
381 } 378 }
382 } 379 }
383 this._maxDepth = depth; 380 this._maxDepth = depth;
384 }, 381 },
385 382
386 /** 383 /**
387 * @param {!WebInspector.Layers3DView.OutlineType} type 384 * @param {!WebInspector.Layers3DView.OutlineType} type
388 * @param {!WebInspector.Layer} layer 385 * @param {!WebInspector.Layers3DView.Selection} selection
389 * @param {number=} scrollRectIndex
390 */ 386 */
391 _isObjectActive: function(type, layer, scrollRectIndex) 387 _isSelectionActive: function(type, selection)
392 { 388 {
393 var activeObject = this._lastActiveObject[type]; 389 return this._lastSelection[type] && this._lastSelection[type].isEqual(se lection);
394 return activeObject && activeObject.layer && activeObject.layer.id() === layer.id() && (typeof scrollRectIndex !== "number" || activeObject.scrollRectIn dex === scrollRectIndex);
395 }, 390 },
396 391
397 /** 392 /**
398 * @param {!WebInspector.Layer} layer
399 * @return {!WebInspector.Layers3DView.LayerStyle}
400 */
401 _styleForLayer: function(layer)
402 {
403 var isSelected = this._isObjectActive(WebInspector.Layers3DView.OutlineT ype.Selected, layer);
404 var isHovered = this._isObjectActive(WebInspector.Layers3DView.OutlineTy pe.Hovered, layer);
405 var borderColor;
406 if (isSelected)
407 borderColor = WebInspector.Layers3DView.SelectedBorderColor;
408 else if (isHovered)
409 borderColor = WebInspector.Layers3DView.HoveredBorderColor;
410 else
411 borderColor = WebInspector.Layers3DView.BorderColor;
412 var borderWidth = isSelected ? WebInspector.Layers3DView.SelectedBorderW idth : WebInspector.Layers3DView.BorderWidth;
413 return {borderColor: borderColor, borderWidth: borderWidth};
414 },
415
416 /**
417 * @param {!WebInspector.Layer} layer 393 * @param {!WebInspector.Layer} layer
418 * @return {number} 394 * @return {number}
419 */ 395 */
420 _depthForLayer: function(layer) 396 _depthForLayer: function(layer)
421 { 397 {
422 return this._depthByLayerId[layer.id()] * WebInspector.Layers3DView.Laye rSpacing; 398 return this._depthByLayerId[layer.id()] * WebInspector.Layers3DView.Laye rSpacing;
423 }, 399 },
424 400
425 /** 401 /**
426 * @param {!WebInspector.Layer} layer 402 * @param {!WebInspector.Layer} layer
427 * @param {number} index 403 * @param {number} index
428 * @return {number} 404 * @return {number}
429 */ 405 */
430 _calculateScrollRectDepth: function(layer, index) 406 _calculateScrollRectDepth: function(layer, index)
431 { 407 {
432 return this._depthForLayer(layer) + index * WebInspector.Layers3DView.Sc rollRectSpacing + 1; 408 return this._depthForLayer(layer) + index * WebInspector.Layers3DView.Sc rollRectSpacing + 1;
433 }, 409 },
434 410
435 /** 411 /**
436 * @param {!WebInspector.Layer} layer 412 * @param {!WebInspector.Layer} layer
437 */ 413 */
438 _calculateLayerRect: function(layer) 414 _calculateLayerRect: function(layer)
439 { 415 {
440 if (!this._isVisible[layer.id()]) 416 if (!this._isVisible[layer.id()])
441 return; 417 return;
442 var activeObject = WebInspector.Layers3DView.ActiveObject.createLayerAct iveObject(layer); 418 var selection = new WebInspector.Layers3DView.LayerSelection(layer);
443 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); 419 var rect = new WebInspector.Layers3DView.Rectangle(selection);
444 var style = this._styleForLayer(layer);
445 rect.setVertices(layer.quad(), this._depthForLayer(layer)); 420 rect.setVertices(layer.quad(), this._depthForLayer(layer));
446 rect.lineWidth = style.borderWidth; 421 this._appendRect(rect);
447 rect.borderColor = style.borderColor; 422 },
423
424 /**
425 * @param {!WebInspector.Layers3DView.Rectangle} rect
426 */
427 _appendRect: function(rect)
428 {
429 var selection = rect.relatedObject;
430 var isSelected = this._isSelectionActive(WebInspector.Layers3DView.Outli neType.Selected, selection);
431 var isHovered = this._isSelectionActive(WebInspector.Layers3DView.Outlin eType.Hovered, selection);
432 if (isSelected) {
433 rect.borderColor = WebInspector.Layers3DView.SelectedBorderColor;
434 } else if (isHovered) {
435 rect.borderColor = WebInspector.Layers3DView.HoveredBorderColor;
436 var fillColor = rect.fillColor || [255, 255, 255, 1];
437 var maskColor = WebInspector.Layers3DView.HoveredImageMaskColor;
438 rect.fillColor = [fillColor[0] * maskColor[0] / 255, fillColor[1] * maskColor[1] / 255, fillColor[2] * maskColor[2] / 255, fillColor[3] * maskColor[ 3]];
439 } else {
440 rect.borderColor = WebInspector.Layers3DView.BorderColor;
441 }
442 rect.lineWidth = isSelected ? WebInspector.Layers3DView.SelectedBorderWi dth : WebInspector.Layers3DView.BorderWidth;
448 this._rects.push(rect); 443 this._rects.push(rect);
449 }, 444 },
450 445
451 /** 446 /**
452 * @param {!WebInspector.Layer} layer 447 * @param {!WebInspector.Layer} layer
453 */ 448 */
454 _calculateLayerScrollRects: function(layer) 449 _calculateLayerScrollRects: function(layer)
455 { 450 {
456 var scrollRects = layer.scrollRects(); 451 var scrollRects = layer.scrollRects();
457 for (var i = 0; i < scrollRects.length; ++i) { 452 for (var i = 0; i < scrollRects.length; ++i) {
458 var activeObject = WebInspector.Layers3DView.ActiveObject.createScro llRectActiveObject(layer, i); 453 var selection = new WebInspector.Layers3DView.ScrollRectSelection(la yer, i);
459 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); 454 var rect = new WebInspector.Layers3DView.Rectangle(selection);
460 rect.calculateVerticesFromRect(layer, scrollRects[i].rect, this._cal culateScrollRectDepth(layer, i)); 455 rect.calculateVerticesFromRect(layer, scrollRects[i].rect, this._cal culateScrollRectDepth(layer, i));
461 var isSelected = this._isObjectActive(WebInspector.Layers3DView.Outl ineType.Selected, layer, i); 456 rect.fillColor = WebInspector.Layers3DView.ScrollRectBackgroundColor ;
462 var color = isSelected ? WebInspector.Layers3DView.SelectedScrollRec tBackgroundColor : WebInspector.Layers3DView.ScrollRectBackgroundColor; 457 this._appendRect(rect);
463 rect.fillColor = color;
464 rect.borderColor = WebInspector.Layers3DView.ScrollRectBorderColor;
465 this._rects.push(rect);
466 } 458 }
467 }, 459 },
468 460
469 /** 461 /**
470 * @param {!WebInspector.Layer} layer 462 * @param {!WebInspector.Layer} layer
471 */ 463 */
472 _calculateLayerImageRect: function(layer) 464 _calculateLayerImageRect: function(layer)
473 { 465 {
474 var layerTexture = this._layerTexture; 466 var layerTexture = this._layerTexture;
475 if (layer.id() !== layerTexture.layerId) 467 if (layer.id() !== layerTexture.layerId)
476 return; 468 return;
477 var activeObject = WebInspector.Layers3DView.ActiveObject.createLayerAct iveObject(layer); 469 var selection = new WebInspector.Layers3DView.LayerSelection(layer);
478 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); 470 var rect = new WebInspector.Layers3DView.Rectangle(selection);
479 rect.setVertices(layer.quad(), this._depthForLayer(layer)); 471 rect.setVertices(layer.quad(), this._depthForLayer(layer));
480 rect.texture = layerTexture.texture; 472 rect.texture = layerTexture.texture;
481 this._rects.push(rect); 473 this._appendRect(rect);
482 }, 474 },
483 475
484 /** 476 /**
485 * @param {!WebInspector.Layer} layer 477 * @param {!WebInspector.Layer} layer
486 */ 478 */
487 _calculateLayerTileRects: function(layer) 479 _calculateLayerTileRects: function(layer)
488 { 480 {
489 var tiles = this._textureManager.tilesForLayer(layer.id()); 481 var tiles = this._textureManager.tilesForLayer(layer.id());
490 for (var i = 0; i < tiles.length; ++i) { 482 for (var i = 0; i < tiles.length; ++i) {
491 var tile = tiles[i]; 483 var tile = tiles[i];
492 if (!tile.texture) 484 if (!tile.texture)
493 continue; 485 continue;
494 var activeObject = WebInspector.Layers3DView.ActiveObject.createTile ActiveObject(layer, tile.traceEvent); 486 var selection = new WebInspector.Layers3DView.TileSelection(layer, t ile.traceEvent);
495 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); 487 var rect = new WebInspector.Layers3DView.Rectangle(selection);
496 rect.calculateVerticesFromRect(layer, {x: tile.rect[0], y: tile.rect [1], width: tile.rect[2], height: tile.rect[3]}, this._depthForLayer(layer) + 1) ; 488 rect.calculateVerticesFromRect(layer, {x: tile.rect[0], y: tile.rect [1], width: tile.rect[2], height: tile.rect[3]}, this._depthForLayer(layer) + 1) ;
497 rect.texture = tile.texture; 489 rect.texture = tile.texture;
498 this._rects.push(rect); 490 this._appendRect(rect);
499 } 491 }
500 }, 492 },
501 493
502 _calculateRects: function() 494 _calculateRects: function()
503 { 495 {
504 this._rects = []; 496 this._rects = [];
505 497
506 this._layerTree.forEachLayer(this._calculateLayerRect.bind(this)); 498 this._layerTree.forEachLayer(this._calculateLayerRect.bind(this));
507 499
508 if (this._showSlowScrollRectsSetting.get()) 500 if (this._showSlowScrollRectsSetting.get())
509 this._layerTree.forEachLayer(this._calculateLayerScrollRects.bind(th is)); 501 this._layerTree.forEachLayer(this._calculateLayerScrollRects.bind(th is));
510 502
511 if (this._showPaintsSetting.get()) { 503 if (this._showPaintsSetting.get()) {
512 if (this._layerTexture) 504 if (this._layerTexture)
513 this._layerTree.forEachLayer(this._calculateLayerImageRect.bind( this)); 505 this._layerTree.forEachLayer(this._calculateLayerImageRect.bind( this));
514 else 506 else
515 this._layerTree.forEachLayer(this._calculateLayerTileRects.bind( this)); 507 this._layerTree.forEachLayer(this._calculateLayerTileRects.bind( this));
516 } 508 }
517 }, 509 },
518 510
519 /** 511 /**
520 * @param {!Array.<number>} color 512 * @param {!Array.<number>} color
521 * @return {!Array.<number>} 513 * @return {!Array.<number>}
522 */ 514 */
523 _makeColorsArray: function(color) 515 _makeColorsArray: function(color)
524 { 516 {
525 var colors = []; 517 var colors = [];
526 var normalizedColor = [color[0] / 255, color[1] / 255, color[2] / 255, c olor[3]]; 518 var normalizedColor = [color[0] / 255, color[1] / 255, color[2] / 255, c olor[3]];
527 for (var i = 0; i < 4; i++) { 519 for (var i = 0; i < 4; i++)
528 colors = colors.concat(normalizedColor); 520 colors = colors.concat(normalizedColor);
529 }
530 return colors; 521 return colors;
531 }, 522 },
532 523
533 /** 524 /**
534 * @param {!Object} attribute 525 * @param {!Object} attribute
535 * @param {!Array.<number>} array 526 * @param {!Array.<number>} array
536 * @param {!number} length 527 * @param {!number} length
537 */ 528 */
538 _setVertexAttribute: function(attribute, array, length) 529 _setVertexAttribute: function(attribute, array, length)
539 { 530 {
540 var gl = this._gl; 531 var gl = this._gl;
541 var buffer = gl.createBuffer(); 532 var buffer = gl.createBuffer();
542 gl.bindBuffer(gl.ARRAY_BUFFER, buffer); 533 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
543 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(array), gl.STATIC_DRAW); 534 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(array), gl.STATIC_DRAW);
544 gl.vertexAttribPointer(attribute, length, gl.FLOAT, false, 0, 0); 535 gl.vertexAttribPointer(attribute, length, gl.FLOAT, false, 0, 0);
545 }, 536 },
546 537
547 /** 538 /**
548 * @param {!Array.<number>} vertices 539 * @param {!Array.<number>} vertices
549 * @param {number} mode 540 * @param {number} mode
550 * @param {!Array.<number>=} color 541 * @param {!Array.<number>=} color
551 * @param {!Object=} texture 542 * @param {!Object=} texture
552 */ 543 */
553 _drawRectangle: function(vertices, mode, color, texture) 544 _drawRectangle: function(vertices, mode, color, texture)
554 { 545 {
555 var gl = this._gl; 546 var gl = this._gl;
556 var white = [255, 255, 255, 1]; 547 var white = [255, 255, 255, 1];
548 color = color || white;
557 this._setVertexAttribute(this._shaderProgram.vertexPositionAttribute, ve rtices, 3); 549 this._setVertexAttribute(this._shaderProgram.vertexPositionAttribute, ve rtices, 3);
558 this._setVertexAttribute(this._shaderProgram.textureCoordAttribute, [0, 1, 1, 1, 1, 0, 0, 0], 2); 550 this._setVertexAttribute(this._shaderProgram.textureCoordAttribute, [0, 1, 1, 1, 1, 0, 0, 0], 2);
551 this._setVertexAttribute(this._shaderProgram.vertexColorAttribute, this. _makeColorsArray(color), color.length);
559 552
560 if (texture) { 553 if (texture) {
561 this._setVertexAttribute(this._shaderProgram.vertexColorAttribute, t his._makeColorsArray(white), white.length);
562 gl.activeTexture(gl.TEXTURE0); 554 gl.activeTexture(gl.TEXTURE0);
563 gl.bindTexture(gl.TEXTURE_2D, texture); 555 gl.bindTexture(gl.TEXTURE_2D, texture);
564 gl.uniform1i(this._shaderProgram.samplerUniform, 0); 556 gl.uniform1i(this._shaderProgram.samplerUniform, 0);
565 } else { 557 } else {
566 this._setVertexAttribute(this._shaderProgram.vertexColorAttribute, t his._makeColorsArray(color || white), color.length);
567 gl.bindTexture(gl.TEXTURE_2D, this._whiteTexture); 558 gl.bindTexture(gl.TEXTURE_2D, this._whiteTexture);
568 } 559 }
569 560
570 var numberOfVertices = vertices.length / 3; 561 var numberOfVertices = vertices.length / 3;
571 gl.drawArrays(mode, 0, numberOfVertices); 562 gl.drawArrays(mode, 0, numberOfVertices);
572 }, 563 },
573 564
574 /** 565 /**
575 * @param {!Array.<number>} vertices 566 * @param {!Array.<number>} vertices
576 * @param {!WebGLTexture} texture 567 * @param {!WebGLTexture} texture
568 * @param {!Array.<number>=} color
577 */ 569 */
578 _drawTexture: function(vertices, texture) 570 _drawTexture: function(vertices, texture, color)
579 { 571 {
580 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, undefined, texture) ; 572 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, color, texture);
581 }, 573 },
582 574
583 _drawViewportAndChrome: function() 575 _drawViewportAndChrome: function()
584 { 576 {
585 var viewport = this._layerTree.viewportSize(); 577 var viewport = this._layerTree.viewportSize();
586 if (!viewport) 578 if (!viewport)
587 return; 579 return;
588 580
589 var drawChrome = !WebInspector.settings.frameViewerHideChromeWindow.get( ) && this._chromeTextures.length >= 3 && this._chromeTextures.indexOf(undefined) < 0; 581 var drawChrome = !WebInspector.settings.frameViewerHideChromeWindow.get( ) && this._chromeTextures.length >= 3 && this._chromeTextures.indexOf(undefined) < 0;
590 var z = (this._maxDepth + 1) * WebInspector.Layers3DView.LayerSpacing; 582 var z = (this._maxDepth + 1) * WebInspector.Layers3DView.LayerSpacing;
(...skipping 21 matching lines...) Expand all
612 } 604 }
613 }, 605 },
614 606
615 /** 607 /**
616 * @param {!WebInspector.Layers3DView.Rectangle} rect 608 * @param {!WebInspector.Layers3DView.Rectangle} rect
617 */ 609 */
618 _drawViewRect: function(rect) 610 _drawViewRect: function(rect)
619 { 611 {
620 var vertices = rect.vertices; 612 var vertices = rect.vertices;
621 if (rect.texture) 613 if (rect.texture)
622 this._drawTexture(vertices, rect.texture); 614 this._drawTexture(vertices, rect.texture, rect.fillColor || undefine d);
623 else if (rect.fillColor) 615 else if (rect.fillColor)
624 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, rect.fillColor) ; 616 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, rect.fillColor) ;
625 this._gl.lineWidth(rect.lineWidth); 617 this._gl.lineWidth(rect.lineWidth);
626 if (rect.borderColor) 618 if (rect.borderColor)
627 this._drawRectangle(vertices, this._gl.LINE_LOOP, rect.borderColor); 619 this._drawRectangle(vertices, this._gl.LINE_LOOP, rect.borderColor);
628 }, 620 },
629 621
630 _update: function() 622 _update: function()
631 { 623 {
632 if (!this.isShowing()) { 624 if (!this.isShowing()) {
(...skipping 15 matching lines...) Expand all
648 this._textureManager.setScale(Number.constrain(0.1, 1, this._scale)); 640 this._textureManager.setScale(Number.constrain(0.1, 1, this._scale));
649 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); 641 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
650 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 642 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
651 643
652 this._rects.forEach(this._drawViewRect.bind(this)); 644 this._rects.forEach(this._drawViewRect.bind(this));
653 this._drawViewportAndChrome(); 645 this._drawViewportAndChrome();
654 }, 646 },
655 647
656 /** 648 /**
657 * @param {!Event} event 649 * @param {!Event} event
658 * @return {?WebInspector.Layers3DView.ActiveObject} 650 * @return {?WebInspector.Layers3DView.Selection}
659 */ 651 */
660 _activeObjectFromEventPoint: function(event) 652 _selectionFromEventPoint: function(event)
661 { 653 {
662 if (!this._layerTree) 654 if (!this._layerTree)
663 return null; 655 return null;
664 var closestIntersectionPoint = Infinity; 656 var closestIntersectionPoint = Infinity;
665 var closestObject = null; 657 var closestObject = null;
666 var projectionMatrix = new WebKitCSSMatrix().scale(1, -1, -1).translate( -1, -1, 0).multiply(this._projectionMatrix); 658 var projectionMatrix = new WebKitCSSMatrix().scale(1, -1, -1).translate( -1, -1, 0).multiply(this._projectionMatrix);
667 var x0 = (event.clientX - this._canvasElement.totalOffsetLeft()) * windo w.devicePixelRatio; 659 var x0 = (event.clientX - this._canvasElement.totalOffsetLeft()) * windo w.devicePixelRatio;
668 var y0 = -(event.clientY - this._canvasElement.totalOffsetTop()) * windo w.devicePixelRatio; 660 var y0 = -(event.clientY - this._canvasElement.totalOffsetTop()) * windo w.devicePixelRatio;
669 661
670 /** 662 /**
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 this._showSlowScrollRectsSetting = this._createVisibilitySetting("Slow s croll rects", "frameViewerShowSlowScrollRects", true, this._panelStatusBarElemen t); 701 this._showSlowScrollRectsSetting = this._createVisibilitySetting("Slow s croll rects", "frameViewerShowSlowScrollRects", true, this._panelStatusBarElemen t);
710 this._showPaintsSetting = this._createVisibilitySetting("Paints", "frame ViewerShowPaints", true, this._panelStatusBarElement); 702 this._showPaintsSetting = this._createVisibilitySetting("Paints", "frame ViewerShowPaints", true, this._panelStatusBarElement);
711 WebInspector.settings.frameViewerHideChromeWindow.addChangeListener(this ._update, this); 703 WebInspector.settings.frameViewerHideChromeWindow.addChangeListener(this ._update, this);
712 }, 704 },
713 705
714 /** 706 /**
715 * @param {!Event} event 707 * @param {!Event} event
716 */ 708 */
717 _onContextMenu: function(event) 709 _onContextMenu: function(event)
718 { 710 {
719 var activeObject = this._activeObjectFromEventPoint(event); 711 var selection = this._selectionFromEventPoint(event);
720 var node = activeObject && activeObject.layer && activeObject.layer.node ForSelfOrAncestor(); 712 var node = selection && selection.layer && selection.layer.nodeForSelfOr Ancestor();
721 var contextMenu = new WebInspector.ContextMenu(event); 713 var contextMenu = new WebInspector.ContextMenu(event);
722 contextMenu.appendItem(WebInspector.UIString("Reset View"), this._transf ormController.resetAndNotify.bind(this._transformController), false); 714 contextMenu.appendItem(WebInspector.UIString("Reset View"), this._transf ormController.resetAndNotify.bind(this._transformController), false);
723 if (activeObject && activeObject.type() === WebInspector.Layers3DView.Ac tiveObject.Type.Tile) 715 if (selection && selection.type() === WebInspector.Layers3DView.Selectio n.Type.Tile)
724 contextMenu.appendItem(WebInspector.UIString("Show Paint Profiler"), this.dispatchEventToListeners.bind(this, WebInspector.Layers3DView.Events.Paint ProfilerRequested, activeObject.traceEvent), false); 716 contextMenu.appendItem(WebInspector.UIString("Show Paint Profiler"), this.dispatchEventToListeners.bind(this, WebInspector.Layers3DView.Events.Paint ProfilerRequested, selection.traceEvent), false);
725 if (node) 717 if (node)
726 contextMenu.appendApplicableItems(node); 718 contextMenu.appendApplicableItems(node);
727 contextMenu.show(); 719 contextMenu.show();
728 }, 720 },
729 721
730 /** 722 /**
731 * @param {!Event} event 723 * @param {!Event} event
732 */ 724 */
733 _onMouseMove: function(event) 725 _onMouseMove: function(event)
734 { 726 {
735 if (event.which) 727 if (event.which)
736 return; 728 return;
737 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.ObjectHov ered, this._activeObjectFromEventPoint(event)); 729 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.ObjectHov ered, this._selectionFromEventPoint(event));
738 }, 730 },
739 731
740 /** 732 /**
741 * @param {!Event} event 733 * @param {!Event} event
742 */ 734 */
743 _onMouseDown: function(event) 735 _onMouseDown: function(event)
744 { 736 {
745 this._mouseDownX = event.clientX; 737 this._mouseDownX = event.clientX;
746 this._mouseDownY = event.clientY; 738 this._mouseDownY = event.clientY;
747 }, 739 },
748 740
749 /** 741 /**
750 * @param {!Event} event 742 * @param {!Event} event
751 */ 743 */
752 _onMouseUp: function(event) 744 _onMouseUp: function(event)
753 { 745 {
754 const maxDistanceInPixels = 6; 746 const maxDistanceInPixels = 6;
755 if (this._mouseDownX && Math.abs(event.clientX - this._mouseDownX) < max DistanceInPixels && Math.abs(event.clientY - this._mouseDownY) < maxDistanceInPi xels) 747 if (this._mouseDownX && Math.abs(event.clientX - this._mouseDownX) < max DistanceInPixels && Math.abs(event.clientY - this._mouseDownY) < maxDistanceInPi xels)
756 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.Objec tSelected, this._activeObjectFromEventPoint(event)); 748 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.Objec tSelected, this._selectionFromEventPoint(event));
757 delete this._mouseDownX; 749 delete this._mouseDownX;
758 delete this._mouseDownY; 750 delete this._mouseDownY;
759 }, 751 },
760 752
761 /** 753 /**
762 * @param {!Event} event 754 * @param {!Event} event
763 */ 755 */
764 _onDoubleClick: function(event) 756 _onDoubleClick: function(event)
765 { 757 {
766 var object = this._activeObjectFromEventPoint(event); 758 var object = this._selectionFromEventPoint(event);
767 if (object) { 759 if (object) {
768 if (object.type() == WebInspector.Layers3DView.ActiveObject.Type.Til e) 760 if (object.type() == WebInspector.Layers3DView.Selection.Type.Tile)
769 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.P aintProfilerRequested, object.traceEvent); 761 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.P aintProfilerRequested, object.traceEvent);
770 else if (object.layer) 762 else if (object.layer)
771 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.L ayerSnapshotRequested, object.layer); 763 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.L ayerSnapshotRequested, object.layer);
772 } 764 }
773 event.stopPropagation(); 765 event.stopPropagation();
774 }, 766 },
775 767
776 __proto__: WebInspector.VBox.prototype 768 __proto__: WebInspector.VBox.prototype
777 } 769 }
778 770
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, thi s._gl.CLAMP_TO_EDGE); 930 this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, thi s._gl.CLAMP_TO_EDGE);
939 this._gl.bindTexture(this._gl.TEXTURE_2D, null); 931 this._gl.bindTexture(this._gl.TEXTURE_2D, null);
940 return texture; 932 return texture;
941 }, 933 },
942 934
943 __proto__: WebInspector.Object.prototype 935 __proto__: WebInspector.Object.prototype
944 } 936 }
945 937
946 /** 938 /**
947 * @constructor 939 * @constructor
948 * @param {?WebInspector.Layers3DView.ActiveObject} relatedObject 940 * @param {?WebInspector.Layers3DView.Selection} relatedObject
949 */ 941 */
950 WebInspector.Layers3DView.Rectangle = function(relatedObject) 942 WebInspector.Layers3DView.Rectangle = function(relatedObject)
951 { 943 {
952 this.relatedObject = relatedObject; 944 this.relatedObject = relatedObject;
953 /** @type {number} */ 945 /** @type {number} */
954 this.lineWidth = 1; 946 this.lineWidth = 1;
955 /** @type {?Array.<number>} */ 947 /** @type {?Array.<number>} */
956 this.borderColor = null; 948 this.borderColor = null;
957 /** @type {?Array.<number>} */ 949 /** @type {?Array.<number>} */
958 this.fillColor = null; 950 this.fillColor = null;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 var product = WebInspector.Geometry.scalarProduct(normal, WebInspect or.Geometry.crossProduct(tVects[i], tVects[(i + 1) % tVects.length])); 1042 var product = WebInspector.Geometry.scalarProduct(normal, WebInspect or.Geometry.crossProduct(tVects[i], tVects[(i + 1) % tVects.length]));
1051 if (product < 0) 1043 if (product < 0)
1052 return undefined; 1044 return undefined;
1053 } 1045 }
1054 return t; 1046 return t;
1055 } 1047 }
1056 } 1048 }
1057 1049
1058 /** 1050 /**
1059 * @constructor 1051 * @constructor
1052 * @param {!WebInspector.Layers3DView.Selection.Type} type
1060 */ 1053 */
1061 WebInspector.Layers3DView.ActiveObject = function() 1054 WebInspector.Layers3DView.Selection = function(type)
1062 { 1055 {
1056 this._type = type;
1063 } 1057 }
1064 1058
1065 /** 1059 /**
1066 * @enum {string} 1060 * @enum {string}
1067 */ 1061 */
1068 WebInspector.Layers3DView.ActiveObject.Type = { 1062 WebInspector.Layers3DView.Selection.Type = {
1069 Layer: "Layer", 1063 Layer: "Layer",
1070 ScrollRect: "ScrollRect", 1064 ScrollRect: "ScrollRect",
1071 Tile: "Tile", 1065 Tile: "Tile",
1072 }; 1066 };
1073 1067
1074 /** 1068 WebInspector.Layers3DView.Selection.prototype = {
1075 * @param {!WebInspector.Layer} layer
1076 * @return {!WebInspector.Layers3DView.ActiveObject}
1077 */
1078 WebInspector.Layers3DView.ActiveObject.createLayerActiveObject = function(layer)
1079 {
1080 var activeObject = new WebInspector.Layers3DView.ActiveObject();
1081 activeObject._type = WebInspector.Layers3DView.ActiveObject.Type.Layer;
1082 activeObject.layer = layer;
1083 return activeObject;
1084 }
1085
1086 /**
1087 * @param {!WebInspector.Layer} layer
1088 * @param {number} scrollRectIndex
1089 * @return {!WebInspector.Layers3DView.ActiveObject}
1090 */
1091 WebInspector.Layers3DView.ActiveObject.createScrollRectActiveObject = function(l ayer, scrollRectIndex)
1092 {
1093 var activeObject = new WebInspector.Layers3DView.ActiveObject();
1094 activeObject._type = WebInspector.Layers3DView.ActiveObject.Type.ScrollRect;
1095 activeObject.layer = layer;
1096 activeObject.scrollRectIndex = scrollRectIndex;
1097 return activeObject;
1098 }
1099
1100 /**
1101 * @param {!WebInspector.Layer} layer
1102 * @param {!WebInspector.TracingModel.Event} traceEvent
1103 * @return {!WebInspector.Layers3DView.ActiveObject}
1104 */
1105 WebInspector.Layers3DView.ActiveObject.createTileActiveObject = function(layer, traceEvent)
1106 {
1107 var activeObject = new WebInspector.Layers3DView.ActiveObject();
1108 activeObject._type = WebInspector.Layers3DView.ActiveObject.Type.Tile;
1109 activeObject.layer = layer;
1110 activeObject.traceEvent = traceEvent;
1111 return activeObject;
1112 }
1113
1114 WebInspector.Layers3DView.ActiveObject.prototype = {
1115 /** 1069 /**
1116 * @return {!WebInspector.Layers3DView.ActiveObject.Type} 1070 * @return {!WebInspector.Layers3DView.Selection.Type}
1117 */ 1071 */
1118 type: function() 1072 type: function()
1119 { 1073 {
1120 return this._type; 1074 return this._type;
1075 },
1076
1077 /**
1078 * @param {!WebInspector.Layers3DView.Selection} other
1079 * @return {boolean}
1080 */
1081 isEqual: function(other)
1082 {
1083 return false;
1121 } 1084 }
1122 }; 1085 };
1123 1086
1124 /** 1087 /**
1125 * @constructor 1088 * @constructor
1089 * @extends {WebInspector.Layers3DView.Selection}
1090 */
1091 WebInspector.Layers3DView.LayerSelection = function(layer)
1092 {
1093 WebInspector.Layers3DView.Selection.call(this, WebInspector.Layers3DView.Sel ection.Type.Layer);
1094 this.layer = layer;
1095 }
1096
1097 WebInspector.Layers3DView.LayerSelection.prototype = {
1098 /**
1099 * @override
1100 * @param {!WebInspector.Layers3DView.Selection} other
1101 * @return {boolean}
1102 */
1103 isEqual: function(other)
1104 {
1105 return other._type === WebInspector.Layers3DView.Selection.Type.Layer && other.layer.id() === this.layer.id();
1106 },
1107
1108 __proto__: WebInspector.Layers3DView.Selection.prototype
1109 };
1110
1111 /**
1112 * @constructor
1113 * @extends {WebInspector.Layers3DView.Selection}
1114 */
1115 WebInspector.Layers3DView.ScrollRectSelection = function(layer, scrollRectIndex)
1116 {
1117 WebInspector.Layers3DView.Selection.call(this, WebInspector.Layers3DView.Sel ection.Type.ScrollRect);
1118 this.layer = layer;
1119 this.scrollRectIndex = scrollRectIndex;
1120 }
1121
1122 WebInspector.Layers3DView.ScrollRectSelection.prototype = {
1123 /**
1124 * @override
1125 * @param {!WebInspector.Layers3DView.Selection} other
1126 * @return {boolean}
1127 */
1128 isEqual: function(other)
1129 {
1130 return other._type === WebInspector.Layers3DView.Selection.Type.ScrollRe ct &&
1131 this.layer.id() === other.layer.id() && this.scrollRectIndex === oth er.scrollRectIndex
1132 },
1133
1134 __proto__: WebInspector.Layers3DView.Selection.prototype
1135 }
1136
1137 /**
1138 * @constructor
1139 * @extends {WebInspector.Layers3DView.Selection}
1140 * @param {!WebInspector.Layer} layer
1141 * @param {!WebInspector.TracingModel.Event} traceEvent
1142 */
1143 WebInspector.Layers3DView.TileSelection = function(layer, traceEvent)
1144 {
1145 WebInspector.Layers3DView.Selection.call(this, WebInspector.Layers3DView.Sel ection.Type.Tile);
1146 this.layer = layer;
1147 this.traceEvent = traceEvent;
1148 }
1149
1150 WebInspector.Layers3DView.TileSelection.prototype = {
1151 /**
1152 * @override
1153 * @param {!WebInspector.Layers3DView.Selection} other
1154 * @return {boolean}
1155 */
1156 isEqual: function(other)
1157 {
1158 return other._type === WebInspector.Layers3DView.Selection.Type.Tile
1159 && this.layer.id() === other.layer.id() && this.traceEvent === other .traceEvent;
1160 },
1161
1162 __proto__: WebInspector.Layers3DView.Selection.prototype
1163 }
1164
1165 /**
1166 * @constructor
1126 * @param {!WebInspector.PaintProfilerSnapshot} snapshot 1167 * @param {!WebInspector.PaintProfilerSnapshot} snapshot
1127 * @param {!Array.<number>} rect 1168 * @param {!Array.<number>} rect
1128 * @param {!WebInspector.TracingModel.Event} traceEvent 1169 * @param {!WebInspector.TracingModel.Event} traceEvent
1129 */ 1170 */
1130 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent) 1171 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent)
1131 { 1172 {
1132 this.snapshot = snapshot; 1173 this.snapshot = snapshot;
1133 this.rect = rect; 1174 this.rect = rect;
1134 this.traceEvent = traceEvent; 1175 this.traceEvent = traceEvent;
1135 this.scale = 0; 1176 this.scale = 0;
1136 /** @type {?WebGLTexture} */ 1177 /** @type {?WebGLTexture} */
1137 this.texture = null; 1178 this.texture = null;
1138 } 1179 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/timeline/LayerTreeOutline.js ('k') | Source/devtools/front_end/timeline/TimelineLayersView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698