| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 116 } |
| 116 | 117 |
| 117 void Layer::SetLayerTreeHost(LayerTreeHost* host) { | 118 void Layer::SetLayerTreeHost(LayerTreeHost* host) { |
| 118 if (layer_tree_host_ == host) | 119 if (layer_tree_host_ == host) |
| 119 return; | 120 return; |
| 120 | 121 |
| 121 if (layer_tree_host_) { | 122 if (layer_tree_host_) { |
| 122 layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id()); | 123 layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id()); |
| 123 layer_tree_host_->property_trees()->needs_rebuild = true; | 124 layer_tree_host_->property_trees()->needs_rebuild = true; |
| 124 layer_tree_host_->UnregisterLayer(this); | 125 layer_tree_host_->UnregisterLayer(this); |
| 126 if (element_id_) { |
| 127 layer_tree_host_->animation_host()->UnregisterElement( |
| 128 element_id_, ElementListType::ACTIVE); |
| 129 layer_tree_host_->RemoveFromElementMap(this); |
| 130 } |
| 125 } | 131 } |
| 126 if (host) { | 132 if (host) { |
| 127 host->property_trees()->needs_rebuild = true; | 133 host->property_trees()->needs_rebuild = true; |
| 128 host->RegisterLayer(this); | 134 host->RegisterLayer(this); |
| 135 if (element_id_) { |
| 136 host->AddToElementMap(this); |
| 137 host->animation_host()->RegisterElement(element_id_, |
| 138 ElementListType::ACTIVE); |
| 139 } |
| 129 } | 140 } |
| 130 | 141 |
| 131 layer_tree_host_ = host; | 142 layer_tree_host_ = host; |
| 132 InvalidatePropertyTreesIndices(); | 143 InvalidatePropertyTreesIndices(); |
| 133 | 144 |
| 134 // When changing hosts, the layer needs to commit its properties to the impl | 145 // When changing hosts, the layer needs to commit its properties to the impl |
| 135 // side for the new host. | 146 // side for the new host. |
| 136 SetNeedsPushProperties(); | 147 SetNeedsPushProperties(); |
| 137 | 148 |
| 138 for (size_t i = 0; i < children_.size(); ++i) | 149 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; | 1796 num_descendants_that_draw_content_ += num; |
| 1786 SetNeedsCommit(); | 1797 SetNeedsCommit(); |
| 1787 if (parent()) | 1798 if (parent()) |
| 1788 parent()->AddDrawableDescendants(num); | 1799 parent()->AddDrawableDescendants(num); |
| 1789 } | 1800 } |
| 1790 | 1801 |
| 1791 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1802 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 1792 benchmark->RunOnLayer(this); | 1803 benchmark->RunOnLayer(this); |
| 1793 } | 1804 } |
| 1794 | 1805 |
| 1795 void Layer::SetElementId(uint64_t id) { | 1806 void Layer::SetElementId(ElementId id) { |
| 1796 DCHECK(IsPropertyChangeAllowed()); | 1807 DCHECK(IsPropertyChangeAllowed()); |
| 1797 if (element_id_ == id) | 1808 if (element_id_ == id) |
| 1798 return; | 1809 return; |
| 1799 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1810 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1800 "Layer::SetElementId", "id", id); | 1811 "Layer::SetElementId", "element", id.AsValue().release()); |
| 1812 if (element_id_ && layer_tree_host()) { |
| 1813 layer_tree_host()->animation_host()->UnregisterElement( |
| 1814 element_id_, ElementListType::ACTIVE); |
| 1815 layer_tree_host()->RemoveFromElementMap(this); |
| 1816 } |
| 1817 |
| 1801 element_id_ = id; | 1818 element_id_ = id; |
| 1819 |
| 1820 if (element_id_ && layer_tree_host()) { |
| 1821 layer_tree_host()->animation_host()->RegisterElement( |
| 1822 element_id_, ElementListType::ACTIVE); |
| 1823 layer_tree_host()->AddToElementMap(this); |
| 1824 } |
| 1825 |
| 1802 SetNeedsCommit(); | 1826 SetNeedsCommit(); |
| 1803 } | 1827 } |
| 1804 | 1828 |
| 1805 void Layer::SetMutableProperties(uint32_t properties) { | 1829 void Layer::SetMutableProperties(uint32_t properties) { |
| 1806 DCHECK(IsPropertyChangeAllowed()); | 1830 DCHECK(IsPropertyChangeAllowed()); |
| 1807 if (mutable_properties_ == properties) | 1831 if (mutable_properties_ == properties) |
| 1808 return; | 1832 return; |
| 1809 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1833 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1810 "Layer::SetMutableProperties", "properties", properties); | 1834 "Layer::SetMutableProperties", "properties", properties); |
| 1811 mutable_properties_ = properties; | 1835 mutable_properties_ = properties; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1827 ->data.num_copy_requests_in_subtree; | 1851 ->data.num_copy_requests_in_subtree; |
| 1828 } | 1852 } |
| 1829 | 1853 |
| 1830 gfx::Transform Layer::screen_space_transform() const { | 1854 gfx::Transform Layer::screen_space_transform() const { |
| 1831 DCHECK_NE(transform_tree_index_, -1); | 1855 DCHECK_NE(transform_tree_index_, -1); |
| 1832 return draw_property_utils::ScreenSpaceTransform( | 1856 return draw_property_utils::ScreenSpaceTransform( |
| 1833 this, layer_tree_host_->property_trees()->transform_tree); | 1857 this, layer_tree_host_->property_trees()->transform_tree); |
| 1834 } | 1858 } |
| 1835 | 1859 |
| 1836 } // namespace cc | 1860 } // namespace cc |
| OLD | NEW |