From e6b29c494898402e221db3ff490d219ca0bab9fe Mon Sep 17 00:00:00 2001 From: staraz Date: Tue, 6 Dec 2016 17:03:45 -0800 Subject: [PATCH] Add Satisfy() and Require() to MojoCompositorFrameSink Sometimes Wayland client requires a surface before it is created by SubmitCompositorFrame() since the request and creation use different message pipes. This CL moves the implementation of Require and Satisfy to CompositorFrameSink so that they share one message pipe with SubmitCompositorFrame and things would happen in the correct order. This is a temporary fix. kylechar@'s change of surface reference (CL 2541683004) would formally address this issue. BUG=659601 CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel Review-Url: https://codereview.chromium.org/2551083003 Cr-Commit-Position: refs/heads/master@{#436806} --- cc/ipc/mojo_compositor_frame_sink.mojom | 11 +++++++++++ cc/surfaces/compositor_frame_sink_support.cc | 17 +++++++++++++++++ cc/surfaces/compositor_frame_sink_support.h | 3 +++ .../offscreen_canvas_compositor_frame_sink.cc | 13 +++++++++++++ .../offscreen_canvas_compositor_frame_sink.h | 3 +++ .../ui/surfaces/gpu_compositor_frame_sink.cc | 9 +++++++++ .../ui/surfaces/gpu_compositor_frame_sink.h | 3 +++ 7 files changed, 59 insertions(+) diff --git a/cc/ipc/mojo_compositor_frame_sink.mojom b/cc/ipc/mojo_compositor_frame_sink.mojom index 284a470fc63194..87ddd3aff8b26a 100644 --- a/cc/ipc/mojo_compositor_frame_sink.mojom +++ b/cc/ipc/mojo_compositor_frame_sink.mojom @@ -10,6 +10,7 @@ import "cc/ipc/frame_sink_id.mojom"; import "cc/ipc/local_frame_id.mojom"; import "cc/ipc/surface_reference.mojom"; import "cc/ipc/returned_resource.mojom"; +import "cc/ipc/surface_sequence.mojom"; // A MojoCompositorFrameSink is an interface for receiving CompositorFrame // structs. A CompositorFrame contains the complete output meant for display. @@ -42,6 +43,16 @@ interface MojoCompositorFrameSink { // that its resources gets returned in time. EvictFrame(); + // TODO(staraz): Delete Require() and Satisfy() once surface references + // (CL 2541683004) are ready. + // Add the provided |sequence| as a destruction dependency of the + // surface associated with the provided |local_frame_id|. + Require(cc.mojom.LocalFrameId local_frame_id, + cc.mojom.SurfaceSequence sequence); + + // Mark the sequence as satisfied and garbage collect surfaces. + Satisfy(cc.mojom.SurfaceSequence sequence); + // TODO(fsamuel): ReadbackBitmap API would be useful here. }; diff --git a/cc/surfaces/compositor_frame_sink_support.cc b/cc/surfaces/compositor_frame_sink_support.cc index c049ac7f3c0861..d28ea4a2d4f536 100644 --- a/cc/surfaces/compositor_frame_sink_support.cc +++ b/cc/surfaces/compositor_frame_sink_support.cc @@ -8,6 +8,7 @@ #include "cc/scheduler/begin_frame_source.h" #include "cc/surfaces/compositor_frame_sink_support_client.h" #include "cc/surfaces/display.h" +#include "cc/surfaces/surface.h" #include "cc/surfaces/surface_manager.h" namespace cc { @@ -83,6 +84,22 @@ void CompositorFrameSinkSupport::SubmitCompositorFrame( } } +void CompositorFrameSinkSupport::Require(const LocalFrameId& local_frame_id, + const SurfaceSequence& sequence) { + Surface* surface = surface_manager_->GetSurfaceForId( + SurfaceId(frame_sink_id_, local_frame_id)); + if (!surface) { + DLOG(ERROR) << "Attempting to require callback on nonexistent surface"; + return; + } + surface->AddDestructionDependency(sequence); +} + +void CompositorFrameSinkSupport::Satisfy(const SurfaceSequence& sequence) { + std::vector sequences = {sequence.sequence}; + surface_manager_->DidSatisfySequences(sequence.frame_sink_id, &sequences); +} + void CompositorFrameSinkSupport::DidReceiveCompositorFrameAck() { DCHECK_GT(ack_pending_count_, 0); ack_pending_count_--; diff --git a/cc/surfaces/compositor_frame_sink_support.h b/cc/surfaces/compositor_frame_sink_support.h index 239e19425de25b..f9973d31f9fb27 100644 --- a/cc/surfaces/compositor_frame_sink_support.h +++ b/cc/surfaces/compositor_frame_sink_support.h @@ -39,6 +39,9 @@ class CC_SURFACES_EXPORT CompositorFrameSinkSupport void SetNeedsBeginFrame(bool needs_begin_frame); void SubmitCompositorFrame(const LocalFrameId& local_frame_id, CompositorFrame frame); + void Require(const LocalFrameId& local_frame_id, + const SurfaceSequence& sequence); + void Satisfy(const SurfaceSequence& sequence); void AddChildFrameSink(const FrameSinkId& child_frame_sink_id); void RemoveChildFrameSink(const FrameSinkId& child_frame_sink_id); diff --git a/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc b/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc index 42515b52c32e94..e90ba3f4f5ea62 100644 --- a/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc +++ b/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc @@ -74,6 +74,19 @@ void OffscreenCanvasCompositorFrameSink::EvictFrame() { NOTIMPLEMENTED(); } +void OffscreenCanvasCompositorFrameSink::Require( + const cc::LocalFrameId& local_frame_id, + const cc::SurfaceSequence& sequence) { + // TODO(staraz): Implement this. + NOTIMPLEMENTED(); +} + +void OffscreenCanvasCompositorFrameSink::Satisfy( + const cc::SurfaceSequence& sequence) { + // TODO(staraz): Implement this. + NOTIMPLEMENTED(); +} + void OffscreenCanvasCompositorFrameSink::ReturnResources( const cc::ReturnedResourceArray& resources) { if (resources.empty()) diff --git a/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.h b/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.h index 34b80bf9355d22..abd818700f7ce7 100644 --- a/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.h +++ b/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.h @@ -36,6 +36,9 @@ class OffscreenCanvasCompositorFrameSink void RemoveSurfaceReferences( const std::vector& references) override; void EvictFrame() override; + void Require(const cc::LocalFrameId& local_frame_id, + const cc::SurfaceSequence& sequence) override; + void Satisfy(const cc::SurfaceSequence& sequence) override; // cc::SurfaceFactoryClient implementation. void ReturnResources(const cc::ReturnedResourceArray& resources) override; diff --git a/services/ui/surfaces/gpu_compositor_frame_sink.cc b/services/ui/surfaces/gpu_compositor_frame_sink.cc index bb4b913fadca0e..fe372ced204aee 100644 --- a/services/ui/surfaces/gpu_compositor_frame_sink.cc +++ b/services/ui/surfaces/gpu_compositor_frame_sink.cc @@ -57,6 +57,15 @@ void GpuCompositorFrameSink::RemoveSurfaceReferences( display_compositor_->RemoveSurfaceReferences(references); } +void GpuCompositorFrameSink::Require(const cc::LocalFrameId& local_frame_id, + const cc::SurfaceSequence& sequence) { + support_.Require(local_frame_id, sequence); +} + +void GpuCompositorFrameSink::Satisfy(const cc::SurfaceSequence& sequence) { + support_.Satisfy(sequence); +} + void GpuCompositorFrameSink::DidReceiveCompositorFrameAck() { if (client_) client_->DidReceiveCompositorFrameAck(); diff --git a/services/ui/surfaces/gpu_compositor_frame_sink.h b/services/ui/surfaces/gpu_compositor_frame_sink.h index e2d1eb01aefce5..5d4ac51bae8f7f 100644 --- a/services/ui/surfaces/gpu_compositor_frame_sink.h +++ b/services/ui/surfaces/gpu_compositor_frame_sink.h @@ -48,6 +48,9 @@ class GpuCompositorFrameSink const std::vector& references) override; void RemoveSurfaceReferences( const std::vector& references) override; + void Require(const cc::LocalFrameId& local_frame_id, + const cc::SurfaceSequence& sequence) override; + void Satisfy(const cc::SurfaceSequence& sequence) override; // cc::mojom::MojoCompositorFrameSinkPrivate: void AddChildFrameSink(const cc::FrameSinkId& child_frame_sink_id) override;