Commit e2714332 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Allow mirrored layers to disable visibility sync with their source layers

This allows us prevent updating the visibility of the mirrored backdrop
in the desk preview view based on changes in the source backdrop's layer
visibility.

BUG=978917

Change-Id: I98c80a7c697f61fff37a06aab377f157099ded17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1693186Reviewed-by: default avatardanakj <danakj@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675862}
parent 92790902
......@@ -85,6 +85,7 @@ void MirrorLayerTree(ui::Layer* source_layer,
mirror->SetVisible(true);
mirror->SetOpacity(1);
mirror->set_sync_bounds_with_source(true);
mirror->set_sync_visibility_with_source(false);
if (layer_data.should_reset_transform)
mirror->SetTransform(gfx::Transform());
......
......@@ -1398,9 +1398,12 @@ void Layer::SetOpacityFromAnimation(float opacity,
void Layer::SetVisibilityFromAnimation(bool visible,
PropertyChangeReason reason) {
// Sync changes with the mirror layers.
for (const auto& mirror : mirrors_)
mirror->dest()->SetVisible(visible);
// Sync changes with the mirror layers only if they want so.
for (const auto& mirror : mirrors_) {
Layer* mirror_dest = mirror->dest();
if (mirror_dest->sync_visibility_with_source_)
mirror_dest->SetVisible(visible);
}
if (visible_ == visible)
return;
......
......@@ -92,6 +92,13 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate,
sync_bounds_with_source_ = sync_bounds;
}
// This method is relevant only if this layer is a mirror destination layer.
// Sets whether this mirror layer's visibility is synchronized with the source
// layer's visibility.
void set_sync_visibility_with_source(bool sync_visibility) {
sync_visibility_with_source_ = sync_visibility;
}
// Sets up this layer to mirror output of |subtree_reflected_layer|, including
// its entire hierarchy. |this| should be of type LAYER_SOLID_COLOR and should
// not be a descendant of |subtree_reflected_layer|. This is achieved by using
......@@ -613,6 +620,10 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate,
// the source layer are propagated to this mirror layer.
bool sync_bounds_with_source_ = false;
// If true, and this is a destination mirror layer, changes in the source
// layer's visibility are propagated to this mirror layer.
bool sync_visibility_with_source_ = true;
gfx::Rect bounds_;
std::unique_ptr<SubpixelPositionOffsetCache> subpixel_position_offset_;
......
......@@ -1279,6 +1279,15 @@ TEST_F(LayerWithNullDelegateTest, MirroringVisibility) {
EXPECT_FALSE(l1->cc_layer_for_testing()->hide_layer_and_subtree());
EXPECT_FALSE(l2->cc_layer_for_testing()->hide_layer_and_subtree());
EXPECT_FALSE(l2_mirror->cc_layer_for_testing()->hide_layer_and_subtree());
// Disable visibility sync on the mirrored layer. Changes in |l2|'s visibility
// shouldn't affect the visibility of |l2_mirror|.
l2_mirror->set_sync_visibility_with_source(false);
l2->SetVisible(false);
EXPECT_FALSE(l2->IsDrawn());
EXPECT_TRUE(l2->cc_layer_for_testing()->hide_layer_and_subtree());
EXPECT_TRUE(l2_mirror->IsDrawn());
EXPECT_FALSE(l2_mirror->cc_layer_for_testing()->hide_layer_and_subtree());
}
TEST_F(LayerWithDelegateTest, RoundedCorner) {
......
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