| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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._lastActiveObject = {}; |
| 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> */ |
| 62 this._chromeTextures = []; |
| 61 | 63 |
| 62 WebInspector.settings.showPaintRects.addChangeListener(this._update, this); | 64 WebInspector.settings.showPaintRects.addChangeListener(this._update, this); |
| 63 } | 65 } |
| 64 | 66 |
| 65 /** @typedef {{borderColor: !Array.<number>, borderWidth: number}} */ | 67 /** @typedef {{borderColor: !Array.<number>, borderWidth: number}} */ |
| 66 WebInspector.Layers3DView.LayerStyle; | 68 WebInspector.Layers3DView.LayerStyle; |
| 67 | 69 |
| 68 /** @typedef {{layerId: string, rect: !Array.<number>, snapshot: !WebInspector.P
aintProfilerSnapshot, traceEvent: !WebInspector.TracingModel.Event}} */ | 70 /** @typedef {{layerId: string, rect: !Array.<number>, snapshot: !WebInspector.P
aintProfilerSnapshot, traceEvent: !WebInspector.TracingModel.Event}} */ |
| 69 WebInspector.Layers3DView.PaintTile; | 71 WebInspector.Layers3DView.PaintTile; |
| 70 | 72 |
| 71 /** | 73 /** |
| 72 * @enum {string} | 74 * @enum {string} |
| 73 */ | 75 */ |
| 74 WebInspector.Layers3DView.OutlineType = { | 76 WebInspector.Layers3DView.OutlineType = { |
| 75 Hovered: "hovered", | 77 Hovered: "hovered", |
| 76 Selected: "selected" | 78 Selected: "selected" |
| 77 } | 79 } |
| 78 | 80 |
| 79 /** | 81 /** |
| 80 * @enum {string} | 82 * @enum {string} |
| 81 */ | 83 */ |
| 82 WebInspector.Layers3DView.Events = { | 84 WebInspector.Layers3DView.Events = { |
| 83 ObjectHovered: "ObjectHovered", | 85 ObjectHovered: "ObjectHovered", |
| 84 ObjectSelected: "ObjectSelected", | 86 ObjectSelected: "ObjectSelected", |
| 85 LayerSnapshotRequested: "LayerSnapshotRequested", | 87 LayerSnapshotRequested: "LayerSnapshotRequested", |
| 86 JumpToPaintEventRequested: "JumpToPaintEventRequested" | 88 JumpToPaintEventRequested: "JumpToPaintEventRequested" |
| 87 } | 89 } |
| 88 | 90 |
| 89 /** | 91 /** |
| 92 * @enum {number} |
| 93 */ |
| 94 WebInspector.Layers3DView.ChromeTexture = { |
| 95 Left: 0, |
| 96 Middle: 1, |
| 97 Right: 2 |
| 98 } |
| 99 |
| 100 /** |
| 90 * @enum {string} | 101 * @enum {string} |
| 91 */ | 102 */ |
| 92 WebInspector.Layers3DView.ScrollRectTitles = { | 103 WebInspector.Layers3DView.ScrollRectTitles = { |
| 93 RepaintsOnScroll: WebInspector.UIString("repaints on scroll"), | 104 RepaintsOnScroll: WebInspector.UIString("repaints on scroll"), |
| 94 TouchEventHandler: WebInspector.UIString("touch event listener"), | 105 TouchEventHandler: WebInspector.UIString("touch event listener"), |
| 95 WheelEventHandler: WebInspector.UIString("mousewheel event listener") | 106 WheelEventHandler: WebInspector.UIString("mousewheel event listener") |
| 96 } | 107 } |
| 97 | 108 |
| 98 WebInspector.Layers3DView.FragmentShader = "\ | 109 WebInspector.Layers3DView.FragmentShader = "\ |
| 99 precision mediump float;\ | 110 precision mediump float;\ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 117 gl_Position = uPMatrix * vec4(aVertexPosition, 1.0);\ | 128 gl_Position = uPMatrix * vec4(aVertexPosition, 1.0);\ |
| 118 vColor = aVertexColor;\ | 129 vColor = aVertexColor;\ |
| 119 vTextureCoord = aTextureCoord;\ | 130 vTextureCoord = aTextureCoord;\ |
| 120 }"; | 131 }"; |
| 121 | 132 |
| 122 WebInspector.Layers3DView.SelectedBackgroundColor = [20, 40, 110, 0.66]; | 133 WebInspector.Layers3DView.SelectedBackgroundColor = [20, 40, 110, 0.66]; |
| 123 WebInspector.Layers3DView.BackgroundColor = [0, 0, 0, 0]; | 134 WebInspector.Layers3DView.BackgroundColor = [0, 0, 0, 0]; |
| 124 WebInspector.Layers3DView.HoveredBorderColor = [0, 0, 255, 1]; | 135 WebInspector.Layers3DView.HoveredBorderColor = [0, 0, 255, 1]; |
| 125 WebInspector.Layers3DView.SelectedBorderColor = [0, 255, 0, 1]; | 136 WebInspector.Layers3DView.SelectedBorderColor = [0, 255, 0, 1]; |
| 126 WebInspector.Layers3DView.BorderColor = [0, 0, 0, 1]; | 137 WebInspector.Layers3DView.BorderColor = [0, 0, 0, 1]; |
| 138 WebInspector.Layers3DView.ViewportBorderColor = [160, 160, 160, 1]; |
| 127 WebInspector.Layers3DView.ScrollRectBackgroundColor = [178, 0, 0, 0.4]; | 139 WebInspector.Layers3DView.ScrollRectBackgroundColor = [178, 0, 0, 0.4]; |
| 128 WebInspector.Layers3DView.SelectedScrollRectBackgroundColor = [178, 0, 0, 0.6]; | 140 WebInspector.Layers3DView.SelectedScrollRectBackgroundColor = [178, 0, 0, 0.6]; |
| 129 WebInspector.Layers3DView.ScrollRectBorderColor = [178, 0, 0, 1]; | 141 WebInspector.Layers3DView.ScrollRectBorderColor = [178, 0, 0, 1]; |
| 130 WebInspector.Layers3DView.BorderWidth = 1; | 142 WebInspector.Layers3DView.BorderWidth = 1; |
| 131 WebInspector.Layers3DView.SelectedBorderWidth = 2; | 143 WebInspector.Layers3DView.SelectedBorderWidth = 2; |
| 144 WebInspector.Layers3DView.ViewportBorderWidth = 3; |
| 132 | 145 |
| 133 WebInspector.Layers3DView.LayerSpacing = 20; | 146 WebInspector.Layers3DView.LayerSpacing = 20; |
| 134 WebInspector.Layers3DView.ScrollRectSpacing = 4; | 147 WebInspector.Layers3DView.ScrollRectSpacing = 4; |
| 135 | 148 |
| 136 WebInspector.Layers3DView.prototype = { | 149 WebInspector.Layers3DView.prototype = { |
| 137 /** | 150 /** |
| 138 * @param {?WebInspector.LayerTreeBase} layerTree | 151 * @param {?WebInspector.LayerTreeBase} layerTree |
| 139 */ | 152 */ |
| 140 setLayerTree: function(layerTree) | 153 setLayerTree: function(layerTree) |
| 141 { | 154 { |
| 142 this._layerTree = layerTree; | 155 this._layerTree = layerTree; |
| 143 this._textureManager.reset(); | 156 this._textureManager.reset(); |
| 144 this._update(); | 157 this._update(); |
| 145 }, | 158 }, |
| 146 | 159 |
| 147 /** | 160 /** |
| 148 * @param {?Array.<!WebInspector.Layers3DView.PaintTile>} tiles | 161 * @param {?Array.<!WebInspector.Layers3DView.PaintTile>} tiles |
| 149 */ | 162 */ |
| 150 setTiles: function(tiles) | 163 setTiles: function(tiles) |
| 151 { | 164 { |
| 152 this._textureManager.setTiles(tiles); | 165 this._textureManager.setTiles(tiles); |
| 153 }, | 166 }, |
| 154 | 167 |
| 155 /** | 168 /** |
| 156 * @param {!WebInspector.Layer} layer | 169 * @param {!WebInspector.Layer} layer |
| 157 * @param {string=} imageURL | 170 * @param {string=} imageURL |
| 158 */ | 171 */ |
| 159 showImageForLayer: function(layer, imageURL) | 172 showImageForLayer: function(layer, imageURL) |
| 160 { | 173 { |
| 161 this._textureManager.createTexture(onTextureCreated.bind(this), imageURL
); | 174 if (imageURL) |
| 175 this._textureManager.createTexture(onTextureCreated.bind(this), imag
eURL); |
| 176 else |
| 177 onTextureCreated.call(this, null); |
| 162 | 178 |
| 163 /** | 179 /** |
| 164 * @this {WebInspector.Layers3DView} | 180 * @this {WebInspector.Layers3DView} |
| 165 * @param {!WebGLTexture} texture | 181 * @param {?WebGLTexture} texture |
| 166 */ | 182 */ |
| 167 function onTextureCreated(texture) | 183 function onTextureCreated(texture) |
| 168 { | 184 { |
| 169 this._layerTexture = {layerId: layer.id(), texture: texture}; | 185 this._layerTexture = texture ? {layerId: layer.id(), texture: textur
e} : null; |
| 170 this._update(); | 186 this._update(); |
| 171 } | 187 } |
| 172 }, | 188 }, |
| 173 | 189 |
| 174 onResize: function() | 190 onResize: function() |
| 175 { | 191 { |
| 176 this._update(); | 192 this._update(); |
| 177 }, | 193 }, |
| 178 | 194 |
| 179 wasShown: function() | 195 wasShown: function() |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 { | 309 { |
| 294 return new Float32Array([m.m11, m.m12, m.m13, m.m14, m.m21, m.m22, m.m23
, m.m24, m.m31, m.m32, m.m33, m.m34, m.m41, m.m42, m.m43, m.m44]); | 310 return new Float32Array([m.m11, m.m12, m.m13, m.m14, m.m21, m.m22, m.m23
, m.m24, m.m31, m.m32, m.m33, m.m34, m.m41, m.m42, m.m43, m.m44]); |
| 295 }, | 311 }, |
| 296 | 312 |
| 297 _initProjectionMatrix: function() | 313 _initProjectionMatrix: function() |
| 298 { | 314 { |
| 299 var projectionMatrix = this._calculateProjectionMatrix(); | 315 var projectionMatrix = this._calculateProjectionMatrix(); |
| 300 this._pMatrix = new WebKitCSSMatrix().scale(1, -1, -1).translate(-1, -1,
0) | 316 this._pMatrix = new WebKitCSSMatrix().scale(1, -1, -1).translate(-1, -1,
0) |
| 301 .scale(2 / this._canvasElement.width, 2 / this._canvasElement.height
, 1 / 1000000).multiply(projectionMatrix); | 317 .scale(2 / this._canvasElement.width, 2 / this._canvasElement.height
, 1 / 1000000).multiply(projectionMatrix); |
| 302 this._gl.uniformMatrix4fv(this._shaderProgram.pMatrixUniform, false, thi
s._arrayFromMatrix(this._pMatrix)); | 318 this._gl.uniformMatrix4fv(this._shaderProgram.pMatrixUniform, false, thi
s._arrayFromMatrix(this._pMatrix)); |
| 303 this._textureScale = Math.min(1, Math.max(projectionMatrix.m11, projecti
onMatrix.m22)); | 319 this._scale = Math.max(projectionMatrix.m11, projectionMatrix.m22); |
| 304 }, | 320 }, |
| 305 | 321 |
| 306 _initWhiteTexture: function() | 322 _initWhiteTexture: function() |
| 307 { | 323 { |
| 308 this._whiteTexture = this._gl.createTexture(); | 324 this._whiteTexture = this._gl.createTexture(); |
| 309 this._gl.bindTexture(this._gl.TEXTURE_2D, this._whiteTexture); | 325 this._gl.bindTexture(this._gl.TEXTURE_2D, this._whiteTexture); |
| 310 var whitePixel = new Uint8Array([255, 255, 255, 255]); | 326 var whitePixel = new Uint8Array([255, 255, 255, 255]); |
| 311 this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, 1, 1, 0, this
._gl.RGBA, this._gl.UNSIGNED_BYTE, whitePixel); | 327 this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, 1, 1, 0, this
._gl.RGBA, this._gl.UNSIGNED_BYTE, whitePixel); |
| 312 }, | 328 }, |
| 313 | 329 |
| 330 _initChromeTextures: function() |
| 331 { |
| 332 /** |
| 333 * @this {WebInspector.Layers3DView} |
| 334 * @param {!WebInspector.Layers3DView.ChromeTexture} index |
| 335 * @param {?WebGLTexture} value |
| 336 */ |
| 337 function saveChromeTexture(index, value) |
| 338 { |
| 339 this._chromeTextures[index] = value || undefined; |
| 340 } |
| 341 this._textureManager.createTexture(saveChromeTexture.bind(this, WebInspe
ctor.Layers3DView.ChromeTexture.Left), "Images/chromeLeft.png"); |
| 342 this._textureManager.createTexture(saveChromeTexture.bind(this, WebInspe
ctor.Layers3DView.ChromeTexture.Middle), "Images/chromeMiddle.png"); |
| 343 this._textureManager.createTexture(saveChromeTexture.bind(this, WebInspe
ctor.Layers3DView.ChromeTexture.Right), "Images/chromeRight.png"); |
| 344 }, |
| 345 |
| 314 _initGLIfNecessary: function() | 346 _initGLIfNecessary: function() |
| 315 { | 347 { |
| 316 if (this._gl) | 348 if (this._gl) |
| 317 return this._gl; | 349 return this._gl; |
| 318 this._gl = this._initGL(this._canvasElement); | 350 this._gl = this._initGL(this._canvasElement); |
| 319 this._initShaders(); | 351 this._initShaders(); |
| 320 this._initWhiteTexture(); | 352 this._initWhiteTexture(); |
| 353 this._initChromeTextures(); |
| 321 this._textureManager.setContext(this._gl); | 354 this._textureManager.setContext(this._gl); |
| 322 return this._gl; | 355 return this._gl; |
| 323 }, | 356 }, |
| 324 | 357 |
| 325 _calculateDepths: function() | 358 _calculateDepths: function() |
| 326 { | 359 { |
| 327 this._depthByLayerId = {}; | 360 this._depthByLayerId = {}; |
| 328 this._isVisible = {}; | 361 this._isVisible = {}; |
| 329 var depth = 0; | 362 var depth = 0; |
| 330 var root = this._layerTree.root(); | 363 var root = this._layerTree.root(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 if (!tile.texture) | 485 if (!tile.texture) |
| 453 continue; | 486 continue; |
| 454 var activeObject = WebInspector.Layers3DView.ActiveObject.createTile
ActiveObject(layer, tile.traceEvent); | 487 var activeObject = WebInspector.Layers3DView.ActiveObject.createTile
ActiveObject(layer, tile.traceEvent); |
| 455 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); | 488 var rect = new WebInspector.Layers3DView.Rectangle(activeObject); |
| 456 rect.calculateVerticesFromRect(layer, {x: tile.rect[0], y: tile.rect
[1], width: tile.rect[2], height: tile.rect[3]}, this._depthForLayer(layer) + 1)
; | 489 rect.calculateVerticesFromRect(layer, {x: tile.rect[0], y: tile.rect
[1], width: tile.rect[2], height: tile.rect[3]}, this._depthForLayer(layer) + 1)
; |
| 457 rect.texture = tile.texture; | 490 rect.texture = tile.texture; |
| 458 this._rects.push(rect); | 491 this._rects.push(rect); |
| 459 } | 492 } |
| 460 }, | 493 }, |
| 461 | 494 |
| 462 _calculateViewportRect: function() | |
| 463 { | |
| 464 var rect = new WebInspector.Layers3DView.Rectangle(null); | |
| 465 var viewport = this._layerTree.viewportSize(); | |
| 466 var depth = (this._maxDepth + 1) * WebInspector.Layers3DView.LayerSpacin
g; | |
| 467 var vertices = [0, 0, depth, viewport.width, 0, depth, viewport.width, v
iewport.height, depth, 0, viewport.height, depth]; | |
| 468 rect.vertices = vertices; | |
| 469 rect.borderColor = [0, 0, 0, 1]; | |
| 470 rect.lineWidth = 3; | |
| 471 this._rects.push(rect); | |
| 472 }, | |
| 473 | |
| 474 _calculateRects: function() | 495 _calculateRects: function() |
| 475 { | 496 { |
| 476 this._rects = []; | 497 this._rects = []; |
| 477 | 498 |
| 478 this._layerTree.forEachLayer(this._calculateLayerRect.bind(this)); | 499 this._layerTree.forEachLayer(this._calculateLayerRect.bind(this)); |
| 479 | 500 |
| 480 if (this._showSlowScrollRectsSetting.get()) | 501 if (this._showSlowScrollRectsSetting.get()) |
| 481 this._layerTree.forEachLayer(this._calculateLayerScrollRects.bind(th
is)); | 502 this._layerTree.forEachLayer(this._calculateLayerScrollRects.bind(th
is)); |
| 482 | 503 |
| 483 if (this._showPaintsSetting.get()) { | 504 if (this._showPaintsSetting.get()) { |
| 484 if (this._layerTexture) | 505 if (this._layerTexture) |
| 485 this._layerTree.forEachLayer(this._calculateLayerImageRect.bind(
this)); | 506 this._layerTree.forEachLayer(this._calculateLayerImageRect.bind(
this)); |
| 486 else | 507 else |
| 487 this._layerTree.forEachLayer(this._calculateLayerTileRects.bind(
this)); | 508 this._layerTree.forEachLayer(this._calculateLayerTileRects.bind(
this)); |
| 488 } | 509 } |
| 489 | |
| 490 if (this._layerTree.viewportSize() && this._showViewportSetting.get()) | |
| 491 this._calculateViewportRect(); | |
| 492 }, | 510 }, |
| 493 | 511 |
| 494 /** | 512 /** |
| 495 * @param {!Array.<number>} color | 513 * @param {!Array.<number>} color |
| 496 * @return {!Array.<number>} | 514 * @return {!Array.<number>} |
| 497 */ | 515 */ |
| 498 _makeColorsArray: function(color) | 516 _makeColorsArray: function(color) |
| 499 { | 517 { |
| 500 var colors = []; | 518 var colors = []; |
| 501 var normalizedColor = [color[0] / 255, color[1] / 255, color[2] / 255, c
olor[3]]; | 519 var normalizedColor = [color[0] / 255, color[1] / 255, color[2] / 255, c
olor[3]]; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 514 { | 532 { |
| 515 var gl = this._gl; | 533 var gl = this._gl; |
| 516 var buffer = gl.createBuffer(); | 534 var buffer = gl.createBuffer(); |
| 517 gl.bindBuffer(gl.ARRAY_BUFFER, buffer); | 535 gl.bindBuffer(gl.ARRAY_BUFFER, buffer); |
| 518 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(array), gl.STATIC_DRAW); | 536 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(array), gl.STATIC_DRAW); |
| 519 gl.vertexAttribPointer(attribute, length, gl.FLOAT, false, 0, 0); | 537 gl.vertexAttribPointer(attribute, length, gl.FLOAT, false, 0, 0); |
| 520 }, | 538 }, |
| 521 | 539 |
| 522 /** | 540 /** |
| 523 * @param {!Array.<number>} vertices | 541 * @param {!Array.<number>} vertices |
| 524 * @param {boolean} isBorder | 542 * @param {number} mode |
| 525 * @param {!Array.<number>=} color | 543 * @param {!Array.<number>=} color |
| 526 * @param {!Object=} texture | 544 * @param {!Object=} texture |
| 527 */ | 545 */ |
| 528 _drawRectangle: function(vertices, isBorder, color, texture) | 546 _drawRectangle: function(vertices, mode, color, texture) |
| 529 { | 547 { |
| 530 var gl = this._gl; | 548 var gl = this._gl; |
| 531 var glMode = isBorder ? gl.LINE_LOOP : gl.TRIANGLE_FAN; | |
| 532 var white = [255, 255, 255, 1]; | 549 var white = [255, 255, 255, 1]; |
| 533 this._setVertexAttribute(this._shaderProgram.vertexPositionAttribute, ve
rtices, 3); | 550 this._setVertexAttribute(this._shaderProgram.vertexPositionAttribute, ve
rtices, 3); |
| 534 this._setVertexAttribute(this._shaderProgram.textureCoordAttribute, [0,
1, 1, 1, 1, 0, 0, 0], 2); | 551 this._setVertexAttribute(this._shaderProgram.textureCoordAttribute, [0,
1, 1, 1, 1, 0, 0, 0], 2); |
| 535 | 552 |
| 536 if (texture) { | 553 if (texture) { |
| 537 this._setVertexAttribute(this._shaderProgram.vertexColorAttribute, t
his._makeColorsArray(white), white.length); | 554 this._setVertexAttribute(this._shaderProgram.vertexColorAttribute, t
his._makeColorsArray(white), white.length); |
| 538 gl.activeTexture(gl.TEXTURE0); | 555 gl.activeTexture(gl.TEXTURE0); |
| 539 gl.bindTexture(gl.TEXTURE_2D, texture); | 556 gl.bindTexture(gl.TEXTURE_2D, texture); |
| 540 gl.uniform1i(this._shaderProgram.samplerUniform, 0); | 557 gl.uniform1i(this._shaderProgram.samplerUniform, 0); |
| 541 } else { | 558 } else { |
| 542 this._setVertexAttribute(this._shaderProgram.vertexColorAttribute, t
his._makeColorsArray(color || white), color.length); | 559 this._setVertexAttribute(this._shaderProgram.vertexColorAttribute, t
his._makeColorsArray(color || white), color.length); |
| 543 gl.bindTexture(gl.TEXTURE_2D, this._whiteTexture); | 560 gl.bindTexture(gl.TEXTURE_2D, this._whiteTexture); |
| 544 } | 561 } |
| 545 | 562 |
| 546 var numberOfVertices = 4; | 563 var numberOfVertices = vertices.length / 3; |
| 547 gl.drawArrays(glMode, 0, numberOfVertices); | 564 gl.drawArrays(mode, 0, numberOfVertices); |
| 548 }, | 565 }, |
| 549 | 566 |
| 550 /** | 567 /** |
| 568 * @param {!Array.<number>} vertices |
| 569 * @param {!WebGLTexture} texture |
| 570 */ |
| 571 _drawTexture: function(vertices, texture) |
| 572 { |
| 573 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, undefined, texture)
; |
| 574 }, |
| 575 |
| 576 _drawViewportAndChrome: function() |
| 577 { |
| 578 var viewport = this._layerTree.viewportSize(); |
| 579 if (!viewport) |
| 580 return; |
| 581 |
| 582 var drawChrome = this._showChromeSetting.get() && this._chromeTextures.l
ength >= 3 && this._chromeTextures.indexOf(undefined) < 0; |
| 583 var z = (this._maxDepth + 1) * WebInspector.Layers3DView.LayerSpacing; |
| 584 var borderWidth = Math.round(WebInspector.Layers3DView.ViewportBorderWid
th * this._scale); |
| 585 var vertices = [viewport.width, 0, z, viewport.width, viewport.height, z
, 0, viewport.height, z, 0, 0, z]; |
| 586 this._gl.lineWidth(borderWidth); |
| 587 this._drawRectangle(vertices, drawChrome ? this._gl.LINE_STRIP : this._g
l.LINE_LOOP, WebInspector.Layers3DView.ViewportBorderColor); |
| 588 |
| 589 if (!drawChrome) |
| 590 return; |
| 591 |
| 592 var borderAdjustment = WebInspector.Layers3DView.ViewportBorderWidth / 2
; |
| 593 var viewportWidth = this._layerTree.viewportSize().width + 2 * borderAdj
ustment; |
| 594 var chromeHeight = this._chromeTextures[0].image.naturalHeight; |
| 595 var middleFragmentWidth = viewportWidth - this._chromeTextures[0].image.
naturalWidth - this._chromeTextures[2].image.naturalWidth; |
| 596 var x = -borderAdjustment; |
| 597 var y = -chromeHeight; |
| 598 for (var i = 0; i < this._chromeTextures.length; ++i) { |
| 599 var width = i === WebInspector.Layers3DView.ChromeTexture.Middle ? m
iddleFragmentWidth : this._chromeTextures[i].image.naturalWidth; |
| 600 if (width < 0 || x + width > viewportWidth) |
| 601 break; |
| 602 vertices = [x, y, z, x + width, y, z, x + width, y + chromeHeight, z
, x, y + chromeHeight, z]; |
| 603 this._drawTexture(vertices, /** @type {!WebGLTexture} */ (this._chro
meTextures[i])); |
| 604 x += width; |
| 605 } |
| 606 }, |
| 607 |
| 608 /** |
| 551 * @param {!WebInspector.Layers3DView.Rectangle} rect | 609 * @param {!WebInspector.Layers3DView.Rectangle} rect |
| 552 */ | 610 */ |
| 553 _drawViewRect: function(rect) | 611 _drawViewRect: function(rect) |
| 554 { | 612 { |
| 555 var vertices = rect.vertices; | 613 var vertices = rect.vertices; |
| 556 if (rect.texture) | 614 if (rect.texture) |
| 557 this._drawRectangle(vertices, false, undefined, rect.texture); | 615 this._drawTexture(vertices, rect.texture); |
| 558 else if (rect.fillColor) | 616 else if (rect.fillColor) |
| 559 this._drawRectangle(vertices, false, rect.fillColor); | 617 this._drawRectangle(vertices, this._gl.TRIANGLE_FAN, rect.fillColor)
; |
| 560 this._gl.lineWidth(rect.lineWidth); | 618 this._gl.lineWidth(rect.lineWidth); |
| 561 if (rect.borderColor) | 619 if (rect.borderColor) |
| 562 this._drawRectangle(vertices, true, rect.borderColor); | 620 this._drawRectangle(vertices, this._gl.LINE_LOOP, rect.borderColor); |
| 563 }, | 621 }, |
| 564 | 622 |
| 565 _update: function() | 623 _update: function() |
| 566 { | 624 { |
| 567 if (!this.isShowing()) { | 625 if (!this.isShowing()) { |
| 568 this._needsUpdate = true; | 626 this._needsUpdate = true; |
| 569 return; | 627 return; |
| 570 } | 628 } |
| 571 var contentRoot = this._layerTree && this._layerTree.contentRoot(); | 629 var contentRoot = this._layerTree && this._layerTree.contentRoot(); |
| 572 if (!contentRoot || !this._layerTree.root()) { | 630 if (!contentRoot || !this._layerTree.root()) { |
| 573 this._emptyView.show(this.element); | 631 this._emptyView.show(this.element); |
| 574 return; | 632 return; |
| 575 } | 633 } |
| 576 this._emptyView.detach(); | 634 this._emptyView.detach(); |
| 577 | 635 |
| 578 var gl = this._initGLIfNecessary(); | 636 var gl = this._initGLIfNecessary(); |
| 579 this._resizeCanvas(); | 637 this._resizeCanvas(); |
| 580 this._initProjectionMatrix(); | 638 this._initProjectionMatrix(); |
| 581 this._calculateDepths(); | 639 this._calculateDepths(); |
| 582 | 640 |
| 583 this._textureManager.setScale(this._textureScale); | 641 this._textureManager.setScale(Math.min(1, this._scale)); |
| 584 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); | 642 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); |
| 585 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); | 643 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); |
| 586 | 644 |
| 587 this._calculateRects(); | 645 this._calculateRects(); |
| 588 this._rects.forEach(this._drawViewRect.bind(this)); | 646 this._rects.forEach(this._drawViewRect.bind(this)); |
| 647 this._drawViewportAndChrome(); |
| 589 }, | 648 }, |
| 590 | 649 |
| 591 /** | 650 /** |
| 592 * @param {!Event} event | 651 * @param {!Event} event |
| 593 * @return {?WebInspector.Layers3DView.ActiveObject} | 652 * @return {?WebInspector.Layers3DView.ActiveObject} |
| 594 */ | 653 */ |
| 595 _activeObjectFromEventPoint: function(event) | 654 _activeObjectFromEventPoint: function(event) |
| 596 { | 655 { |
| 597 if (!this._layerTree) | 656 if (!this._layerTree) |
| 598 return null; | 657 return null; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 var setting = WebInspector.settings.createSetting(name, value) | 693 var setting = WebInspector.settings.createSetting(name, value) |
| 635 WebInspector.SettingsUI.bindCheckbox(checkbox.inputElement, setting); | 694 WebInspector.SettingsUI.bindCheckbox(checkbox.inputElement, setting); |
| 636 setting.addChangeListener(this._update, this); | 695 setting.addChangeListener(this._update, this); |
| 637 return setting; | 696 return setting; |
| 638 }, | 697 }, |
| 639 | 698 |
| 640 _initStatusBar: function() | 699 _initStatusBar: function() |
| 641 { | 700 { |
| 642 this._panelStatusBarElement = this.element.createChild("div", "panel-sta
tus-bar"); | 701 this._panelStatusBarElement = this.element.createChild("div", "panel-sta
tus-bar"); |
| 643 this._panelStatusBarElement.appendChild(this._transformController.contro
lPanelElement()); | 702 this._panelStatusBarElement.appendChild(this._transformController.contro
lPanelElement()); |
| 644 this._showViewportSetting = this._createVisibilitySetting("Viewport", "s
howViewport", true, this._panelStatusBarElement); | 703 this._showChromeSetting = this._createVisibilitySetting("Chrome", "showC
hrome", true, this._panelStatusBarElement); |
| 645 this._showSlowScrollRectsSetting = this._createVisibilitySetting("Slow s
croll rects", "showSlowScrollRects", true, this._panelStatusBarElement); | 704 this._showSlowScrollRectsSetting = this._createVisibilitySetting("Slow s
croll rects", "showSlowScrollRects", true, this._panelStatusBarElement); |
| 646 this._showPaintsSetting = this._createVisibilitySetting("Paints", "showP
aints", true, this._panelStatusBarElement); | 705 this._showPaintsSetting = this._createVisibilitySetting("Paints", "showP
aints", true, this._panelStatusBarElement); |
| 647 }, | 706 }, |
| 648 | 707 |
| 649 /** | 708 /** |
| 650 * @param {!Event} event | 709 * @param {!Event} event |
| 651 */ | 710 */ |
| 652 _onContextMenu: function(event) | 711 _onContextMenu: function(event) |
| 653 { | 712 { |
| 654 var activeObject = this._activeObjectFromEventPoint(event); | 713 var activeObject = this._activeObjectFromEventPoint(event); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 console.assert(this._scale && this._gl); | 868 console.assert(this._scale && this._gl); |
| 810 tile.scale = this._scale; | 869 tile.scale = this._scale; |
| 811 tile.snapshot.requestImage(null, null, tile.scale, onGotImage.bind(this)
); | 870 tile.snapshot.requestImage(null, null, tile.scale, onGotImage.bind(this)
); |
| 812 | 871 |
| 813 /** | 872 /** |
| 814 * @this {WebInspector.LayerTextureManager} | 873 * @this {WebInspector.LayerTextureManager} |
| 815 * @param {string=} imageURL | 874 * @param {string=} imageURL |
| 816 */ | 875 */ |
| 817 function onGotImage(imageURL) | 876 function onGotImage(imageURL) |
| 818 { | 877 { |
| 819 this.createTexture(onTextureCreated.bind(this), imageURL); | 878 if (imageURL) |
| 879 this.createTexture(onTextureCreated.bind(this), imageURL); |
| 820 } | 880 } |
| 821 | 881 |
| 822 /** | 882 /** |
| 823 * @this {WebInspector.LayerTextureManager} | 883 * @this {WebInspector.LayerTextureManager} |
| 824 * @param {!WebGLTexture} texture | 884 * @param {?WebGLTexture} texture |
| 825 */ | 885 */ |
| 826 function onTextureCreated(texture) | 886 function onTextureCreated(texture) |
| 827 { | 887 { |
| 828 tile.texture = texture; | 888 tile.texture = texture; |
| 829 this.dispatchEventToListeners(WebInspector.LayerTextureManager.Event
s.TextureUpdated); | 889 this.dispatchEventToListeners(WebInspector.LayerTextureManager.Event
s.TextureUpdated); |
| 830 } | 890 } |
| 831 }, | 891 }, |
| 832 | 892 |
| 833 /** | 893 /** |
| 834 * @param {!function(!WebGLTexture)} textureCreatedCallback | 894 * @param {function(?WebGLTexture)} textureCreatedCallback |
| 835 * @param {string=} imageURL | 895 * @param {string} imageURL |
| 836 */ | 896 */ |
| 837 createTexture: function(textureCreatedCallback, imageURL) | 897 createTexture: function(textureCreatedCallback, imageURL) |
| 838 { | 898 { |
| 839 var image = new Image(); | 899 var image = new Image(); |
| 840 image.addEventListener("load", onImageLoaded.bind(this), false); | 900 image.addEventListener("load", onImageLoaded.bind(this), false); |
| 901 image.addEventListener("error", onImageError, false); |
| 841 image.src = imageURL; | 902 image.src = imageURL; |
| 842 | 903 |
| 843 /** | 904 /** |
| 844 * @this {WebInspector.LayerTextureManager} | 905 * @this {WebInspector.LayerTextureManager} |
| 845 */ | 906 */ |
| 846 function onImageLoaded() | 907 function onImageLoaded() |
| 847 { | 908 { |
| 848 textureCreatedCallback(this._createTextureForImage(image)); | 909 textureCreatedCallback(this._createTextureForImage(image)); |
| 849 } | 910 } |
| 911 |
| 912 function onImageError() |
| 913 { |
| 914 textureCreatedCallback(null); |
| 915 } |
| 850 }, | 916 }, |
| 851 | 917 |
| 852 /** | 918 /** |
| 853 * @param {!Image} image | 919 * @param {!Image} image |
| 854 * @return {!WebGLTexture} texture | 920 * @return {!WebGLTexture} texture |
| 855 */ | 921 */ |
| 856 _createTextureForImage: function(image) | 922 _createTextureForImage: function(image) |
| 857 { | 923 { |
| 858 var texture = this._gl.createTexture(); | 924 var texture = this._gl.createTexture(); |
| 859 texture.image = image; | 925 texture.image = image; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 */ | 1123 */ |
| 1058 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent) | 1124 WebInspector.LayerTextureManager.Tile = function(snapshot, rect, traceEvent) |
| 1059 { | 1125 { |
| 1060 this.snapshot = snapshot; | 1126 this.snapshot = snapshot; |
| 1061 this.rect = rect; | 1127 this.rect = rect; |
| 1062 this.traceEvent = traceEvent; | 1128 this.traceEvent = traceEvent; |
| 1063 this.scale = 0; | 1129 this.scale = 0; |
| 1064 /** @type {?WebGLTexture} */ | 1130 /** @type {?WebGLTexture} */ |
| 1065 this.texture = null; | 1131 this.texture = null; |
| 1066 } | 1132 } |
| OLD | NEW |