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

Side by Side Diff: cc/layers/layer.cc

Issue 1944623002: CC Animation: Use ElementId to attach CC animation players. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erasedomids
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 } 116 }
117 117
118 void Layer::SetLayerTreeHost(LayerTreeHost* host) { 118 void Layer::SetLayerTreeHost(LayerTreeHost* host) {
119 if (layer_tree_host_ == host) 119 if (layer_tree_host_ == host)
120 return; 120 return;
121 121
122 if (layer_tree_host_) { 122 if (layer_tree_host_) {
123 layer_tree_host_->property_trees()->needs_rebuild = true; 123 layer_tree_host_->property_trees()->needs_rebuild = true;
124 layer_tree_host_->UnregisterLayer(this); 124 layer_tree_host_->UnregisterLayer(this);
125 if (element_id())
126 layer_tree_host_->UnregisterLayerForElementId(this);
125 } 127 }
126 if (host) { 128 if (host) {
127 host->property_trees()->needs_rebuild = true; 129 host->property_trees()->needs_rebuild = true;
128 host->RegisterLayer(this); 130 host->RegisterLayer(this);
131 if (element_id())
132 host->RegisterLayerForElementId(this);
129 } 133 }
130 134
131 layer_tree_host_ = host; 135 layer_tree_host_ = host;
132 InvalidatePropertyTreesIndices(); 136 InvalidatePropertyTreesIndices();
133 137
134 // When changing hosts, the layer needs to commit its properties to the impl 138 // When changing hosts, the layer needs to commit its properties to the impl
135 // side for the new host. 139 // side for the new host.
136 SetNeedsPushProperties(); 140 SetNeedsPushProperties();
137 141
138 for (size_t i = 0; i < children_.size(); ++i) 142 for (size_t i = 0; i < children_.size(); ++i)
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 if (!did_scroll_callback_.is_null()) 840 if (!did_scroll_callback_.is_null())
837 did_scroll_callback_.Run(); 841 did_scroll_callback_.Run();
838 // The callback could potentially change the layer structure: 842 // The callback could potentially change the layer structure:
839 // "this" may have been destroyed during the process. 843 // "this" may have been destroyed during the process.
840 } 844 }
841 845
842 void Layer::SetScrollClipLayerId(int clip_layer_id) { 846 void Layer::SetScrollClipLayerId(int clip_layer_id) {
843 DCHECK(IsPropertyChangeAllowed()); 847 DCHECK(IsPropertyChangeAllowed());
844 if (scroll_clip_layer_id_ == clip_layer_id) 848 if (scroll_clip_layer_id_ == clip_layer_id)
845 return; 849 return;
850
851 if (layer_tree_host_ && element_id())
852 layer_tree_host_->UnregisterLayerForElementId(this);
853
846 scroll_clip_layer_id_ = clip_layer_id; 854 scroll_clip_layer_id_ = clip_layer_id;
855
856 if (layer_tree_host_ && element_id())
857 layer_tree_host_->RegisterLayerForElementId(this);
858
847 SetNeedsCommit(); 859 SetNeedsCommit();
848 } 860 }
849 861
850 Layer* Layer::scroll_clip_layer() const { 862 Layer* Layer::scroll_clip_layer() const {
851 return layer_tree_host()->LayerById(scroll_clip_layer_id_); 863 return layer_tree_host()->LayerById(scroll_clip_layer_id_);
852 } 864 }
853 865
854 void Layer::SetUserScrollable(bool horizontal, bool vertical) { 866 void Layer::SetUserScrollable(bool horizontal, bool vertical) {
855 DCHECK(IsPropertyChangeAllowed()); 867 DCHECK(IsPropertyChangeAllowed());
856 if (user_scrollable_horizontal_ == horizontal && 868 if (user_scrollable_horizontal_ == horizontal &&
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { 1736 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) {
1725 benchmark->RunOnLayer(this); 1737 benchmark->RunOnLayer(this);
1726 } 1738 }
1727 1739
1728 void Layer::SetElementId(ElementId id) { 1740 void Layer::SetElementId(ElementId id) {
1729 DCHECK(IsPropertyChangeAllowed()); 1741 DCHECK(IsPropertyChangeAllowed());
1730 if (element_id_ == id) 1742 if (element_id_ == id)
1731 return; 1743 return;
1732 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 1744 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1733 "Layer::SetElementId", "id", id); 1745 "Layer::SetElementId", "id", id);
1746 if (layer_tree_host_ && element_id())
1747 layer_tree_host_->UnregisterLayerForElementId(this);
1748
1734 element_id_ = id; 1749 element_id_ = id;
1750
1751 if (layer_tree_host_ && element_id())
1752 layer_tree_host_->RegisterLayerForElementId(this);
1753
1735 SetNeedsCommit(); 1754 SetNeedsCommit();
1736 } 1755 }
1737 1756
1738 void Layer::SetMutableProperties(uint32_t properties) { 1757 void Layer::SetMutableProperties(uint32_t properties) {
1739 DCHECK(IsPropertyChangeAllowed()); 1758 DCHECK(IsPropertyChangeAllowed());
1740 if (mutable_properties_ == properties) 1759 if (mutable_properties_ == properties)
1741 return; 1760 return;
1742 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 1761 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1743 "Layer::SetMutableProperties", "properties", properties); 1762 "Layer::SetMutableProperties", "properties", properties);
1744 mutable_properties_ = properties; 1763 mutable_properties_ = properties;
(...skipping 15 matching lines...) Expand all
1760 ->data.num_copy_requests_in_subtree; 1779 ->data.num_copy_requests_in_subtree;
1761 } 1780 }
1762 1781
1763 gfx::Transform Layer::screen_space_transform() const { 1782 gfx::Transform Layer::screen_space_transform() const {
1764 DCHECK_NE(transform_tree_index_, -1); 1783 DCHECK_NE(transform_tree_index_, -1);
1765 return draw_property_utils::ScreenSpaceTransform( 1784 return draw_property_utils::ScreenSpaceTransform(
1766 this, layer_tree_host_->property_trees()->transform_tree); 1785 this, layer_tree_host_->property_trees()->transform_tree);
1767 } 1786 }
1768 1787
1769 } // namespace cc 1788 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698