Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 this._picturesForLayer = {}; | 52 this._picturesForLayer = {}; |
| 53 this._scrollRectQuadsForLayer = {}; | 53 this._scrollRectQuadsForLayer = {}; |
| 54 this._isVisible = {}; | 54 this._isVisible = {}; |
| 55 this._layerTree = null; | 55 this._layerTree = null; |
| 56 this._textureManager = new WebInspector.LayerTextureManager(); | 56 this._textureManager = new WebInspector.LayerTextureManager(); |
| 57 this._textureManager.addEventListener(WebInspector.LayerTextureManager.Event s.TextureUpdated, this._update, this); | 57 this._textureManager.addEventListener(WebInspector.LayerTextureManager.Event s.TextureUpdated, this._update, this); |
| 58 | 58 |
| 59 WebInspector.settings.showPaintRects.addChangeListener(this._update, this); | 59 WebInspector.settings.showPaintRects.addChangeListener(this._update, this); |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** @typedef {{layer: !WebInspector.Layer, scrollRectIndex: number}|{layer: !Web Inspector.Layer}} */ | |
| 63 WebInspector.Layers3DView.ActiveObject; | |
| 64 | |
| 65 /** @typedef {{borderColor: !Array.<number>, borderWidth: number}} */ | 62 /** @typedef {{borderColor: !Array.<number>, borderWidth: number}} */ |
| 66 WebInspector.Layers3DView.LayerStyle; | 63 WebInspector.Layers3DView.LayerStyle; |
| 67 | 64 |
| 68 /** @typedef {{layerId: string, rect: !Array.<number>, snapshot: !WebInspector.P aintProfilerSnapshot}} */ | 65 /** @typedef {{layerId: string, rect: !Array.<number>, snapshot: !WebInspector.P aintProfilerSnapshot, traceEvent: !WebInspector.TracingModel.Event}} */ |
| 69 WebInspector.Layers3DView.PaintTile; | 66 WebInspector.Layers3DView.PaintTile; |
| 70 | 67 |
| 71 /** | 68 /** |
| 72 * @enum {string} | 69 * @enum {string} |
| 73 */ | 70 */ |
| 74 WebInspector.Layers3DView.OutlineType = { | 71 WebInspector.Layers3DView.OutlineType = { |
| 75 Hovered: "hovered", | 72 Hovered: "hovered", |
| 76 Selected: "selected" | 73 Selected: "selected" |
| 77 } | 74 } |
| 78 | 75 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 142 |
| 146 /** | 143 /** |
| 147 * @param {?Array.<!WebInspector.Layers3DView.PaintTile>} tiles | 144 * @param {?Array.<!WebInspector.Layers3DView.PaintTile>} tiles |
| 148 */ | 145 */ |
| 149 setTiles: function(tiles) | 146 setTiles: function(tiles) |
| 150 { | 147 { |
| 151 this._textureManager.setTiles(tiles); | 148 this._textureManager.setTiles(tiles); |
| 152 }, | 149 }, |
| 153 | 150 |
| 154 /** | 151 /** |
| 152 * @param {!function(!WebInspector.TracingModel.Event)} callback | |
| 153 */ | |
| 154 setSelectPaintEventCallback: function(callback) | |
|
caseq
2014/07/17 13:12:22
Why isn't this an event?
malch
2014/07/17 15:17:44
Done.
| |
| 155 { | |
| 156 this._selectPaintEventCallback = callback; | |
| 157 }, | |
| 158 | |
| 159 /** | |
| 155 * @param {!WebInspector.Layer} layer | 160 * @param {!WebInspector.Layer} layer |
| 156 * @param {string=} imageURL | 161 * @param {string=} imageURL |
| 157 */ | 162 */ |
| 158 showImageForLayer: function(layer, imageURL) | 163 showImageForLayer: function(layer, imageURL) |
| 159 { | 164 { |
| 160 this._textureManager.createTexture(onTextureCreated.bind(this), imageURL ); | 165 this._textureManager.createTexture(onTextureCreated.bind(this), imageURL ); |
| 161 | 166 |
| 162 /** | 167 /** |
| 163 * @this {WebInspector.Layers3DView} | 168 * @this {WebInspector.Layers3DView} |
| 164 * @param {!WebGLTexture} texture | 169 * @param {!WebGLTexture} texture |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 return this._depthForLayer(layer) + index * WebInspector.Layers3DView.Sc rollRectSpacing + 1; | 396 return this._depthForLayer(layer) + index * WebInspector.Layers3DView.Sc rollRectSpacing + 1; |
| 392 }, | 397 }, |
| 393 | 398 |
| 394 /** | 399 /** |
| 395 * @param {!WebInspector.Layer} layer | 400 * @param {!WebInspector.Layer} layer |
| 396 */ | 401 */ |
| 397 _calculateLayerRect: function(layer) | 402 _calculateLayerRect: function(layer) |
| 398 { | 403 { |
| 399 if (!this._isVisible[layer.id()]) | 404 if (!this._isVisible[layer.id()]) |
| 400 return; | 405 return; |
| 401 var rect = new WebInspector.Layers3DView.Rectangle({layer: layer}); | 406 var activeObject = WebInspector.Layers3DView.ActiveObject.layerActiveObj ect(layer); |
| 407 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); | |
| 402 var style = this._styleForLayer(layer); | 408 var style = this._styleForLayer(layer); |
| 403 rect.setVertices(layer.quad(), this._depthForLayer(layer)); | 409 rect.setVertices(layer.quad(), this._depthForLayer(layer)); |
| 404 rect.lineWidth = style.borderWidth; | 410 rect.lineWidth = style.borderWidth; |
| 405 rect.borderColor = style.borderColor; | 411 rect.borderColor = style.borderColor; |
| 406 this._rects.push(rect); | 412 this._rects.push(rect); |
| 407 }, | 413 }, |
| 408 | 414 |
| 409 /** | 415 /** |
| 410 * @param {!WebInspector.Layer} layer | 416 * @param {!WebInspector.Layer} layer |
| 411 */ | 417 */ |
| 412 _calculateLayerScrollRects: function(layer) | 418 _calculateLayerScrollRects: function(layer) |
| 413 { | 419 { |
| 414 var scrollRects = layer.scrollRects(); | 420 var scrollRects = layer.scrollRects(); |
| 415 for (var i = 0; i < scrollRects.length; ++i) { | 421 for (var i = 0; i < scrollRects.length; ++i) { |
| 416 var rect = new WebInspector.Layers3DView.Rectangle({layer: layer, sc rollRectIndex: i}); | 422 var activeObject = WebInspector.Layers3DView.ActiveObject.scrollRect ActiveObject(layer, i); |
| 423 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); | |
| 417 rect.calculateVerticesFromRect(layer, scrollRects[i].rect, this._cal culateScrollRectDepth(layer, i)); | 424 rect.calculateVerticesFromRect(layer, scrollRects[i].rect, this._cal culateScrollRectDepth(layer, i)); |
| 418 var isSelected = this._isObjectActive(WebInspector.Layers3DView.Outl ineType.Selected, layer, i); | 425 var isSelected = this._isObjectActive(WebInspector.Layers3DView.Outl ineType.Selected, layer, i); |
| 419 var color = isSelected ? WebInspector.Layers3DView.SelectedScrollRec tBackgroundColor : WebInspector.Layers3DView.ScrollRectBackgroundColor; | 426 var color = isSelected ? WebInspector.Layers3DView.SelectedScrollRec tBackgroundColor : WebInspector.Layers3DView.ScrollRectBackgroundColor; |
| 420 rect.fillColor = color; | 427 rect.fillColor = color; |
| 421 rect.borderColor = WebInspector.Layers3DView.ScrollRectBorderColor; | 428 rect.borderColor = WebInspector.Layers3DView.ScrollRectBorderColor; |
| 422 this._rects.push(rect); | 429 this._rects.push(rect); |
| 423 } | 430 } |
| 424 }, | 431 }, |
| 425 | 432 |
| 426 /** | 433 /** |
| 427 * @param {!WebInspector.Layer} layer | 434 * @param {!WebInspector.Layer} layer |
| 428 */ | 435 */ |
| 429 _calculateLayerImageRect: function(layer) | 436 _calculateLayerImageRect: function(layer) |
| 430 { | 437 { |
| 431 var layerTexture = this._layerTexture; | 438 var layerTexture = this._layerTexture; |
| 432 if (layer.id() !== layerTexture.layerId) | 439 if (layer.id() !== layerTexture.layerId) |
| 433 return; | 440 return; |
| 434 var rect = new WebInspector.Layers3DView.Rectangle({layer: layer}); | 441 var activeObject = WebInspector.Layers3DView.ActiveObject.layerActiveObj ect(layer); |
| 442 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); | |
| 435 rect.setVertices(layer.quad(), this._depthForLayer(layer)); | 443 rect.setVertices(layer.quad(), this._depthForLayer(layer)); |
| 436 rect.texture = layerTexture.texture; | 444 rect.texture = layerTexture.texture; |
| 437 this._rects.push(rect); | 445 this._rects.push(rect); |
| 438 }, | 446 }, |
| 439 | 447 |
| 440 /** | 448 /** |
| 441 * @param {!WebInspector.Layer} layer | 449 * @param {!WebInspector.Layer} layer |
| 442 */ | 450 */ |
| 443 _calculateLayerTileRects: function(layer) | 451 _calculateLayerTileRects: function(layer) |
| 444 { | 452 { |
| 445 var tiles = this._textureManager.tilesForLayer(layer.id()); | 453 var tiles = this._textureManager.tilesForLayer(layer.id()); |
| 446 for (var i = 0; i < tiles.length; ++i) { | 454 for (var i = 0; i < tiles.length; ++i) { |
| 447 var tile = tiles[i]; | 455 var tile = tiles[i]; |
| 448 if (!tile.texture) | 456 if (!tile.texture) |
| 449 continue; | 457 continue; |
| 450 var rect = new WebInspector.Layers3DView.Rectangle({layer: layer}); | 458 var activeObject = WebInspector.Layers3DView.ActiveObject.tileActive Object(layer, tile.traceEvent); |
| 451 rect.calculateVerticesFromRect(layer, {x: tile.rect[0], y: tile.rect [1], width: tile.rect[2], height: tile.rect[3]}, this._depthForLayer(layer)); | 459 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); |
| 460 rect.calculateVerticesFromRect(layer, {x: tile.rect[0], y: tile.rect [1], width: tile.rect[2], height: tile.rect[3]}, this._depthForLayer(layer) + 1) ; | |
| 452 rect.texture = tile.texture; | 461 rect.texture = tile.texture; |
| 453 this._rects.push(rect); | 462 this._rects.push(rect); |
| 454 } | 463 } |
| 455 }, | 464 }, |
| 456 | 465 |
| 457 _calculateViewportRect: function() | 466 _calculateViewportRect: function() |
| 458 { | 467 { |
| 459 var rect = new WebInspector.Layers3DView.Rectangle(null); | 468 var rect = new WebInspector.Layers3DView.Rectangle(null); |
| 460 var viewport = this._layerTree.viewportSize(); | 469 var viewport = this._layerTree.viewportSize(); |
| 461 var depth = (this._maxDepth + 1) * WebInspector.Layers3DView.LayerSpacin g; | 470 var depth = (this._maxDepth + 1) * WebInspector.Layers3DView.LayerSpacin g; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 642 | 651 |
| 643 /** | 652 /** |
| 644 * @param {!Event} event | 653 * @param {!Event} event |
| 645 */ | 654 */ |
| 646 _onContextMenu: function(event) | 655 _onContextMenu: function(event) |
| 647 { | 656 { |
| 648 var activeObject = this._activeObjectFromEventPoint(event); | 657 var activeObject = this._activeObjectFromEventPoint(event); |
| 649 var node = activeObject && activeObject.layer && activeObject.layer.node ForSelfOrAncestor(); | 658 var node = activeObject && activeObject.layer && activeObject.layer.node ForSelfOrAncestor(); |
| 650 var contextMenu = new WebInspector.ContextMenu(event); | 659 var contextMenu = new WebInspector.ContextMenu(event); |
| 651 contextMenu.appendItem("Reset view", this._transformController.resetAndN otify.bind(this._transformController), false); | 660 contextMenu.appendItem("Reset view", this._transformController.resetAndN otify.bind(this._transformController), false); |
| 661 if (this._selectPaintEventCallback && activeObject.type() === WebInspect or.Layers3DView.ActiveObject.Type.Tile) | |
| 662 contextMenu.appendItem("Paint event", this._selectPaintEventCallback .bind(this, activeObject.traceEvent), false); | |
|
caseq
2014/07/17 13:12:22
Use WebInspector.UIString() around UI strings (als
malch
2014/07/17 15:17:44
Done.
| |
| 652 if (node) | 663 if (node) |
| 653 contextMenu.appendApplicableItems(node); | 664 contextMenu.appendApplicableItems(node); |
| 654 contextMenu.show(); | 665 contextMenu.show(); |
| 655 }, | 666 }, |
| 656 | 667 |
| 657 /** | 668 /** |
| 658 * @param {!Event} event | 669 * @param {!Event} event |
| 659 */ | 670 */ |
| 660 _onMouseMove: function(event) | 671 _onMouseMove: function(event) |
| 661 { | 672 { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 684 delete this._mouseDownX; | 695 delete this._mouseDownX; |
| 685 delete this._mouseDownY; | 696 delete this._mouseDownY; |
| 686 }, | 697 }, |
| 687 | 698 |
| 688 /** | 699 /** |
| 689 * @param {!Event} event | 700 * @param {!Event} event |
| 690 */ | 701 */ |
| 691 _onDoubleClick: function(event) | 702 _onDoubleClick: function(event) |
| 692 { | 703 { |
| 693 var object = this._activeObjectFromEventPoint(event); | 704 var object = this._activeObjectFromEventPoint(event); |
| 694 if (object && object.layer) | 705 if (object) { |
| 695 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.Layer SnapshotRequested, object.layer); | 706 if (object.type() == WebInspector.Layers3DView.ActiveObject.Type.Til e) |
| 707 this._selectPaintEventCallback.call(this, object.traceEvent); | |
|
caseq
2014/07/17 13:12:22
Why are we invoking the client callback with `this
malch
2014/07/17 15:17:44
Acknowledged.
| |
| 708 else if (object.layer) | |
| 709 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.L ayerSnapshotRequested, object.layer); | |
| 710 } | |
| 696 event.stopPropagation(); | 711 event.stopPropagation(); |
| 697 }, | 712 }, |
| 698 | 713 |
| 699 __proto__: WebInspector.VBox.prototype | 714 __proto__: WebInspector.VBox.prototype |
| 700 } | 715 } |
| 701 | 716 |
| 702 /** | 717 /** |
| 703 * @constructor | 718 * @constructor |
| 704 * @extends {WebInspector.Object} | 719 * @extends {WebInspector.Object} |
| 705 */ | 720 */ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 this._tilesByLayerId = {}; | 754 this._tilesByLayerId = {}; |
| 740 if (!paintTiles) | 755 if (!paintTiles) |
| 741 return; | 756 return; |
| 742 for (var i = 0; i < paintTiles.length; ++i) { | 757 for (var i = 0; i < paintTiles.length; ++i) { |
| 743 var layerId = paintTiles[i].layerId; | 758 var layerId = paintTiles[i].layerId; |
| 744 var tilesForLayer = this._tilesByLayerId[layerId]; | 759 var tilesForLayer = this._tilesByLayerId[layerId]; |
| 745 if (!tilesForLayer) { | 760 if (!tilesForLayer) { |
| 746 tilesForLayer = []; | 761 tilesForLayer = []; |
| 747 this._tilesByLayerId[layerId] = tilesForLayer; | 762 this._tilesByLayerId[layerId] = tilesForLayer; |
| 748 } | 763 } |
| 749 var tile = new WebInspector.LayerTextureManager.Tile(paintTiles[i].s napshot, paintTiles[i].rect); | 764 var tile = new WebInspector.LayerTextureManager.Tile(paintTiles[i].s napshot, paintTiles[i].rect, paintTiles[i].traceEvent); |
| 750 tilesForLayer.push(tile); | 765 tilesForLayer.push(tile); |
| 751 if (this._scale && this._gl) | 766 if (this._scale && this._gl) |
| 752 this._updateTile(tile); | 767 this._updateTile(tile); |
| 753 } | 768 } |
| 754 }, | 769 }, |
| 755 | 770 |
| 756 /** | 771 /** |
| 757 * @param {number} scale | 772 * @param {number} scale |
| 758 */ | 773 */ |
| 759 setScale: function(scale) | 774 setScale: function(scale) |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 966 var product = WebInspector.Geometry.scalarProduct(normal, WebInspect or.Geometry.crossProduct(tVects[i], tVects[(i + 1) % tVects.length])); | 981 var product = WebInspector.Geometry.scalarProduct(normal, WebInspect or.Geometry.crossProduct(tVects[i], tVects[(i + 1) % tVects.length])); |
| 967 if (product < 0) | 982 if (product < 0) |
| 968 return undefined; | 983 return undefined; |
| 969 } | 984 } |
| 970 return t; | 985 return t; |
| 971 } | 986 } |
| 972 } | 987 } |
| 973 | 988 |
| 974 /** | 989 /** |
| 975 * @constructor | 990 * @constructor |
| 991 */ | |
| 992 WebInspector.Layers3DView.ActiveObject = function() | |
| 993 { | |
| 994 } | |
| 995 | |
| 996 /** | |
| 997 * @enum {string} | |
| 998 */ | |
| 999 WebInspector.Layers3DView.ActiveObject.Type = { | |
| 1000 Layer: "Layer", | |
| 1001 ScrollRect: "ScrollRect", | |
| 1002 Tile: "Tile", | |
| 1003 }; | |
| 1004 | |
| 1005 /** | |
| 1006 * @param {!WebInspector.Layer} layer | |
| 1007 * @return {!WebInspector.Layers3DView.ActiveObject} | |
| 1008 */ | |
| 1009 WebInspector.Layers3DView.ActiveObject.layerActiveObject = function(layer) | |
|
caseq
2014/07/17 13:12:22
Here and below, since these create objects, let's
malch
2014/07/17 15:17:44
Done.
| |
| 1010 { | |
| 1011 var activeObject = new WebInspector.Layers3DView.ActiveObject(); | |
| 1012 activeObject._type = WebInspector.Layers3DView.ActiveObject.Type.Layer; | |
| 1013 activeObject.layer = layer; | |
| 1014 return activeObject; | |
| 1015 } | |
| 1016 | |
| 1017 /** | |
| 1018 * @param {!WebInspector.Layer} layer | |
| 1019 * @param {number} scrollRectIndex | |
| 1020 * @return {!WebInspector.Layers3DView.ActiveObject} | |
| 1021 */ | |
| 1022 WebInspector.Layers3DView.ActiveObject.scrollRectActiveObject = function(layer, scrollRectIndex) | |
| 1023 { | |
| 1024 var activeObject = new WebInspector.Layers3DView.ActiveObject(); | |
| 1025 activeObject._type = WebInspector.Layers3DView.ActiveObject.Type.ScrollRect; | |
| 1026 activeObject.layer = layer; | |
| 1027 activeObject.scrollRectIndex = scrollRectIndex; | |
| 1028 return activeObject; | |
| 1029 } | |
| 1030 | |
| 1031 /** | |
| 1032 * @param {!WebInspector.Layer} layer | |
| 1033 * @param {!WebInspector.TracingModel.Event} traceEvent | |
| 1034 * @return {!WebInspector.Layers3DView.ActiveObject} | |
| 1035 */ | |
| 1036 WebInspector.Layers3DView.ActiveObject.tileActiveObject = function(layer, traceE vent) | |
| 1037 { | |
| 1038 var activeObject = new WebInspector.Layers3DView.ActiveObject(); | |
| 1039 activeObject._type = WebInspector.Layers3DView.ActiveObject.Type.Tile; | |
| 1040 activeObject.layer = layer; | |
| 1041 activeObject.traceEvent = traceEvent; | |
| 1042 return activeObject; | |
| 1043 } | |
| 1044 | |
| 1045 WebInspector.Layers3DView.ActiveObject.prototype = { | |
| 1046 /** | |
| 1047 * @return {!WebInspector.Layers3DView.ActiveObject.Type} | |
| 1048 */ | |
| 1049 type: function() | |
| 1050 { | |
| 1051 return this._type; | |
| 1052 } | |
| 1053 }; | |
| 1054 | |
| 1055 /** | |
| 1056 * @constructor | |
| 976 * @param {!WebInspector.PaintProfilerSnapshot} snapshot | 1057 * @param {!WebInspector.PaintProfilerSnapshot} snapshot |
| 977 * @param {!Array.<number>} rect | 1058 * @param {!Array.<number>} rect |
| 1059 * @param {!WebInspector.TracingModel.Event} traceEvent | |
| 978 */ | 1060 */ |
| 979 WebInspector.LayerTextureManager.Tile = function(snapshot, rect) | 1061 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent) |
| 980 { | 1062 { |
| 981 this.snapshot = snapshot; | 1063 this.snapshot = snapshot; |
| 982 this.rect = rect; | 1064 this.rect = rect; |
| 1065 this.traceEvent = traceEvent; | |
| 983 this.scale = 0; | 1066 this.scale = 0; |
| 984 /** @type {?WebGLTexture} */ | 1067 /** @type {?WebGLTexture} */ |
| 985 this.texture = null; | 1068 this.texture = null; |
| 986 } | 1069 } |
| OLD | NEW |