| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/layer_tree_host_common.h" | 7 #include "cc/layer_tree_host_common.h" |
| 8 | 8 |
| 9 #include "FloatQuad.h" | 9 #include "FloatQuad.h" |
| 10 #include "IntRect.h" | 10 #include "IntRect.h" |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep
this layer | 526 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep
this layer |
| 527 // fixed correctly. | 527 // fixed correctly. |
| 528 combinedTransform = currentScrollCompensationMatrix * combinedTransform; | 528 combinedTransform = currentScrollCompensationMatrix * combinedTransform; |
| 529 } | 529 } |
| 530 | 530 |
| 531 // The drawTransform that gets computed below is effectively the layer's dra
wTransform, unless | 531 // The drawTransform that gets computed below is effectively the layer's dra
wTransform, unless |
| 532 // the layer itself creates a renderSurface. In that case, the renderSurface
re-parents the transforms. | 532 // the layer itself creates a renderSurface. In that case, the renderSurface
re-parents the transforms. |
| 533 WebTransformationMatrix drawTransform = combinedTransform; | 533 WebTransformationMatrix drawTransform = combinedTransform; |
| 534 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { | 534 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
| 535 // M[draw] = M[parent] * LT * S[layer2content] | 535 // M[draw] = M[parent] * LT * S[layer2content] |
| 536 drawTransform.scaleNonUniform(layer->bounds().width() / static_cast<doub
le>(layer->contentBounds().width()), | 536 drawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), |
| 537 layer->bounds().height() / static_cast<dou
ble>(layer->contentBounds().height())); | 537 1.0 / layer->contentsScaleY()); |
| 538 } | 538 } |
| 539 | 539 |
| 540 // layerScreenSpaceTransform represents the transform between root layer's "
screen space" and local content space. | 540 // layerScreenSpaceTransform represents the transform between root layer's "
screen space" and local content space. |
| 541 WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix; | 541 WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix; |
| 542 if (!layer->preserves3D()) | 542 if (!layer->preserves3D()) |
| 543 MathUtil::flattenTransformTo2d(layerScreenSpaceTransform); | 543 MathUtil::flattenTransformTo2d(layerScreenSpaceTransform); |
| 544 layerScreenSpaceTransform.multiply(drawTransform); | 544 layerScreenSpaceTransform.multiply(drawTransform); |
| 545 layer->setScreenSpaceTransform(layerScreenSpaceTransform); | 545 layer->setScreenSpaceTransform(layerScreenSpaceTransform); |
| 546 | 546 |
| 547 bool animatingTransformToTarget = layer->transformIsAnimating(); | 547 bool animatingTransformToTarget = layer->transformIsAnimating(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 567 | 567 |
| 568 if (!layer->renderSurface()) | 568 if (!layer->renderSurface()) |
| 569 layer->createRenderSurface(); | 569 layer->createRenderSurface(); |
| 570 | 570 |
| 571 RenderSurfaceType* renderSurface = layer->renderSurface(); | 571 RenderSurfaceType* renderSurface = layer->renderSurface(); |
| 572 renderSurface->clearLayerLists(); | 572 renderSurface->clearLayerLists(); |
| 573 | 573 |
| 574 // The owning layer's draw transform has a scale from content to layer s
pace which we need to undo and | 574 // The owning layer's draw transform has a scale from content to layer s
pace which we need to undo and |
| 575 // replace with a scale from the surface's subtree into layer space. | 575 // replace with a scale from the surface's subtree into layer space. |
| 576 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { | 576 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
| 577 drawTransform.scaleNonUniform(layer->contentBounds().width() / stati
c_cast<double>(layer->bounds().width()), | 577 drawTransform.scaleNonUniform(layer->contentsScaleX(), |
| 578 layer->contentBounds().height() / stat
ic_cast<double>(layer->bounds().height())); | 578 layer->contentsScaleY()); |
| 579 } | 579 } |
| 580 drawTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / re
nderSurfaceSublayerScale.y()); | 580 drawTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / re
nderSurfaceSublayerScale.y()); |
| 581 renderSurface->setDrawTransform(drawTransform); | 581 renderSurface->setDrawTransform(drawTransform); |
| 582 | 582 |
| 583 // The origin of the new surface is the upper left corner of the layer. | 583 // The origin of the new surface is the upper left corner of the layer. |
| 584 WebTransformationMatrix layerDrawTransform; | 584 WebTransformationMatrix layerDrawTransform; |
| 585 layerDrawTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), rende
rSurfaceSublayerScale.y()); | 585 layerDrawTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), rende
rSurfaceSublayerScale.y()); |
| 586 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { | 586 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
| 587 layerDrawTransform.scaleNonUniform(layer->bounds().width() / static_
cast<double>(layer->contentBounds().width()), | 587 layerDrawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), |
| 588 layer->bounds().height() / static
_cast<double>(layer->contentBounds().height())); | 588 1.0 / layer->contentsScaleY()); |
| 589 } | 589 } |
| 590 layer->setDrawTransform(layerDrawTransform); | 590 layer->setDrawTransform(layerDrawTransform); |
| 591 | 591 |
| 592 // Inside the surface's subtree, we scale everything to the owning layer
's scale. | 592 // Inside the surface's subtree, we scale everything to the owning layer
's scale. |
| 593 // The sublayer matrix transforms centered layer rects into target | 593 // The sublayer matrix transforms centered layer rects into target |
| 594 // surface content space. | 594 // surface content space. |
| 595 sublayerMatrix.makeIdentity(); | 595 sublayerMatrix.makeIdentity(); |
| 596 sublayerMatrix.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSur
faceSublayerScale.y()); | 596 sublayerMatrix.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSur
faceSublayerScale.y()); |
| 597 | 597 |
| 598 // The opacity value is moved from the layer to its surface, so that the
entire subtree properly inherits opacity. | 598 // The opacity value is moved from the layer to its surface, so that the
entire subtree properly inherits opacity. |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 | 756 |
| 757 if (clippedContentRect.isEmpty()) | 757 if (clippedContentRect.isEmpty()) |
| 758 renderSurface->clearLayerLists(); | 758 renderSurface->clearLayerLists(); |
| 759 | 759 |
| 760 renderSurface->setContentRect(clippedContentRect); | 760 renderSurface->setContentRect(clippedContentRect); |
| 761 | 761 |
| 762 // The owning layer's screenSpaceTransform has a scale from content to l
ayer space which we need to undo and | 762 // The owning layer's screenSpaceTransform has a scale from content to l
ayer space which we need to undo and |
| 763 // replace with a scale from the surface's subtree into layer space. | 763 // replace with a scale from the surface's subtree into layer space. |
| 764 WebTransformationMatrix screenSpaceTransform = layer->screenSpaceTransfo
rm(); | 764 WebTransformationMatrix screenSpaceTransform = layer->screenSpaceTransfo
rm(); |
| 765 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { | 765 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
| 766 screenSpaceTransform.scaleNonUniform(layer->contentBounds().width()
/ static_cast<double>(layer->bounds().width()), | 766 screenSpaceTransform.scaleNonUniform(layer->contentsScaleX(), |
| 767 layer->contentBounds().height() / stat
ic_cast<double>(layer->bounds().height())); | 767 layer->contentsScaleY()); |
| 768 } | 768 } |
| 769 screenSpaceTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(),
1 / renderSurfaceSublayerScale.y()); | 769 screenSpaceTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(),
1 / renderSurfaceSublayerScale.y()); |
| 770 renderSurface->setScreenSpaceTransform(screenSpaceTransform); | 770 renderSurface->setScreenSpaceTransform(screenSpaceTransform); |
| 771 | 771 |
| 772 if (layer->replicaLayer()) { | 772 if (layer->replicaLayer()) { |
| 773 WebTransformationMatrix surfaceOriginToReplicaOriginTransform; | 773 WebTransformationMatrix surfaceOriginToReplicaOriginTransform; |
| 774 surfaceOriginToReplicaOriginTransform.scaleNonUniform(renderSurfaceS
ublayerScale.x(), renderSurfaceSublayerScale.y()); | 774 surfaceOriginToReplicaOriginTransform.scaleNonUniform(renderSurfaceS
ublayerScale.x(), renderSurfaceSublayerScale.y()); |
| 775 surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer(
)->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(), | 775 surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer(
)->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(), |
| 776 layer->replicaLayer(
)->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height()); | 776 layer->replicaLayer(
)->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height()); |
| 777 surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer()
->transform()); | 777 surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer()
->transform()); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 | 921 |
| 922 foundLayer = currentLayer; | 922 foundLayer = currentLayer; |
| 923 break; | 923 break; |
| 924 } | 924 } |
| 925 | 925 |
| 926 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. | 926 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. |
| 927 return foundLayer; | 927 return foundLayer; |
| 928 } | 928 } |
| 929 | 929 |
| 930 } // namespace cc | 930 } // namespace cc |
| OLD | NEW |