OLD | NEW |
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 Loading... |
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 LayerImplList::const_iterator begin() const; | 151 LayerImplList::const_iterator begin() const; |
152 LayerImplList::const_iterator end() const; | 152 LayerImplList::const_iterator end() const; |
153 LayerImplList::reverse_iterator rbegin(); | 153 LayerImplList::reverse_iterator rbegin(); |
154 LayerImplList::reverse_iterator rend(); | 154 LayerImplList::reverse_iterator 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 Loading... |
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 BuildLayerListAndPropertyTreesForTesting(); | 262 void BuildLayerListAndPropertyTreesForTesting(); |
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 22 matching lines...) Expand all Loading... |
299 | 290 |
300 // These return the size of the root scrollable area and the size of | 291 // These return the size of the root scrollable area and the size of |
301 // the user-visible scrolling viewport, in CSS layout coordinates. | 292 // the user-visible scrolling viewport, in CSS layout coordinates. |
302 gfx::SizeF ScrollableSize() const; | 293 gfx::SizeF ScrollableSize() const; |
303 gfx::SizeF ScrollableViewportSize() const; | 294 gfx::SizeF ScrollableViewportSize() const; |
304 | 295 |
305 gfx::Rect RootScrollLayerDeviceViewportBounds() const; | 296 gfx::Rect RootScrollLayerDeviceViewportBounds() const; |
306 | 297 |
307 LayerImpl* LayerById(int id) const; | 298 LayerImpl* LayerById(int id) const; |
308 | 299 |
| 300 // TODO(vollick): this is deprecated. It is used by |
| 301 // animation/compositor-worker to look up layers to mutate, but in future, we |
| 302 // will update property trees. |
| 303 LayerImpl* LayerByElementId(ElementId element_id) const; |
| 304 void AddToElementMap(LayerImpl* layer); |
| 305 void RemoveFromElementMap(LayerImpl* layer); |
| 306 |
309 void AddLayerShouldPushProperties(LayerImpl* layer); | 307 void AddLayerShouldPushProperties(LayerImpl* layer); |
310 void RemoveLayerShouldPushProperties(LayerImpl* layer); | 308 void RemoveLayerShouldPushProperties(LayerImpl* layer); |
311 std::unordered_set<LayerImpl*>& LayersThatShouldPushProperties(); | 309 std::unordered_set<LayerImpl*>& LayersThatShouldPushProperties(); |
312 bool LayerNeedsPushPropertiesForTesting(LayerImpl* layer); | 310 bool LayerNeedsPushPropertiesForTesting(LayerImpl* layer); |
313 | 311 |
314 // These should be called by LayerImpl's ctor/dtor. | 312 // These should be called by LayerImpl's ctor/dtor. |
315 void RegisterLayer(LayerImpl* layer); | 313 void RegisterLayer(LayerImpl* layer); |
316 void UnregisterLayer(LayerImpl* layer); | 314 void UnregisterLayer(LayerImpl* layer); |
317 | 315 |
318 // These manage ownership of the LayerImpl. | 316 // These manage ownership of the LayerImpl. |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 float painted_device_scale_factor_; | 520 float painted_device_scale_factor_; |
523 | 521 |
524 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; | 522 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; |
525 | 523 |
526 std::unique_ptr<OwnedLayerImplList> layers_; | 524 std::unique_ptr<OwnedLayerImplList> layers_; |
527 LayerImplMap layer_id_map_; | 525 LayerImplMap layer_id_map_; |
528 LayerImplList layer_list_; | 526 LayerImplList layer_list_; |
529 // Set of layers that need to push properties. | 527 // Set of layers that need to push properties. |
530 std::unordered_set<LayerImpl*> layers_that_should_push_properties_; | 528 std::unordered_set<LayerImpl*> layers_that_should_push_properties_; |
531 | 529 |
532 std::unordered_map<uint64_t, ElementLayers> element_layers_map_; | 530 std::unordered_map<ElementId, LayerImpl*, ElementIdHash> element_layers_map_; |
533 | 531 |
534 std::unordered_map<int, float> opacity_animations_map_; | 532 std::unordered_map<int, float> opacity_animations_map_; |
535 std::unordered_map<int, gfx::Transform> transform_animations_map_; | 533 std::unordered_map<int, gfx::Transform> transform_animations_map_; |
536 | 534 |
537 // Maps from clip layer ids to scroll layer ids. Note that this only includes | 535 // Maps from clip layer ids to scroll layer ids. Note that this only includes |
538 // the subset of clip layers that act as scrolling containers. (This is | 536 // the subset of clip layers that act as scrolling containers. (This is |
539 // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.) | 537 // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.) |
540 std::unordered_map<int, int> clip_scroll_map_; | 538 std::unordered_map<int, int> clip_scroll_map_; |
541 | 539 |
542 // Maps scroll layer ids to scrollbar layer ids. For each scroll layer, there | 540 // 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 Loading... |
585 | 583 |
586 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; | 584 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; |
587 | 585 |
588 private: | 586 private: |
589 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); | 587 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); |
590 }; | 588 }; |
591 | 589 |
592 } // namespace cc | 590 } // namespace cc |
593 | 591 |
594 #endif // CC_TREES_LAYER_TREE_IMPL_H_ | 592 #endif // CC_TREES_LAYER_TREE_IMPL_H_ |
OLD | NEW |