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

Unified Diff: cc/layers/layer.cc

Issue 373113003: Keeping track of descendants that draw content instead of recalcualting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/layer.cc
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 8722aa695a7390a5d471d3dd7ea9ac999b3a5b79..11b80365022a810dce6206e1568ae068f1b85832 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -47,6 +47,7 @@ Layer::Layer()
parent_(NULL),
layer_tree_host_(NULL),
scroll_clip_layer_id_(INVALID_ID),
+ num_descendants_that_draw_content_(0),
should_scroll_on_main_thread_(false),
have_wheel_event_handlers_(false),
have_scroll_event_handlers_(false),
@@ -55,6 +56,7 @@ Layer::Layer()
is_root_for_isolated_group_(false),
is_container_for_fixed_position_layers_(false),
is_drawable_(false),
+ draws_content_(false),
hide_layer_and_subtree_(false),
masks_to_bounds_(false),
contents_opaque_(false),
@@ -250,6 +252,8 @@ void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) {
index = std::min(index, children_.size());
children_.insert(children_.begin() + index, child);
+ AddDrawableDescendants(child->NumDescendantsThatDrawContent() +
+ (child->DrawsContent() ? 1 : 0));
SetNeedsFullTreeSync();
}
@@ -280,6 +284,8 @@ void Layer::RemoveChildOrDependent(Layer* child) {
continue;
child->SetParent(NULL);
+ AddDrawableDescendants(-child->NumDescendantsThatDrawContent() -
+ (child->DrawsContent() ? 1 : 0));
children_.erase(iter);
SetNeedsFullTreeSync();
return;
@@ -779,7 +785,7 @@ void Layer::SetIsDrawable(bool is_drawable) {
return;
is_drawable_ = is_drawable;
- SetNeedsCommit();
+ UpdateDrawsContent(HasDrawableContent());
}
void Layer::SetHideLayerAndSubtree(bool hide) {
@@ -902,6 +908,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) {
layer->SetTransformAndInvertibility(transform_, transform_is_invertible_);
DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly()));
layer->Set3dSortingContextId(sorting_context_id_);
+ layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_);
layer->SetScrollClipLayer(scroll_clip_layer_id_);
layer->set_user_scrollable_horizontal(user_scrollable_horizontal_);
@@ -1008,9 +1015,38 @@ scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
}
bool Layer::DrawsContent() const {
+ return draws_content_;
+}
+
+bool Layer::HasDrawableContent() const {
return is_drawable_;
}
+void Layer::UpdateDrawsContent(bool has_drawable_content) {
+ bool draws_content = has_drawable_content;
+ DCHECK(is_drawable_ || !has_drawable_content);
+ if (draws_content == draws_content_)
+ return;
+
+ if (HasDelegatedContent()) {
+ // Layers with delegated content need to be treated as if they have as
+ // many children as the number of layers they own delegated quads for.
+ // Since we don't know this number right now, we choose one that acts like
+ // infinity for our purposes.
+ AddDrawableDescendants(draws_content ? 1000 : -1000);
+ }
+
+ if (parent())
+ parent()->AddDrawableDescendants(draws_content ? 1 : -1);
+
+ draws_content_ = draws_content;
+ SetNeedsCommit();
+}
+
+int Layer::NumDescendantsThatDrawContent() const {
+ return num_descendants_that_draw_content_;
+}
+
void Layer::SavePaintProperties() {
DCHECK(layer_tree_host_);
@@ -1191,7 +1227,23 @@ void Layer::RemoveFromClipTree() {
clip_parent_ = NULL;
}
+void Layer::AddDrawableDescendants(int num) {
+ DCHECK_GE(num_descendants_that_draw_content_, 0);
+ DCHECK_GE(num_descendants_that_draw_content_ + num, 0);
+ if (num == 0)
+ return;
+ num_descendants_that_draw_content_ += num;
+ SetNeedsCommit();
+ if (parent())
+ parent()->AddDrawableDescendants(num);
+}
+
void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) {
benchmark->RunOnLayer(this);
}
+
+bool Layer::HasDelegatedContent() const {
+ return false;
+}
+
} // namespace cc
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698