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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..22a74ad536d762c302772c49cac6c25a39a2b10b |
| --- /dev/null |
| +++ b/components/exo/compositor_frame_sink_holder.cc |
| @@ -0,0 +1,69 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/exo/compositor_frame_sink_holder.h" |
| + |
| +#include "cc/resources/returned_resource.h" |
| +#include "components/exo/surface.h" |
| + |
| +namespace exo { |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// CompositorFrameSinkHolder, public: |
| +CompositorFrameSinkHolder::CompositorFrameSinkHolder( |
| + std::unique_ptr<ExoCompositorFrameSink> compositor_frame_sink, |
| + Surface* surface, |
| + cc::mojom::MojoCompositorFrameSinkClientRequest request) |
| + : compositor_frame_sink_(std::move(compositor_frame_sink)), |
| + surface_(surface), |
| + binding_(this, std::move(request)) {} |
| + |
| +bool CompositorFrameSinkHolder::HasReleaseCallbacks(cc::ResourceId id) { |
| + return release_callbacks_.count(id); |
| +} |
| + |
| +void CompositorFrameSinkHolder::AddResourceReleaseCallback( |
| + cc::ResourceId id, |
| + std::unique_ptr<cc::SingleReleaseCallback> callback) { |
| + release_callbacks_[id] = std::make_pair(this, std::move(callback)); |
|
Fady Samuel
2016/11/23 14:39:02
This is so icky. Holding a reference to self is su
|
| +} |
| + |
| +void CompositorFrameSinkHolder::SubmitCompositorFrame( |
| + const cc::LocalFrameId& local_frame_id, |
| + cc::CompositorFrame frame) { |
| + if (compositor_frame_sink_) |
| + compositor_frame_sink_->SubmitCompositorFrame(local_frame_id, |
| + std::move(frame)); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// cc::SurfaceFactoryClient overrides: |
| + |
| +// TODO(staraz): Implement this |
| +void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck() {} |
| + |
| +// TODO(staraz): Implement this |
| +void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) {} |
|
Fady Samuel
2016/11/23 14:39:02
I think you'll likely want to implement this.
|
| + |
| +void CompositorFrameSinkHolder::ReclaimResources( |
| + const cc::ReturnedResourceArray& resources) { |
| + scoped_refptr<CompositorFrameSinkHolder> holder(this); |
| + for (auto& resource : resources) { |
| + auto it = release_callbacks_.find(resource.id); |
| + DCHECK(it != release_callbacks_.end()); |
| + it->second.second->Run(resource.sync_token, resource.lost); |
| + release_callbacks_.erase(it); |
| + } |
| +} |
| + |
| +void CompositorFrameSinkHolder::WillDrawSurface() { |
| + if (surface_) |
| + surface_->WillDraw(); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// ExoComopositorFrameSink, private: |
| +CompositorFrameSinkHolder::~CompositorFrameSinkHolder() {} |
| + |
| +} // namespace exo |