diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-13 18:43:28 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-13 18:43:28 +0000 |
commit | 537d7f0ccd094a8c110b3b728a062ae7cd0d3d9c (patch) | |
tree | 2efb919edd3bc885b40a996ec5af9d1e095f2630 /ui | |
parent | 97441547137c71fb2a6ba149f39b2a896dfc5960 (diff) | |
download | chromium_src-537d7f0ccd094a8c110b3b728a062ae7cd0d3d9c.zip chromium_src-537d7f0ccd094a8c110b3b728a062ae7cd0d3d9c.tar.gz chromium_src-537d7f0ccd094a8c110b3b728a062ae7cd0d3d9c.tar.bz2 |
Fixes transform of holes to match that of the child view in ::Draw
The transform applied to holes was incorrect when the bounds of the child were non zero
In Layer::Draw the transform is first applied, then the translation, changed the code in Layer::RecomputeHole to match that
This put the holes in the wrong place for the views_desktop demo.
I have not seen a place where this was broken in chromium, however it might prevent
future bugs once we apply transformations to child views
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/8249005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105340 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/compositor/layer.cc | 11 | ||||
-rw-r--r-- | ui/gfx/compositor/layer_unittest.cc | 15 |
2 files changed, 18 insertions, 8 deletions
diff --git a/ui/gfx/compositor/layer.cc b/ui/gfx/compositor/layer.cc index b9b1cd3..8266bff 100644 --- a/ui/gfx/compositor/layer.cc +++ b/ui/gfx/compositor/layer.cc @@ -328,8 +328,15 @@ void Layer::RecomputeHole() { !IsApproximateMultilpleOf(degrees, 90.0f)) continue; - gfx::Rect candidate_hole = children_[i]->bounds(); - children_[i]->transform().TransformRect(&candidate_hole); + // The reason why we don't just take the bounds and apply the transform is + // that the bounds encodes a position, too, so the effective transformation + // matrix is actually different that the one reported. As well, the bounds + // will not necessarily be at the origin. + gfx::Rect candidate_hole(children_[i]->bounds_.size()); + ui::Transform transform = children_[i]->transform(); + transform.ConcatTranslate(static_cast<float>(children_[i]->bounds_.x()), + static_cast<float>(children_[i]->bounds_.y())); + transform.TransformRect(&candidate_hole); // This layer might not contain the child (e.g., a portion of the child may // be offscreen). Only the portion of the child that overlaps this layer is diff --git a/ui/gfx/compositor/layer_unittest.cc b/ui/gfx/compositor/layer_unittest.cc index 5521cf2..bb05c0b 100644 --- a/ui/gfx/compositor/layer_unittest.cc +++ b/ui/gfx/compositor/layer_unittest.cc @@ -539,9 +539,9 @@ TEST_F(LayerWithNullDelegateTest, NoHoleWithTransform) { EXPECT_TRUE(!parent->hole_rect().IsEmpty()); ui::Transform t; - t.SetTranslate(-75, -75); + t.SetTranslate(-50, -50); t.ConcatRotate(45.0f); - t.ConcatTranslate(75, 75); + t.ConcatTranslate(50, 50); child->SetTransform(t); EXPECT_EQ(gfx::Rect(0, 0, 0, 0), parent->hole_rect()); @@ -558,13 +558,16 @@ TEST_F(LayerWithNullDelegateTest, HoleWithNinetyDegreeTransforms) { for (int i = -4; i <= 4; ++i) { ui::Transform t; - t.SetTranslate(-75, -75); + // Need to rotate in local coordinates. + t.SetTranslate(-25, -25); t.ConcatRotate(90.0f * i); - t.ConcatTranslate(75, 75); + t.ConcatTranslate(25, 25); child->SetTransform(t); - gfx::Rect target_rect = child->bounds(); - child->transform().TransformRect(&target_rect); + gfx::Rect target_rect(child->bounds().size()); + t.ConcatTranslate(child->bounds().x(), child->bounds().y()); + t.TransformRect(&target_rect); + EXPECT_EQ(target_rect, parent->hole_rect()); } } |