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/begin_frame_args.h" |
8 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
9 #include "cc/output/compositor_frame_sink_client.h" | 10 #include "cc/output/compositor_frame_sink_client.h" |
10 #include "gpu/ipc/client/gpu_channel_host.h" | 11 #include "gpu/ipc/client/gpu_channel_host.h" |
11 | 12 |
12 namespace ui { | 13 namespace ui { |
13 | 14 |
14 // static | 15 // static |
15 std::unique_ptr<WindowCompositorFrameSink> WindowCompositorFrameSink::Create( | 16 std::unique_ptr<WindowCompositorFrameSink> WindowCompositorFrameSink::Create( |
16 scoped_refptr<cc::ContextProvider> context_provider, | 17 scoped_refptr<cc::ContextProvider> context_provider, |
17 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 18 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 if (!client_) | 98 if (!client_) |
98 return; | 99 return; |
99 client_->DidReceiveCompositorFrameAck(); | 100 client_->DidReceiveCompositorFrameAck(); |
100 } | 101 } |
101 | 102 |
102 void WindowCompositorFrameSink::OnBeginFrame( | 103 void WindowCompositorFrameSink::OnBeginFrame( |
103 const cc::BeginFrameArgs& begin_frame_args) { | 104 const cc::BeginFrameArgs& begin_frame_args) { |
104 begin_frame_source_->OnBeginFrame(begin_frame_args); | 105 begin_frame_source_->OnBeginFrame(begin_frame_args); |
105 } | 106 } |
106 | 107 |
| 108 void WindowCompositorFrameSink::OnDidFinishFrame(const cc::BeginFrameAck& ack) { |
| 109 // If there was damage, SubmitCompositorFrame serves as ack. |
| 110 if (!ack.has_damage) |
| 111 compositor_frame_sink_->BeginFrameDidNotDraw(ack); |
| 112 } |
| 113 |
107 void WindowCompositorFrameSink::ReclaimResources( | 114 void WindowCompositorFrameSink::ReclaimResources( |
108 const cc::ReturnedResourceArray& resources) { | 115 const cc::ReturnedResourceArray& resources) { |
109 DCHECK(thread_checker_); | 116 DCHECK(thread_checker_); |
110 DCHECK(thread_checker_->CalledOnValidThread()); | 117 DCHECK(thread_checker_->CalledOnValidThread()); |
111 if (!client_) | 118 if (!client_) |
112 return; | 119 return; |
113 client_->ReclaimResources(resources); | 120 client_->ReclaimResources(resources); |
114 } | 121 } |
115 | 122 |
116 void WindowCompositorFrameSink::WillDrawSurface() { | 123 void WindowCompositorFrameSink::WillDrawSurface() { |
117 // TODO(fsamuel, staraz): Implement this. | 124 // TODO(fsamuel, staraz): Implement this. |
118 } | 125 } |
119 | 126 |
120 void WindowCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { | 127 void WindowCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { |
121 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames); | 128 compositor_frame_sink_->SetNeedsBeginFrame(needs_begin_frames); |
122 } | 129 } |
123 | 130 |
124 WindowCompositorFrameSinkBinding::~WindowCompositorFrameSinkBinding() {} | 131 WindowCompositorFrameSinkBinding::~WindowCompositorFrameSinkBinding() {} |
125 | 132 |
126 WindowCompositorFrameSinkBinding::WindowCompositorFrameSinkBinding( | 133 WindowCompositorFrameSinkBinding::WindowCompositorFrameSinkBinding( |
127 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink_request, | 134 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink_request, |
128 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSinkClient> | 135 mojo::InterfacePtrInfo<cc::mojom::MojoCompositorFrameSinkClient> |
129 compositor_frame_sink_client) | 136 compositor_frame_sink_client) |
130 : compositor_frame_sink_request_(std::move(compositor_frame_sink_request)), | 137 : compositor_frame_sink_request_(std::move(compositor_frame_sink_request)), |
131 compositor_frame_sink_client_(std::move(compositor_frame_sink_client)) {} | 138 compositor_frame_sink_client_(std::move(compositor_frame_sink_client)) {} |
132 | 139 |
133 } // namespace ui | 140 } // namespace ui |
OLD | NEW |