diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 00:15:30 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 00:15:30 +0000 |
commit | 07908ebca049d8cf91ef2777e4c77b30e0c93fb2 (patch) | |
tree | 72ec0f7432006fb4319c5fb390cbc67f622b73ec /ui | |
parent | c0c1fa2d1272ede6a2bed69ce5a08a836baecb5c (diff) | |
download | chromium_src-07908ebca049d8cf91ef2777e4c77b30e0c93fb2.zip chromium_src-07908ebca049d8cf91ef2777e4c77b30e0c93fb2.tar.gz chromium_src-07908ebca049d8cf91ef2777e4c77b30e0c93fb2.tar.bz2 |
Repaint when the layer's scale has changed.
BUG=none
TEST=updated compositor_tests. Tested manually on the device too.
Review URL: https://chromiumcodereview.appspot.com/10388039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/compositor/layer.cc | 8 | ||||
-rw-r--r-- | ui/compositor/layer_unittest.cc | 27 |
2 files changed, 21 insertions, 14 deletions
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index 6ba3211..be6c577 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -362,6 +362,7 @@ void Layer::OnDeviceScaleFactorChanged(float device_scale_factor) { device_scale_factor_ = device_scale_factor; RecomputeTransform(); RecomputeDrawsContentAndUVRect(); + SchedulePaint(gfx::Rect(bounds_.size())); for (size_t i = 0; i < children_.size(); ++i) children_[i]->OnDeviceScaleFactorChanged(device_scale_factor); } @@ -452,6 +453,10 @@ void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { bool was_move = bounds_.size() == bounds.size(); bounds_ = bounds; + + RecomputeTransform(); + RecomputeDrawsContentAndUVRect(); + if (was_move) { // Don't schedule a draw if we're invisible. We'll schedule one // automatically when we get visible. @@ -461,9 +466,6 @@ void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { // Always schedule a paint, even if we're invisible. SchedulePaint(gfx::Rect(bounds.size())); } - - RecomputeTransform(); - RecomputeDrawsContentAndUVRect(); } void Layer::SetTransformImmediately(const ui::Transform& transform) { diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc index 6143ebb..ba143daf 100644 --- a/ui/compositor/layer_unittest.cc +++ b/ui/compositor/layer_unittest.cc @@ -237,6 +237,12 @@ class TestLayerDelegate : public LayerDelegate { scale_y_ = matrix.getScaleY(); } + void reset() { + color_index_ = 0; + paint_size_.SetSize(0, 0); + scale_x_ = scale_y_ = 0.0f; + } + private: std::vector<SkColor> colors_; int color_index_; @@ -1066,10 +1072,7 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) { size_in_pixel = l1->web_layer().bounds(); EXPECT_EQ("140x180", size_in_pixel.ToString()); - SchedulePaintForLayer(root.get()); - SchedulePaintForLayer(l1.get()); RunPendingMessages(); - EXPECT_EQ("200x220", root_delegate.paint_size().ToString()); EXPECT_EQ("140x180", l1_delegate.paint_size().ToString()); @@ -1084,8 +1087,6 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) { EXPECT_EQ("280x360", size_in_pixel.ToString()); // Canvas size must have been scaled down up. - SchedulePaintForLayer(root.get()); - SchedulePaintForLayer(l1.get()); RunPendingMessages(); EXPECT_EQ("400x440", root_delegate.paint_size().ToString()); EXPECT_EQ("2.0 2.0", root_delegate.ToScaleString()); @@ -1103,13 +1104,21 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) { EXPECT_EQ("140x180", size_in_pixel.ToString()); // Canvas size must have been scaled down too. - SchedulePaintForLayer(root.get()); - SchedulePaintForLayer(l1.get()); RunPendingMessages(); EXPECT_EQ("200x220", root_delegate.paint_size().ToString()); EXPECT_EQ("1.0 1.0", root_delegate.ToScaleString()); EXPECT_EQ("140x180", l1_delegate.paint_size().ToString()); EXPECT_EQ("1.0 1.0", l1_delegate.ToScaleString()); + + root_delegate.reset(); + l1_delegate.reset(); + // Just changing the size shouldn't trigger repaint. + GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(1000, 1000)); + RunPendingMessages(); + EXPECT_EQ("0x0", root_delegate.paint_size().ToString()); + EXPECT_EQ("0.0 0.0", root_delegate.ToScaleString()); + EXPECT_EQ("0x0", l1_delegate.paint_size().ToString()); + EXPECT_EQ("0.0 0.0", l1_delegate.ToScaleString()); } TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) { @@ -1131,7 +1140,6 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) { gfx::Size size_in_pixel = l1->web_layer().bounds(); EXPECT_EQ("140x180", size_in_pixel.ToString()); - SchedulePaintForLayer(l1.get()); RunPendingMessages(); EXPECT_EQ("140x180", l1_delegate.paint_size().ToString()); EXPECT_EQ("1.0 1.0", l1_delegate.ToScaleString()); @@ -1151,7 +1159,6 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) { EXPECT_EQ("10,20 140x180", l1->bounds().ToString()); size_in_pixel = l1->web_layer().bounds(); EXPECT_EQ("280x360", size_in_pixel.ToString()); - SchedulePaintForLayer(l1.get()); RunPendingMessages(); EXPECT_EQ("280x360", l1_delegate.paint_size().ToString()); EXPECT_EQ("2.0 2.0", l1_delegate.ToScaleString()); @@ -1172,8 +1179,6 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_NoScaleCanvas) { GetCompositor()->SetScaleAndSize(2.0f, gfx::Size(500, 500)); GetCompositor()->SetRootLayer(root.get()); - - SchedulePaintForLayer(l1.get()); RunPendingMessages(); EXPECT_EQ("280x360", l1_delegate.paint_size().ToString()); EXPECT_EQ("1.0 1.0", l1_delegate.ToScaleString()); |