OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/android/synchronous_compositor_output_surface.h" | 5 #include "content/renderer/android/synchronous_compositor_output_surface.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 | 192 |
193 static void NoOpDrawCallback(cc::SurfaceDrawStatus s) {} | 193 static void NoOpDrawCallback(cc::SurfaceDrawStatus s) {} |
194 | 194 |
195 void SynchronousCompositorOutputSurface::SwapBuffers( | 195 void SynchronousCompositorOutputSurface::SwapBuffers( |
196 cc::CompositorFrame frame) { | 196 cc::CompositorFrame frame) { |
197 DCHECK(CalledOnValidThread()); | 197 DCHECK(CalledOnValidThread()); |
198 DCHECK(sync_client_); | 198 DCHECK(sync_client_); |
199 | 199 |
200 if (fallback_tick_running_) { | 200 if (fallback_tick_running_) { |
201 client_->DidSwapBuffers(); | |
202 client_->DidSwapBuffersComplete(); | |
203 DCHECK(frame.delegated_frame_data->resource_list.empty()); | 201 DCHECK(frame.delegated_frame_data->resource_list.empty()); |
204 cc::ReturnedResourceArray return_resources; | 202 cc::ReturnedResourceArray return_resources; |
205 ReturnResources(return_resources); | 203 ReturnResources(return_resources); |
| 204 did_swap_ = true; |
206 return; | 205 return; |
207 } | 206 } |
208 | 207 |
209 cc::CompositorFrame swap_frame; | 208 cc::CompositorFrame swap_frame; |
210 | 209 |
211 if (in_software_draw_) { | 210 if (in_software_draw_) { |
212 // The frame we send to the client is actually just the metadata. Preserve | 211 // The frame we send to the client is actually just the metadata. Preserve |
213 // the |frame| for the software path below. | 212 // the |frame| for the software path below. |
214 swap_frame.metadata = frame.metadata.Clone(); | 213 swap_frame.metadata = frame.metadata.Clone(); |
215 | 214 |
(...skipping 13 matching lines...) Expand all Loading... |
229 delegated_surface_id_, std::move(frame), base::Bind(&NoOpDrawCallback)); | 228 delegated_surface_id_, std::move(frame), base::Bind(&NoOpDrawCallback)); |
230 display_->DrawAndSwap(); | 229 display_->DrawAndSwap(); |
231 } else { | 230 } else { |
232 // For hardware draws we send the whole frame to the client so it can draw | 231 // For hardware draws we send the whole frame to the client so it can draw |
233 // the content in it. | 232 // the content in it. |
234 swap_frame = std::move(frame); | 233 swap_frame = std::move(frame); |
235 } | 234 } |
236 | 235 |
237 sync_client_->SwapBuffers(output_surface_id_, std::move(swap_frame)); | 236 sync_client_->SwapBuffers(output_surface_id_, std::move(swap_frame)); |
238 DeliverMessages(); | 237 DeliverMessages(); |
239 client_->DidSwapBuffers(); | |
240 did_swap_ = true; | 238 did_swap_ = true; |
241 } | 239 } |
242 | 240 |
243 void SynchronousCompositorOutputSurface::CancelFallbackTick() { | 241 void SynchronousCompositorOutputSurface::CancelFallbackTick() { |
244 fallback_tick_.Cancel(); | 242 fallback_tick_.Cancel(); |
245 fallback_tick_pending_ = false; | 243 fallback_tick_pending_ = false; |
246 } | 244 } |
247 | 245 |
248 void SynchronousCompositorOutputSurface::FallbackTickFired() { | 246 void SynchronousCompositorOutputSurface::FallbackTickFired() { |
249 DCHECK(CalledOnValidThread()); | 247 DCHECK(CalledOnValidThread()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 324 |
327 void SynchronousCompositorOutputSurface::InvokeComposite( | 325 void SynchronousCompositorOutputSurface::InvokeComposite( |
328 const gfx::Transform& transform, | 326 const gfx::Transform& transform, |
329 const gfx::Rect& viewport, | 327 const gfx::Rect& viewport, |
330 const gfx::Rect& clip) { | 328 const gfx::Rect& clip) { |
331 gfx::Transform adjusted_transform = transform; | 329 gfx::Transform adjusted_transform = transform; |
332 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0); | 330 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0); |
333 did_swap_ = false; | 331 did_swap_ = false; |
334 client_->OnDraw(adjusted_transform, viewport, clip, in_software_draw_); | 332 client_->OnDraw(adjusted_transform, viewport, clip, in_software_draw_); |
335 | 333 |
336 if (did_swap_) | 334 if (did_swap_) { |
| 335 // This must happen after unwinding the stack and leaving the compositor. |
| 336 // Usually it is a separate task but we just defer it until OnDraw completes |
| 337 // instead. |
337 client_->DidSwapBuffersComplete(); | 338 client_->DidSwapBuffersComplete(); |
| 339 } |
338 } | 340 } |
339 | 341 |
340 void SynchronousCompositorOutputSurface::OnReclaimResources( | 342 void SynchronousCompositorOutputSurface::OnReclaimResources( |
341 uint32_t output_surface_id, | 343 uint32_t output_surface_id, |
342 const cc::CompositorFrameAck& ack) { | 344 const cc::CompositorFrameAck& ack) { |
343 // Ignore message if it's a stale one coming from a different output surface | 345 // Ignore message if it's a stale one coming from a different output surface |
344 // (e.g. after a lost context). | 346 // (e.g. after a lost context). |
345 if (output_surface_id != output_surface_id_) | 347 if (output_surface_id != output_surface_id_) |
346 return; | 348 return; |
347 ReclaimResources(&ack); | 349 ReclaimResources(&ack); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 client_->ReclaimResources(&ack); | 404 client_->ReclaimResources(&ack); |
403 } | 405 } |
404 | 406 |
405 void SynchronousCompositorOutputSurface::SetBeginFrameSource( | 407 void SynchronousCompositorOutputSurface::SetBeginFrameSource( |
406 cc::BeginFrameSource* begin_frame_source) { | 408 cc::BeginFrameSource* begin_frame_source) { |
407 // Software output is synchronous and doesn't use a BeginFrameSource. | 409 // Software output is synchronous and doesn't use a BeginFrameSource. |
408 NOTREACHED(); | 410 NOTREACHED(); |
409 } | 411 } |
410 | 412 |
411 } // namespace content | 413 } // namespace content |
OLD | NEW |