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

Side by Side Diff: cc/trees/layer_tree_impl.h

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: respond to reviewer feedback. Created 4 years, 6 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #ifndef CC_TREES_LAYER_TREE_IMPL_H_ 5 #ifndef CC_TREES_LAYER_TREE_IMPL_H_
6 #define CC_TREES_LAYER_TREE_IMPL_H_ 6 #define CC_TREES_LAYER_TREE_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 void PushPropertiesTo(LayerTreeImpl* tree_impl); 147 void PushPropertiesTo(LayerTreeImpl* tree_impl);
148 148
149 void MoveChangeTrackingToLayers(); 149 void MoveChangeTrackingToLayers();
150 150
151 LayerListIterator<LayerImpl> begin(); 151 LayerListIterator<LayerImpl> begin();
152 LayerListIterator<LayerImpl> end(); 152 LayerListIterator<LayerImpl> end();
153 LayerListReverseIterator<LayerImpl> rbegin(); 153 LayerListReverseIterator<LayerImpl> rbegin();
154 LayerListReverseIterator<LayerImpl> rend(); 154 LayerListReverseIterator<LayerImpl> rend();
155 155
156 struct CC_EXPORT ElementLayers {
157 // Transform and opacity mutations apply to this layer.
158 LayerImpl* main = nullptr;
159 // Scroll mutations apply to this layer.
160 LayerImpl* scroll = nullptr;
161 };
162
163 void AddToElementMap(LayerImpl* layer);
164 void RemoveFromElementMap(LayerImpl* layer);
165
166 void AddToOpacityAnimationsMap(int id, float opacity); 156 void AddToOpacityAnimationsMap(int id, float opacity);
167 void AddToTransformAnimationsMap(int id, gfx::Transform transform); 157 void AddToTransformAnimationsMap(int id, gfx::Transform transform);
168 158
169 ElementLayers GetMutableLayers(uint64_t element_id);
170 int source_frame_number() const { return source_frame_number_; } 159 int source_frame_number() const { return source_frame_number_; }
171 void set_source_frame_number(int frame_number) { 160 void set_source_frame_number(int frame_number) {
172 source_frame_number_ = frame_number; 161 source_frame_number_ = frame_number;
173 } 162 }
174 163
175 bool is_first_frame_after_commit() const { 164 bool is_first_frame_after_commit() const {
176 return source_frame_number_ != is_first_frame_after_commit_tracker_; 165 return source_frame_number_ != is_first_frame_after_commit_tracker_;
177 } 166 }
178 167
179 void set_is_first_frame_after_commit(bool is_first_frame_after_commit) { 168 void set_is_first_frame_after_commit(bool is_first_frame_after_commit) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return elastic_overscroll_.get(); 246 return elastic_overscroll_.get();
258 } 247 }
259 248
260 SyncedTopControls* top_controls_shown_ratio() { 249 SyncedTopControls* top_controls_shown_ratio() {
261 return top_controls_shown_ratio_.get(); 250 return top_controls_shown_ratio_.get();
262 } 251 }
263 const SyncedTopControls* top_controls_shown_ratio() const { 252 const SyncedTopControls* top_controls_shown_ratio() const {
264 return top_controls_shown_ratio_.get(); 253 return top_controls_shown_ratio_.get();
265 } 254 }
266 255
256 void SetElementIdsForTesting();
257
267 // Updates draw properties and render surface layer list, as well as tile 258 // Updates draw properties and render surface layer list, as well as tile
268 // priorities. Returns false if it was unable to update. Updating lcd 259 // priorities. Returns false if it was unable to update. Updating lcd
269 // text may cause invalidations, so should only be done after a commit. 260 // text may cause invalidations, so should only be done after a commit.
270 bool UpdateDrawProperties(bool update_lcd_text); 261 bool UpdateDrawProperties(bool update_lcd_text);
271 void BuildPropertyTreesForTesting(); 262 void BuildPropertyTreesForTesting();
272 263
273 void set_needs_update_draw_properties() { 264 void set_needs_update_draw_properties() {
274 needs_update_draw_properties_ = true; 265 needs_update_draw_properties_ = true;
275 } 266 }
276 bool needs_update_draw_properties() const { 267 bool needs_update_draw_properties() const {
(...skipping 17 matching lines...) Expand all
294 285
295 // These return the size of the root scrollable area and the size of 286 // These return the size of the root scrollable area and the size of
296 // the user-visible scrolling viewport, in CSS layout coordinates. 287 // the user-visible scrolling viewport, in CSS layout coordinates.
297 gfx::SizeF ScrollableSize() const; 288 gfx::SizeF ScrollableSize() const;
298 gfx::SizeF ScrollableViewportSize() const; 289 gfx::SizeF ScrollableViewportSize() const;
299 290
300 gfx::Rect RootScrollLayerDeviceViewportBounds() const; 291 gfx::Rect RootScrollLayerDeviceViewportBounds() const;
301 292
302 LayerImpl* LayerById(int id) const; 293 LayerImpl* LayerById(int id) const;
303 294
295 // TODO(vollick): this is deprecated. It is used by
296 // animation/compositor-worker to look up layers to mutate, but in future, we
297 // will update property trees.
298 LayerImpl* LayerByElementId(ElementId element_id) const;
299 void AddToElementMap(LayerImpl* layer);
300 void RemoveFromElementMap(LayerImpl* layer);
301
304 void AddLayerShouldPushProperties(LayerImpl* layer); 302 void AddLayerShouldPushProperties(LayerImpl* layer);
305 void RemoveLayerShouldPushProperties(LayerImpl* layer); 303 void RemoveLayerShouldPushProperties(LayerImpl* layer);
306 std::unordered_set<LayerImpl*>& LayersThatShouldPushProperties(); 304 std::unordered_set<LayerImpl*>& LayersThatShouldPushProperties();
307 bool LayerNeedsPushPropertiesForTesting(LayerImpl* layer); 305 bool LayerNeedsPushPropertiesForTesting(LayerImpl* layer);
308 306
309 // These should be called by LayerImpl's ctor/dtor. 307 // These should be called by LayerImpl's ctor/dtor.
310 void RegisterLayer(LayerImpl* layer); 308 void RegisterLayer(LayerImpl* layer);
311 void UnregisterLayer(LayerImpl* layer); 309 void UnregisterLayer(LayerImpl* layer);
312 310
313 // These manage ownership of the LayerImpl. 311 // These manage ownership of the LayerImpl.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 float device_scale_factor_; 508 float device_scale_factor_;
511 float painted_device_scale_factor_; 509 float painted_device_scale_factor_;
512 510
513 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; 511 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_;
514 512
515 std::unique_ptr<OwnedLayerImplList> layers_; 513 std::unique_ptr<OwnedLayerImplList> layers_;
516 LayerImplMap layer_id_map_; 514 LayerImplMap layer_id_map_;
517 // Set of layers that need to push properties. 515 // Set of layers that need to push properties.
518 std::unordered_set<LayerImpl*> layers_that_should_push_properties_; 516 std::unordered_set<LayerImpl*> layers_that_should_push_properties_;
519 517
520 std::unordered_map<uint64_t, ElementLayers> element_layers_map_; 518 std::unordered_map<ElementId, LayerImpl*, ElementIdHash> element_layers_map_;
521 519
522 std::unordered_map<int, float> opacity_animations_map_; 520 std::unordered_map<int, float> opacity_animations_map_;
523 std::unordered_map<int, gfx::Transform> transform_animations_map_; 521 std::unordered_map<int, gfx::Transform> transform_animations_map_;
524 522
525 // Maps from clip layer ids to scroll layer ids. Note that this only includes 523 // Maps from clip layer ids to scroll layer ids. Note that this only includes
526 // the subset of clip layers that act as scrolling containers. (This is 524 // the subset of clip layers that act as scrolling containers. (This is
527 // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.) 525 // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.)
528 std::unordered_map<int, int> clip_scroll_map_; 526 std::unordered_map<int, int> clip_scroll_map_;
529 527
530 // Maps scroll layer ids to scrollbar layer ids. For each scroll layer, there 528 // Maps scroll layer ids to scrollbar layer ids. For each scroll layer, there
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 571
574 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; 572 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_;
575 573
576 private: 574 private:
577 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); 575 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl);
578 }; 576 };
579 577
580 } // namespace cc 578 } // namespace cc
581 579
582 #endif // CC_TREES_LAYER_TREE_IMPL_H_ 580 #endif // CC_TREES_LAYER_TREE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698