Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/exo/compositor_frame_sink_holder.h" | |
| 6 | |
| 7 #include "cc/resources/returned_resource.h" | |
| 8 #include "components/exo/surface.h" | |
| 9 | |
| 10 namespace exo { | |
| 11 | |
| 12 //////////////////////////////////////////////////////////////////////////////// | |
| 13 // CompositorFrameSinkHolder, public: | |
| 14 CompositorFrameSinkHolder::CompositorFrameSinkHolder( | |
| 15 std::unique_ptr<ExoCompositorFrameSink> compositor_frame_sink, | |
| 16 Surface* surface, | |
| 17 cc::mojom::MojoCompositorFrameSinkClientRequest request) | |
| 18 : compositor_frame_sink_(std::move(compositor_frame_sink)), | |
| 19 surface_(surface), | |
| 20 binding_(this, std::move(request)) {} | |
| 21 | |
| 22 bool CompositorFrameSinkHolder::HasReleaseCallbacks(cc::ResourceId id) { | |
| 23 return release_callbacks_.count(id); | |
| 24 } | |
| 25 | |
| 26 void CompositorFrameSinkHolder::AddResourceReleaseCallback( | |
| 27 cc::ResourceId id, | |
| 28 std::unique_ptr<cc::SingleReleaseCallback> callback) { | |
| 29 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
| |
| 30 } | |
| 31 | |
| 32 void CompositorFrameSinkHolder::SubmitCompositorFrame( | |
| 33 const cc::LocalFrameId& local_frame_id, | |
| 34 cc::CompositorFrame frame) { | |
| 35 if (compositor_frame_sink_) | |
| 36 compositor_frame_sink_->SubmitCompositorFrame(local_frame_id, | |
| 37 std::move(frame)); | |
| 38 } | |
| 39 | |
| 40 //////////////////////////////////////////////////////////////////////////////// | |
| 41 // cc::SurfaceFactoryClient overrides: | |
| 42 | |
| 43 // TODO(staraz): Implement this | |
| 44 void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck() {} | |
| 45 | |
| 46 // TODO(staraz): Implement this | |
| 47 void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) {} | |
|
Fady Samuel
2016/11/23 14:39:02
I think you'll likely want to implement this.
| |
| 48 | |
| 49 void CompositorFrameSinkHolder::ReclaimResources( | |
| 50 const cc::ReturnedResourceArray& resources) { | |
| 51 scoped_refptr<CompositorFrameSinkHolder> holder(this); | |
| 52 for (auto& resource : resources) { | |
| 53 auto it = release_callbacks_.find(resource.id); | |
| 54 DCHECK(it != release_callbacks_.end()); | |
| 55 it->second.second->Run(resource.sync_token, resource.lost); | |
| 56 release_callbacks_.erase(it); | |
| 57 } | |
| 58 } | |
| 59 | |
| 60 void CompositorFrameSinkHolder::WillDrawSurface() { | |
| 61 if (surface_) | |
| 62 surface_->WillDraw(); | |
| 63 } | |
| 64 | |
| 65 //////////////////////////////////////////////////////////////////////////////// | |
| 66 // ExoComopositorFrameSink, private: | |
| 67 CompositorFrameSinkHolder::~CompositorFrameSinkHolder() {} | |
| 68 | |
| 69 } // namespace exo | |
| OLD | NEW |