Commit c7c23036 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Copy damaged region when cloinng

Bug: 1134279
Test: covered by unittests
Change-Id: Ic8a411f57e8401321454f187dbcace2bd3c3c85d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2451709Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814240}
parent b6d1eb91
...@@ -281,6 +281,9 @@ std::unique_ptr<Layer> Layer::Clone() const { ...@@ -281,6 +281,9 @@ std::unique_ptr<Layer> Layer::Clone() const {
clone->SetIsFastRoundedCorner(is_fast_rounded_corner()); clone->SetIsFastRoundedCorner(is_fast_rounded_corner());
clone->SetName(name_); clone->SetName(name_);
// the |damaged_region_| will be sent to cc later in SendDamagedRects().
clone->damaged_region_ = damaged_region_;
return clone; return clone;
} }
......
...@@ -841,6 +841,25 @@ TEST_F(LayerWithDelegateTest, Cloning) { ...@@ -841,6 +841,25 @@ TEST_F(LayerWithDelegateTest, Cloning) {
EXPECT_EQ(SK_ColorGREEN, clone->background_color()); EXPECT_EQ(SK_ColorGREEN, clone->background_color());
} }
TEST_F(LayerWithDelegateTest, CloneDamagedRegion) {
std::unique_ptr<Layer> layer = CreateLayer(LAYER_TEXTURED);
// Set a delegate so that the damage region is accumulated.
DrawTreeLayerDelegate delegate(gfx::Rect(0, 0, 10, 10));
layer->set_delegate(&delegate);
cc::Region damaged_region;
damaged_region.Union(gfx::Rect(10, 10, 5, 5));
damaged_region.Union(gfx::Rect(20, 20, 7, 7));
for (auto rect : damaged_region)
layer->SchedulePaint(rect);
ASSERT_EQ(damaged_region, layer->damaged_region());
auto clone = layer->Clone();
EXPECT_EQ(damaged_region, clone->damaged_region());
}
TEST_F(LayerWithDelegateTest, Mirroring) { TEST_F(LayerWithDelegateTest, Mirroring) {
std::unique_ptr<Layer> root = CreateNoTextureLayer(gfx::Rect(0, 0, 100, 100)); std::unique_ptr<Layer> root = CreateNoTextureLayer(gfx::Rect(0, 0, 100, 100));
std::unique_ptr<Layer> child = CreateLayer(LAYER_TEXTURED); std::unique_ptr<Layer> child = CreateLayer(LAYER_TEXTURED);
......
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