| Index: cc/surfaces/direct_compositor_frame_sink.cc
|
| diff --git a/cc/surfaces/direct_compositor_frame_sink.cc b/cc/surfaces/direct_compositor_frame_sink.cc
|
| index 1fa4d8d150a4ebf01d2b1cd59053a630aedf1842..10c37ee7cc3842ae45d3b48987aead9a936d9612 100644
|
| --- a/cc/surfaces/direct_compositor_frame_sink.cc
|
| +++ b/cc/surfaces/direct_compositor_frame_sink.cc
|
| @@ -29,12 +29,14 @@
|
| shared_bitmap_manager),
|
| frame_sink_id_(frame_sink_id),
|
| surface_manager_(surface_manager),
|
| - display_(display) {
|
| + display_(display),
|
| + factory_(frame_sink_id, surface_manager, this) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| capabilities_.can_force_reclaim_resources = true;
|
| // Display and DirectCompositorFrameSink share a GL context, so sync
|
| // points aren't needed when passing resources between them.
|
| capabilities_.delegated_sync_points_required = false;
|
| + factory_.set_needs_sync_points(false);
|
| }
|
|
|
| DirectCompositorFrameSink::DirectCompositorFrameSink(
|
| @@ -45,7 +47,8 @@
|
| : CompositorFrameSink(std::move(vulkan_context_provider)),
|
| frame_sink_id_(frame_sink_id),
|
| surface_manager_(surface_manager),
|
| - display_(display) {
|
| + display_(display),
|
| + factory_(frame_sink_id_, surface_manager, this) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| capabilities_.can_force_reclaim_resources = true;
|
| }
|
| @@ -61,28 +64,26 @@
|
| if (!CompositorFrameSink::BindToClient(client))
|
| return false;
|
|
|
| + surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
|
| +
|
| // We want the Display's output surface to hear about lost context, and since
|
| // this shares a context with it, we should not be listening for lost context
|
| // callbacks on the context here.
|
| if (auto* cp = context_provider())
|
| cp->SetLostContextCallback(base::Closure());
|
|
|
| - support_ = base::MakeUnique<CompositorFrameSinkSupport>(
|
| - this, surface_manager_, frame_sink_id_, display_, false,
|
| - capabilities_.delegated_sync_points_required);
|
| -
|
| - begin_frame_source_ = base::MakeUnique<ExternalBeginFrameSource>(this);
|
| - client_->SetBeginFrameSource(begin_frame_source_.get());
|
| // Avoid initializing GL context here, as this should be sharing the
|
| // Display's context.
|
| -
|
| + display_->Initialize(this, surface_manager_);
|
| return true;
|
| }
|
|
|
| void DirectCompositorFrameSink::DetachFromClient() {
|
| - client_->SetBeginFrameSource(nullptr);
|
| - begin_frame_source_.reset();
|
| - support_.reset();
|
| + // Unregister the SurfaceFactoryClient here instead of the dtor so that only
|
| + // one client is alive for this namespace at any given time.
|
| + surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
|
| + factory_.EvictSurface();
|
| +
|
| CompositorFrameSink::DetachFromClient();
|
| }
|
|
|
| @@ -92,12 +93,30 @@
|
| delegated_local_surface_id_ = surface_id_allocator_.GenerateId();
|
| last_swap_frame_size_ = frame_size;
|
| }
|
| - support_->SubmitCompositorFrame(delegated_local_surface_id_,
|
| - std::move(frame));
|
| + display_->SetLocalSurfaceId(delegated_local_surface_id_,
|
| + frame.metadata.device_scale_factor);
|
| +
|
| + factory_.SubmitCompositorFrame(
|
| + delegated_local_surface_id_, std::move(frame),
|
| + base::Bind(&DirectCompositorFrameSink::DidDrawCallback,
|
| + base::Unretained(this)));
|
| }
|
|
|
| void DirectCompositorFrameSink::ForceReclaimResources() {
|
| - support_->ForceReclaimResources();
|
| + if (delegated_local_surface_id_.is_valid())
|
| + factory_.ClearSurface();
|
| +}
|
| +
|
| +void DirectCompositorFrameSink::ReturnResources(
|
| + const ReturnedResourceArray& resources) {
|
| + if (client_)
|
| + client_->ReclaimResources(resources);
|
| +}
|
| +
|
| +void DirectCompositorFrameSink::SetBeginFrameSource(
|
| + BeginFrameSource* begin_frame_source) {
|
| + DCHECK(client_);
|
| + client_->SetBeginFrameSource(begin_frame_source);
|
| }
|
|
|
| void DirectCompositorFrameSink::DisplayOutputSurfaceLost() {
|
| @@ -117,29 +136,8 @@
|
| // be drawn.
|
| }
|
|
|
| -void DirectCompositorFrameSink::DidReceiveCompositorFrameAck() {
|
| - client_->DidReceiveCompositorFrameAck();
|
| -}
|
| -
|
| -void DirectCompositorFrameSink::OnBeginFrame(const BeginFrameArgs& args) {
|
| - begin_frame_source_->OnBeginFrame(args);
|
| -}
|
| -
|
| -void DirectCompositorFrameSink::ReclaimResources(
|
| - const ReturnedResourceArray& resources) {
|
| - client_->ReclaimResources(resources);
|
| -}
|
| -
|
| -void DirectCompositorFrameSink::WillDrawSurface() {
|
| - // TODO(staraz): Implement this.
|
| -}
|
| -
|
| void DirectCompositorFrameSink::DidDrawCallback() {
|
| client_->DidReceiveCompositorFrameAck();
|
| }
|
|
|
| -void DirectCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frame) {
|
| - support_->SetNeedsBeginFrame(needs_begin_frame);
|
| -}
|
| -
|
| } // namespace cc
|
|
|