Commit e886edbb authored by trchen's avatar trchen Committed by Commit bot

[SPv2] Fix PaintArtifactCompositor clip layer origin undo order

The CL https://codereview.chromium.org/1782713003/
I submitted a few days ago was still wrong.
This time a test is also added.

Review URL: https://codereview.chromium.org/1805823002

Cr-Commit-Position: refs/heads/master@{#381523}
parent a136dc99
...@@ -181,7 +181,7 @@ scoped_refptr<cc::Layer> createClipLayer(const ClipPaintPropertyNode* node) ...@@ -181,7 +181,7 @@ scoped_refptr<cc::Layer> createClipLayer(const ClipPaintPropertyNode* node)
FloatPoint offsetDueToParentClipOffset = node->parent()->clipRect().rect().location(); FloatPoint offsetDueToParentClipOffset = node->parent()->clipRect().rect().location();
gfx::Transform undoClipOffset; gfx::Transform undoClipOffset;
undoClipOffset.Translate(-offsetDueToParentClipOffset.x(), -offsetDueToParentClipOffset.y()); undoClipOffset.Translate(-offsetDueToParentClipOffset.x(), -offsetDueToParentClipOffset.y());
transform.PreconcatTransform(undoClipOffset); transform.ConcatTransform(undoClipOffset);
} }
scoped_refptr<cc::Layer> layer = cc::Layer::Create(); scoped_refptr<cc::Layer> layer = cc::Layer::Create();
...@@ -302,7 +302,7 @@ scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(const Paint ...@@ -302,7 +302,7 @@ scoped_refptr<cc::Layer> PaintArtifactCompositor::layerForPaintChunk(const Paint
FloatPoint offsetDueToClipOffset = clip->clipRect().rect().location(); FloatPoint offsetDueToClipOffset = clip->clipRect().rect().location();
gfx::Transform undoClipOffset; gfx::Transform undoClipOffset;
undoClipOffset.Translate(-offsetDueToClipOffset.x(), -offsetDueToClipOffset.y()); undoClipOffset.Translate(-offsetDueToClipOffset.x(), -offsetDueToClipOffset.y());
transform.PreconcatTransform(undoClipOffset); transform.ConcatTransform(undoClipOffset);
} }
scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(contentLayerClient.get()); scoped_refptr<cc::PictureLayer> layer = cc::PictureLayer::Create(contentLayerClient.get());
......
...@@ -144,6 +144,34 @@ TEST_F(PaintArtifactCompositorTest, TransformCombining) ...@@ -144,6 +144,34 @@ TEST_F(PaintArtifactCompositorTest, TransformCombining)
} }
} }
TEST_F(PaintArtifactCompositorTest, LayerOriginCancellation)
{
RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
nullptr, FloatRoundedRect(100, 100, 100, 100));
RefPtr<TransformPaintPropertyNode> transform = TransformPaintPropertyNode::create(
TransformationMatrix().scale(2), FloatPoint3D());
TestPaintArtifact artifact;
artifact.chunk(transform, clip, nullptr)
.rectDrawing(FloatRect(12, 34, 56, 78), Color::white);
update(artifact.build());
ASSERT_EQ(1u, rootLayer()->children().size());
cc::Layer* clipLayer = rootLayer()->child_at(0);
EXPECT_EQ(gfx::Size(100, 100), clipLayer->bounds());
EXPECT_EQ(translation(100, 100), clipLayer->transform());
EXPECT_TRUE(clipLayer->masks_to_bounds());
ASSERT_EQ(1u, clipLayer->children().size());
cc::Layer* layer = clipLayer->child_at(0);
EXPECT_EQ(gfx::Size(56, 78), layer->bounds());
gfx::Transform expectedTransform;
expectedTransform.Translate(-100, -100);
expectedTransform.Scale(2, 2);
expectedTransform.Translate(12, 34);
EXPECT_EQ(expectedTransform, layer->transform());
}
TEST_F(PaintArtifactCompositorTest, OneClip) TEST_F(PaintArtifactCompositorTest, OneClip)
{ {
RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create( RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment