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 |
79 /** | 76 /** |
80 * @enum {string} | 77 * @enum {string} |
81 */ | 78 */ |
82 WebInspector.Layers3DView.Events = { | 79 WebInspector.Layers3DView.Events = { |
83 ObjectHovered: "ObjectHovered", | 80 ObjectHovered: "ObjectHovered", |
84 ObjectSelected: "ObjectSelected", | 81 ObjectSelected: "ObjectSelected", |
85 LayerSnapshotRequested: "LayerSnapshotRequested" | 82 LayerSnapshotRequested: "LayerSnapshotRequested", |
| 83 JumpToPaintEventRequested: "JumpToPaintEventRequested" |
86 } | 84 } |
87 | 85 |
88 /** | 86 /** |
89 * @enum {string} | 87 * @enum {string} |
90 */ | 88 */ |
91 WebInspector.Layers3DView.ScrollRectTitles = { | 89 WebInspector.Layers3DView.ScrollRectTitles = { |
92 RepaintsOnScroll: WebInspector.UIString("repaints on scroll"), | 90 RepaintsOnScroll: WebInspector.UIString("repaints on scroll"), |
93 TouchEventHandler: WebInspector.UIString("touch event listener"), | 91 TouchEventHandler: WebInspector.UIString("touch event listener"), |
94 WheelEventHandler: WebInspector.UIString("mousewheel event listener") | 92 WheelEventHandler: WebInspector.UIString("mousewheel event listener") |
95 } | 93 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 return this._depthForLayer(layer) + index * WebInspector.Layers3DView.Sc
rollRectSpacing + 1; | 389 return this._depthForLayer(layer) + index * WebInspector.Layers3DView.Sc
rollRectSpacing + 1; |
392 }, | 390 }, |
393 | 391 |
394 /** | 392 /** |
395 * @param {!WebInspector.Layer} layer | 393 * @param {!WebInspector.Layer} layer |
396 */ | 394 */ |
397 _calculateLayerRect: function(layer) | 395 _calculateLayerRect: function(layer) |
398 { | 396 { |
399 if (!this._isVisible[layer.id()]) | 397 if (!this._isVisible[layer.id()]) |
400 return; | 398 return; |
401 var rect = new WebInspector.Layers3DView.Rectangle({layer: layer}); | 399 var activeObject = WebInspector.Layers3DView.ActiveObject.createLayerAct
iveObject(layer); |
| 400 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); |
402 var style = this._styleForLayer(layer); | 401 var style = this._styleForLayer(layer); |
403 rect.setVertices(layer.quad(), this._depthForLayer(layer)); | 402 rect.setVertices(layer.quad(), this._depthForLayer(layer)); |
404 rect.lineWidth = style.borderWidth; | 403 rect.lineWidth = style.borderWidth; |
405 rect.borderColor = style.borderColor; | 404 rect.borderColor = style.borderColor; |
406 this._rects.push(rect); | 405 this._rects.push(rect); |
407 }, | 406 }, |
408 | 407 |
409 /** | 408 /** |
410 * @param {!WebInspector.Layer} layer | 409 * @param {!WebInspector.Layer} layer |
411 */ | 410 */ |
412 _calculateLayerScrollRects: function(layer) | 411 _calculateLayerScrollRects: function(layer) |
413 { | 412 { |
414 var scrollRects = layer.scrollRects(); | 413 var scrollRects = layer.scrollRects(); |
415 for (var i = 0; i < scrollRects.length; ++i) { | 414 for (var i = 0; i < scrollRects.length; ++i) { |
416 var rect = new WebInspector.Layers3DView.Rectangle({layer: layer, sc
rollRectIndex: i}); | 415 var activeObject = WebInspector.Layers3DView.ActiveObject.createScro
llRectActiveObject(layer, i); |
| 416 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); |
417 rect.calculateVerticesFromRect(layer, scrollRects[i].rect, this._cal
culateScrollRectDepth(layer, i)); | 417 rect.calculateVerticesFromRect(layer, scrollRects[i].rect, this._cal
culateScrollRectDepth(layer, i)); |
418 var isSelected = this._isObjectActive(WebInspector.Layers3DView.Outl
ineType.Selected, layer, i); | 418 var isSelected = this._isObjectActive(WebInspector.Layers3DView.Outl
ineType.Selected, layer, i); |
419 var color = isSelected ? WebInspector.Layers3DView.SelectedScrollRec
tBackgroundColor : WebInspector.Layers3DView.ScrollRectBackgroundColor; | 419 var color = isSelected ? WebInspector.Layers3DView.SelectedScrollRec
tBackgroundColor : WebInspector.Layers3DView.ScrollRectBackgroundColor; |
420 rect.fillColor = color; | 420 rect.fillColor = color; |
421 rect.borderColor = WebInspector.Layers3DView.ScrollRectBorderColor; | 421 rect.borderColor = WebInspector.Layers3DView.ScrollRectBorderColor; |
422 this._rects.push(rect); | 422 this._rects.push(rect); |
423 } | 423 } |
424 }, | 424 }, |
425 | 425 |
426 /** | 426 /** |
427 * @param {!WebInspector.Layer} layer | 427 * @param {!WebInspector.Layer} layer |
428 */ | 428 */ |
429 _calculateLayerImageRect: function(layer) | 429 _calculateLayerImageRect: function(layer) |
430 { | 430 { |
431 var layerTexture = this._layerTexture; | 431 var layerTexture = this._layerTexture; |
432 if (layer.id() !== layerTexture.layerId) | 432 if (layer.id() !== layerTexture.layerId) |
433 return; | 433 return; |
434 var rect = new WebInspector.Layers3DView.Rectangle({layer: layer}); | 434 var activeObject = WebInspector.Layers3DView.ActiveObject.createLayerAct
iveObject(layer); |
| 435 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); |
435 rect.setVertices(layer.quad(), this._depthForLayer(layer)); | 436 rect.setVertices(layer.quad(), this._depthForLayer(layer)); |
436 rect.texture = layerTexture.texture; | 437 rect.texture = layerTexture.texture; |
437 this._rects.push(rect); | 438 this._rects.push(rect); |
438 }, | 439 }, |
439 | 440 |
440 /** | 441 /** |
441 * @param {!WebInspector.Layer} layer | 442 * @param {!WebInspector.Layer} layer |
442 */ | 443 */ |
443 _calculateLayerTileRects: function(layer) | 444 _calculateLayerTileRects: function(layer) |
444 { | 445 { |
445 var tiles = this._textureManager.tilesForLayer(layer.id()); | 446 var tiles = this._textureManager.tilesForLayer(layer.id()); |
446 for (var i = 0; i < tiles.length; ++i) { | 447 for (var i = 0; i < tiles.length; ++i) { |
447 var tile = tiles[i]; | 448 var tile = tiles[i]; |
448 if (!tile.texture) | 449 if (!tile.texture) |
449 continue; | 450 continue; |
450 var rect = new WebInspector.Layers3DView.Rectangle({layer: layer}); | 451 var activeObject = WebInspector.Layers3DView.ActiveObject.createTile
ActiveObject(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)); | 452 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); |
| 453 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; | 454 rect.texture = tile.texture; |
453 this._rects.push(rect); | 455 this._rects.push(rect); |
454 } | 456 } |
455 }, | 457 }, |
456 | 458 |
457 _calculateViewportRect: function() | 459 _calculateViewportRect: function() |
458 { | 460 { |
459 var rect = new WebInspector.Layers3DView.Rectangle(null); | 461 var rect = new WebInspector.Layers3DView.Rectangle(null); |
460 var viewport = this._layerTree.viewportSize(); | 462 var viewport = this._layerTree.viewportSize(); |
461 var depth = (this._maxDepth + 1) * WebInspector.Layers3DView.LayerSpacin
g; | 463 var depth = (this._maxDepth + 1) * WebInspector.Layers3DView.LayerSpacin
g; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 }, | 643 }, |
642 | 644 |
643 /** | 645 /** |
644 * @param {!Event} event | 646 * @param {!Event} event |
645 */ | 647 */ |
646 _onContextMenu: function(event) | 648 _onContextMenu: function(event) |
647 { | 649 { |
648 var activeObject = this._activeObjectFromEventPoint(event); | 650 var activeObject = this._activeObjectFromEventPoint(event); |
649 var node = activeObject && activeObject.layer && activeObject.layer.node
ForSelfOrAncestor(); | 651 var node = activeObject && activeObject.layer && activeObject.layer.node
ForSelfOrAncestor(); |
650 var contextMenu = new WebInspector.ContextMenu(event); | 652 var contextMenu = new WebInspector.ContextMenu(event); |
651 contextMenu.appendItem("Reset view", this._transformController.resetAndN
otify.bind(this._transformController), false); | 653 contextMenu.appendItem(WebInspector.UIString("Reset View"), this._transf
ormController.resetAndNotify.bind(this._transformController), false); |
| 654 if (activeObject.type() === WebInspector.Layers3DView.ActiveObject.Type.
Tile) |
| 655 contextMenu.appendItem(WebInspector.UIString("Jump to Paint Event"),
this.dispatchEventToListeners.bind(this, WebInspector.Layers3DView.Events.JumpT
oPaintEventRequested, activeObject.traceEvent), false); |
652 if (node) | 656 if (node) |
653 contextMenu.appendApplicableItems(node); | 657 contextMenu.appendApplicableItems(node); |
654 contextMenu.show(); | 658 contextMenu.show(); |
655 }, | 659 }, |
656 | 660 |
657 /** | 661 /** |
658 * @param {!Event} event | 662 * @param {!Event} event |
659 */ | 663 */ |
660 _onMouseMove: function(event) | 664 _onMouseMove: function(event) |
661 { | 665 { |
(...skipping 22 matching lines...) Expand all Loading... |
684 delete this._mouseDownX; | 688 delete this._mouseDownX; |
685 delete this._mouseDownY; | 689 delete this._mouseDownY; |
686 }, | 690 }, |
687 | 691 |
688 /** | 692 /** |
689 * @param {!Event} event | 693 * @param {!Event} event |
690 */ | 694 */ |
691 _onDoubleClick: function(event) | 695 _onDoubleClick: function(event) |
692 { | 696 { |
693 var object = this._activeObjectFromEventPoint(event); | 697 var object = this._activeObjectFromEventPoint(event); |
694 if (object && object.layer) | 698 if (object) { |
695 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.Layer
SnapshotRequested, object.layer); | 699 if (object.type() == WebInspector.Layers3DView.ActiveObject.Type.Til
e) |
| 700 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.J
umpToPaintEventRequested, object.traceEvent); |
| 701 else if (object.layer) |
| 702 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.L
ayerSnapshotRequested, object.layer); |
| 703 } |
696 event.stopPropagation(); | 704 event.stopPropagation(); |
697 }, | 705 }, |
698 | 706 |
699 __proto__: WebInspector.VBox.prototype | 707 __proto__: WebInspector.VBox.prototype |
700 } | 708 } |
701 | 709 |
702 /** | 710 /** |
703 * @constructor | 711 * @constructor |
704 * @extends {WebInspector.Object} | 712 * @extends {WebInspector.Object} |
705 */ | 713 */ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 this._tilesByLayerId = {}; | 747 this._tilesByLayerId = {}; |
740 if (!paintTiles) | 748 if (!paintTiles) |
741 return; | 749 return; |
742 for (var i = 0; i < paintTiles.length; ++i) { | 750 for (var i = 0; i < paintTiles.length; ++i) { |
743 var layerId = paintTiles[i].layerId; | 751 var layerId = paintTiles[i].layerId; |
744 var tilesForLayer = this._tilesByLayerId[layerId]; | 752 var tilesForLayer = this._tilesByLayerId[layerId]; |
745 if (!tilesForLayer) { | 753 if (!tilesForLayer) { |
746 tilesForLayer = []; | 754 tilesForLayer = []; |
747 this._tilesByLayerId[layerId] = tilesForLayer; | 755 this._tilesByLayerId[layerId] = tilesForLayer; |
748 } | 756 } |
749 var tile = new WebInspector.LayerTextureManager.Tile(paintTiles[i].s
napshot, paintTiles[i].rect); | 757 var tile = new WebInspector.LayerTextureManager.Tile(paintTiles[i].s
napshot, paintTiles[i].rect, paintTiles[i].traceEvent); |
750 tilesForLayer.push(tile); | 758 tilesForLayer.push(tile); |
751 if (this._scale && this._gl) | 759 if (this._scale && this._gl) |
752 this._updateTile(tile); | 760 this._updateTile(tile); |
753 } | 761 } |
754 }, | 762 }, |
755 | 763 |
756 /** | 764 /** |
757 * @param {number} scale | 765 * @param {number} scale |
758 */ | 766 */ |
759 setScale: function(scale) | 767 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])); | 974 var product = WebInspector.Geometry.scalarProduct(normal, WebInspect
or.Geometry.crossProduct(tVects[i], tVects[(i + 1) % tVects.length])); |
967 if (product < 0) | 975 if (product < 0) |
968 return undefined; | 976 return undefined; |
969 } | 977 } |
970 return t; | 978 return t; |
971 } | 979 } |
972 } | 980 } |
973 | 981 |
974 /** | 982 /** |
975 * @constructor | 983 * @constructor |
| 984 */ |
| 985 WebInspector.Layers3DView.ActiveObject = function() |
| 986 { |
| 987 } |
| 988 |
| 989 /** |
| 990 * @enum {string} |
| 991 */ |
| 992 WebInspector.Layers3DView.ActiveObject.Type = { |
| 993 Layer: "Layer", |
| 994 ScrollRect: "ScrollRect", |
| 995 Tile: "Tile", |
| 996 }; |
| 997 |
| 998 /** |
| 999 * @param {!WebInspector.Layer} layer |
| 1000 * @return {!WebInspector.Layers3DView.ActiveObject} |
| 1001 */ |
| 1002 WebInspector.Layers3DView.ActiveObject.createLayerActiveObject = function(layer) |
| 1003 { |
| 1004 var activeObject = new WebInspector.Layers3DView.ActiveObject(); |
| 1005 activeObject._type = WebInspector.Layers3DView.ActiveObject.Type.Layer; |
| 1006 activeObject.layer = layer; |
| 1007 return activeObject; |
| 1008 } |
| 1009 |
| 1010 /** |
| 1011 * @param {!WebInspector.Layer} layer |
| 1012 * @param {number} scrollRectIndex |
| 1013 * @return {!WebInspector.Layers3DView.ActiveObject} |
| 1014 */ |
| 1015 WebInspector.Layers3DView.ActiveObject.createScrollRectActiveObject = function(l
ayer, scrollRectIndex) |
| 1016 { |
| 1017 var activeObject = new WebInspector.Layers3DView.ActiveObject(); |
| 1018 activeObject._type = WebInspector.Layers3DView.ActiveObject.Type.ScrollRect; |
| 1019 activeObject.layer = layer; |
| 1020 activeObject.scrollRectIndex = scrollRectIndex; |
| 1021 return activeObject; |
| 1022 } |
| 1023 |
| 1024 /** |
| 1025 * @param {!WebInspector.Layer} layer |
| 1026 * @param {!WebInspector.TracingModel.Event} traceEvent |
| 1027 * @return {!WebInspector.Layers3DView.ActiveObject} |
| 1028 */ |
| 1029 WebInspector.Layers3DView.ActiveObject.createTileActiveObject = function(layer,
traceEvent) |
| 1030 { |
| 1031 var activeObject = new WebInspector.Layers3DView.ActiveObject(); |
| 1032 activeObject._type = WebInspector.Layers3DView.ActiveObject.Type.Tile; |
| 1033 activeObject.layer = layer; |
| 1034 activeObject.traceEvent = traceEvent; |
| 1035 return activeObject; |
| 1036 } |
| 1037 |
| 1038 WebInspector.Layers3DView.ActiveObject.prototype = { |
| 1039 /** |
| 1040 * @return {!WebInspector.Layers3DView.ActiveObject.Type} |
| 1041 */ |
| 1042 type: function() |
| 1043 { |
| 1044 return this._type; |
| 1045 } |
| 1046 }; |
| 1047 |
| 1048 /** |
| 1049 * @constructor |
976 * @param {!WebInspector.PaintProfilerSnapshot} snapshot | 1050 * @param {!WebInspector.PaintProfilerSnapshot} snapshot |
977 * @param {!Array.<number>} rect | 1051 * @param {!Array.<number>} rect |
| 1052 * @param {!WebInspector.TracingModel.Event} traceEvent |
978 */ | 1053 */ |
979 WebInspector.LayerTextureManager.Tile = function(snapshot, rect) | 1054 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent) |
980 { | 1055 { |
981 this.snapshot = snapshot; | 1056 this.snapshot = snapshot; |
982 this.rect = rect; | 1057 this.rect = rect; |
| 1058 this.traceEvent = traceEvent; |
983 this.scale = 0; | 1059 this.scale = 0; |
984 /** @type {?WebGLTexture} */ | 1060 /** @type {?WebGLTexture} */ |
985 this.texture = null; | 1061 this.texture = null; |
986 } | 1062 } |
OLD | NEW |