| OLD | NEW |
| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 void Layer::SetLayerTreeHost(LayerTreeHost* host) { | 117 void Layer::SetLayerTreeHost(LayerTreeHost* host) { |
| 118 if (layer_tree_host_ == host) | 118 if (layer_tree_host_ == host) |
| 119 return; | 119 return; |
| 120 | 120 |
| 121 if (layer_tree_host_) { | 121 if (layer_tree_host_) { |
| 122 layer_tree_host_->property_trees()->needs_rebuild = true; | 122 layer_tree_host_->property_trees()->needs_rebuild = true; |
| 123 layer_tree_host_->UnregisterLayer(this); | 123 layer_tree_host_->UnregisterLayer(this); |
| 124 if (element_id()) |
| 125 layer_tree_host_->UnregisterLayerForElementId(this); |
| 124 } | 126 } |
| 125 if (host) { | 127 if (host) { |
| 126 host->property_trees()->needs_rebuild = true; | 128 host->property_trees()->needs_rebuild = true; |
| 127 host->RegisterLayer(this); | 129 host->RegisterLayer(this); |
| 130 if (element_id()) |
| 131 host->RegisterLayerForElementId(this); |
| 128 } | 132 } |
| 129 | 133 |
| 130 layer_tree_host_ = host; | 134 layer_tree_host_ = host; |
| 131 InvalidatePropertyTreesIndices(); | 135 InvalidatePropertyTreesIndices(); |
| 132 | 136 |
| 133 // When changing hosts, the layer needs to commit its properties to the impl | 137 // When changing hosts, the layer needs to commit its properties to the impl |
| 134 // side for the new host. | 138 // side for the new host. |
| 135 SetNeedsPushProperties(); | 139 SetNeedsPushProperties(); |
| 136 | 140 |
| 137 for (size_t i = 0; i < children_.size(); ++i) | 141 for (size_t i = 0; i < children_.size(); ++i) |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 if (!did_scroll_callback_.is_null()) | 836 if (!did_scroll_callback_.is_null()) |
| 833 did_scroll_callback_.Run(); | 837 did_scroll_callback_.Run(); |
| 834 // The callback could potentially change the layer structure: | 838 // The callback could potentially change the layer structure: |
| 835 // "this" may have been destroyed during the process. | 839 // "this" may have been destroyed during the process. |
| 836 } | 840 } |
| 837 | 841 |
| 838 void Layer::SetScrollClipLayerId(int clip_layer_id) { | 842 void Layer::SetScrollClipLayerId(int clip_layer_id) { |
| 839 DCHECK(IsPropertyChangeAllowed()); | 843 DCHECK(IsPropertyChangeAllowed()); |
| 840 if (scroll_clip_layer_id_ == clip_layer_id) | 844 if (scroll_clip_layer_id_ == clip_layer_id) |
| 841 return; | 845 return; |
| 846 |
| 847 if (layer_tree_host_ && element_id()) |
| 848 layer_tree_host_->UnregisterLayerForElementId(this); |
| 849 |
| 842 scroll_clip_layer_id_ = clip_layer_id; | 850 scroll_clip_layer_id_ = clip_layer_id; |
| 851 |
| 852 if (layer_tree_host_ && element_id()) |
| 853 layer_tree_host_->RegisterLayerForElementId(this); |
| 854 |
| 843 SetNeedsCommit(); | 855 SetNeedsCommit(); |
| 844 } | 856 } |
| 845 | 857 |
| 846 Layer* Layer::scroll_clip_layer() const { | 858 Layer* Layer::scroll_clip_layer() const { |
| 847 return layer_tree_host()->LayerById(scroll_clip_layer_id_); | 859 return layer_tree_host()->LayerById(scroll_clip_layer_id_); |
| 848 } | 860 } |
| 849 | 861 |
| 850 void Layer::SetUserScrollable(bool horizontal, bool vertical) { | 862 void Layer::SetUserScrollable(bool horizontal, bool vertical) { |
| 851 DCHECK(IsPropertyChangeAllowed()); | 863 DCHECK(IsPropertyChangeAllowed()); |
| 852 if (user_scrollable_horizontal_ == horizontal && | 864 if (user_scrollable_horizontal_ == horizontal && |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1728 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 1717 benchmark->RunOnLayer(this); | 1729 benchmark->RunOnLayer(this); |
| 1718 } | 1730 } |
| 1719 | 1731 |
| 1720 void Layer::SetElementId(ElementId id) { | 1732 void Layer::SetElementId(ElementId id) { |
| 1721 DCHECK(IsPropertyChangeAllowed()); | 1733 DCHECK(IsPropertyChangeAllowed()); |
| 1722 if (element_id_ == id) | 1734 if (element_id_ == id) |
| 1723 return; | 1735 return; |
| 1724 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1736 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1725 "Layer::SetElementId", "id", id); | 1737 "Layer::SetElementId", "id", id); |
| 1738 if (layer_tree_host_ && element_id()) |
| 1739 layer_tree_host_->UnregisterLayerForElementId(this); |
| 1740 |
| 1726 element_id_ = id; | 1741 element_id_ = id; |
| 1742 |
| 1743 if (layer_tree_host_ && element_id()) |
| 1744 layer_tree_host_->RegisterLayerForElementId(this); |
| 1745 |
| 1727 SetNeedsCommit(); | 1746 SetNeedsCommit(); |
| 1728 } | 1747 } |
| 1729 | 1748 |
| 1730 void Layer::SetMutableProperties(uint32_t properties) { | 1749 void Layer::SetMutableProperties(uint32_t properties) { |
| 1731 DCHECK(IsPropertyChangeAllowed()); | 1750 DCHECK(IsPropertyChangeAllowed()); |
| 1732 if (mutable_properties_ == properties) | 1751 if (mutable_properties_ == properties) |
| 1733 return; | 1752 return; |
| 1734 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1753 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1735 "Layer::SetMutableProperties", "properties", properties); | 1754 "Layer::SetMutableProperties", "properties", properties); |
| 1736 mutable_properties_ = properties; | 1755 mutable_properties_ = properties; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1752 ->data.num_copy_requests_in_subtree; | 1771 ->data.num_copy_requests_in_subtree; |
| 1753 } | 1772 } |
| 1754 | 1773 |
| 1755 gfx::Transform Layer::screen_space_transform() const { | 1774 gfx::Transform Layer::screen_space_transform() const { |
| 1756 DCHECK_NE(transform_tree_index_, -1); | 1775 DCHECK_NE(transform_tree_index_, -1); |
| 1757 return draw_property_utils::ScreenSpaceTransform( | 1776 return draw_property_utils::ScreenSpaceTransform( |
| 1758 this, layer_tree_host_->property_trees()->transform_tree); | 1777 this, layer_tree_host_->property_trees()->transform_tree); |
| 1759 } | 1778 } |
| 1760 | 1779 |
| 1761 } // namespace cc | 1780 } // namespace cc |
| OLD | NEW |