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