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

Unified Diff: cc/surfaces/surface.h

Issue 2676373004: Implement service-side surface synchronization (Closed)
Patch Set: Better unit test name 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.h
diff --git a/cc/surfaces/surface.h b/cc/surfaces/surface.h
index 0ac97a13b05bd675b9b941daceea0c8e7be6f050..0e74e16ea0a23ec98f4a5200ce6b1bfe153a738c 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_frame_observer.h"
#include "cc/surfaces/surface_factory.h"
#include "cc/surfaces/surface_id.h"
#include "cc/surfaces/surface_sequence.h"
@@ -54,14 +55,30 @@ class CC_SURFACES_EXPORT Surface {
void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback);
void EvictFrame();
void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request);
+
+ // Notifies the Surface that a blocking SurfaceId now has an active frame.
+ void NotifySurfaceIdAvailable(const SurfaceId& surface_id);
+
+ void AddObserver(PendingFrameObserver* observer);
+ void RemoveObserver(PendingFrameObserver* 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(
std::multimap<int, std::unique_ptr<CopyOutputRequest>>* copy_requests);
// Returns the most recent frame that is eligible to be rendered.
- // You must check whether HasFrame() returns true before calling this method.
- const CompositorFrame& GetEligibleFrame() const;
+ // You must check whether HasActiveFrame() returns true before calling this
+ // method.
+ const CompositorFrame& GetActiveFrame() const;
+
+ // Returns the currently pending frame. You must check where HasPendingFrame()
+ // returns true before calling this method.
+ const 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 +105,20 @@ class CC_SURFACES_EXPORT Surface {
return referenced_surfaces_;
}
- bool HasFrame() const { return current_frame_.has_value(); }
+ bool HasActiveFrame() const { return active_frame_.has_value(); }
+ bool HasPendingFrame() const { return pending_frame_.has_value(); }
bool destroyed() const { return destroyed_; }
void set_destroyed(bool destroyed) { destroyed_ = destroyed; }
private:
+ void ActivatePendingFrame();
kylechar 2017/02/09 15:50:31 What does ActivePendingFrame() do exactly? Can you
+ // Called when all of the surface's dependencies have been resolved.
+ void ActivateFrame(CompositorFrame frame);
+ void UpdateBlockingSurfaces(
+ const base::Optional<CompositorFrame>& previous_pending_frame,
+ const CompositorFrame& current_frame);
+
void UnrefFrameResources(const CompositorFrame& frame_data);
void ClearCopyRequests();
@@ -101,7 +126,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 +138,16 @@ class CC_SURFACES_EXPORT Surface {
std::vector<SurfaceId> referenced_surfaces_;
+ SurfaceDependencies blocking_surfaces_;
+ base::ObserverList<PendingFrameObserver, true> observers_;
+
DrawCallback draw_callback_;
DISALLOW_COPY_AND_ASSIGN(Surface);
};
+using PendingSurfaceSet = base::flat_set<Surface*>;
+
} // namespace cc
#endif // CC_SURFACES_SURFACE_H_

Powered by Google App Engine
This is Rietveld 408576698