| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/surfaces/direct_output_surface_ozone.h" | 5 #include "services/ui/surfaces/direct_output_surface_ozone.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // presenting the back buffer, enabling the browser compositor to run ahead. | 46 // presenting the back buffer, enabling the browser compositor to run ahead. |
| 47 // Surfaceless implementation acks at the time of actual buffer swap, which | 47 // Surfaceless implementation acks at the time of actual buffer swap, which |
| 48 // shifts the start of the new frame forward relative to the old | 48 // shifts the start of the new frame forward relative to the old |
| 49 // implementation. | 49 // implementation. |
| 50 capabilities_.max_frames_pending = 2; | 50 capabilities_.max_frames_pending = 2; |
| 51 | 51 |
| 52 buffer_queue_->Initialize(); | 52 buffer_queue_->Initialize(); |
| 53 | 53 |
| 54 context_provider->SetSwapBuffersCompletionCallback( | 54 context_provider->SetSwapBuffersCompletionCallback( |
| 55 base::Bind(&DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted, | 55 base::Bind(&DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted, |
| 56 base::Unretained(this))); | 56 weak_ptr_factory_.GetWeakPtr())); |
| 57 context_provider->SetUpdateVSyncParametersCallback( |
| 58 base::Bind(&DirectOutputSurfaceOzone::OnVSyncParametersUpdated, |
| 59 weak_ptr_factory_.GetWeakPtr())); |
| 57 } | 60 } |
| 58 | 61 |
| 59 DirectOutputSurfaceOzone::~DirectOutputSurfaceOzone() { | 62 DirectOutputSurfaceOzone::~DirectOutputSurfaceOzone() { |
| 60 // TODO(rjkroege): Support cleanup. | 63 // TODO(rjkroege): Support cleanup. |
| 61 } | 64 } |
| 62 | 65 |
| 63 void DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) { | 66 void DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) { |
| 64 DCHECK(client); | 67 DCHECK(client); |
| 65 DCHECK(!client_); | 68 DCHECK(!client_); |
| 66 client_ = client; | 69 client_ = client; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 bool DirectOutputSurfaceOzone::SurfaceIsSuspendForRecycle() const { | 136 bool DirectOutputSurfaceOzone::SurfaceIsSuspendForRecycle() const { |
| 134 return false; | 137 return false; |
| 135 } | 138 } |
| 136 | 139 |
| 137 bool DirectOutputSurfaceOzone::HasExternalStencilTest() const { | 140 bool DirectOutputSurfaceOzone::HasExternalStencilTest() const { |
| 138 return false; | 141 return false; |
| 139 } | 142 } |
| 140 | 143 |
| 141 void DirectOutputSurfaceOzone::ApplyExternalStencil() {} | 144 void DirectOutputSurfaceOzone::ApplyExternalStencil() {} |
| 142 | 145 |
| 143 void DirectOutputSurfaceOzone::OnUpdateVSyncParametersFromGpu( | |
| 144 base::TimeTicks timebase, | |
| 145 base::TimeDelta interval) { | |
| 146 DCHECK(client_); | |
| 147 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); | |
| 148 } | |
| 149 | |
| 150 void DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted( | 146 void DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted( |
| 151 const std::vector<ui::LatencyInfo>& latency_info, | 147 const std::vector<ui::LatencyInfo>& latency_info, |
| 152 gfx::SwapResult result, | 148 gfx::SwapResult result, |
| 153 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { | 149 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { |
| 154 bool force_swap = false; | 150 bool force_swap = false; |
| 155 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { | 151 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { |
| 156 // Even through the swap failed, this is a fixable error so we can pretend | 152 // Even through the swap failed, this is a fixable error so we can pretend |
| 157 // it succeeded to the rest of the system. | 153 // it succeeded to the rest of the system. |
| 158 result = gfx::SwapResult::SWAP_ACK; | 154 result = gfx::SwapResult::SWAP_ACK; |
| 159 buffer_queue_->RecreateBuffers(); | 155 buffer_queue_->RecreateBuffers(); |
| 160 force_swap = true; | 156 force_swap = true; |
| 161 } | 157 } |
| 162 | 158 |
| 163 buffer_queue_->PageFlipComplete(); | 159 buffer_queue_->PageFlipComplete(); |
| 164 client_->DidReceiveSwapBuffersAck(); | 160 client_->DidReceiveSwapBuffersAck(); |
| 165 | 161 |
| 166 if (force_swap) | 162 if (force_swap) |
| 167 client_->SetNeedsRedrawRect(gfx::Rect(swap_size_)); | 163 client_->SetNeedsRedrawRect(gfx::Rect(swap_size_)); |
| 168 } | 164 } |
| 169 | 165 |
| 166 void DirectOutputSurfaceOzone::OnVSyncParametersUpdated( |
| 167 base::TimeTicks timebase, |
| 168 base::TimeDelta interval) { |
| 169 // TODO(brianderson): We should not be receiving 0 intervals. |
| 170 synthetic_begin_frame_source_->OnUpdateVSyncParameters( |
| 171 timebase, |
| 172 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval); |
| 173 } |
| 174 |
| 170 } // namespace ui | 175 } // namespace ui |
| OLD | NEW |