Chromium Code Reviews| Index: cc/layers/layer.cc |
| diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc |
| index 82978daa03633a23d52b405414b4be0ead50b08c..20a117e4aaf9e82ac4243bcecfe4c584d0e26412 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) { |
| @@ -900,6 +906,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,9 +1013,43 @@ 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; |
|
danakj
2014/08/06 14:57:07
can you DCHECK(is_drawable_ || !has_drawable_conte
awoloszyn
2014/08/08 15:53:20
I will DCHECK(HasDrawableContent() || !has_drawabl
danakj
2014/08/08 16:04:04
Oh I see. Can we just make HUD layer's constructor
|
| + if (draws_content == draws_content_) |
| + return; |
| + |
| + if (HasDelegatedContent()) { |
| + // As per the comment that was originally in |
|
danakj
2014/08/06 14:57:07
I think you can drop the mention of Precalculate,
awoloszyn
2014/08/08 15:53:20
Done.
|
| + // LayerTreeHost::PrecalculateMetaInformation: |
| + // 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()) { |
| + if (draws_content) { |
| + parent()->AddDrawableDescendants(1); |
|
danakj
2014/08/06 14:57:07
draws_content ? 1 : -1 like you did above for dele
awoloszyn
2014/08/08 15:53:20
Done.
|
| + } else { |
| + parent()->AddDrawableDescendants(-1); |
| + } |
| + } |
| + draws_content_ = draws_content; |
| + SetNeedsCommit(); |
| +} |
| + |
| +int Layer::NumDescendantsThatDrawContent() const { |
| + return num_descendants_that_draw_content_; |
| +} |
| + |
| void Layer::SavePaintProperties() { |
| DCHECK(layer_tree_host_); |
| @@ -1189,7 +1230,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 |