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 |
156 void AddToOpacityAnimationsMap(int id, float opacity); | 166 void AddToOpacityAnimationsMap(int id, float opacity); |
157 void AddToTransformAnimationsMap(int id, gfx::Transform transform); | 167 void AddToTransformAnimationsMap(int id, gfx::Transform transform); |
158 | 168 |
| 169 ElementLayers GetMutableLayers(uint64_t element_id); |
159 int source_frame_number() const { return source_frame_number_; } | 170 int source_frame_number() const { return source_frame_number_; } |
160 void set_source_frame_number(int frame_number) { | 171 void set_source_frame_number(int frame_number) { |
161 source_frame_number_ = frame_number; | 172 source_frame_number_ = frame_number; |
162 } | 173 } |
163 | 174 |
164 bool is_first_frame_after_commit() const { | 175 bool is_first_frame_after_commit() const { |
165 return source_frame_number_ != is_first_frame_after_commit_tracker_; | 176 return source_frame_number_ != is_first_frame_after_commit_tracker_; |
166 } | 177 } |
167 | 178 |
168 void set_is_first_frame_after_commit(bool is_first_frame_after_commit) { | 179 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... |
246 return elastic_overscroll_.get(); | 257 return elastic_overscroll_.get(); |
247 } | 258 } |
248 | 259 |
249 SyncedTopControls* top_controls_shown_ratio() { | 260 SyncedTopControls* top_controls_shown_ratio() { |
250 return top_controls_shown_ratio_.get(); | 261 return top_controls_shown_ratio_.get(); |
251 } | 262 } |
252 const SyncedTopControls* top_controls_shown_ratio() const { | 263 const SyncedTopControls* top_controls_shown_ratio() const { |
253 return top_controls_shown_ratio_.get(); | 264 return top_controls_shown_ratio_.get(); |
254 } | 265 } |
255 | 266 |
256 void SetElementIdsForTesting(); | |
257 | |
258 // Updates draw properties and render surface layer list, as well as tile | 267 // Updates draw properties and render surface layer list, as well as tile |
259 // priorities. Returns false if it was unable to update. Updating lcd | 268 // priorities. Returns false if it was unable to update. Updating lcd |
260 // text may cause invalidations, so should only be done after a commit. | 269 // text may cause invalidations, so should only be done after a commit. |
261 bool UpdateDrawProperties(bool update_lcd_text); | 270 bool UpdateDrawProperties(bool update_lcd_text); |
262 void BuildLayerListAndPropertyTreesForTesting(); | 271 void BuildLayerListAndPropertyTreesForTesting(); |
263 | 272 |
264 void set_needs_update_draw_properties() { | 273 void set_needs_update_draw_properties() { |
265 needs_update_draw_properties_ = true; | 274 needs_update_draw_properties_ = true; |
266 } | 275 } |
267 bool needs_update_draw_properties() const { | 276 bool needs_update_draw_properties() const { |
(...skipping 22 matching lines...) Expand all Loading... |
290 | 299 |
291 // These return the size of the root scrollable area and the size of | 300 // These return the size of the root scrollable area and the size of |
292 // the user-visible scrolling viewport, in CSS layout coordinates. | 301 // the user-visible scrolling viewport, in CSS layout coordinates. |
293 gfx::SizeF ScrollableSize() const; | 302 gfx::SizeF ScrollableSize() const; |
294 gfx::SizeF ScrollableViewportSize() const; | 303 gfx::SizeF ScrollableViewportSize() const; |
295 | 304 |
296 gfx::Rect RootScrollLayerDeviceViewportBounds() const; | 305 gfx::Rect RootScrollLayerDeviceViewportBounds() const; |
297 | 306 |
298 LayerImpl* LayerById(int id) const; | 307 LayerImpl* LayerById(int id) const; |
299 | 308 |
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 | |
307 void AddLayerShouldPushProperties(LayerImpl* layer); | 309 void AddLayerShouldPushProperties(LayerImpl* layer); |
308 void RemoveLayerShouldPushProperties(LayerImpl* layer); | 310 void RemoveLayerShouldPushProperties(LayerImpl* layer); |
309 std::unordered_set<LayerImpl*>& LayersThatShouldPushProperties(); | 311 std::unordered_set<LayerImpl*>& LayersThatShouldPushProperties(); |
310 bool LayerNeedsPushPropertiesForTesting(LayerImpl* layer); | 312 bool LayerNeedsPushPropertiesForTesting(LayerImpl* layer); |
311 | 313 |
312 // These should be called by LayerImpl's ctor/dtor. | 314 // These should be called by LayerImpl's ctor/dtor. |
313 void RegisterLayer(LayerImpl* layer); | 315 void RegisterLayer(LayerImpl* layer); |
314 void UnregisterLayer(LayerImpl* layer); | 316 void UnregisterLayer(LayerImpl* layer); |
315 | 317 |
316 // These manage ownership of the LayerImpl. | 318 // These manage ownership of the LayerImpl. |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 float painted_device_scale_factor_; | 516 float painted_device_scale_factor_; |
515 | 517 |
516 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; | 518 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; |
517 | 519 |
518 std::unique_ptr<OwnedLayerImplList> layers_; | 520 std::unique_ptr<OwnedLayerImplList> layers_; |
519 LayerImplMap layer_id_map_; | 521 LayerImplMap layer_id_map_; |
520 std::vector<LayerImpl*> layer_list_; | 522 std::vector<LayerImpl*> layer_list_; |
521 // Set of layers that need to push properties. | 523 // Set of layers that need to push properties. |
522 std::unordered_set<LayerImpl*> layers_that_should_push_properties_; | 524 std::unordered_set<LayerImpl*> layers_that_should_push_properties_; |
523 | 525 |
524 std::unordered_map<ElementId, LayerImpl*, ElementIdHash> element_layers_map_; | 526 std::unordered_map<uint64_t, ElementLayers> element_layers_map_; |
525 | 527 |
526 std::unordered_map<int, float> opacity_animations_map_; | 528 std::unordered_map<int, float> opacity_animations_map_; |
527 std::unordered_map<int, gfx::Transform> transform_animations_map_; | 529 std::unordered_map<int, gfx::Transform> transform_animations_map_; |
528 | 530 |
529 // Maps from clip layer ids to scroll layer ids. Note that this only includes | 531 // Maps from clip layer ids to scroll layer ids. Note that this only includes |
530 // the subset of clip layers that act as scrolling containers. (This is | 532 // the subset of clip layers that act as scrolling containers. (This is |
531 // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.) | 533 // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.) |
532 std::unordered_map<int, int> clip_scroll_map_; | 534 std::unordered_map<int, int> clip_scroll_map_; |
533 | 535 |
534 // Maps scroll layer ids to scrollbar layer ids. For each scroll layer, there | 536 // Maps scroll layer ids to scrollbar layer ids. For each scroll layer, there |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; | 580 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; |
579 | 581 |
580 private: | 582 private: |
581 void BuildLayerListForTesting(); | 583 void BuildLayerListForTesting(); |
582 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); | 584 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); |
583 }; | 585 }; |
584 | 586 |
585 } // namespace cc | 587 } // namespace cc |
586 | 588 |
587 #endif // CC_TREES_LAYER_TREE_IMPL_H_ | 589 #endif // CC_TREES_LAYER_TREE_IMPL_H_ |
OLD | NEW |