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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 ~GpuSurfacelessBrowserCompositorOutputSurface() { | 56 ~GpuSurfacelessBrowserCompositorOutputSurface() { |
57 } | 57 } |
58 | 58 |
59 bool GpuSurfacelessBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() | 59 bool GpuSurfacelessBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() |
60 const { | 60 const { |
61 return true; | 61 return true; |
62 } | 62 } |
63 | 63 |
64 unsigned GpuSurfacelessBrowserCompositorOutputSurface::GetOverlayTextureId() | 64 unsigned GpuSurfacelessBrowserCompositorOutputSurface::GetOverlayTextureId() |
65 const { | 65 const { |
66 return buffer_queue_->current_texture_id(); | 66 return buffer_queue_->GetCurrentTextureId(); |
67 } | 67 } |
68 | 68 |
69 void GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers( | 69 void GpuSurfacelessBrowserCompositorOutputSurface::SwapBuffers( |
70 cc::OutputSurfaceFrame frame) { | 70 cc::OutputSurfaceFrame frame) { |
71 DCHECK(buffer_queue_); | 71 DCHECK(buffer_queue_); |
72 DCHECK(reshape_size_ == frame.size); | 72 DCHECK(reshape_size_ == frame.size); |
73 // TODO(ccameron): What if a swap comes again before OnGpuSwapBuffersCompleted | 73 // TODO(ccameron): What if a swap comes again before OnGpuSwapBuffersCompleted |
74 // happens, we'd see the wrong swap size there? | 74 // happens, we'd see the wrong swap size there? |
75 swap_size_ = reshape_size_; | 75 swap_size_ = reshape_size_; |
76 buffer_queue_->SwapBuffers(frame.sub_buffer_rect ? *frame.sub_buffer_rect | 76 |
77 : gfx::Rect(swap_size_)); | 77 gfx::Rect damage_rect = |
| 78 frame.sub_buffer_rect ? *frame.sub_buffer_rect : gfx::Rect(swap_size_); |
| 79 // Use previous buffer when damage rect is empty. This avoids unnecessary |
| 80 // partial swap work and makes it possible to support empty swaps on devices |
| 81 // where partial swaps are disabled. |
| 82 if (!damage_rect.IsEmpty()) |
| 83 buffer_queue_->SwapBuffers(damage_rect); |
| 84 |
78 GpuBrowserCompositorOutputSurface::SwapBuffers(std::move(frame)); | 85 GpuBrowserCompositorOutputSurface::SwapBuffers(std::move(frame)); |
79 } | 86 } |
80 | 87 |
81 void GpuSurfacelessBrowserCompositorOutputSurface::BindFramebuffer() { | 88 void GpuSurfacelessBrowserCompositorOutputSurface::BindFramebuffer() { |
82 DCHECK(buffer_queue_); | 89 DCHECK(buffer_queue_); |
83 buffer_queue_->BindFramebuffer(); | 90 buffer_queue_->BindFramebuffer(); |
84 } | 91 } |
85 | 92 |
86 GLenum GpuSurfacelessBrowserCompositorOutputSurface:: | 93 GLenum GpuSurfacelessBrowserCompositorOutputSurface:: |
87 GetFramebufferCopyTextureFormat() { | 94 GetFramebufferCopyTextureFormat() { |
(...skipping 26 matching lines...) Expand all Loading... |
114 force_swap = true; | 121 force_swap = true; |
115 } | 122 } |
116 buffer_queue_->PageFlipComplete(); | 123 buffer_queue_->PageFlipComplete(); |
117 GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( | 124 GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted( |
118 latency_info, result, params_mac); | 125 latency_info, result, params_mac); |
119 if (force_swap) | 126 if (force_swap) |
120 client_->SetNeedsRedrawRect(gfx::Rect(swap_size_)); | 127 client_->SetNeedsRedrawRect(gfx::Rect(swap_size_)); |
121 } | 128 } |
122 | 129 |
123 } // namespace content | 130 } // namespace content |
OLD | NEW |