| 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 "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" | 5 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s
urface.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/output_surface_client.h" | 10 #include "cc/output/output_surface_client.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // more closely with the previous surfaced behavior. | 41 // more closely with the previous surfaced behavior. |
| 42 // With a surface, swap buffer ack used to return early, before actually | 42 // With a surface, swap buffer ack used to return early, before actually |
| 43 // presenting the back buffer, enabling the browser compositor to run ahead. | 43 // presenting the back buffer, enabling the browser compositor to run ahead. |
| 44 // Surfaceless implementation acks at the time of actual buffer swap, which | 44 // Surfaceless implementation acks at the time of actual buffer swap, which |
| 45 // shifts the start of the new frame forward relative to the old | 45 // shifts the start of the new frame forward relative to the old |
| 46 // implementation. | 46 // implementation. |
| 47 capabilities_.max_frames_pending = 2; | 47 capabilities_.max_frames_pending = 2; |
| 48 | 48 |
| 49 gl_helper_.reset(new display_compositor::GLHelper( | 49 gl_helper_.reset(new display_compositor::GLHelper( |
| 50 context_provider_->ContextGL(), context_provider_->ContextSupport())); | 50 context_provider_->ContextGL(), context_provider_->ContextSupport())); |
| 51 output_surface_.reset(new display_compositor::BufferQueue( | 51 buffer_queue_.reset(new display_compositor::BufferQueue( |
| 52 context_provider_, target, internalformat_, gl_helper_.get(), | 52 context_provider_->ContextGL(), target, internalformat_, gl_helper_.get(), |
| 53 gpu_memory_buffer_manager_, surface_handle)); | 53 gpu_memory_buffer_manager_, surface_handle)); |
| 54 output_surface_->Initialize(); | 54 buffer_queue_->Initialize(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 GpuSurfacelessBrowserCompositorOutputSurface:: | 57 GpuSurfacelessBrowserCompositorOutputSurface:: |
| 58 ~GpuSurfacelessBrowserCompositorOutputSurface() { | 58 ~GpuSurfacelessBrowserCompositorOutputSurface() { |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool GpuSurfacelessBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() | 61 bool GpuSurfacelessBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() |
| 62 const { | 62 const { |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 unsigned GpuSurfacelessBrowserCompositorOutputSurface::GetOverlayTextureId() | 66 unsigned GpuSurfacelessBrowserCompositorOutputSurface::GetOverlayTextureId() |
| 67 const { | 67 const { |
| 68 return output_surface_->current_texture_id(); | 68 return buffer_queue_->current_texture_id(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers( | 71 void GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers( |
| 72 cc::CompositorFrame* frame) { | 72 cc::CompositorFrame* frame) { |
| 73 DCHECK(output_surface_); | 73 DCHECK(buffer_queue_); |
| 74 output_surface_->SwapBuffers(frame->gl_frame_data->sub_buffer_rect); | 74 buffer_queue_->SwapBuffers(frame->gl_frame_data->sub_buffer_rect); |
| 75 GpuBrowserCompositorOutputSurface::SwapBuffers(frame); | 75 GpuBrowserCompositorOutputSurface::SwapBuffers(frame); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void GpuSurfacelessBrowserCompositorOutputSurface::OnSwapBuffersComplete() { | 78 void GpuSurfacelessBrowserCompositorOutputSurface::OnSwapBuffersComplete() { |
| 79 DCHECK(output_surface_); | 79 DCHECK(buffer_queue_); |
| 80 output_surface_->PageFlipComplete(); | 80 buffer_queue_->PageFlipComplete(); |
| 81 GpuBrowserCompositorOutputSurface::OnSwapBuffersComplete(); | 81 GpuBrowserCompositorOutputSurface::OnSwapBuffersComplete(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void GpuSurfacelessBrowserCompositorOutputSurface::BindFramebuffer() { | 84 void GpuSurfacelessBrowserCompositorOutputSurface::BindFramebuffer() { |
| 85 DCHECK(output_surface_); | 85 DCHECK(buffer_queue_); |
| 86 output_surface_->BindFramebuffer(); | 86 buffer_queue_->BindFramebuffer(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void GpuSurfacelessBrowserCompositorOutputSurface::Reshape( | 89 void GpuSurfacelessBrowserCompositorOutputSurface::Reshape( |
| 90 const gfx::Size& size, | 90 const gfx::Size& size, |
| 91 float scale_factor, | 91 float scale_factor, |
| 92 bool alpha) { | 92 bool alpha) { |
| 93 GpuBrowserCompositorOutputSurface::Reshape(size, scale_factor, alpha); | 93 GpuBrowserCompositorOutputSurface::Reshape(size, scale_factor, alpha); |
| 94 DCHECK(output_surface_); | 94 DCHECK(buffer_queue_); |
| 95 output_surface_->Reshape(SurfaceSize(), scale_factor); | 95 buffer_queue_->Reshape(SurfaceSize(), scale_factor); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void GpuSurfacelessBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( | 98 void GpuSurfacelessBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( |
| 99 const std::vector<ui::LatencyInfo>& latency_info, | 99 const std::vector<ui::LatencyInfo>& latency_info, |
| 100 gfx::SwapResult result, | 100 gfx::SwapResult result, |
| 101 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { | 101 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { |
| 102 bool force_swap = false; | 102 bool force_swap = false; |
| 103 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { | 103 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { |
| 104 // Even through the swap failed, this is a fixable error so we can pretend | 104 // Even through the swap failed, this is a fixable error so we can pretend |
| 105 // it succeeded to the rest of the system. | 105 // it succeeded to the rest of the system. |
| 106 result = gfx::SwapResult::SWAP_ACK; | 106 result = gfx::SwapResult::SWAP_ACK; |
| 107 output_surface_->RecreateBuffers(); | 107 buffer_queue_->RecreateBuffers(); |
| 108 force_swap = true; | 108 force_swap = true; |
| 109 } | 109 } |
| 110 GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( | 110 GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( |
| 111 latency_info, result, params_mac); | 111 latency_info, result, params_mac); |
| 112 if (force_swap) | 112 if (force_swap) |
| 113 client_->SetNeedsRedrawRect(gfx::Rect(SurfaceSize())); | 113 client_->SetNeedsRedrawRect(gfx::Rect(SurfaceSize())); |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace content | 116 } // namespace content |
| OLD | NEW |