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

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

Issue 2873313004: Harmonize LayerTreeHost/LayerTreeHostImpl synchronization steps (Closed)
Patch Set: Ace of rebase Created 3 years, 7 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 495
461 void AddToLayerList(LayerImpl* layer); 496 void AddToLayerList(LayerImpl* layer);
462 497
463 void ClearLayerList(); 498 void ClearLayerList();
464 499
465 void BuildLayerListForTesting(); 500 void BuildLayerListForTesting();
466 void HandleScrollbarShowRequestsFromMain(); 501 void HandleScrollbarShowRequestsFromMain();
467 502
468 void InvalidateRegionForImages(const ImageIdFlatSet& images_to_invalidate); 503 void InvalidateRegionForImages(const ImageIdFlatSet& images_to_invalidate);
469 504
505 LayerTreeLifecycle& lifecycle() { return lifecycle_; }
506
470 protected: 507 protected:
471 float ClampPageScaleFactorToLimits(float page_scale_factor) const; 508 float ClampPageScaleFactorToLimits(float page_scale_factor) const;
472 void PushPageScaleFactorAndLimits(const float* page_scale_factor, 509 void PushPageScaleFactorAndLimits(const float* page_scale_factor,
473 float min_page_scale_factor, 510 float min_page_scale_factor,
474 float max_page_scale_factor); 511 float max_page_scale_factor);
475 bool SetPageScaleFactorLimits(float min_page_scale_factor, 512 bool SetPageScaleFactorLimits(float min_page_scale_factor,
476 float max_page_scale_factor); 513 float max_page_scale_factor);
477 bool IsViewportLayerId(int id) const; 514 bool IsViewportLayerId(int id) const;
478 void UpdateScrollbars(int scroll_layer_id, int clip_layer_id); 515 void UpdateScrollbars(int scroll_layer_id, int clip_layer_id);
479 void DidUpdatePageScale(); 516 void DidUpdatePageScale();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 bool browser_controls_shrink_blink_size_; 611 bool browser_controls_shrink_blink_size_;
575 float top_controls_height_; 612 float top_controls_height_;
576 float bottom_controls_height_; 613 float bottom_controls_height_;
577 614
578 // The amount that the browser controls are shown from 0 (hidden) to 1 (fully 615 // The amount that the browser controls are shown from 0 (hidden) to 1 (fully
579 // shown). 616 // shown).
580 scoped_refptr<SyncedBrowserControls> top_controls_shown_ratio_; 617 scoped_refptr<SyncedBrowserControls> top_controls_shown_ratio_;
581 618
582 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; 619 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_;
583 620
621 // Tracks the lifecycle which is used for enforcing dependencies between
622 // lifecycle states. See: |LayerTreeLifecycle|.
623 LayerTreeLifecycle lifecycle_;
624
584 private: 625 private:
585 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); 626 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl);
586 }; 627 };
587 628
588 } // namespace cc 629 } // namespace cc
589 630
590 #endif // CC_TREES_LAYER_TREE_IMPL_H_ 631 #endif // CC_TREES_LAYER_TREE_IMPL_H_
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698