| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 "services/ui/public/cpp/compositor_frame_sink.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "cc/output/compositor_frame.h" | |
| 9 #include "cc/output/compositor_frame_sink_client.h" | |
| 10 #include "gpu/ipc/client/gpu_channel_host.h" | |
| 11 #include "services/ui/public/cpp/gpu_service.h" | |
| 12 #include "services/ui/public/cpp/window_surface.h" | |
| 13 | |
| 14 namespace ui { | |
| 15 | |
| 16 CompositorFrameSink::CompositorFrameSink( | |
| 17 scoped_refptr<cc::ContextProvider> context_provider, | |
| 18 std::unique_ptr<ui::WindowSurface> surface) | |
| 19 : cc::CompositorFrameSink(std::move(context_provider), nullptr), | |
| 20 surface_(std::move(surface)) {} | |
| 21 | |
| 22 CompositorFrameSink::~CompositorFrameSink() {} | |
| 23 | |
| 24 bool CompositorFrameSink::BindToClient(cc::CompositorFrameSinkClient* client) { | |
| 25 if (!cc::CompositorFrameSink::BindToClient(client)) | |
| 26 return false; | |
| 27 | |
| 28 surface_->BindToThread(); | |
| 29 surface_->set_client(this); | |
| 30 | |
| 31 // TODO(enne): Get this from the WindowSurface via ServerWindowSurface. | |
| 32 begin_frame_source_.reset(new cc::DelayBasedBeginFrameSource( | |
| 33 base::MakeUnique<cc::DelayBasedTimeSource>( | |
| 34 base::ThreadTaskRunnerHandle::Get().get()))); | |
| 35 | |
| 36 client->SetBeginFrameSource(begin_frame_source_.get()); | |
| 37 return true; | |
| 38 } | |
| 39 | |
| 40 void CompositorFrameSink::DetachFromClient() { | |
| 41 client_->SetBeginFrameSource(nullptr); | |
| 42 begin_frame_source_.reset(); | |
| 43 surface_.reset(); | |
| 44 cc::CompositorFrameSink::DetachFromClient(); | |
| 45 } | |
| 46 | |
| 47 void CompositorFrameSink::SubmitCompositorFrame(cc::CompositorFrame frame) { | |
| 48 surface_->SubmitCompositorFrame(std::move(frame)); | |
| 49 } | |
| 50 | |
| 51 void CompositorFrameSink::DidReceiveCompositorFrameAck() { | |
| 52 client_->DidReceiveCompositorFrameAck(); | |
| 53 } | |
| 54 | |
| 55 void CompositorFrameSink::ReclaimResources( | |
| 56 const cc::ReturnedResourceArray& resources) { | |
| 57 client_->ReclaimResources(resources); | |
| 58 } | |
| 59 | |
| 60 } // namespace ui | |
| OLD | NEW |