| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "services/ui/public/cpp/window_compositor_frame_sink.h" | 5 #include "services/ui/public/cpp/window_compositor_frame_sink.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/output/compositor_frame_sink_client.h" | 9 #include "cc/output/compositor_frame_sink_client.h" |
| 10 #include "gpu/ipc/client/gpu_channel_host.h" | 10 #include "gpu/ipc/client/gpu_channel_host.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 if (!cc::CompositorFrameSink::BindToClient(client)) | 40 if (!cc::CompositorFrameSink::BindToClient(client)) |
| 41 return false; | 41 return false; |
| 42 | 42 |
| 43 DCHECK(!thread_checker_); | 43 DCHECK(!thread_checker_); |
| 44 thread_checker_.reset(new base::ThreadChecker()); | 44 thread_checker_.reset(new base::ThreadChecker()); |
| 45 compositor_frame_sink_.Bind(std::move(compositor_frame_sink_info_)); | 45 compositor_frame_sink_.Bind(std::move(compositor_frame_sink_info_)); |
| 46 client_binding_.reset( | 46 client_binding_.reset( |
| 47 new mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient>( | 47 new mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient>( |
| 48 this, std::move(client_request_))); | 48 this, std::move(client_request_))); |
| 49 | 49 |
| 50 // TODO(enne): Get this from the WindowSurface via ServerWindowSurface. | 50 begin_frame_source_ = base::MakeUnique<cc::ExternalBeginFrameSource>(this); |
| 51 begin_frame_source_.reset(new cc::DelayBasedBeginFrameSource( | |
| 52 base::MakeUnique<cc::DelayBasedTimeSource>( | |
| 53 base::ThreadTaskRunnerHandle::Get().get()))); | |
| 54 | 51 |
| 55 client->SetBeginFrameSource(begin_frame_source_.get()); | 52 client->SetBeginFrameSource(begin_frame_source_.get()); |
| 56 return true; | 53 return true; |
| 57 } | 54 } |
| 58 | 55 |
| 59 void WindowCompositorFrameSink::DetachFromClient() { | 56 void WindowCompositorFrameSink::DetachFromClient() { |
| 60 client_->SetBeginFrameSource(nullptr); | 57 client_->SetBeginFrameSource(nullptr); |
| 61 begin_frame_source_.reset(); | 58 begin_frame_source_.reset(); |
| 62 compositor_frame_sink_.reset(); | 59 compositor_frame_sink_.reset(); |
| 63 cc::CompositorFrameSink::DetachFromClient(); | 60 cc::CompositorFrameSink::DetachFromClient(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 86 client_request_(std::move(client_request)) {} | 83 client_request_(std::move(client_request)) {} |
| 87 | 84 |
| 88 void WindowCompositorFrameSink::DidReceiveCompositorFrameAck() { | 85 void WindowCompositorFrameSink::DidReceiveCompositorFrameAck() { |
| 89 DCHECK(thread_checker_); | 86 DCHECK(thread_checker_); |
| 90 DCHECK(thread_checker_->CalledOnValidThread()); | 87 DCHECK(thread_checker_->CalledOnValidThread()); |
| 91 if (!client_) | 88 if (!client_) |
| 92 return; | 89 return; |
| 93 client_->DidReceiveCompositorFrameAck(); | 90 client_->DidReceiveCompositorFrameAck(); |
| 94 } | 91 } |
| 95 | 92 |
| 93 void WindowCompositorFrameSink::OnBeginFrame( |
| 94 const cc::BeginFrameArgs& begin_frame_args) { |
| 95 begin_frame_source_->OnBeginFrame(begin_frame_args); |
| 96 } |
| 97 |
| 96 void WindowCompositorFrameSink::ReclaimResources( | 98 void WindowCompositorFrameSink::ReclaimResources( |
| 97 const cc::ReturnedResourceArray& resources) { | 99 const cc::ReturnedResourceArray& resources) { |
| 98 DCHECK(thread_checker_); | 100 DCHECK(thread_checker_); |
| 99 DCHECK(thread_checker_->CalledOnValidThread()); | 101 DCHECK(thread_checker_->CalledOnValidThread()); |
| 100 if (!client_) | 102 if (!client_) |
| 101 return; | 103 return; |
| 102 client_->ReclaimResources(resources); | 104 client_->ReclaimResources(resources); |
| 103 } | 105 } |
| 104 | 106 |
| 107 void WindowCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { |
| 108 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames); |
| 109 } |
| 110 |
| 105 WindowCompositorFrameSinkBinding::~WindowCompositorFrameSinkBinding() {} | 111 WindowCompositorFrameSinkBinding::~WindowCompositorFrameSinkBinding() {} |
| 106 | 112 |
| 107 WindowCompositorFrameSinkBinding::WindowCompositorFrameSinkBinding( | 113 WindowCompositorFrameSinkBinding::WindowCompositorFrameSinkBinding( |
| 108 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink_request, | 114 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink_request, |
| 109 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSinkClient> | 115 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSinkClient> |
| 110 compositor_frame_sink_client) | 116 compositor_frame_sink_client) |
| 111 : compositor_frame_sink_request_(std::move(compositor_frame_sink_request)), | 117 : compositor_frame_sink_request_(std::move(compositor_frame_sink_request)), |
| 112 compositor_frame_sink_client_(std::move(compositor_frame_sink_client)) {} | 118 compositor_frame_sink_client_(std::move(compositor_frame_sink_client)) {} |
| 113 | 119 |
| 114 } // namespace ui | 120 } // namespace ui |
| OLD | NEW |