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 LayerListIterator<LayerImpl> begin() const; | 151 LayerListIterator<LayerImpl> begin() const; |
152 LayerListIterator<LayerImpl> end() const; | 152 LayerListIterator<LayerImpl> end() const; |
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 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 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 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 float device_scale_factor_; | 513 float device_scale_factor_; |
516 float painted_device_scale_factor_; | 514 float painted_device_scale_factor_; |
517 | 515 |
518 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; | 516 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; |
519 | 517 |
520 std::unique_ptr<OwnedLayerImplList> layers_; | 518 std::unique_ptr<OwnedLayerImplList> layers_; |
521 LayerImplMap layer_id_map_; | 519 LayerImplMap layer_id_map_; |
522 // Set of layers that need to push properties. | 520 // Set of layers that need to push properties. |
523 std::unordered_set<LayerImpl*> layers_that_should_push_properties_; | 521 std::unordered_set<LayerImpl*> layers_that_should_push_properties_; |
524 | 522 |
525 std::unordered_map<uint64_t, ElementLayers> element_layers_map_; | 523 std::unordered_map<ElementId, LayerImpl*, ElementIdHash> element_layers_map_; |
526 | 524 |
527 std::unordered_map<int, float> opacity_animations_map_; | 525 std::unordered_map<int, float> opacity_animations_map_; |
528 std::unordered_map<int, gfx::Transform> transform_animations_map_; | 526 std::unordered_map<int, gfx::Transform> transform_animations_map_; |
529 | 527 |
530 // Maps from clip layer ids to scroll layer ids. Note that this only includes | 528 // Maps from clip layer ids to scroll layer ids. Note that this only includes |
531 // the subset of clip layers that act as scrolling containers. (This is | 529 // the subset of clip layers that act as scrolling containers. (This is |
532 // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.) | 530 // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.) |
533 std::unordered_map<int, int> clip_scroll_map_; | 531 std::unordered_map<int, int> clip_scroll_map_; |
534 | 532 |
535 // Maps scroll layer ids to scrollbar layer ids. For each scroll layer, there | 533 // 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... |
578 | 576 |
579 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; | 577 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; |
580 | 578 |
581 private: | 579 private: |
582 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); | 580 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); |
583 }; | 581 }; |
584 | 582 |
585 } // namespace cc | 583 } // namespace cc |
586 | 584 |
587 #endif // CC_TREES_LAYER_TREE_IMPL_H_ | 585 #endif // CC_TREES_LAYER_TREE_IMPL_H_ |
OLD | NEW |