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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep
this layer | 518 // explicitly compensate for all ancestors' nonzero scrollDeltas to keep
this layer |
519 // fixed correctly. | 519 // fixed correctly. |
520 combinedTransform = currentScrollCompensationMatrix * combinedTransform; | 520 combinedTransform = currentScrollCompensationMatrix * combinedTransform; |
521 } | 521 } |
522 | 522 |
523 // The drawTransform that gets computed below is effectively the layer's dra
wTransform, unless | 523 // The drawTransform that gets computed below is effectively the layer's dra
wTransform, unless |
524 // the layer itself creates a renderSurface. In that case, the renderSurface
re-parents the transforms. | 524 // the layer itself creates a renderSurface. In that case, the renderSurface
re-parents the transforms. |
525 WebTransformationMatrix drawTransform = combinedTransform; | 525 WebTransformationMatrix drawTransform = combinedTransform; |
526 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { | 526 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
527 // M[draw] = M[parent] * LT * S[layer2content] | 527 // M[draw] = M[parent] * LT * S[layer2content] |
528 drawTransform.scaleNonUniform(layer->bounds().width() / static_cast<doub
le>(layer->contentBounds().width()), | 528 drawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), |
529 layer->bounds().height() / static_cast<dou
ble>(layer->contentBounds().height())); | 529 1.0 / layer->contentsScaleY()); |
530 } | 530 } |
531 | 531 |
532 // layerScreenSpaceTransform represents the transform between root layer's "
screen space" and local content space. | 532 // layerScreenSpaceTransform represents the transform between root layer's "
screen space" and local content space. |
533 WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix; | 533 WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix; |
534 if (!layer->preserves3D()) | 534 if (!layer->preserves3D()) |
535 MathUtil::flattenTransformTo2d(layerScreenSpaceTransform); | 535 MathUtil::flattenTransformTo2d(layerScreenSpaceTransform); |
536 layerScreenSpaceTransform.multiply(drawTransform); | 536 layerScreenSpaceTransform.multiply(drawTransform); |
537 layer->setScreenSpaceTransform(layerScreenSpaceTransform); | 537 layer->setScreenSpaceTransform(layerScreenSpaceTransform); |
538 | 538 |
539 bool animatingTransformToTarget = layer->transformIsAnimating(); | 539 bool animatingTransformToTarget = layer->transformIsAnimating(); |
(...skipping 19 matching lines...) Expand all Loading... |
559 | 559 |
560 if (!layer->renderSurface()) | 560 if (!layer->renderSurface()) |
561 layer->createRenderSurface(); | 561 layer->createRenderSurface(); |
562 | 562 |
563 RenderSurfaceType* renderSurface = layer->renderSurface(); | 563 RenderSurfaceType* renderSurface = layer->renderSurface(); |
564 renderSurface->clearLayerLists(); | 564 renderSurface->clearLayerLists(); |
565 | 565 |
566 // The owning layer's draw transform has a scale from content to layer s
pace which we need to undo and | 566 // The owning layer's draw transform has a scale from content to layer s
pace which we need to undo and |
567 // replace with a scale from the surface's subtree into layer space. | 567 // replace with a scale from the surface's subtree into layer space. |
568 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { | 568 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
569 drawTransform.scaleNonUniform(layer->contentBounds().width() / stati
c_cast<double>(layer->bounds().width()), | 569 drawTransform.scaleNonUniform(layer->contentsScaleX(), |
570 layer->contentBounds().height() / stat
ic_cast<double>(layer->bounds().height())); | 570 layer->contentsScaleY()); |
571 } | 571 } |
572 drawTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / re
nderSurfaceSublayerScale.y()); | 572 drawTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(), 1 / re
nderSurfaceSublayerScale.y()); |
573 renderSurface->setDrawTransform(drawTransform); | 573 renderSurface->setDrawTransform(drawTransform); |
574 | 574 |
575 // The origin of the new surface is the upper left corner of the layer. | 575 // The origin of the new surface is the upper left corner of the layer. |
576 WebTransformationMatrix layerDrawTransform; | 576 WebTransformationMatrix layerDrawTransform; |
577 layerDrawTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), rende
rSurfaceSublayerScale.y()); | 577 layerDrawTransform.scaleNonUniform(renderSurfaceSublayerScale.x(), rende
rSurfaceSublayerScale.y()); |
578 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { | 578 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
579 layerDrawTransform.scaleNonUniform(layer->bounds().width() / static_
cast<double>(layer->contentBounds().width()), | 579 layerDrawTransform.scaleNonUniform(1.0 / layer->contentsScaleX(), |
580 layer->bounds().height() / static
_cast<double>(layer->contentBounds().height())); | 580 1.0 / layer->contentsScaleY()); |
581 } | 581 } |
582 layer->setDrawTransform(layerDrawTransform); | 582 layer->setDrawTransform(layerDrawTransform); |
583 | 583 |
584 // Inside the surface's subtree, we scale everything to the owning layer
's scale. | 584 // Inside the surface's subtree, we scale everything to the owning layer
's scale. |
585 // The sublayer matrix transforms centered layer rects into target | 585 // The sublayer matrix transforms centered layer rects into target |
586 // surface content space. | 586 // surface content space. |
587 sublayerMatrix.makeIdentity(); | 587 sublayerMatrix.makeIdentity(); |
588 sublayerMatrix.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSur
faceSublayerScale.y()); | 588 sublayerMatrix.scaleNonUniform(renderSurfaceSublayerScale.x(), renderSur
faceSublayerScale.y()); |
589 | 589 |
590 // The opacity value is moved from the layer to its surface, so that the
entire subtree properly inherits opacity. | 590 // The opacity value is moved from the layer to its surface, so that the
entire subtree properly inherits opacity. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 | 744 |
745 if (clippedContentRect.isEmpty()) | 745 if (clippedContentRect.isEmpty()) |
746 renderSurface->clearLayerLists(); | 746 renderSurface->clearLayerLists(); |
747 | 747 |
748 renderSurface->setContentRect(clippedContentRect); | 748 renderSurface->setContentRect(clippedContentRect); |
749 | 749 |
750 // The owning layer's screenSpaceTransform has a scale from content to l
ayer space which we need to undo and | 750 // The owning layer's screenSpaceTransform has a scale from content to l
ayer space which we need to undo and |
751 // replace with a scale from the surface's subtree into layer space. | 751 // replace with a scale from the surface's subtree into layer space. |
752 WebTransformationMatrix screenSpaceTransform = layer->screenSpaceTransfo
rm(); | 752 WebTransformationMatrix screenSpaceTransform = layer->screenSpaceTransfo
rm(); |
753 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { | 753 if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
754 screenSpaceTransform.scaleNonUniform(layer->contentBounds().width()
/ static_cast<double>(layer->bounds().width()), | 754 screenSpaceTransform.scaleNonUniform(layer->contentsScaleX(), |
755 layer->contentBounds().height() / stat
ic_cast<double>(layer->bounds().height())); | 755 layer->contentsScaleY()); |
756 } | 756 } |
757 screenSpaceTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(),
1 / renderSurfaceSublayerScale.y()); | 757 screenSpaceTransform.scaleNonUniform(1 / renderSurfaceSublayerScale.x(),
1 / renderSurfaceSublayerScale.y()); |
758 renderSurface->setScreenSpaceTransform(screenSpaceTransform); | 758 renderSurface->setScreenSpaceTransform(screenSpaceTransform); |
759 | 759 |
760 if (layer->replicaLayer()) { | 760 if (layer->replicaLayer()) { |
761 WebTransformationMatrix surfaceOriginToReplicaOriginTransform; | 761 WebTransformationMatrix surfaceOriginToReplicaOriginTransform; |
762 surfaceOriginToReplicaOriginTransform.scaleNonUniform(renderSurfaceS
ublayerScale.x(), renderSurfaceSublayerScale.y()); | 762 surfaceOriginToReplicaOriginTransform.scaleNonUniform(renderSurfaceS
ublayerScale.x(), renderSurfaceSublayerScale.y()); |
763 surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer(
)->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(), | 763 surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer(
)->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(), |
764 layer->replicaLayer(
)->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height()); | 764 layer->replicaLayer(
)->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height()); |
765 surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer()
->transform()); | 765 surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer()
->transform()); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 | 931 |
932 foundLayer = currentLayer; | 932 foundLayer = currentLayer; |
933 break; | 933 break; |
934 } | 934 } |
935 | 935 |
936 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. | 936 // This can potentially return 0, which means the screenSpacePoint did not s
uccessfully hit test any layers, not even the root layer. |
937 return foundLayer; | 937 return foundLayer; |
938 } | 938 } |
939 | 939 |
940 } // namespace cc | 940 } // namespace cc |
OLD | NEW |