| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 class ResourceProvider; | 47 class ResourceProvider; |
| 48 class TileManager; | 48 class TileManager; |
| 49 class UIResourceRequest; | 49 class UIResourceRequest; |
| 50 class VideoFrameControllerClient; | 50 class VideoFrameControllerClient; |
| 51 struct PendingPageScaleAnimation; | 51 struct PendingPageScaleAnimation; |
| 52 | 52 |
| 53 typedef std::vector<UIResourceRequest> UIResourceRequestQueue; | 53 typedef std::vector<UIResourceRequest> UIResourceRequestQueue; |
| 54 typedef SyncedProperty<AdditionGroup<float>> SyncedBrowserControls; | 54 typedef SyncedProperty<AdditionGroup<float>> SyncedBrowserControls; |
| 55 typedef SyncedProperty<AdditionGroup<gfx::Vector2dF>> SyncedElasticOverscroll; | 55 typedef SyncedProperty<AdditionGroup<gfx::Vector2dF>> SyncedElasticOverscroll; |
| 56 | 56 |
| 57 class LayerTreeLifecycle { |
| 58 public: |
| 59 enum LifecycleState { |
| 60 kNotSyncing, |
| 61 |
| 62 // The following states are the steps performed when syncing properties to |
| 63 // this tree (see: LayerTreeHost::FinishCommitOnImplThread or |
| 64 // LayerTreeHostImpl::ActivateSyncTree). |
| 65 kBeginningSync, |
| 66 kSyncedPropertyTrees, |
| 67 kSyncedLayerProperties, |
| 68 kLastSyncState = kSyncedLayerProperties, |
| 69 |
| 70 // TODO(pdr): Add states to cover more than just the synchronization steps. |
| 71 }; |
| 72 |
| 73 void AdvanceTo(LifecycleState); |
| 74 |
| 75 bool AllowsPropertyTreeAccess() const { |
| 76 return state_ == kNotSyncing || state_ >= kSyncedPropertyTrees; |
| 77 } |
| 78 bool AllowsLayerPropertyAccess() const { |
| 79 return state_ == kNotSyncing || state_ >= kSyncedLayerProperties; |
| 80 } |
| 81 |
| 82 private: |
| 83 LifecycleState state_ = kNotSyncing; |
| 84 }; |
| 85 |
| 57 class CC_EXPORT LayerTreeImpl { | 86 class CC_EXPORT LayerTreeImpl { |
| 58 public: | 87 public: |
| 59 // This is the number of times a fixed point has to be hit continuously by a | 88 // This is the number of times a fixed point has to be hit continuously by a |
| 60 // layer to consider it as jittering. | 89 // layer to consider it as jittering. |
| 61 enum : int { kFixedPointHitsThreshold = 3 }; | 90 enum : int { kFixedPointHitsThreshold = 3 }; |
| 62 LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl, | 91 LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl, |
| 63 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, | 92 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, |
| 64 scoped_refptr<SyncedBrowserControls> top_controls_shown_ratio, | 93 scoped_refptr<SyncedBrowserControls> top_controls_shown_ratio, |
| 65 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll); | 94 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll); |
| 66 virtual ~LayerTreeImpl(); | 95 virtual ~LayerTreeImpl(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return layer_list_.empty() ? nullptr : layer_list_[0]; | 152 return layer_list_.empty() ? nullptr : layer_list_[0]; |
| 124 } | 153 } |
| 125 const RenderSurfaceImpl* RootRenderSurface() const; | 154 const RenderSurfaceImpl* RootRenderSurface() const; |
| 126 bool LayerListIsEmpty() const; | 155 bool LayerListIsEmpty() const; |
| 127 void SetRootLayerForTesting(std::unique_ptr<LayerImpl>); | 156 void SetRootLayerForTesting(std::unique_ptr<LayerImpl>); |
| 128 void OnCanDrawStateChangedForTree(); | 157 void OnCanDrawStateChangedForTree(); |
| 129 bool IsRootLayer(const LayerImpl* layer) const; | 158 bool IsRootLayer(const LayerImpl* layer) const; |
| 130 std::unique_ptr<OwnedLayerImplList> DetachLayers(); | 159 std::unique_ptr<OwnedLayerImplList> DetachLayers(); |
| 131 | 160 |
| 132 void SetPropertyTrees(PropertyTrees* property_trees); | 161 void SetPropertyTrees(PropertyTrees* property_trees); |
| 133 PropertyTrees* property_trees() { return &property_trees_; } | 162 PropertyTrees* property_trees() { |
| 163 // TODO(pdr): We should enable this DCHECK because it will catch uses of |
| 164 // stale property trees, but it currently fails too many existing tests. |
| 165 // DCHECK(lifecycle().AllowsPropertyTreeAccess()); |
| 166 return &property_trees_; |
| 167 } |
| 134 | 168 |
| 169 void PushPropertyTreesTo(LayerTreeImpl* tree_impl); |
| 135 void PushPropertiesTo(LayerTreeImpl* tree_impl); | 170 void PushPropertiesTo(LayerTreeImpl* tree_impl); |
| 136 | 171 |
| 137 void MoveChangeTrackingToLayers(); | 172 void MoveChangeTrackingToLayers(); |
| 138 | 173 |
| 139 void ForceRecalculateRasterScales(); | 174 void ForceRecalculateRasterScales(); |
| 140 | 175 |
| 141 LayerImplList::const_iterator begin() const; | 176 LayerImplList::const_iterator begin() const; |
| 142 LayerImplList::const_iterator end() const; | 177 LayerImplList::const_iterator end() const; |
| 143 LayerImplList::reverse_iterator rbegin(); | 178 LayerImplList::reverse_iterator rbegin(); |
| 144 LayerImplList::reverse_iterator rend(); | 179 LayerImplList::reverse_iterator rend(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 const ScrollNode* CurrentlyScrollingNode() const; | 214 const ScrollNode* CurrentlyScrollingNode() const; |
| 180 int LastScrolledScrollNodeIndex() const; | 215 int LastScrolledScrollNodeIndex() const; |
| 181 void SetCurrentlyScrollingNode(ScrollNode* node); | 216 void SetCurrentlyScrollingNode(ScrollNode* node); |
| 182 void ClearCurrentlyScrollingNode(); | 217 void ClearCurrentlyScrollingNode(); |
| 183 | 218 |
| 184 void SetViewportLayersFromIds(int overscroll_elasticity_layer, | 219 void SetViewportLayersFromIds(int overscroll_elasticity_layer, |
| 185 int page_scale_layer_id, | 220 int page_scale_layer_id, |
| 186 int inner_viewport_scroll_layer_id, | 221 int inner_viewport_scroll_layer_id, |
| 187 int outer_viewport_scroll_layer_id); | 222 int outer_viewport_scroll_layer_id); |
| 188 void ClearViewportLayers(); | 223 void ClearViewportLayers(); |
| 189 // Sets the viewport layer types. This depends on the viewport layers from | |
| 190 // SetViewportLayersFromIds and the viewport layer's scroll_clip_layer_ids. | |
| 191 void UpdateViewportLayerTypes(); | |
| 192 LayerImpl* OverscrollElasticityLayer() { | 224 LayerImpl* OverscrollElasticityLayer() { |
| 193 return LayerById(overscroll_elasticity_layer_id_); | 225 return LayerById(overscroll_elasticity_layer_id_); |
| 194 } | 226 } |
| 195 LayerImpl* PageScaleLayer() { return LayerById(page_scale_layer_id_); } | 227 LayerImpl* PageScaleLayer() { return LayerById(page_scale_layer_id_); } |
| 196 void ApplySentScrollAndScaleDeltasFromAbortedCommit(); | 228 void ApplySentScrollAndScaleDeltasFromAbortedCommit(); |
| 197 | 229 |
| 198 SkColor background_color() const { return background_color_; } | 230 SkColor background_color() const { return background_color_; } |
| 199 void set_background_color(SkColor color) { background_color_ = color; } | 231 void set_background_color(SkColor color) { background_color_ = color; } |
| 200 | 232 |
| 201 bool has_transparent_background() const { | 233 bool has_transparent_background() const { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 | 492 |
| 461 void AddToLayerList(LayerImpl* layer); | 493 void AddToLayerList(LayerImpl* layer); |
| 462 | 494 |
| 463 void ClearLayerList(); | 495 void ClearLayerList(); |
| 464 | 496 |
| 465 void BuildLayerListForTesting(); | 497 void BuildLayerListForTesting(); |
| 466 void HandleScrollbarShowRequestsFromMain(); | 498 void HandleScrollbarShowRequestsFromMain(); |
| 467 | 499 |
| 468 void InvalidateRegionForImages(const ImageIdFlatSet& images_to_invalidate); | 500 void InvalidateRegionForImages(const ImageIdFlatSet& images_to_invalidate); |
| 469 | 501 |
| 502 LayerTreeLifecycle& lifecycle() { return lifecycle_; } |
| 503 |
| 470 protected: | 504 protected: |
| 471 float ClampPageScaleFactorToLimits(float page_scale_factor) const; | 505 float ClampPageScaleFactorToLimits(float page_scale_factor) const; |
| 472 void PushPageScaleFactorAndLimits(const float* page_scale_factor, | 506 void PushPageScaleFactorAndLimits(const float* page_scale_factor, |
| 473 float min_page_scale_factor, | 507 float min_page_scale_factor, |
| 474 float max_page_scale_factor); | 508 float max_page_scale_factor); |
| 475 bool SetPageScaleFactorLimits(float min_page_scale_factor, | 509 bool SetPageScaleFactorLimits(float min_page_scale_factor, |
| 476 float max_page_scale_factor); | 510 float max_page_scale_factor); |
| 477 bool IsViewportLayerId(int id) const; | 511 bool IsViewportLayerId(int id) const; |
| 478 void UpdateScrollbars(int scroll_layer_id, int clip_layer_id); | 512 void UpdateScrollbars(int scroll_layer_id, int clip_layer_id); |
| 479 void DidUpdatePageScale(); | 513 void DidUpdatePageScale(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 bool browser_controls_shrink_blink_size_; | 608 bool browser_controls_shrink_blink_size_; |
| 575 float top_controls_height_; | 609 float top_controls_height_; |
| 576 float bottom_controls_height_; | 610 float bottom_controls_height_; |
| 577 | 611 |
| 578 // The amount that the browser controls are shown from 0 (hidden) to 1 (fully | 612 // The amount that the browser controls are shown from 0 (hidden) to 1 (fully |
| 579 // shown). | 613 // shown). |
| 580 scoped_refptr<SyncedBrowserControls> top_controls_shown_ratio_; | 614 scoped_refptr<SyncedBrowserControls> top_controls_shown_ratio_; |
| 581 | 615 |
| 582 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; | 616 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; |
| 583 | 617 |
| 618 // Tracks the lifecycle which is used for enforcing dependencies between |
| 619 // lifecycle states. See: |LayerTreeLifecycle|. |
| 620 LayerTreeLifecycle lifecycle_; |
| 621 |
| 584 private: | 622 private: |
| 585 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); | 623 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); |
| 586 }; | 624 }; |
| 587 | 625 |
| 588 } // namespace cc | 626 } // namespace cc |
| 589 | 627 |
| 590 #endif // CC_TREES_LAYER_TREE_IMPL_H_ | 628 #endif // CC_TREES_LAYER_TREE_IMPL_H_ |
| OLD | NEW |