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

Unified Diff: cc/surfaces/surface.h

Issue 2582823002: WIP: Surface Synchronization System
Patch Set: Only create ClientSurfaceEmbedder if window is visible. Trash it otherwise. Created 3 years, 11 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.h
diff --git a/cc/surfaces/surface.h b/cc/surfaces/surface.h
index 0ac97a13b05bd675b9b941daceea0c8e7be6f050..28bec6e9e9336373a46bca995437e00cb9f42c81 100644
--- a/cc/surfaces/surface.h
+++ b/cc/surfaces/surface.h
@@ -20,6 +20,7 @@
#include "base/optional.h"
#include "cc/output/copy_output_request.h"
#include "cc/surfaces/frame_sink_id.h"
+#include "cc/surfaces/pending_surface_observer.h"
#include "cc/surfaces/surface_factory.h"
#include "cc/surfaces/surface_id.h"
#include "cc/surfaces/surface_sequence.h"
@@ -54,6 +55,17 @@ class CC_SURFACES_EXPORT Surface {
void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback);
void EvictFrame();
void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request);
+
+ // Reports to the Surface that a blocking SurfaceId is now available.
+ void ReportSurfaceIdAvailable(const SurfaceId& surface_id);
+
+ void AddObserver(PendingSurfaceObserver* observer);
+ void RemoveObserver(PendingSurfaceObserver* observer);
+
+ // Called if a deadline has been hit and this surface is not yet active but
+ // it's marked as respecting deadlines.
+ void ActivatePendingFrameForDeadline();
+
// Adds each CopyOutputRequest in the current frame to copy_requests. The
// caller takes ownership of them. |copy_requests| is keyed by RenderPass ids.
void TakeCopyOutputRequests(
@@ -63,6 +75,9 @@ class CC_SURFACES_EXPORT Surface {
// You must check whether HasFrame() returns true before calling this method.
const CompositorFrame& GetEligibleFrame() const;
+ // Returns the currently pending frame.
+ const base::Optional<CompositorFrame>& GetPendingFrame();
+
// Returns a number that increments by 1 every time a new frame is enqueued.
int frame_index() const { return frame_index_; }
@@ -88,12 +103,16 @@ class CC_SURFACES_EXPORT Surface {
return referenced_surfaces_;
}
- bool HasFrame() const { return current_frame_.has_value(); }
+ bool HasFrame() const { return active_frame_.has_value(); }
bool destroyed() const { return destroyed_; }
void set_destroyed(bool destroyed) { destroyed_ = destroyed; }
private:
+ void ActivatePendingFrame();
+ // Called when all of the surface's dependencies have been resolved.
+ void ActivateFrame(CompositorFrame frame);
+
void UnrefFrameResources(const CompositorFrame& frame_data);
void ClearCopyRequests();
@@ -101,7 +120,8 @@ class CC_SURFACES_EXPORT Surface {
SurfaceId previous_frame_surface_id_;
base::WeakPtr<SurfaceFactory> factory_;
// TODO(jamesr): Support multiple frames in flight.
- base::Optional<CompositorFrame> current_frame_;
+ base::Optional<CompositorFrame> pending_frame_;
+ base::Optional<CompositorFrame> active_frame_;
int frame_index_;
bool destroyed_;
std::vector<SurfaceSequence> destruction_dependencies_;
@@ -112,11 +132,16 @@ class CC_SURFACES_EXPORT Surface {
std::vector<SurfaceId> referenced_surfaces_;
+ SurfaceDependencies blocked_on_surfaces_;
+ base::ObserverList<PendingSurfaceObserver, true> observers_;
+
DrawCallback draw_callback_;
DISALLOW_COPY_AND_ASSIGN(Surface);
};
+using PendingSurfaceSet = std::unordered_set<Surface*>;
+
} // namespace cc
#endif // CC_SURFACES_SURFACE_H_

Powered by Google App Engine
This is Rietveld 408576698