Chromium Code Reviews| Index: components/exo/compositor_frame_sink_holder.cc |
| diff --git a/components/exo/compositor_frame_sink_holder.cc b/components/exo/compositor_frame_sink_holder.cc |
| index b516b842a52f5ec660badee0bfed3aa464022818..37cc683f50bae8e71c99e8c23f76f665d23aafa4 100644 |
| --- a/components/exo/compositor_frame_sink_holder.cc |
| +++ b/components/exo/compositor_frame_sink_holder.cc |
| @@ -4,6 +4,7 @@ |
| #include "components/exo/compositor_frame_sink_holder.h" |
| +#include "cc/output/compositor_frame_sink.h" |
| #include "cc/resources/returned_resource.h" |
| #include "components/exo/surface.h" |
| @@ -14,15 +15,23 @@ namespace exo { |
| CompositorFrameSinkHolder::CompositorFrameSinkHolder( |
| Surface* surface, |
| - const cc::FrameSinkId& frame_sink_id, |
| - cc::SurfaceManager* surface_manager) |
| + std::unique_ptr<cc::CompositorFrameSink> frame_sink) |
| : surface_(surface), |
| - frame_sink_( |
| - new CompositorFrameSink(frame_sink_id, surface_manager, this)), |
| - begin_frame_source_(base::MakeUnique<cc::ExternalBeginFrameSource>(this)), |
| + frame_sink_(std::move(frame_sink)), |
| weak_factory_(this) { |
| surface_->AddSurfaceObserver(this); |
| - surface_->SetBeginFrameSource(begin_frame_source_.get()); |
| + frame_sink_->BindToClient(this); |
| +} |
| + |
| +CompositorFrameSinkHolder::~CompositorFrameSinkHolder() { |
| + frame_sink_->DetachFromClient(); |
| + if (surface_) |
| + surface_->RemoveSurfaceObserver(this); |
| + |
| + // Release all resources which aren't returned from CompositorFrameSink. |
| + const gpu::SyncToken token; |
|
reveman
2017/05/09 17:35:58
nit: how common is it that we actually have toms r
Peng
2017/05/09 19:48:49
I tested with several wayland clients. the size of
|
| + for (auto& callback : release_callbacks_) |
| + callback.second.Run(token, false); |
| } |
| bool CompositorFrameSinkHolder::HasReleaseCallbackForResource( |
| @@ -38,17 +47,12 @@ void CompositorFrameSinkHolder::SetResourceReleaseCallback( |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// cc::mojom::MojoCompositorFrameSinkClient overrides: |
| +// cc::CompositorFrameSinkClient overrides: |
| -void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck( |
| - const cc::ReturnedResourceArray& resources) { |
| - ReclaimResources(resources); |
| +void CompositorFrameSinkHolder::SetBeginFrameSource( |
| + cc::BeginFrameSource* source) { |
| if (surface_) |
| - surface_->DidReceiveCompositorFrameAck(); |
| -} |
| - |
| -void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) { |
| - begin_frame_source_->OnBeginFrame(args); |
| + surface_->SetBeginFrameSource(source); |
| } |
| void CompositorFrameSinkHolder::ReclaimResources( |
| @@ -63,17 +67,9 @@ void CompositorFrameSinkHolder::ReclaimResources( |
| } |
| } |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// cc::ExternalBeginFrameSourceClient overrides: |
| - |
| -void CompositorFrameSinkHolder::OnNeedsBeginFrames(bool needs_begin_frames) { |
| - frame_sink_->SetNeedsBeginFrame(needs_begin_frames); |
| -} |
| - |
| -void CompositorFrameSinkHolder::OnDidFinishFrame(const cc::BeginFrameAck& ack) { |
| - // If there was damage, the submitted CompositorFrame includes the ack. |
| - if (!ack.has_damage) |
| - frame_sink_->BeginFrameDidNotSwap(ack); |
| +void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck() { |
| + if (surface_) |
| + surface_->DidReceiveCompositorFrameAck(); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -84,12 +80,4 @@ void CompositorFrameSinkHolder::OnSurfaceDestroying(Surface* surface) { |
| surface_ = nullptr; |
| } |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// ExoComopositorFrameSink, private: |
| - |
| -CompositorFrameSinkHolder::~CompositorFrameSinkHolder() { |
| - if (surface_) |
| - surface_->RemoveSurfaceObserver(this); |
| -} |
| - |
| } // namespace exo |