diff options
| author | oshima <oshima@chromium.org> | 2016-03-16 15:32:47 -0700 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2016-03-16 22:35:25 +0000 |
| commit | e083cc6e0b6d6e0e345b553041f2e241aca5e448 (patch) | |
| tree | b807d5cbd50f31aba91d04b065704e916be26110 | |
| parent | 4e7ecf36fb2af3e3677c085de5b1ea6e7e75f3be (diff) | |
| download | chromium_src-e083cc6e0b6d6e0e345b553041f2e241aca5e448.zip chromium_src-e083cc6e0b6d6e0e345b553041f2e241aca5e448.tar.gz chromium_src-e083cc6e0b6d6e0e345b553041f2e241aca5e448.tar.bz2 | |
RecreateLayer should copy the transform as well.
BUG=581917
TEST=LayerOwnerTest.RecreateLayerWithTransform
Review URL: https://codereview.chromium.org/1800393002
Cr-Commit-Position: refs/heads/master@{#381571}
| -rw-r--r-- | ui/compositor/layer_owner.cc | 1 | ||||
| -rw-r--r-- | ui/compositor/layer_owner_unittest.cc | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/ui/compositor/layer_owner.cc b/ui/compositor/layer_owner.cc index f406d88..44bb322 100644 --- a/ui/compositor/layer_owner.cc +++ b/ui/compositor/layer_owner.cc @@ -49,6 +49,7 @@ scoped_ptr<Layer> LayerOwner::RecreateLayer() { new_layer->SetFillsBoundsCompletely(old_layer->FillsBoundsCompletely()); new_layer->SetSubpixelPositionOffset(old_layer->subpixel_position_offset()); new_layer->SetLayerInverted(old_layer->layer_inverted()); + new_layer->SetTransform(old_layer->GetTargetTransform()); if (old_layer->type() == LAYER_SOLID_COLOR) new_layer->SetColor(old_layer->GetTargetColor()); SkRegion* alpha_shape = old_layer->alpha_shape(); diff --git a/ui/compositor/layer_owner_unittest.cc b/ui/compositor/layer_owner_unittest.cc index add8345..69216aa 100644 --- a/ui/compositor/layer_owner_unittest.cc +++ b/ui/compositor/layer_owner_unittest.cc @@ -157,6 +157,31 @@ TEST(LayerOwnerTest, InvertPropertyRemainSameWithRecreateLayer) { EXPECT_EQ(old_layer2->layer_inverted(), owner.layer()->layer_inverted()); } +TEST(LayerOwnerTest, RecreateLayerWithTransform) { + LayerOwner owner; + Layer* layer = new Layer; + owner.SetLayer(layer); + + gfx::Transform transform; + transform.Scale(2, 1); + transform.Translate(10, 5); + + layer->SetTransform(transform); + + scoped_ptr<Layer> old_layer1 = owner.RecreateLayer(); + // Both new layer and original layer have the same transform. + EXPECT_EQ(transform, old_layer1->GetTargetTransform()); + EXPECT_EQ(transform, owner.layer()->GetTargetTransform()); + + // But they're now separated, so changing the old layer's transform + // should not affect the owner's. + owner.layer()->SetTransform(gfx::Transform()); + EXPECT_EQ(transform, old_layer1->GetTargetTransform()); + scoped_ptr<Layer> old_layer2 = owner.RecreateLayer(); + EXPECT_TRUE(old_layer2->GetTargetTransform().IsIdentity()); + EXPECT_TRUE(owner.layer()->GetTargetTransform().IsIdentity()); +} + TEST_F(LayerOwnerTestWithCompositor, RecreateRootLayerWithCompositor) { LayerOwner owner; Layer* layer = new Layer; |
