Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: ui/compositor/layer.cc

Issue 16896017: Add a hide_layer_and_subtree() flag to cc::Layer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hide-subtree-flag: SetIsDrawable on the new cc_layer Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer.cc
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index 09009eae4bea691e2d975b00da9ec28c3a4b71df..1c0fc68c87b29b640a3059b22e3fd12f173d715c 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,8 @@ 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_->SetIsDrawable(type_ != LAYER_NOT_DRAWN);
+ cc_layer_->SetHideLayerAndSubtree(!visible_);
}
void Layer::SwitchCCLayerForTest() {
@@ -773,7 +760,7 @@ void Layer::SetVisibilityImmediately(bool visible) {
return;
visible_ = visible;
- UpdateIsDrawn();
+ cc_layer_->SetHideLayerAndSubtree(!visible_);
}
void Layer::SetBrightnessImmediately(float brightness) {
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/compositor/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698