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

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, 5 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: cc/layers/layer.cc
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 82978daa03633a23d52b405414b4be0ead50b08c..cfb93d4e82e64005692331daa5fa0aa4b3b11f3e 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,9 @@ 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) +
+ (child->HasDelegatedContent() ? 1000 : 0));
SetNeedsFullTreeSync();
}
@@ -280,6 +285,9 @@ void Layer::RemoveChildOrDependent(Layer* child) {
continue;
child->SetParent(NULL);
+ AddDrawableDescendants(-child->NumDescendantsThatDrawContent() -
+ (child->DrawsContent() ? 1 : 0) -
+ (child->HasDelegatedContent() ? 1000 : 0));
danakj 2014/07/14 20:22:02 i don't think you need to do this here after you a
awoloszyn 2014/07/16 20:44:19 Done.
children_.erase(iter);
SetNeedsFullTreeSync();
return;
@@ -779,6 +787,7 @@ void Layer::SetIsDrawable(bool is_drawable) {
return;
is_drawable_ = is_drawable;
+ UpdateDrawsContent();
SetNeedsCommit();
}
@@ -900,6 +909,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_);
@@ -1006,7 +1016,36 @@ scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) {
}
bool Layer::DrawsContent() const {
- return is_drawable_;
+ return draws_content_;
+}
+
+bool Layer::HasDrawableContent() const {
+ return true;
+}
+
+void Layer::UpdateDrawsContent() {
+ bool draws_content = is_drawable_ && HasDrawableContent();
+ if (draws_content == draws_content_)
+ return;
+ // As per the comment that was originally in
+ // LayerTreeHost::PrecalculateMetaInformation:
+ // Layers with delegated content need to be treated as if they have as
danakj 2014/07/14 20:22:02 This isn't quite what we're doing yet. Right now y
awoloszyn 2014/07/16 20:44:19 I moved this into NumDescendantsThatDrawContent().
+ // 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.
+
+ if (parent()) {
+ if (draws_content) {
+ parent()->AddDrawableDescendants(1 + (HasDelegatedContent() ? 1000 : 0));
+ } else {
+ parent()->AddDrawableDescendants(-1 - (HasDelegatedContent() ? 1000 : 0));
+ }
+ }
+ draws_content_ = draws_content;
danakj 2014/07/14 20:22:02 SetNeedsCommit in here, please add this to the tes
awoloszyn 2014/07/16 20:44:20 Done.
+}
+
+int Layer::NumDescendantsThatDrawContent() const {
+ return num_descendants_that_draw_content_;
}
void Layer::SavePaintProperties() {
@@ -1189,7 +1228,22 @@ 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
danakj 2014/07/14 20:22:02 blank line above
awoloszyn 2014/07/16 20:44:20 Done.

Powered by Google App Engine
This is Rietveld 408576698