| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); | 113 manager_->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void ImageTransportHelper::SendUpdateVSyncParameters( | 116 void ImageTransportHelper::SendUpdateVSyncParameters( |
| 117 base::TimeTicks timebase, base::TimeDelta interval) { | 117 base::TimeTicks timebase, base::TimeDelta interval) { |
| 118 manager_->Send(new GpuHostMsg_UpdateVSyncParameters(stub_->surface_id(), | 118 manager_->Send(new GpuHostMsg_UpdateVSyncParameters(stub_->surface_id(), |
| 119 timebase, | 119 timebase, |
| 120 interval)); | 120 interval)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void ImageTransportHelper::SendLatencyInfo( | 123 void ImageTransportHelper::SwapBuffersCompleted( |
| 124 const std::vector<ui::LatencyInfo>& latency_info) { | 124 const std::vector<ui::LatencyInfo>& latency_info) { |
| 125 manager_->Send(new GpuHostMsg_FrameDrawn(latency_info)); | 125 stub_->SwapBuffersCompleted(latency_info); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void ImageTransportHelper::SetScheduled(bool is_scheduled) { | 128 void ImageTransportHelper::SetScheduled(bool is_scheduled) { |
| 129 gpu::GpuScheduler* scheduler = Scheduler(); | 129 gpu::GpuScheduler* scheduler = Scheduler(); |
| 130 if (!scheduler) | 130 if (!scheduler) |
| 131 return; | 131 return; |
| 132 | 132 |
| 133 scheduler->SetScheduled(is_scheduled); | 133 scheduler->SetScheduled(is_scheduled); |
| 134 } | 134 } |
| 135 | 135 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 for (size_t i = 0; i < latency_info_.size(); ++i) { | 238 for (size_t i = 0; i < latency_info_.size(); ++i) { |
| 239 latency_info_[i].AddLatencyNumber( | 239 latency_info_[i].AddLatencyNumber( |
| 240 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0); | 240 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0); |
| 241 } | 241 } |
| 242 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); | 242 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); |
| 243 for (size_t i = 0; i < latency_info_.size(); i++) { | 243 for (size_t i = 0; i < latency_info_.size(); i++) { |
| 244 latency_info_[i].AddLatencyNumber( | 244 latency_info_[i].AddLatencyNumber( |
| 245 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); | 245 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); |
| 246 } | 246 } |
| 247 | 247 |
| 248 helper_->SendLatencyInfo(latency_info_); | 248 helper_->SwapBuffersCompleted(latency_info_); |
| 249 latency_info_.clear(); | 249 latency_info_.clear(); |
| 250 return result; | 250 return result; |
| 251 } | 251 } |
| 252 | 252 |
| 253 bool PassThroughImageTransportSurface::PostSubBuffer( | 253 bool PassThroughImageTransportSurface::PostSubBuffer( |
| 254 int x, int y, int width, int height) { | 254 int x, int y, int width, int height) { |
| 255 SendVSyncUpdateIfAvailable(); | 255 SendVSyncUpdateIfAvailable(); |
| 256 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); | 256 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); |
| 257 for (size_t i = 0; i < latency_info_.size(); i++) { | 257 for (size_t i = 0; i < latency_info_.size(); i++) { |
| 258 latency_info_[i].AddLatencyNumber( | 258 latency_info_[i].AddLatencyNumber( |
| 259 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); | 259 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); |
| 260 } | 260 } |
| 261 | 261 |
| 262 helper_->SendLatencyInfo(latency_info_); | 262 helper_->SwapBuffersCompleted(latency_info_); |
| 263 latency_info_.clear(); | 263 latency_info_.clear(); |
| 264 return result; | 264 return result; |
| 265 } | 265 } |
| 266 | 266 |
| 267 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { | 267 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { |
| 268 if (!did_set_swap_interval_) { | 268 if (!did_set_swap_interval_) { |
| 269 ImageTransportHelper::SetSwapInterval(context); | 269 ImageTransportHelper::SetSwapInterval(context); |
| 270 did_set_swap_interval_ = true; | 270 did_set_swap_interval_ = true; |
| 271 } | 271 } |
| 272 return true; | 272 return true; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 297 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { | 297 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { |
| 298 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); | 298 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); |
| 299 if (vsync_provider) { | 299 if (vsync_provider) { |
| 300 vsync_provider->GetVSyncParameters( | 300 vsync_provider->GetVSyncParameters( |
| 301 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters, | 301 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters, |
| 302 helper_->AsWeakPtr())); | 302 helper_->AsWeakPtr())); |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 | 305 |
| 306 } // namespace content | 306 } // namespace content |
| OLD | NEW |