| 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/output_surface_client.h" | 9 #include "cc/output/output_surface_client.h" |
| 10 #include "cc/output/output_surface_frame.h" | 10 #include "cc/output/output_surface_frame.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 unsigned int target, | 28 unsigned int target, |
| 29 unsigned int internalformat, | 29 unsigned int internalformat, |
| 30 gfx::BufferFormat format, | 30 gfx::BufferFormat format, |
| 31 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) | 31 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) |
| 32 : GpuBrowserCompositorOutputSurface(std::move(context), | 32 : GpuBrowserCompositorOutputSurface(std::move(context), |
| 33 update_vsync_parameters_callback, | 33 update_vsync_parameters_callback, |
| 34 std::move(overlay_candidate_validator)), | 34 std::move(overlay_candidate_validator)), |
| 35 gpu_memory_buffer_manager_(gpu_memory_buffer_manager) { | 35 gpu_memory_buffer_manager_(gpu_memory_buffer_manager) { |
| 36 capabilities_.uses_default_gl_framebuffer = false; | 36 capabilities_.uses_default_gl_framebuffer = false; |
| 37 capabilities_.flipped_output_surface = true; | 37 capabilities_.flipped_output_surface = true; |
| 38 capabilities_.supports_stencil = true; |
| 38 // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling | 39 // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling |
| 39 // more closely with the previous surfaced behavior. | 40 // more closely with the previous surfaced behavior. |
| 40 // With a surface, swap buffer ack used to return early, before actually | 41 // With a surface, swap buffer ack used to return early, before actually |
| 41 // presenting the back buffer, enabling the browser compositor to run ahead. | 42 // presenting the back buffer, enabling the browser compositor to run ahead. |
| 42 // Surfaceless implementation acks at the time of actual buffer swap, which | 43 // Surfaceless implementation acks at the time of actual buffer swap, which |
| 43 // shifts the start of the new frame forward relative to the old | 44 // shifts the start of the new frame forward relative to the old |
| 44 // implementation. | 45 // implementation. |
| 45 capabilities_.max_frames_pending = 2; | 46 capabilities_.max_frames_pending = 2; |
| 46 | 47 |
| 47 gl_helper_.reset(new display_compositor::GLHelper( | 48 gl_helper_.reset(new display_compositor::GLHelper( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 85 |
| 85 GLenum GpuSurfacelessBrowserCompositorOutputSurface:: | 86 GLenum GpuSurfacelessBrowserCompositorOutputSurface:: |
| 86 GetFramebufferCopyTextureFormat() { | 87 GetFramebufferCopyTextureFormat() { |
| 87 return buffer_queue_->internal_format(); | 88 return buffer_queue_->internal_format(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void GpuSurfacelessBrowserCompositorOutputSurface::Reshape( | 91 void GpuSurfacelessBrowserCompositorOutputSurface::Reshape( |
| 91 const gfx::Size& size, | 92 const gfx::Size& size, |
| 92 float device_scale_factor, | 93 float device_scale_factor, |
| 93 const gfx::ColorSpace& color_space, | 94 const gfx::ColorSpace& color_space, |
| 94 bool has_alpha) { | 95 bool has_alpha, |
| 96 bool use_stencil) { |
| 95 reshape_size_ = size; | 97 reshape_size_ = size; |
| 96 GpuBrowserCompositorOutputSurface::Reshape(size, device_scale_factor, | 98 GpuBrowserCompositorOutputSurface::Reshape( |
| 97 color_space, has_alpha); | 99 size, device_scale_factor, color_space, has_alpha, use_stencil); |
| 98 DCHECK(buffer_queue_); | 100 DCHECK(buffer_queue_); |
| 99 buffer_queue_->Reshape(size, device_scale_factor, color_space); | 101 buffer_queue_->Reshape(size, device_scale_factor, color_space, use_stencil); |
| 100 } | 102 } |
| 101 | 103 |
| 102 void GpuSurfacelessBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( | 104 void GpuSurfacelessBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( |
| 103 const std::vector<ui::LatencyInfo>& latency_info, | 105 const std::vector<ui::LatencyInfo>& latency_info, |
| 104 gfx::SwapResult result, | 106 gfx::SwapResult result, |
| 105 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { | 107 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { |
| 106 bool force_swap = false; | 108 bool force_swap = false; |
| 107 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { | 109 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { |
| 108 // Even through the swap failed, this is a fixable error so we can pretend | 110 // Even through the swap failed, this is a fixable error so we can pretend |
| 109 // it succeeded to the rest of the system. | 111 // it succeeded to the rest of the system. |
| 110 result = gfx::SwapResult::SWAP_ACK; | 112 result = gfx::SwapResult::SWAP_ACK; |
| 111 buffer_queue_->RecreateBuffers(); | 113 buffer_queue_->RecreateBuffers(); |
| 112 force_swap = true; | 114 force_swap = true; |
| 113 } | 115 } |
| 114 buffer_queue_->PageFlipComplete(); | 116 buffer_queue_->PageFlipComplete(); |
| 115 GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( | 117 GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( |
| 116 latency_info, result, params_mac); | 118 latency_info, result, params_mac); |
| 117 if (force_swap) | 119 if (force_swap) |
| 118 client_->SetNeedsRedrawRect(gfx::Rect(swap_size_)); | 120 client_->SetNeedsRedrawRect(gfx::Rect(swap_size_)); |
| 119 } | 121 } |
| 120 | 122 |
| 121 } // namespace content | 123 } // namespace content |
| OLD | NEW |