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

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: 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)
pfeldman 2014/11/11 17:25:48 {}
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 rect.lineWidth = isSelected ? WebInspector.Layers3DView.SelectedBorderWi dth : WebInspector.Layers3DView.BorderWidth;
448 this._rects.push(rect); 442 this._rects.push(rect);
449 }, 443 },
450 444
451 /** 445 /**
452 * @param {!WebInspector.Layer} layer 446 * @param {!WebInspector.Layer} layer
453 */ 447 */
454 _calculateLayerScrollRects: function(layer) 448 _calculateLayerScrollRects: function(layer)
455 { 449 {
456 var scrollRects = layer.scrollRects(); 450 var scrollRects = layer.scrollRects();
457 for (var i = 0; i < scrollRects.length; ++i) { 451 for (var i = 0; i < scrollRects.length; ++i) {
458 var activeObject = WebInspector.Layers3DView.ActiveObject.createScro llRectActiveObject(layer, i); 452 var selection = new WebInspector.Layers3DView.ScrollRectSelection(la yer, i);
459 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); 453 var rect = new WebInspector.Layers3DView.Rectangle(selection);
460 rect.calculateVerticesFromRect(layer, scrollRects[i].rect, this._cal culateScrollRectDepth(layer, i)); 454 rect.calculateVerticesFromRect(layer, scrollRects[i].rect, this._cal culateScrollRectDepth(layer, i));
461 var isSelected = this._isObjectActive(WebInspector.Layers3DView.Outl ineType.Selected, layer, i); 455 rect.fillColor = WebInspector.Layers3DView.ScrollRectBackgroundColor ;
462 var color = isSelected ? WebInspector.Layers3DView.SelectedScrollRec tBackgroundColor : WebInspector.Layers3DView.ScrollRectBackgroundColor; 456 this._appendRect(rect);
463 rect.fillColor = color;
464 rect.borderColor = WebInspector.Layers3DView.ScrollRectBorderColor;
465 this._rects.push(rect);
466 } 457 }
467 }, 458 },
468 459
469 /** 460 /**
470 * @param {!WebInspector.Layer} layer 461 * @param {!WebInspector.Layer} layer
471 */ 462 */
472 _calculateLayerImageRect: function(layer) 463 _calculateLayerImageRect: function(layer)
473 { 464 {
474 var layerTexture = this._layerTexture; 465 var layerTexture = this._layerTexture;
475 if (layer.id() !== layerTexture.layerId) 466 if (layer.id() !== layerTexture.layerId)
476 return; 467 return;
477 var activeObject = WebInspector.Layers3DView.ActiveObject.createLayerAct iveObject(layer); 468 var selection = new WebInspector.Layers3DView.LayerSelection(layer);
478 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); 469 var rect = new WebInspector.Layers3DView.Rectangle(selection);
479 rect.setVertices(layer.quad(), this._depthForLayer(layer)); 470 rect.setVertices(layer.quad(), this._depthForLayer(layer));
480 rect.texture = layerTexture.texture; 471 rect.texture = layerTexture.texture;
481 this._rects.push(rect); 472 this._appendRect(rect);
482 }, 473 },
483 474
484 /** 475 /**
485 * @param {!WebInspector.Layer} layer 476 * @param {!WebInspector.Layer} layer
486 */ 477 */
487 _calculateLayerTileRects: function(layer) 478 _calculateLayerTileRects: function(layer)
488 { 479 {
489 var tiles = this._textureManager.tilesForLayer(layer.id()); 480 var tiles = this._textureManager.tilesForLayer(layer.id());
490 for (var i = 0; i < tiles.length; ++i) { 481 for (var i = 0; i < tiles.length; ++i) {
491 var tile = tiles[i]; 482 var tile = tiles[i];
492 if (!tile.texture) 483 if (!tile.texture)
493 continue; 484 continue;
494 var activeObject = WebInspector.Layers3DView.ActiveObject.createTile ActiveObject(layer, tile.traceEvent); 485 var selection = new WebInspector.Layers3DView.TileSelection(layer, t ile.traceEvent);
495 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); 486 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) ; 487 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; 488 rect.texture = tile.texture;
498 this._rects.push(rect); 489 this._appendRect(rect);
499 } 490 }
500 }, 491 },
501 492
502 _calculateRects: function() 493 _calculateRects: function()
503 { 494 {
504 this._rects = []; 495 this._rects = [];
505 496
506 this._layerTree.forEachLayer(this._calculateLayerRect.bind(this)); 497 this._layerTree.forEachLayer(this._calculateLayerRect.bind(this));
507 498
508 if (this._showSlowScrollRectsSetting.get()) 499 if (this._showSlowScrollRectsSetting.get())
509 this._layerTree.forEachLayer(this._calculateLayerScrollRects.bind(th is)); 500 this._layerTree.forEachLayer(this._calculateLayerScrollRects.bind(th is));
510 501
511 if (this._showPaintsSetting.get()) { 502 if (this._showPaintsSetting.get()) {
512 if (this._layerTexture) 503 if (this._layerTexture)
513 this._layerTree.forEachLayer(this._calculateLayerImageRect.bind( this)); 504 this._layerTree.forEachLayer(this._calculateLayerImageRect.bind( this));
514 else 505 else
515 this._layerTree.forEachLayer(this._calculateLayerTileRects.bind( this)); 506 this._layerTree.forEachLayer(this._calculateLayerTileRects.bind( this));
516 } 507 }
517 }, 508 },
518 509
519 /** 510 /**
520 * @param {!Array.<number>} color 511 * @param {!Array.<number>} color
521 * @return {!Array.<number>} 512 * @return {!Array.<number>}
522 */ 513 */
523 _makeColorsArray: function(color) 514 _makeColorsArray: function(color)
524 { 515 {
525 var colors = []; 516 var colors = [];
526 var normalizedColor = [color[0] / 255, color[1] / 255, color[2] / 255, c olor[3]]; 517 var normalizedColor = [color[0] / 255, color[1] / 255, color[2] / 255, c olor[3]];
527 for (var i = 0; i < 4; i++) { 518 for (var i = 0; i < 4; i++)
528 colors = colors.concat(normalizedColor); 519 colors = colors.concat(normalizedColor);
529 }
530 return colors; 520 return colors;
531 }, 521 },
532 522
533 /** 523 /**
534 * @param {!Object} attribute 524 * @param {!Object} attribute
535 * @param {!Array.<number>} array 525 * @param {!Array.<number>} array
536 * @param {!number} length 526 * @param {!number} length
537 */ 527 */
538 _setVertexAttribute: function(attribute, array, length) 528 _setVertexAttribute: function(attribute, array, length)
539 { 529 {
540 var gl = this._gl; 530 var gl = this._gl;
541 var buffer = gl.createBuffer(); 531 var buffer = gl.createBuffer();
542 gl.bindBuffer(gl.ARRAY_BUFFER, buffer); 532 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
543 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(array), gl.STATIC_DRAW); 533 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(array), gl.STATIC_DRAW);
544 gl.vertexAttribPointer(attribute, length, gl.FLOAT, false, 0, 0); 534 gl.vertexAttribPointer(attribute, length, gl.FLOAT, false, 0, 0);
545 }, 535 },
546 536
547 /** 537 /**
548 * @param {!Array.<number>} vertices 538 * @param {!Array.<number>} vertices
549 * @param {number} mode 539 * @param {number} mode
550 * @param {!Array.<number>=} color 540 * @param {!Array.<number>=} color
551 * @param {!Object=} texture 541 * @param {!Object=} texture
552 */ 542 */
553 _drawRectangle: function(vertices, mode, color, texture) 543 _drawRectangle: function(vertices, mode, color, texture)
554 { 544 {
555 var gl = this._gl; 545 var gl = this._gl;
556 var white = [255, 255, 255, 1]; 546 var white = [255, 255, 255, 1];
547 color = color || white;
557 this._setVertexAttribute(this._shaderProgram.vertexPositionAttribute, ve rtices, 3); 548 this._setVertexAttribute(this._shaderProgram.vertexPositionAttribute, ve rtices, 3);
558 this._setVertexAttribute(this._shaderProgram.textureCoordAttribute, [0, 1, 1, 1, 1, 0, 0, 0], 2); 549 this._setVertexAttribute(this._shaderProgram.textureCoordAttribute, [0, 1, 1, 1, 1, 0, 0, 0], 2);
550 this._setVertexAttribute(this._shaderProgram.vertexColorAttribute, this. _makeColorsArray(color), color.length);
559 551
560 if (texture) { 552 if (texture) {
561 this._setVertexAttribute(this._shaderProgram.vertexColorAttribute, t his._makeColorsArray(white), white.length);
562 gl.activeTexture(gl.TEXTURE0); 553 gl.activeTexture(gl.TEXTURE0);
563 gl.bindTexture(gl.TEXTURE_2D, texture); 554 gl.bindTexture(gl.TEXTURE_2D, texture);
564 gl.uniform1i(this._shaderProgram.samplerUniform, 0); 555 gl.uniform1i(this._shaderProgram.samplerUniform, 0);
565 } else { 556 } else {
566 this._setVertexAttribute(this._shaderProgram.vertexColorAttribute, t his._makeColorsArray(color || white), color.length);
567 gl.bindTexture(gl.TEXTURE_2D, this._whiteTexture); 557 gl.bindTexture(gl.TEXTURE_2D, this._whiteTexture);
568 } 558 }
569 559
570 var numberOfVertices = vertices.length / 3; 560 var numberOfVertices = vertices.length / 3;
571 gl.drawArrays(mode, 0, numberOfVertices); 561 gl.drawArrays(mode, 0, numberOfVertices);
572 }, 562 },
573 563
574 /** 564 /**
575 * @param {!Array.<number>} vertices 565 * @param {!Array.<number>} vertices
576 * @param {!WebGLTexture} texture 566 * @param {!WebGLTexture} texture
567 * @param {!Array.<number>=} color
577 */ 568 */
578 _drawTexture: function(vertices, texture) 569 _drawTexture: function(vertices, texture, color)
579 { 570 {
580 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, undefined, texture) ; 571 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, color, texture);
581 }, 572 },
582 573
583 _drawViewportAndChrome: function() 574 _drawViewportAndChrome: function()
584 { 575 {
585 var viewport = this._layerTree.viewportSize(); 576 var viewport = this._layerTree.viewportSize();
586 if (!viewport) 577 if (!viewport)
587 return; 578 return;
588 579
589 var drawChrome = !WebInspector.settings.frameViewerHideChromeWindow.get( ) && this._chromeTextures.length >= 3 && this._chromeTextures.indexOf(undefined) < 0; 580 var drawChrome = !WebInspector.settings.frameViewerHideChromeWindow.get( ) && this._chromeTextures.length >= 3 && this._chromeTextures.indexOf(undefined) < 0;
590 var z = (this._maxDepth + 1) * WebInspector.Layers3DView.LayerSpacing; 581 var z = (this._maxDepth + 1) * WebInspector.Layers3DView.LayerSpacing;
(...skipping 21 matching lines...) Expand all
612 } 603 }
613 }, 604 },
614 605
615 /** 606 /**
616 * @param {!WebInspector.Layers3DView.Rectangle} rect 607 * @param {!WebInspector.Layers3DView.Rectangle} rect
617 */ 608 */
618 _drawViewRect: function(rect) 609 _drawViewRect: function(rect)
619 { 610 {
620 var vertices = rect.vertices; 611 var vertices = rect.vertices;
621 if (rect.texture) 612 if (rect.texture)
622 this._drawTexture(vertices, rect.texture); 613 this._drawTexture(vertices, rect.texture, rect.fillColor || undefine d);
623 else if (rect.fillColor) 614 else if (rect.fillColor)
624 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, rect.fillColor) ; 615 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, rect.fillColor) ;
625 this._gl.lineWidth(rect.lineWidth); 616 this._gl.lineWidth(rect.lineWidth);
626 if (rect.borderColor) 617 if (rect.borderColor)
627 this._drawRectangle(vertices, this._gl.LINE_LOOP, rect.borderColor); 618 this._drawRectangle(vertices, this._gl.LINE_LOOP, rect.borderColor);
628 }, 619 },
629 620
630 _update: function() 621 _update: function()
631 { 622 {
632 if (!this.isShowing()) { 623 if (!this.isShowing()) {
(...skipping 15 matching lines...) Expand all
648 this._textureManager.setScale(Number.constrain(0.1, 1, this._scale)); 639 this._textureManager.setScale(Number.constrain(0.1, 1, this._scale));
649 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); 640 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
650 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 641 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
651 642
652 this._rects.forEach(this._drawViewRect.bind(this)); 643 this._rects.forEach(this._drawViewRect.bind(this));
653 this._drawViewportAndChrome(); 644 this._drawViewportAndChrome();
654 }, 645 },
655 646
656 /** 647 /**
657 * @param {!Event} event 648 * @param {!Event} event
658 * @return {?WebInspector.Layers3DView.ActiveObject} 649 * @return {?WebInspector.Layers3DView.Selection}
659 */ 650 */
660 _activeObjectFromEventPoint: function(event) 651 _selectionFromEventPoint: function(event)
661 { 652 {
662 if (!this._layerTree) 653 if (!this._layerTree)
663 return null; 654 return null;
664 var closestIntersectionPoint = Infinity; 655 var closestIntersectionPoint = Infinity;
665 var closestObject = null; 656 var closestObject = null;
666 var projectionMatrix = new WebKitCSSMatrix().scale(1, -1, -1).translate( -1, -1, 0).multiply(this._projectionMatrix); 657 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; 658 var x0 = (event.clientX - this._canvasElement.totalOffsetLeft()) * windo w.devicePixelRatio;
668 var y0 = -(event.clientY - this._canvasElement.totalOffsetTop()) * windo w.devicePixelRatio; 659 var y0 = -(event.clientY - this._canvasElement.totalOffsetTop()) * windo w.devicePixelRatio;
669 660
670 /** 661 /**
(...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); 700 this._showSlowScrollRectsSetting = this._createVisibilitySetting("Slow s croll rects", "frameViewerShowSlowScrollRects", true, this._panelStatusBarElemen t);
710 this._showPaintsSetting = this._createVisibilitySetting("Paints", "frame ViewerShowPaints", true, this._panelStatusBarElement); 701 this._showPaintsSetting = this._createVisibilitySetting("Paints", "frame ViewerShowPaints", true, this._panelStatusBarElement);
711 WebInspector.settings.frameViewerHideChromeWindow.addChangeListener(this ._update, this); 702 WebInspector.settings.frameViewerHideChromeWindow.addChangeListener(this ._update, this);
712 }, 703 },
713 704
714 /** 705 /**
715 * @param {!Event} event 706 * @param {!Event} event
716 */ 707 */
717 _onContextMenu: function(event) 708 _onContextMenu: function(event)
718 { 709 {
719 var activeObject = this._activeObjectFromEventPoint(event); 710 var selection = this._selectionFromEventPoint(event);
720 var node = activeObject && activeObject.layer && activeObject.layer.node ForSelfOrAncestor(); 711 var node = selection && selection.layer && selection.layer.nodeForSelfOr Ancestor();
721 var contextMenu = new WebInspector.ContextMenu(event); 712 var contextMenu = new WebInspector.ContextMenu(event);
722 contextMenu.appendItem(WebInspector.UIString("Reset View"), this._transf ormController.resetAndNotify.bind(this._transformController), false); 713 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) 714 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); 715 contextMenu.appendItem(WebInspector.UIString("Show Paint Profiler"), this.dispatchEventToListeners.bind(this, WebInspector.Layers3DView.Events.Paint ProfilerRequested, selection.traceEvent), false);
725 if (node) 716 if (node)
726 contextMenu.appendApplicableItems(node); 717 contextMenu.appendApplicableItems(node);
727 contextMenu.show(); 718 contextMenu.show();
728 }, 719 },
729 720
730 /** 721 /**
731 * @param {!Event} event 722 * @param {!Event} event
732 */ 723 */
733 _onMouseMove: function(event) 724 _onMouseMove: function(event)
734 { 725 {
735 if (event.which) 726 if (event.which)
736 return; 727 return;
737 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.ObjectHov ered, this._activeObjectFromEventPoint(event)); 728 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.ObjectHov ered, this._selectionFromEventPoint(event));
738 }, 729 },
739 730
740 /** 731 /**
741 * @param {!Event} event 732 * @param {!Event} event
742 */ 733 */
743 _onMouseDown: function(event) 734 _onMouseDown: function(event)
744 { 735 {
745 this._mouseDownX = event.clientX; 736 this._mouseDownX = event.clientX;
746 this._mouseDownY = event.clientY; 737 this._mouseDownY = event.clientY;
747 }, 738 },
748 739
749 /** 740 /**
750 * @param {!Event} event 741 * @param {!Event} event
751 */ 742 */
752 _onMouseUp: function(event) 743 _onMouseUp: function(event)
753 { 744 {
754 const maxDistanceInPixels = 6; 745 const maxDistanceInPixels = 6;
755 if (this._mouseDownX && Math.abs(event.clientX - this._mouseDownX) < max DistanceInPixels && Math.abs(event.clientY - this._mouseDownY) < maxDistanceInPi xels) 746 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)); 747 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.Objec tSelected, this._selectionFromEventPoint(event));
757 delete this._mouseDownX; 748 delete this._mouseDownX;
758 delete this._mouseDownY; 749 delete this._mouseDownY;
759 }, 750 },
760 751
761 /** 752 /**
762 * @param {!Event} event 753 * @param {!Event} event
763 */ 754 */
764 _onDoubleClick: function(event) 755 _onDoubleClick: function(event)
765 { 756 {
766 var object = this._activeObjectFromEventPoint(event); 757 var object = this._selectionFromEventPoint(event);
767 if (object) { 758 if (object) {
768 if (object.type() == WebInspector.Layers3DView.ActiveObject.Type.Til e) 759 if (object.type() == WebInspector.Layers3DView.Selection.Type.Tile)
769 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.P aintProfilerRequested, object.traceEvent); 760 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.P aintProfilerRequested, object.traceEvent);
770 else if (object.layer) 761 else if (object.layer)
771 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.L ayerSnapshotRequested, object.layer); 762 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.L ayerSnapshotRequested, object.layer);
772 } 763 }
773 event.stopPropagation(); 764 event.stopPropagation();
774 }, 765 },
775 766
776 __proto__: WebInspector.VBox.prototype 767 __proto__: WebInspector.VBox.prototype
777 } 768 }
778 769
(...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); 929 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); 930 this._gl.bindTexture(this._gl.TEXTURE_2D, null);
940 return texture; 931 return texture;
941 }, 932 },
942 933
943 __proto__: WebInspector.Object.prototype 934 __proto__: WebInspector.Object.prototype
944 } 935 }
945 936
946 /** 937 /**
947 * @constructor 938 * @constructor
948 * @param {?WebInspector.Layers3DView.ActiveObject} relatedObject 939 * @param {?WebInspector.Layers3DView.Selection} relatedObject
949 */ 940 */
950 WebInspector.Layers3DView.Rectangle = function(relatedObject) 941 WebInspector.Layers3DView.Rectangle = function(relatedObject)
951 { 942 {
952 this.relatedObject = relatedObject; 943 this.relatedObject = relatedObject;
953 /** @type {number} */ 944 /** @type {number} */
954 this.lineWidth = 1; 945 this.lineWidth = 1;
955 /** @type {?Array.<number>} */ 946 /** @type {?Array.<number>} */
956 this.borderColor = null; 947 this.borderColor = null;
957 /** @type {?Array.<number>} */ 948 /** @type {?Array.<number>} */
958 this.fillColor = null; 949 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])); 1041 var product = WebInspector.Geometry.scalarProduct(normal, WebInspect or.Geometry.crossProduct(tVects[i], tVects[(i + 1) % tVects.length]));
1051 if (product < 0) 1042 if (product < 0)
1052 return undefined; 1043 return undefined;
1053 } 1044 }
1054 return t; 1045 return t;
1055 } 1046 }
1056 } 1047 }
1057 1048
1058 /** 1049 /**
1059 * @constructor 1050 * @constructor
1051 * @param {!WebInspector.Layers3DView.Selection.Type} type
1060 */ 1052 */
1061 WebInspector.Layers3DView.ActiveObject = function() 1053 WebInspector.Layers3DView.Selection = function(type)
1062 { 1054 {
1055 this._type = type;
1063 } 1056 }
1064 1057
1065 /** 1058 /**
1066 * @enum {string} 1059 * @enum {string}
1067 */ 1060 */
1068 WebInspector.Layers3DView.ActiveObject.Type = { 1061 WebInspector.Layers3DView.Selection.Type = {
1069 Layer: "Layer", 1062 Layer: "Layer",
1070 ScrollRect: "ScrollRect", 1063 ScrollRect: "ScrollRect",
1071 Tile: "Tile", 1064 Tile: "Tile",
1072 }; 1065 };
1073 1066
1074 /** 1067 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 /** 1068 /**
1116 * @return {!WebInspector.Layers3DView.ActiveObject.Type} 1069 * @return {!WebInspector.Layers3DView.Selection.Type}
1117 */ 1070 */
1118 type: function() 1071 type: function()
1119 { 1072 {
1120 return this._type; 1073 return this._type;
1074 },
1075
1076 /**
1077 * @param {!WebInspector.Layers3DView.Selection} other
1078 * @return {boolean}
1079 */
1080 isEqual: function(other)
1081 {
1082 return false;
1121 } 1083 }
1122 }; 1084 };
1123 1085
1124 /** 1086 /**
1125 * @constructor 1087 * @constructor
1088 * @extends {WebInspector.Layers3DView.Selection}
1089 */
1090 WebInspector.Layers3DView.LayerSelection = function(layer)
1091 {
1092 WebInspector.Layers3DView.Selection.call(this, WebInspector.Layers3DView.Sel ection.Type.Layer);
1093 this.layer = layer;
1094 }
1095
1096 WebInspector.Layers3DView.LayerSelection.prototype = {
1097 /**
1098 * @override
1099 * @param {!WebInspector.Layers3DView.Selection} other
1100 * @return {boolean}
1101 */
1102 isEqual: function(other)
1103 {
1104 return other._type === WebInspector.Layers3DView.Selection.Type.Layer && other.layer.id() === this.layer.id();
1105 },
1106
1107 __proto__: WebInspector.Layers3DView.Selection.prototype
1108 };
1109
1110 /**
1111 * @constructor
1112 * @extends {WebInspector.Layers3DView.Selection}
1113 */
1114 WebInspector.Layers3DView.ScrollRectSelection = function(layer, scrollRectIndex)
1115 {
1116 WebInspector.Layers3DView.Selection.call(this, WebInspector.Layers3DView.Sel ection.Type.ScrollRect);
1117 this.layer = layer;
1118 this.scrollRectIndex = scrollRectIndex;
1119 }
1120
1121 WebInspector.Layers3DView.ScrollRectSelection.prototype = {
1122 /**
1123 * @override
1124 * @param {!WebInspector.Layers3DView.Selection} other
1125 * @return {boolean}
1126 */
1127 isEqual: function(other)
1128 {
1129 return other._type === WebInspector.Layers3DView.Selection.Type.ScrollRe ct &&
1130 this.layer.id() === other.layer.id() && this.scrollRectIndex === oth er.scrollRectIndex
1131 },
1132
1133 __proto__: WebInspector.Layers3DView.Selection.prototype
1134 }
1135
1136 /**
1137 * @constructor
1138 * @extends {WebInspector.Layers3DView.Selection}
1139 * @param {!WebInspector.Layer} layer
1140 * @param {!WebInspector.TracingModel.Event} traceEvent
1141 */
1142 WebInspector.Layers3DView.TileSelection = function(layer, traceEvent)
1143 {
1144 WebInspector.Layers3DView.Selection.call(this, WebInspector.Layers3DView.Sel ection.Type.Tile);
1145 this.layer = layer;
1146 this.traceEvent = traceEvent;
1147 }
1148
1149 WebInspector.Layers3DView.TileSelection.prototype = {
1150 /**
1151 * @override
1152 * @param {!WebInspector.Layers3DView.Selection} other
1153 * @return {boolean}
1154 */
1155 isEqual: function(other)
1156 {
1157 return other._type === WebInspector.Layers3DView.Selection.Type.Tile
1158 && this.layer.id() === other.layer.id() && this.traceEvent === other .traceEvent;
1159 },
1160
1161 __proto__: WebInspector.Layers3DView.Selection.prototype
1162 }
1163
1164 /**
1165 * @constructor
1126 * @param {!WebInspector.PaintProfilerSnapshot} snapshot 1166 * @param {!WebInspector.PaintProfilerSnapshot} snapshot
1127 * @param {!Array.<number>} rect 1167 * @param {!Array.<number>} rect
1128 * @param {!WebInspector.TracingModel.Event} traceEvent 1168 * @param {!WebInspector.TracingModel.Event} traceEvent
1129 */ 1169 */
1130 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent) 1170 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent)
1131 { 1171 {
1132 this.snapshot = snapshot; 1172 this.snapshot = snapshot;
1133 this.rect = rect; 1173 this.rect = rect;
1134 this.traceEvent = traceEvent; 1174 this.traceEvent = traceEvent;
1135 this.scale = 0; 1175 this.scale = 0;
1136 /** @type {?WebGLTexture} */ 1176 /** @type {?WebGLTexture} */
1137 this.texture = null; 1177 this.texture = null;
1138 } 1178 }
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