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> |
11 | 11 |
12 #include "base/atomic_sequence_num.h" | 12 #include "base/atomic_sequence_num.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 18 #include "cc/animation/animation_host.h" |
18 #include "cc/animation/mutable_properties.h" | 19 #include "cc/animation/mutable_properties.h" |
19 #include "cc/base/simple_enclosed_region.h" | 20 #include "cc/base/simple_enclosed_region.h" |
20 #include "cc/debug/frame_viewer_instrumentation.h" | 21 #include "cc/debug/frame_viewer_instrumentation.h" |
21 #include "cc/input/main_thread_scrolling_reason.h" | 22 #include "cc/input/main_thread_scrolling_reason.h" |
22 #include "cc/layers/layer_client.h" | 23 #include "cc/layers/layer_client.h" |
23 #include "cc/layers/layer_impl.h" | 24 #include "cc/layers/layer_impl.h" |
24 #include "cc/layers/layer_proto_converter.h" | 25 #include "cc/layers/layer_proto_converter.h" |
25 #include "cc/layers/scrollbar_layer_interface.h" | 26 #include "cc/layers/scrollbar_layer_interface.h" |
26 #include "cc/output/copy_output_request.h" | 27 #include "cc/output/copy_output_request.h" |
27 #include "cc/output/copy_output_result.h" | 28 #include "cc/output/copy_output_result.h" |
(...skipping 23 matching lines...) Expand all Loading... |
51 sorting_context_id_(0), | 52 sorting_context_id_(0), |
52 parent_(nullptr), | 53 parent_(nullptr), |
53 layer_tree_host_(nullptr), | 54 layer_tree_host_(nullptr), |
54 scroll_clip_layer_id_(INVALID_ID), | 55 scroll_clip_layer_id_(INVALID_ID), |
55 num_descendants_that_draw_content_(0), | 56 num_descendants_that_draw_content_(0), |
56 transform_tree_index_(-1), | 57 transform_tree_index_(-1), |
57 effect_tree_index_(-1), | 58 effect_tree_index_(-1), |
58 clip_tree_index_(-1), | 59 clip_tree_index_(-1), |
59 scroll_tree_index_(-1), | 60 scroll_tree_index_(-1), |
60 property_tree_sequence_number_(-1), | 61 property_tree_sequence_number_(-1), |
61 element_id_(0), | |
62 mutable_properties_(MutableProperty::kNone), | 62 mutable_properties_(MutableProperty::kNone), |
63 main_thread_scrolling_reasons_( | 63 main_thread_scrolling_reasons_( |
64 MainThreadScrollingReason::kNotScrollingOnMain), | 64 MainThreadScrollingReason::kNotScrollingOnMain), |
65 should_flatten_transform_from_property_tree_(false), | 65 should_flatten_transform_from_property_tree_(false), |
66 user_scrollable_horizontal_(true), | 66 user_scrollable_horizontal_(true), |
67 user_scrollable_vertical_(true), | 67 user_scrollable_vertical_(true), |
68 is_root_for_isolated_group_(false), | 68 is_root_for_isolated_group_(false), |
69 is_container_for_fixed_position_layers_(false), | 69 is_container_for_fixed_position_layers_(false), |
70 is_drawable_(false), | 70 is_drawable_(false), |
71 draws_content_(false), | 71 draws_content_(false), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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()->RemoveIdFromIdToIndexMaps(id()); | 122 layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id()); |
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_->animation_host()->UnregisterElement( |
| 127 element_id_, ElementListType::ACTIVE); |
| 128 layer_tree_host_->RemoveFromElementMap(this); |
| 129 } |
125 } | 130 } |
126 if (host) { | 131 if (host) { |
127 host->property_trees()->needs_rebuild = true; | 132 host->property_trees()->needs_rebuild = true; |
128 host->RegisterLayer(this); | 133 host->RegisterLayer(this); |
| 134 if (element_id_) { |
| 135 host->AddToElementMap(this); |
| 136 host->animation_host()->RegisterElement(element_id_, |
| 137 ElementListType::ACTIVE); |
| 138 } |
129 } | 139 } |
130 | 140 |
131 layer_tree_host_ = host; | 141 layer_tree_host_ = host; |
132 InvalidatePropertyTreesIndices(); | 142 InvalidatePropertyTreesIndices(); |
133 | 143 |
134 // When changing hosts, the layer needs to commit its properties to the impl | 144 // When changing hosts, the layer needs to commit its properties to the impl |
135 // side for the new host. | 145 // side for the new host. |
136 SetNeedsPushProperties(); | 146 SetNeedsPushProperties(); |
137 | 147 |
138 for (size_t i = 0; i < children_.size(); ++i) | 148 for (size_t i = 0; i < children_.size(); ++i) |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 num_descendants_that_draw_content_ += num; | 1795 num_descendants_that_draw_content_ += num; |
1786 SetNeedsCommit(); | 1796 SetNeedsCommit(); |
1787 if (parent()) | 1797 if (parent()) |
1788 parent()->AddDrawableDescendants(num); | 1798 parent()->AddDrawableDescendants(num); |
1789 } | 1799 } |
1790 | 1800 |
1791 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1801 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
1792 benchmark->RunOnLayer(this); | 1802 benchmark->RunOnLayer(this); |
1793 } | 1803 } |
1794 | 1804 |
1795 void Layer::SetElementId(uint64_t id) { | 1805 void Layer::SetElementId(ElementId id) { |
1796 DCHECK(IsPropertyChangeAllowed()); | 1806 DCHECK(IsPropertyChangeAllowed()); |
1797 if (element_id_ == id) | 1807 if (element_id_ == id) |
1798 return; | 1808 return; |
1799 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1809 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
1800 "Layer::SetElementId", "id", id); | 1810 "Layer::SetElementId", "element", id.AsValue().release()); |
| 1811 if (element_id_ && layer_tree_host()) { |
| 1812 layer_tree_host()->animation_host()->UnregisterElement( |
| 1813 element_id_, ElementListType::ACTIVE); |
| 1814 layer_tree_host()->RemoveFromElementMap(this); |
| 1815 } |
| 1816 |
1801 element_id_ = id; | 1817 element_id_ = id; |
| 1818 |
| 1819 if (element_id_ && layer_tree_host()) { |
| 1820 layer_tree_host()->animation_host()->RegisterElement( |
| 1821 element_id_, ElementListType::ACTIVE); |
| 1822 layer_tree_host()->AddToElementMap(this); |
| 1823 } |
| 1824 |
1802 SetNeedsCommit(); | 1825 SetNeedsCommit(); |
1803 } | 1826 } |
1804 | 1827 |
1805 void Layer::SetMutableProperties(uint32_t properties) { | 1828 void Layer::SetMutableProperties(uint32_t properties) { |
1806 DCHECK(IsPropertyChangeAllowed()); | 1829 DCHECK(IsPropertyChangeAllowed()); |
1807 if (mutable_properties_ == properties) | 1830 if (mutable_properties_ == properties) |
1808 return; | 1831 return; |
1809 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1832 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
1810 "Layer::SetMutableProperties", "properties", properties); | 1833 "Layer::SetMutableProperties", "properties", properties); |
1811 mutable_properties_ = properties; | 1834 mutable_properties_ = properties; |
(...skipping 15 matching lines...) Expand all Loading... |
1827 ->data.num_copy_requests_in_subtree; | 1850 ->data.num_copy_requests_in_subtree; |
1828 } | 1851 } |
1829 | 1852 |
1830 gfx::Transform Layer::screen_space_transform() const { | 1853 gfx::Transform Layer::screen_space_transform() const { |
1831 DCHECK_NE(transform_tree_index_, -1); | 1854 DCHECK_NE(transform_tree_index_, -1); |
1832 return draw_property_utils::ScreenSpaceTransform( | 1855 return draw_property_utils::ScreenSpaceTransform( |
1833 this, layer_tree_host_->property_trees()->transform_tree); | 1856 this, layer_tree_host_->property_trees()->transform_tree); |
1834 } | 1857 } |
1835 | 1858 |
1836 } // namespace cc | 1859 } // namespace cc |
OLD | NEW |