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

Unified Diff: ui/compositor/layer.cc

Issue 12093067: Handle ui::Layer's visibility using cc::Layer's m_isDrawable flag (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use the existing m_isDrawable flag Created 7 years, 11 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 119a1cfa868390103209691c432da434f32c665f..cdcf3392e754823924a17f8d11c3c73627063875 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -134,6 +134,7 @@ void Layer::Add(Layer* child) {
children_.push_back(child);
cc_layer_->addChild(child->cc_layer_);
child->OnDeviceScaleFactorChanged(device_scale_factor_);
+ child->OnParentIsDrawnChanged(IsDrawn(), true);
piman 2013/01/31 23:21:59 If we are going to propagate the information down,
ajuma 2013/02/01 16:04:06 Done.
}
void Layer::Remove(Layer* child) {
@@ -373,6 +374,19 @@ bool Layer::IsDrawn() const {
return layer == NULL;
}
+void Layer::OnParentIsDrawnChanged(bool parent_is_drawn, bool force_update) {
+ if (!visible_ && !force_update)
+ return;
+
+ cc_layer_->setIsDrawable(
+ visible_ && parent_is_drawn && type_ != LAYER_NOT_DRAWN);
+
+ for (size_t i = 0; i < children_.size(); ++i) {
+ children_[i]->OnParentIsDrawnChanged(visible_ && parent_is_drawn,
+ force_update);
+ }
+}
+
bool Layer::ShouldDraw() const {
return type_ != LAYER_NOT_DRAWN && GetCombinedOpacity() > 0.0f;
}
@@ -438,9 +452,9 @@ void Layer::SetExternalTexture(Texture* texture) {
}
cc_layer_->setAnchorPoint(gfx::PointF());
cc_layer_->setContentsOpaque(fills_bounds_opaquely_);
- cc_layer_->setOpacity(visible_ ? opacity_ : 0.f);
+ cc_layer_->setOpacity(opacity_);
cc_layer_->setForceRenderSurface(force_render_surface_);
- cc_layer_->setIsDrawable(true);
+ cc_layer_->setIsDrawable(IsDrawn());
RecomputeTransform();
}
RecomputeDrawsContentAndUVRect();
@@ -645,8 +659,7 @@ void Layer::SetOpacityImmediately(float opacity) {
bool schedule_draw = (opacity != opacity_ && IsDrawn());
opacity_ = opacity;
- if (visible_)
- cc_layer_->setOpacity(opacity);
+ cc_layer_->setOpacity(opacity);
if (schedule_draw)
ScheduleDraw();
}
@@ -656,8 +669,13 @@ void Layer::SetVisibilityImmediately(bool visible) {
return;
visible_ = visible;
- // TODO(piman): Expose a visibility flag on WebLayer.
- cc_layer_->setOpacity(visible_ ? opacity_ : 0.f);
+
+ if (parent_ && !parent_->IsDrawn())
+ return;
+
+ cc_layer_->setIsDrawable(visible_ && type_ != LAYER_NOT_DRAWN);
+ for (size_t i = 0; i < children_.size(); ++i)
+ children_[i]->OnParentIsDrawnChanged(visible_, false);
piman 2013/01/31 23:21:59 Can we share that code with OnParentIsDrawnChanged
ajuma 2013/02/01 16:04:06 Done. The logic is now specified only in UpdateIsD
}
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