| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 this._canvasElement.height = this._canvasElement.offsetHeight * window.d
evicePixelRatio; | 242 this._canvasElement.height = this._canvasElement.offsetHeight * window.d
evicePixelRatio; |
| 243 this._gl.viewportWidth = this._canvasElement.width; | 243 this._gl.viewportWidth = this._canvasElement.width; |
| 244 this._gl.viewportHeight = this._canvasElement.height; | 244 this._gl.viewportHeight = this._canvasElement.height; |
| 245 }, | 245 }, |
| 246 | 246 |
| 247 /** | 247 /** |
| 248 * @return {!CSSMatrix} | 248 * @return {!CSSMatrix} |
| 249 */ | 249 */ |
| 250 _calculateProjectionMatrix: function() | 250 _calculateProjectionMatrix: function() |
| 251 { | 251 { |
| 252 var rootLayerPadding = 20; | 252 var scaleFactorForMargins = 1.2; |
| 253 var rootWidth = this._layerTree.contentRoot().width(); | 253 var viewport = this._layerTree.viewportSize(); |
| 254 var rootHeight = this._layerTree.contentRoot().height(); | 254 var baseWidth = viewport ? viewport.width : this._layerTree.contentRoot(
).width(); |
| 255 var baseHeight = viewport ? viewport.height : this._layerTree.contentRoo
t().height(); |
| 255 var canvasWidth = this._canvasElement.width; | 256 var canvasWidth = this._canvasElement.width; |
| 256 var canvasHeight = this._canvasElement.height; | 257 var canvasHeight = this._canvasElement.height; |
| 257 var scaleX = (canvasWidth - rootLayerPadding) / rootWidth; | 258 var scaleX = canvasWidth / baseWidth / scaleFactorForMargins; |
| 258 var scaleY = (canvasHeight - rootLayerPadding) / rootHeight; | 259 var scaleY = canvasHeight / baseHeight / scaleFactorForMargins; |
| 259 var viewScale = Math.min(scaleX, scaleY); | 260 var viewScale = Math.min(scaleX, scaleY); |
| 260 var scale = this._transformController.scale(); | 261 var scale = this._transformController.scale(); |
| 261 var offsetX = this._transformController.offsetX() * window.devicePixelRa
tio; | 262 var offsetX = this._transformController.offsetX() * window.devicePixelRa
tio; |
| 262 var offsetY = this._transformController.offsetY() * window.devicePixelRa
tio; | 263 var offsetY = this._transformController.offsetY() * window.devicePixelRa
tio; |
| 263 var rotateX = this._transformController.rotateX(); | 264 var rotateX = this._transformController.rotateX(); |
| 264 var rotateY = this._transformController.rotateY(); | 265 var rotateY = this._transformController.rotateY(); |
| 265 return new WebKitCSSMatrix().translate(offsetX, offsetY, 0).scale(scale,
scale, scale).translate(canvasWidth / 2, canvasHeight / 2, 0) | 266 return new WebKitCSSMatrix().translate(offsetX, offsetY, 0).scale(scale,
scale, scale).translate(canvasWidth / 2, canvasHeight / 2, 0) |
| 266 .rotate(rotateX, rotateY, 0).scale(viewScale, viewScale, viewScale).
translate(-rootWidth / 2, -rootHeight / 2, 0); | 267 .rotate(rotateX, rotateY, 0).scale(viewScale, viewScale, viewScale).
translate(-baseWidth / 2, -baseHeight / 2, 0); |
| 267 }, | 268 }, |
| 268 | 269 |
| 269 _initProjectionMatrix: function() | 270 _initProjectionMatrix: function() |
| 270 { | 271 { |
| 271 this._pMatrix = new WebKitCSSMatrix().scale(1, -1, -1).translate(-1, -1,
0) | 272 this._pMatrix = new WebKitCSSMatrix().scale(1, -1, -1).translate(-1, -1,
0) |
| 272 .scale(2 / this._canvasElement.width, 2 / this._canvasElement.height
, 1 / 1000000).multiply(this._calculateProjectionMatrix()); | 273 .scale(2 / this._canvasElement.width, 2 / this._canvasElement.height
, 1 / 1000000).multiply(this._calculateProjectionMatrix()); |
| 273 this._gl.uniformMatrix4fv(this._shaderProgram.pMatrixUniform, false, thi
s._arrayFromMatrix(this._pMatrix)); | 274 this._gl.uniformMatrix4fv(this._shaderProgram.pMatrixUniform, false, thi
s._arrayFromMatrix(this._pMatrix)); |
| 274 }, | 275 }, |
| 275 | 276 |
| 276 /** | 277 /** |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 var scrollRectQuads = this._scrollRectQuadsForLayer[layer.id()]; | 492 var scrollRectQuads = this._scrollRectQuadsForLayer[layer.id()]; |
| 492 for (var i = 0; i < scrollRectQuads.length; ++i) { | 493 for (var i = 0; i < scrollRectQuads.length; ++i) { |
| 493 vertices = this._calculateVerticesForQuad(scrollRectQuads[i], this._
calculateScrollRectDepth(layer, i)); | 494 vertices = this._calculateVerticesForQuad(scrollRectQuads[i], this._
calculateScrollRectDepth(layer, i)); |
| 494 var isSelected = this._isObjectActive(WebInspector.Layers3DView.Outl
ineType.Selected, layer, i); | 495 var isSelected = this._isObjectActive(WebInspector.Layers3DView.Outl
ineType.Selected, layer, i); |
| 495 var color = isSelected ? WebInspector.Layers3DView.SelectedScrollRec
tBackgroundColor : WebInspector.Layers3DView.ScrollRectBackgroundColor; | 496 var color = isSelected ? WebInspector.Layers3DView.SelectedScrollRec
tBackgroundColor : WebInspector.Layers3DView.ScrollRectBackgroundColor; |
| 496 this._drawRectangle(vertices, color, gl.TRIANGLE_FAN); | 497 this._drawRectangle(vertices, color, gl.TRIANGLE_FAN); |
| 497 this._drawRectangle(vertices, WebInspector.Layers3DView.ScrollRectBo
rderColor, gl.LINE_LOOP); | 498 this._drawRectangle(vertices, WebInspector.Layers3DView.ScrollRectBo
rderColor, gl.LINE_LOOP); |
| 498 } | 499 } |
| 499 }, | 500 }, |
| 500 | 501 |
| 502 _drawViewport: function() |
| 503 { |
| 504 var viewport = this._layerTree.viewportSize(); |
| 505 var vertices = [0, 0, 0, viewport.width, 0, 0, viewport.width, viewport.
height, 0, 0, viewport.height, 0]; |
| 506 var color = [0, 0, 0, 1]; |
| 507 this._gl.lineWidth(3.0); |
| 508 this._drawRectangle(vertices, color, this._gl.LINE_LOOP); |
| 509 this._gl.lineWidth(1.0); |
| 510 }, |
| 511 |
| 501 _calculateDepths: function() | 512 _calculateDepths: function() |
| 502 { | 513 { |
| 503 this._depthByLayerId = {}; | 514 this._depthByLayerId = {}; |
| 504 this._isVisible = {}; | 515 this._isVisible = {}; |
| 505 var depth = 0; | 516 var depth = 0; |
| 506 var root = this._layerTree.root(); | 517 var root = this._layerTree.root(); |
| 507 var queue = [root]; | 518 var queue = [root]; |
| 508 this._depthByLayerId[root.id()] = 0; | 519 this._depthByLayerId[root.id()] = 0; |
| 509 this._isVisible[root.id()] = false; | 520 this._isVisible[root.id()] = false; |
| 510 while (queue.length > 0) { | 521 while (queue.length > 0) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 this._emptyView.detach(); | 553 this._emptyView.detach(); |
| 543 | 554 |
| 544 var gl = this._initGLIfNecessary(); | 555 var gl = this._initGLIfNecessary(); |
| 545 this._resizeCanvas(); | 556 this._resizeCanvas(); |
| 546 this._initProjectionMatrix(); | 557 this._initProjectionMatrix(); |
| 547 this._calculateDepths(); | 558 this._calculateDepths(); |
| 548 | 559 |
| 549 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); | 560 gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); |
| 550 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); | 561 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); |
| 551 | 562 |
| 563 if (this._layerTree.viewportSize()) |
| 564 this._drawViewport(); |
| 552 this._layerTree.forEachLayer(this._drawLayer.bind(this)); | 565 this._layerTree.forEachLayer(this._drawLayer.bind(this)); |
| 553 }, | 566 }, |
| 554 | 567 |
| 555 /** | 568 /** |
| 556 * Intersects quad with given transform matrix and line l(t) = (x0, y0, t) | 569 * Intersects quad with given transform matrix and line l(t) = (x0, y0, t) |
| 557 * @param {!Array.<number>} vertices | 570 * @param {!Array.<number>} vertices |
| 558 * @param {!CSSMatrix} matrix | 571 * @param {!CSSMatrix} matrix |
| 559 * @param {!number} x0 | 572 * @param {!number} x0 |
| 560 * @param {!number} y0 | 573 * @param {!number} y0 |
| 561 * @return {(number|undefined)} | 574 * @return {(number|undefined)} |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 _onDoubleClick: function(event) | 697 _onDoubleClick: function(event) |
| 685 { | 698 { |
| 686 var object = this._activeObjectFromEventPoint(event); | 699 var object = this._activeObjectFromEventPoint(event); |
| 687 if (object && object.layer) | 700 if (object && object.layer) |
| 688 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.Layer
SnapshotRequested, object.layer); | 701 this.dispatchEventToListeners(WebInspector.Layers3DView.Events.Layer
SnapshotRequested, object.layer); |
| 689 event.stopPropagation(); | 702 event.stopPropagation(); |
| 690 }, | 703 }, |
| 691 | 704 |
| 692 __proto__: WebInspector.VBox.prototype | 705 __proto__: WebInspector.VBox.prototype |
| 693 } | 706 } |
| OLD | NEW |