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

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

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
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
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()->RemoveIdFromIdToIndexMaps(id()); 123 layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id());
124 layer_tree_host_->property_trees()->needs_rebuild = true; 124 layer_tree_host_->property_trees()->needs_rebuild = true;
125 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 }
126 } 131 }
127 if (host) { 132 if (host) {
128 host->property_trees()->needs_rebuild = true; 133 host->property_trees()->needs_rebuild = true;
129 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 }
130 } 140 }
131 141
132 layer_tree_host_ = host; 142 layer_tree_host_ = host;
133 InvalidatePropertyTreesIndices(); 143 InvalidatePropertyTreesIndices();
134 144
135 // 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
136 // side for the new host. 146 // side for the new host.
137 SetNeedsPushProperties(); 147 SetNeedsPushProperties();
138 148
139 for (size_t i = 0; i < children_.size(); ++i) 149 for (size_t i = 0; i < children_.size(); ++i)
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 num_descendants_that_draw_content_ += num; 1807 num_descendants_that_draw_content_ += num;
1798 SetNeedsCommit(); 1808 SetNeedsCommit();
1799 if (parent()) 1809 if (parent())
1800 parent()->AddDrawableDescendants(num); 1810 parent()->AddDrawableDescendants(num);
1801 } 1811 }
1802 1812
1803 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { 1813 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) {
1804 benchmark->RunOnLayer(this); 1814 benchmark->RunOnLayer(this);
1805 } 1815 }
1806 1816
1807 void Layer::SetElementId(uint64_t id) { 1817 void Layer::SetElementId(ElementId id) {
1808 DCHECK(IsPropertyChangeAllowed()); 1818 DCHECK(IsPropertyChangeAllowed());
1809 if (element_id_ == id) 1819 if (element_id_ == id)
1810 return; 1820 return;
1811 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 1821 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1812 "Layer::SetElementId", "id", id); 1822 "Layer::SetElementId", "element", id.AsValue().release());
1823 if (element_id_ && layer_tree_host()) {
1824 layer_tree_host()->animation_host()->UnregisterElement(
1825 element_id_, ElementListType::ACTIVE);
1826 layer_tree_host()->RemoveFromElementMap(this);
1827 }
1828
1813 element_id_ = id; 1829 element_id_ = id;
1830
1831 if (element_id_ && layer_tree_host()) {
1832 layer_tree_host()->animation_host()->RegisterElement(
1833 element_id_, ElementListType::ACTIVE);
1834 layer_tree_host()->AddToElementMap(this);
1835 }
1836
1814 SetNeedsCommit(); 1837 SetNeedsCommit();
1815 } 1838 }
1816 1839
1817 void Layer::SetMutableProperties(uint32_t properties) { 1840 void Layer::SetMutableProperties(uint32_t properties) {
1818 DCHECK(IsPropertyChangeAllowed()); 1841 DCHECK(IsPropertyChangeAllowed());
1819 if (mutable_properties_ == properties) 1842 if (mutable_properties_ == properties)
1820 return; 1843 return;
1821 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 1844 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
1822 "Layer::SetMutableProperties", "properties", properties); 1845 "Layer::SetMutableProperties", "properties", properties);
1823 mutable_properties_ = properties; 1846 mutable_properties_ = properties;
(...skipping 15 matching lines...) Expand all
1839 ->data.num_copy_requests_in_subtree; 1862 ->data.num_copy_requests_in_subtree;
1840 } 1863 }
1841 1864
1842 gfx::Transform Layer::screen_space_transform() const { 1865 gfx::Transform Layer::screen_space_transform() const {
1843 DCHECK_NE(transform_tree_index_, -1); 1866 DCHECK_NE(transform_tree_index_, -1);
1844 return draw_property_utils::ScreenSpaceTransform( 1867 return draw_property_utils::ScreenSpaceTransform(
1845 this, layer_tree_host_->property_trees()->transform_tree); 1868 this, layer_tree_host_->property_trees()->transform_tree);
1846 } 1869 }
1847 1870
1848 } // namespace cc 1871 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698