Commit 508fca01 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

ui: Copy clip rect property when cloning layer.

Test: compositor_unittests LayerWithDelegateTest.Cloning
Change-Id: I13496c5e339db87ad2b78f868cf135e53c1f1aed
Fixed: 1121302
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2374025Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801453}
parent 84db4a8d
......@@ -96,10 +96,6 @@ class DragWindowController::DragWindowDetails {
window->parent(), &bounds);
window->SetBounds(bounds);
window->SetTransform(original_window->transform());
window->layer()->SetClipRect(original_window->layer()->clip_rect());
window->layer()->SetRoundedCornerRadius(
original_window->layer()->rounded_corner_radii());
window->layer()->SetIsFastRoundedCorner(true);
widget_->SetOpacity(opacity);
}
......
......@@ -273,6 +273,7 @@ std::unique_ptr<Layer> Layer::Clone() const {
clone->SetMasksToBounds(GetMasksToBounds());
clone->SetOpacity(GetTargetOpacity());
clone->SetVisible(GetTargetVisibility());
clone->SetClipRect(GetTargetClipRect());
clone->SetAcceptEvents(accept_events());
clone->SetFillsBoundsOpaquely(fills_bounds_opaquely_);
clone->SetFillsBoundsCompletely(fills_bounds_completely_);
......@@ -497,6 +498,14 @@ bool Layer::GetMasksToBounds() const {
return cc_layer_->masks_to_bounds();
}
gfx::Rect Layer::GetTargetClipRect() const {
if (animator_ &&
animator_->IsAnimatingProperty(LayerAnimationElement::CLIP)) {
return animator_->GetTargetClipRect();
}
return clip_rect();
}
void Layer::SetClipRect(const gfx::Rect& clip_rect) {
GetAnimator()->SetClipRect(clip_rect);
}
......
......@@ -203,6 +203,7 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate,
// Sets/gets the clip rect for the layer. |clip_rect| is in layer space and
// relative to |this| layer. Prefer SetMasksToBounds() to set the clip to the
// bounds of |this| layer. This clips the subtree rooted at |this| layer.
gfx::Rect GetTargetClipRect() const;
void SetClipRect(const gfx::Rect& clip_rect);
gfx::Rect clip_rect() const { return cc_layer_->clip_rect(); }
......
......@@ -746,11 +746,14 @@ TEST_F(LayerWithDelegateTest, Cloning) {
transform.Scale(2, 1);
transform.Translate(10, 5);
gfx::Rect clip_rect(1, 1, 2, 2);
layer->SetTransform(transform);
layer->SetColor(SK_ColorRED);
layer->SetLayerInverted(true);
layer->AddCacheRenderSurfaceRequest();
layer->AddTrilinearFilteringRequest();
layer->SetClipRect(clip_rect);
layer->SetRoundedCornerRadius({1, 2, 4, 5});
layer->SetIsFastRoundedCorner(true);
......@@ -767,12 +770,14 @@ TEST_F(LayerWithDelegateTest, Cloning) {
// Cloning should not preserve trilinear_filtering flag.
EXPECT_NE(layer->cc_layer_for_testing()->trilinear_filtering(),
clone->cc_layer_for_testing()->trilinear_filtering());
EXPECT_EQ(clip_rect, clone->clip_rect());
EXPECT_EQ(layer->rounded_corner_radii(), clone->rounded_corner_radii());
EXPECT_EQ(layer->is_fast_rounded_corner(), clone->is_fast_rounded_corner());
layer->SetTransform(gfx::Transform());
layer->SetColor(SK_ColorGREEN);
layer->SetLayerInverted(false);
layer->SetClipRect(gfx::Rect(10, 10, 10, 10));
layer->SetIsFastRoundedCorner(false);
layer->SetRoundedCornerRadius({3, 6, 9, 12});
......@@ -781,6 +786,7 @@ TEST_F(LayerWithDelegateTest, Cloning) {
EXPECT_EQ(SK_ColorRED, clone->background_color());
EXPECT_EQ(SK_ColorRED, clone->GetTargetColor());
EXPECT_TRUE(clone->layer_inverted());
EXPECT_EQ(clip_rect, clone->clip_rect());
EXPECT_FALSE(layer->is_fast_rounded_corner());
EXPECT_TRUE(clone->is_fast_rounded_corner());
EXPECT_NE(layer->rounded_corner_radii(), clone->rounded_corner_radii());
......
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