summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 19:40:14 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 19:40:14 +0000
commit87e00e1a6657c7516a2479b7230571d9c765264e (patch)
tree4bb9a841e1d0a3e3fb714cb7a55280ca83404075 /ui
parentc3d4a0d5d82206a7748b48433ad85e5bf7ac576e (diff)
downloadchromium_src-87e00e1a6657c7516a2479b7230571d9c765264e.zip
chromium_src-87e00e1a6657c7516a2479b7230571d9c765264e.tar.gz
chromium_src-87e00e1a6657c7516a2479b7230571d9c765264e.tar.bz2
Add a hide_layer_and_subtree() flag to cc::Layer
This flag does what it says. We can use this flag to simplify ui::Layer as it was recursively calling SetIsDrawable() instead, and now can just SetHideLayerAndSubtree() on a single layer. This flag is needed to allow readbacks of layers that are have hidden visibility (possibly due to an ancestor). Tests: LayerTest.CheckPropertyChangeCausesCorrectBehavior LayerImplTest.VerifyLayerChangesAreTrackedProperly LayerTreeHostCommonTest.SubtreeHidden_SingleLayer LayerTreeHostCommonTest.SubtreeHidden_SingleLayerImpl LayerTreeHostCommonTest.SubtreeHidden_TwoLayers LayerTreeHostCommonTest.SubtreeHidden_TwoLayersImpl R=enne, piman BUG=242572 Review URL: https://chromiumcodereview.appspot.com/16896017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207508 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/compositor/layer.cc28
-rw-r--r--ui/compositor/layer.h3
-rw-r--r--ui/compositor/layer_unittest.cc24
3 files changed, 19 insertions, 36 deletions
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index 09009ea..f729c9e 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -47,7 +47,6 @@ Layer::Layer()
compositor_(NULL),
parent_(NULL),
visible_(true),
- is_drawn_(true),
force_render_surface_(false),
fills_bounds_opaquely_(true),
layer_updated_externally_(false),
@@ -72,7 +71,6 @@ Layer::Layer(LayerType type)
compositor_(NULL),
parent_(NULL),
visible_(true),
- is_drawn_(true),
force_render_surface_(false),
fills_bounds_opaquely_(true),
layer_updated_externally_(false),
@@ -142,7 +140,6 @@ void Layer::Add(Layer* child) {
children_.push_back(child);
cc_layer_->AddChild(child->cc_layer_);
child->OnDeviceScaleFactorChanged(device_scale_factor_);
- child->UpdateIsDrawn();
if (GetCompositor())
child->SendPendingThreadedAnimations();
}
@@ -370,21 +367,10 @@ bool Layer::GetTargetVisibility() const {
}
bool Layer::IsDrawn() const {
- return is_drawn_;
-}
-
-void Layer::UpdateIsDrawn() {
- bool updated_is_drawn = visible_ && (!parent_ || parent_->IsDrawn());
-
- if (updated_is_drawn == is_drawn_)
- return;
-
- is_drawn_ = updated_is_drawn;
- cc_layer_->SetIsDrawable(is_drawn_ && type_ != LAYER_NOT_DRAWN);
-
- for (size_t i = 0; i < children_.size(); ++i) {
- children_[i]->UpdateIsDrawn();
- }
+ const Layer* layer = this;
+ while (layer && layer->visible_)
+ layer = layer->parent_;
+ return layer == NULL;
}
bool Layer::ShouldDraw() const {
@@ -478,7 +464,7 @@ void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
cc_layer_->SetAnchorPoint(gfx::PointF());
cc_layer_->SetContentsOpaque(fills_bounds_opaquely_);
cc_layer_->SetForceRenderSurface(force_render_surface_);
- cc_layer_->SetIsDrawable(IsDrawn());
+ cc_layer_->SetHideLayerAndSubtree(!visible_);
}
void Layer::SwitchCCLayerForTest() {
@@ -751,7 +737,7 @@ void Layer::SetBoundsImmediately(const gfx::Rect& bounds) {
if (was_move) {
// Don't schedule a draw if we're invisible. We'll schedule one
// automatically when we get visible.
- if (IsDrawn())
+ if (visible_)
ScheduleDraw();
} else {
// Always schedule a paint, even if we're invisible.
@@ -773,7 +759,7 @@ void Layer::SetVisibilityImmediately(bool visible) {
return;
visible_ = visible;
- UpdateIsDrawn();
+ cc_layer_->SetHideLayerAndSubtree(!visible_);
}
void Layer::SetBrightnessImmediately(float brightness) {
diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h
index 1159d0b..d536bf8 100644
--- a/ui/compositor/layer.h
+++ b/ui/compositor/layer.h
@@ -409,9 +409,6 @@ class COMPOSITOR_EXPORT Layer
// Visibility of this layer. See SetVisible/IsDrawn for more details.
bool visible_;
- // Computed based on the visibility of this layer and its ancestors.
- bool is_drawn_;
-
bool force_render_surface_;
bool fills_bounds_opaquely_;
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
index c326d4a..0be8a0a 100644
--- a/ui/compositor/layer_unittest.cc
+++ b/ui/compositor/layer_unittest.cc
@@ -646,9 +646,9 @@ TEST_F(LayerWithNullDelegateTest, Visibility) {
EXPECT_TRUE(l1->IsDrawn());
EXPECT_TRUE(l2->IsDrawn());
EXPECT_TRUE(l3->IsDrawn());
- EXPECT_TRUE(l1->cc_layer()->DrawsContent());
- EXPECT_TRUE(l2->cc_layer()->DrawsContent());
- EXPECT_TRUE(l3->cc_layer()->DrawsContent());
+ EXPECT_FALSE(l1->cc_layer()->hide_layer_and_subtree());
+ EXPECT_FALSE(l2->cc_layer()->hide_layer_and_subtree());
+ EXPECT_FALSE(l3->cc_layer()->hide_layer_and_subtree());
compositor()->SetRootLayer(l1.get());
@@ -658,25 +658,25 @@ TEST_F(LayerWithNullDelegateTest, Visibility) {
EXPECT_FALSE(l1->IsDrawn());
EXPECT_FALSE(l2->IsDrawn());
EXPECT_FALSE(l3->IsDrawn());
- EXPECT_FALSE(l1->cc_layer()->DrawsContent());
- EXPECT_FALSE(l2->cc_layer()->DrawsContent());
- EXPECT_FALSE(l3->cc_layer()->DrawsContent());
+ EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree());
+ EXPECT_FALSE(l2->cc_layer()->hide_layer_and_subtree());
+ EXPECT_FALSE(l3->cc_layer()->hide_layer_and_subtree());
l3->SetVisible(false);
EXPECT_FALSE(l1->IsDrawn());
EXPECT_FALSE(l2->IsDrawn());
EXPECT_FALSE(l3->IsDrawn());
- EXPECT_FALSE(l1->cc_layer()->DrawsContent());
- EXPECT_FALSE(l2->cc_layer()->DrawsContent());
- EXPECT_FALSE(l3->cc_layer()->DrawsContent());
+ EXPECT_TRUE(l1->cc_layer()->hide_layer_and_subtree());
+ EXPECT_FALSE(l2->cc_layer()->hide_layer_and_subtree());
+ EXPECT_TRUE(l3->cc_layer()->hide_layer_and_subtree());
l1->SetVisible(true);
EXPECT_TRUE(l1->IsDrawn());
EXPECT_TRUE(l2->IsDrawn());
EXPECT_FALSE(l3->IsDrawn());
- EXPECT_TRUE(l1->cc_layer()->DrawsContent());
- EXPECT_TRUE(l2->cc_layer()->DrawsContent());
- EXPECT_FALSE(l3->cc_layer()->DrawsContent());
+ EXPECT_FALSE(l1->cc_layer()->hide_layer_and_subtree());
+ EXPECT_FALSE(l2->cc_layer()->hide_layer_and_subtree());
+ EXPECT_TRUE(l3->cc_layer()->hide_layer_and_subtree());
}
// Checks that stacking-related methods behave as advertised.