Commit db94fe9f authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Ignore position of mask layers in layer tree mode

We ignored position of mask layers before crrev.com/697315 by always
setting the mask layer's offset_to_transform_parent and property tree
state to the same as the masked layer. As we removed the special
handling code for mask layers from PropertyTreeBuilder, now we ignore
position of mask layers in Layer::SetPosition() to keep the original
behavior.

Bug: 100532
Change-Id: I2c9def5e139ea6a3c798593f8f0c2a219d2bdc8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1810844Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697808}
parent 56c09909
......@@ -605,6 +605,7 @@ void Layer::SetMaskLayer(scoped_refptr<PictureLayer> mask_layer) {
// The mask layer should not have any children.
DCHECK(mask_layer->children().empty());
mask_layer->inputs_.position = gfx::PointF();
mask_layer->SetIsDrawable(true);
mask_layer->SetBlendMode(SkBlendMode::kDstIn);
mask_layer->SetIsMask(true);
......@@ -818,6 +819,14 @@ void Layer::SetContentsOpaque(bool opaque) {
}
void Layer::SetPosition(const gfx::PointF& position) {
// The mask layer should always be at the same location as the masked layer
// which is its parent, so its position should be always zero.
if (parent() && parent()->inputs_.mask_layer == this) {
DCHECK(!layer_tree_host_ || !layer_tree_host_->IsUsingLayerLists());
DCHECK(inputs_.position.IsOrigin());
return;
}
DCHECK(IsPropertyChangeAllowed());
if (inputs_.position == position)
return;
......@@ -1387,8 +1396,10 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
"Layer::PushPropertiesTo");
DCHECK(layer_tree_host_);
if (inputs_.mask_layer)
if (inputs_.mask_layer) {
DCHECK_EQ(bounds(), inputs_.mask_layer->bounds());
DCHECK(inputs_.mask_layer->position().IsOrigin());
}
// The element id should be set first because other setters may
// depend on it. Referencing element id on a layer is
......
......@@ -502,6 +502,7 @@ TEST_F(LayerTest, SetMaskLayer) {
scoped_refptr<Layer> parent = Layer::Create();
FakeContentLayerClient client;
scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
mask->SetPosition(gfx::PointF(88, 99));
parent->SetMaskLayer(mask);
ASSERT_EQ(1u, parent->children().size());
......@@ -509,6 +510,11 @@ TEST_F(LayerTest, SetMaskLayer) {
EXPECT_EQ(mask.get(), parent->children()[0]);
EXPECT_TRUE(parent->IsMaskedByChild());
// Should ignore mask layer's position.
EXPECT_TRUE(mask->position().IsOrigin());
mask->SetPosition(gfx::PointF(11, 22));
EXPECT_TRUE(mask->position().IsOrigin());
parent->SetMaskLayer(mask);
ASSERT_EQ(1u, parent->children().size());
EXPECT_EQ(parent.get(), mask->parent());
......
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