| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/gpu/image_transport_surface.h" | 5 #include "content/common/gpu/image_transport_surface.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 219 |
| 220 // We use WeakPtr here to avoid manual management of life time of an instance | 220 // We use WeakPtr here to avoid manual management of life time of an instance |
| 221 // of this class. Callback will not be called once the instance of this class | 221 // of this class. Callback will not be called once the instance of this class |
| 222 // is destroyed. However, this also means that the callback can be run on | 222 // is destroyed. However, this also means that the callback can be run on |
| 223 // the calling thread only. | 223 // the calling thread only. |
| 224 return gfx::GLSurfaceAdapter::PostSubBufferAsync(x, y, width, height, | 224 return gfx::GLSurfaceAdapter::PostSubBufferAsync(x, y, width, height, |
| 225 base::Bind(&PassThroughImageTransportSurface::SwapBuffersCallBack, | 225 base::Bind(&PassThroughImageTransportSurface::SwapBuffersCallBack, |
| 226 weak_ptr_factory_.GetWeakPtr())); | 226 weak_ptr_factory_.GetWeakPtr())); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void PassThroughImageTransportSurface::SwapBuffersCallBack() { | 229 void PassThroughImageTransportSurface::SwapBuffersCallBack(int result) { |
| 230 base::TimeTicks swap_ack_time = base::TimeTicks::Now(); | 230 base::TimeTicks swap_ack_time = base::TimeTicks::Now(); |
| 231 for (auto& latency : latency_info_) { | 231 for (auto& latency : latency_info_) { |
| 232 latency.AddLatencyNumberWithTimestamp( | 232 latency.AddLatencyNumberWithTimestamp( |
| 233 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, | 233 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, |
| 234 swap_ack_time, 1); | 234 swap_ack_time, 1); |
| 235 } | 235 } |
| 236 | 236 |
| 237 helper_->stub()->SendSwapBuffersCompleted(latency_info_); | 237 helper_->stub()->SendSwapBuffersCompleted(latency_info_, result); |
| 238 latency_info_.clear(); | 238 latency_info_.clear(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { | 241 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { |
| 242 if (!did_set_swap_interval_) { | 242 if (!did_set_swap_interval_) { |
| 243 ImageTransportHelper::SetSwapInterval(context); | 243 ImageTransportHelper::SetSwapInterval(context); |
| 244 did_set_swap_interval_ = true; | 244 did_set_swap_interval_ = true; |
| 245 } | 245 } |
| 246 return true; | 246 return true; |
| 247 } | 247 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 271 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { | 271 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { |
| 272 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); | 272 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); |
| 273 if (vsync_provider) { | 273 if (vsync_provider) { |
| 274 vsync_provider->GetVSyncParameters( | 274 vsync_provider->GetVSyncParameters( |
| 275 base::Bind(&GpuCommandBufferStub::SendUpdateVSyncParameters, | 275 base::Bind(&GpuCommandBufferStub::SendUpdateVSyncParameters, |
| 276 helper_->stub()->AsWeakPtr())); | 276 helper_->stub()->AsWeakPtr())); |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 | 279 |
| 280 } // namespace content | 280 } // namespace content |
| OLD | NEW |