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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_impl.h
diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h
index 27faef70bfb58beb9279927f1d6bc3014242db87..3aeb0096416fb5344ab72f3265727c711a10d23f 100644
--- a/cc/trees/layer_tree_impl.h
+++ b/cc/trees/layer_tree_impl.h
@@ -54,6 +54,35 @@ typedef std::vector<UIResourceRequest> UIResourceRequestQueue;
typedef SyncedProperty<AdditionGroup<float>> SyncedBrowserControls;
typedef SyncedProperty<AdditionGroup<gfx::Vector2dF>> SyncedElasticOverscroll;
+class LayerTreeLifecycle {
+ public:
+ enum LifecycleState {
+ kNotSyncing,
+
+ // The following states are the steps performed when syncing properties to
+ // this tree (see: LayerTreeHost::FinishCommitOnImplThread or
+ // LayerTreeHostImpl::ActivateSyncTree).
+ kBeginningSync,
+ kSyncedPropertyTrees,
+ kSyncedLayerProperties,
+ kLastSyncState = kSyncedLayerProperties,
+
+ // TODO(pdr): Add states to cover more than just the synchronization steps.
+ };
+
+ void AdvanceTo(LifecycleState);
+
+ bool AllowsPropertyTreeAccess() const {
+ return state_ == kNotSyncing || state_ >= kSyncedPropertyTrees;
+ }
+ bool AllowsLayerPropertyAccess() const {
+ return state_ == kNotSyncing || state_ >= kSyncedLayerProperties;
+ }
+
+ private:
+ LifecycleState state_ = kNotSyncing;
+};
+
class CC_EXPORT LayerTreeImpl {
public:
// This is the number of times a fixed point has to be hit continuously by a
@@ -130,8 +159,14 @@ class CC_EXPORT LayerTreeImpl {
std::unique_ptr<OwnedLayerImplList> DetachLayers();
void SetPropertyTrees(PropertyTrees* property_trees);
- PropertyTrees* property_trees() { return &property_trees_; }
+ PropertyTrees* property_trees() {
+ // TODO(pdr): We should enable this DCHECK because it will catch uses of
+ // stale property trees, but it currently fails too many existing tests.
+ // DCHECK(lifecycle().AllowsPropertyTreeAccess());
+ return &property_trees_;
+ }
+ void PushPropertyTreesTo(LayerTreeImpl* tree_impl);
void PushPropertiesTo(LayerTreeImpl* tree_impl);
void MoveChangeTrackingToLayers();
@@ -467,6 +502,8 @@ class CC_EXPORT LayerTreeImpl {
void InvalidateRegionForImages(const ImageIdFlatSet& images_to_invalidate);
+ LayerTreeLifecycle& lifecycle() { return lifecycle_; }
+
protected:
float ClampPageScaleFactorToLimits(float page_scale_factor) const;
void PushPageScaleFactorAndLimits(const float* page_scale_factor,
@@ -581,6 +618,10 @@ class CC_EXPORT LayerTreeImpl {
std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_;
+ // Tracks the lifecycle which is used for enforcing dependencies between
+ // lifecycle states. See: |LayerTreeLifecycle|.
+ LayerTreeLifecycle lifecycle_;
+
private:
DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl);
};
« 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