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

Unified Diff: cc/surfaces/surface_dependency_tracker.h

Issue 2676373004: Implement service-side surface synchronization (Closed)
Patch Set: DisplayCompositorLockManager => SurfaceDependencyTracker. Added More Comments Created 3 years, 10 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
Index: cc/surfaces/surface_dependency_tracker.h
diff --git a/cc/surfaces/surface_dependency_tracker.h b/cc/surfaces/surface_dependency_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..fbef3a7b0f225bd2146015c4c47067f14f08bec6
--- /dev/null
+++ b/cc/surfaces/surface_dependency_tracker.h
@@ -0,0 +1,94 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
vmpstr 2017/02/07 22:46:20 nit: 2017
Fady Samuel 2017/02/08 00:52:50 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_SURFACES_SURFACE_DEPENDENCY_TRACKER_H_
+#define CC_SURFACES_SURFACE_DEPENDENCY_TRACKER_H_
+
+#include "cc/scheduler/begin_frame_source.h"
+#include "cc/surfaces/pending_frame_observer.h"
+#include "cc/surfaces/surface.h"
+#include "cc/surfaces/surface_observer.h"
+#include "cc/surfaces/surfaces_export.h"
+
+namespace cc {
+
+class SurfaceManager;
+
+// SurfaceDependencyTracker tracks unresolved dependencies blocking
+// CompositorFrames from activating. This class maintains a map from
+// dependent surface ID to a set of Surfaces that have CompositorFrames
+// blocked on that surface ID. SurfaceDependencyTracker observes when
+// dependent frames activate, and informs blocked surfaces.
+//
+// When a blocking CompositorFrame is first submitted, SurfaceDependencyTracker
+// will begin listening for BeginFrames, setting a deadline some number of
+// BeginFrames in the future. If there are unresolved dependencies when the
+// deadline hits, then SurfaceDependencyTracker will clear then and activate
+// all pending CompositorFrames. Once there are no more remaining pending
+// frames, then SurfaceDependencyTracker will stop observing BeginFrames.
+// TODO(fsamuel): Deadlines should not be global. They should be scoped to a
+// surface subtree. However, that will not be possible until SurfaceReference
+// work is complete.
+class CC_SURFACES_EXPORT SurfaceDependencyTracker : public BeginFrameObserver,
+ public PendingFrameObserver,
+ public SurfaceObserver {
+ public:
+ SurfaceDependencyTracker(SurfaceManager* surface_manager,
+ BeginFrameSource* begin_frame_source);
+ ~SurfaceDependencyTracker() override;
+
+ // Called when |surface| has a pending CompositorFrame and it wishes to be
+ // informed when that surface's dependencies are resolved.
+ void RequestSurfaceResolution(Surface* surface);
+
+ bool has_deadline() const { return has_deadline_; }
+
+ // BeginFrameObserver implementation.
+ void OnBeginFrame(const BeginFrameArgs& args) override;
+ const BeginFrameArgs& LastUsedBeginFrameArgs() const override;
+ void OnBeginFrameSourcePausedChanged(bool paused) override;
+
+ // PendingFrameObserver implementation:
+ void OnSurfaceActivated(Surface* pending_frame) override;
+ void OnSurfaceChanged(
+ Surface* pending_frame,
+ const SurfaceDependencies& added_dependencies,
+ const SurfaceDependencies& removed_dependencies) override;
+ void OnSurfaceDiscarded(Surface* pending_frame) override;
+
+ // SurfaceObserver implementation:
+ void OnSurfaceCreated(const SurfaceInfo& surface_info) override;
+ void OnSurfaceDamaged(const SurfaceId& surface_id, bool* changed) override;
+
+ private:
+ // Informs all Surfaces with pending frames blocked on the provided
+ // |surface_id| that there is now an active frame available in Surface
+ // corresponding to |surface_id|.
+ void ReportSurfaceIdAvailable(const SurfaceId& surface_id);
+
+ SurfaceManager* const surface_manager_;
+
+ // The last begin frame args generated by the begin frame source.
+ BeginFrameArgs last_begin_frame_args_;
+
+ // The BeginFrameSource used to set deadlines.
+ BeginFrameSource* begin_frame_source_;
vmpstr 2017/02/07 22:46:20 should this be a const ptr as well?
Fady Samuel 2017/02/08 00:52:50 Done.
+
+ // Whether or not a frame observer has been added.
vmpstr 2017/02/07 22:46:20 nit: Indicates whether...
Fady Samuel 2017/02/08 00:52:50 Done.
+ bool has_deadline_ = false;
+
+ // The number of BeginFrames observed since a deadline was set.
+ uint32_t begin_frame_count_ = 0;
+
+ std::unordered_map<SurfaceId, PendingSurfaceSet, SurfaceIdHash>
+ blocking_surfaces_;
+
+ PendingSurfaceSet pending_surfaces_;
+
+ DISALLOW_COPY_AND_ASSIGN(SurfaceDependencyTracker);
+};
+
+} // namespace cc
+
+#endif // CC_SURFACES_SURFACE_DEPENDENCY_TRACKER_H_

Powered by Google App Engine
This is Rietveld 408576698