| 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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 void PassThroughImageTransportSurface::SetLatencyInfo( | 244 void PassThroughImageTransportSurface::SetLatencyInfo( |
| 245 const ui::LatencyInfo& latency_info) { | 245 const ui::LatencyInfo& latency_info) { |
| 246 latency_info_ = latency_info; | 246 latency_info_ = latency_info; |
| 247 } | 247 } |
| 248 | 248 |
| 249 bool PassThroughImageTransportSurface::SwapBuffers() { | 249 bool PassThroughImageTransportSurface::SwapBuffers() { |
| 250 // GetVsyncValues before SwapBuffers to work around Mali driver bug: | 250 // GetVsyncValues before SwapBuffers to work around Mali driver bug: |
| 251 // crbug.com/223558. | 251 // crbug.com/223558. |
| 252 SendVSyncUpdateIfAvailable(); | 252 SendVSyncUpdateIfAvailable(); |
| 253 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); | 253 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); |
| 254 latency_info_.swap_timestamp = base::TimeTicks::HighResNow(); | 254 latency_info_.Report(ui::INPUT_EVENT_LATENCY_FRAME_SWAP_COMPONENT); |
| 255 | 255 |
| 256 if (transport_) { | 256 if (transport_) { |
| 257 DCHECK(!is_swap_buffers_pending_); | 257 DCHECK(!is_swap_buffers_pending_); |
| 258 is_swap_buffers_pending_ = true; | 258 is_swap_buffers_pending_ = true; |
| 259 | 259 |
| 260 // Round trip to the browser UI thread, for throttling, by sending a dummy | 260 // Round trip to the browser UI thread, for throttling, by sending a dummy |
| 261 // SwapBuffers message. | 261 // SwapBuffers message. |
| 262 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 262 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
| 263 params.surface_handle = 0; | 263 params.surface_handle = 0; |
| 264 params.latency_info = latency_info_; | 264 params.latency_info = latency_info_; |
| 265 params.size = surface()->GetSize(); | 265 params.size = surface()->GetSize(); |
| 266 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 266 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
| 267 } else { | 267 } else { |
| 268 helper_->SendLatencyInfo(latency_info_); | 268 helper_->SendLatencyInfo(latency_info_); |
| 269 } | 269 } |
| 270 return result; | 270 return result; |
| 271 } | 271 } |
| 272 | 272 |
| 273 bool PassThroughImageTransportSurface::PostSubBuffer( | 273 bool PassThroughImageTransportSurface::PostSubBuffer( |
| 274 int x, int y, int width, int height) { | 274 int x, int y, int width, int height) { |
| 275 SendVSyncUpdateIfAvailable(); | 275 SendVSyncUpdateIfAvailable(); |
| 276 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); | 276 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); |
| 277 latency_info_.swap_timestamp = base::TimeTicks::HighResNow(); | 277 latency_info_.Report(ui::INPUT_EVENT_LATENCY_FRAME_SWAP_COMPONENT); |
| 278 | 278 |
| 279 if (transport_) { | 279 if (transport_) { |
| 280 DCHECK(!is_swap_buffers_pending_); | 280 DCHECK(!is_swap_buffers_pending_); |
| 281 is_swap_buffers_pending_ = true; | 281 is_swap_buffers_pending_ = true; |
| 282 | 282 |
| 283 // Round trip to the browser UI thread, for throttling, by sending a dummy | 283 // Round trip to the browser UI thread, for throttling, by sending a dummy |
| 284 // PostSubBuffer message. | 284 // PostSubBuffer message. |
| 285 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | 285 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
| 286 params.surface_handle = 0; | 286 params.surface_handle = 0; |
| 287 params.latency_info = latency_info_; | 287 params.latency_info = latency_info_; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { | 349 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { |
| 350 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); | 350 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); |
| 351 if (vsync_provider) { | 351 if (vsync_provider) { |
| 352 vsync_provider->GetVSyncParameters( | 352 vsync_provider->GetVSyncParameters( |
| 353 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters, | 353 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters, |
| 354 helper_->AsWeakPtr())); | 354 helper_->AsWeakPtr())); |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 | 357 |
| 358 } // namespace content | 358 } // namespace content |
| OLD | NEW |