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

Unified Diff: ui/compositor/layer.cc

Issue 1588093004: Compute if a layer is drawn without LayerTree hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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) {

Powered by Google App Engine
This is Rietveld 408576698