Index: ui/compositor/layer.cc |
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc |
index e5569d0ff63b8f515ce73594201a4667c8ddcd20..1295599829a2251501cb04c52dc5f91500ad5a96 100644 |
--- a/ui/compositor/layer.cc |
+++ b/ui/compositor/layer.cc |
@@ -75,7 +75,8 @@ Layer::Layer() |
delegate_(NULL), |
owner_(NULL), |
cc_layer_(NULL), |
- device_scale_factor_(1.0f) { |
+ device_scale_factor_(1.0f), |
+ cached_cc_layer_opacity_(1.0f) { |
CreateCcLayer(); |
} |
@@ -99,7 +100,8 @@ Layer::Layer(LayerType type) |
delegate_(NULL), |
owner_(NULL), |
cc_layer_(NULL), |
- device_scale_factor_(1.0f) { |
+ device_scale_factor_(1.0f), |
+ cached_cc_layer_opacity_(1.0f) { |
CreateCcLayer(); |
} |
@@ -142,7 +144,7 @@ const Compositor* Layer::GetCompositor() const { |
} |
float Layer::opacity() const { |
- return cc_layer_->opacity(); |
+ return !visible_ ? cached_cc_layer_opacity_ : cc_layer_->opacity(); |
} |
void Layer::SetCompositor(Compositor* compositor, |
@@ -282,7 +284,10 @@ bool Layer::GetMasksToBounds() const { |
} |
void Layer::SetOpacity(float opacity) { |
- GetAnimator()->SetOpacity(opacity); |
+ if (visible_) |
+ GetAnimator()->SetOpacity(opacity); |
+ else |
+ cached_cc_layer_opacity_ = opacity; |
} |
float Layer::GetCombinedOpacity() const { |
@@ -523,7 +528,6 @@ void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) { |
cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); |
cc_layer_->SetForceRenderSurface(force_render_surface_); |
cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); |
- cc_layer_->SetHideLayerAndSubtree(!visible_); |
SetLayerFilters(); |
SetLayerBackgroundFilters(); |
@@ -912,7 +916,12 @@ void Layer::SetVisibilityFromAnimation(bool visible) { |
return; |
visible_ = visible; |
- cc_layer_->SetHideLayerAndSubtree(!visible_); |
+ if (visible) { |
+ cc_layer_->SetOpacity(cached_cc_layer_opacity_); |
+ } else { |
+ cached_cc_layer_opacity_ = cc_layer_->opacity(); |
+ cc_layer_->SetOpacity(0.f); |
+ } |
} |
void Layer::SetBrightnessFromAnimation(float brightness) { |