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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "content/common/gpu/image_transport_surface.h" | 7 #include "content/common/gpu/image_transport_surface.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 params.route_id = route_id_; | 150 params.route_id = route_id_; |
151 manager_->Send(new GpuHostMsg_AcceleratedSurfaceRelease(params)); | 151 manager_->Send(new GpuHostMsg_AcceleratedSurfaceRelease(params)); |
152 } | 152 } |
153 | 153 |
154 void ImageTransportHelper::SendResizeView(const gfx::Size& size) { | 154 void ImageTransportHelper::SendResizeView(const gfx::Size& size) { |
155 manager_->Send(new GpuHostMsg_ResizeView(stub_->surface_id(), | 155 manager_->Send(new GpuHostMsg_ResizeView(stub_->surface_id(), |
156 route_id_, | 156 route_id_, |
157 size)); | 157 size)); |
158 } | 158 } |
159 | 159 |
| 160 void ImageTransportHelper::SendUpdateVSyncParameters( |
| 161 base::TimeTicks timebase, base::TimeDelta interval) { |
| 162 manager_->Send(new GpuHostMsg_UpdateVSyncParameters(stub_->surface_id(), |
| 163 timebase, |
| 164 interval)); |
| 165 } |
| 166 |
160 void ImageTransportHelper::SetScheduled(bool is_scheduled) { | 167 void ImageTransportHelper::SetScheduled(bool is_scheduled) { |
161 gpu::GpuScheduler* scheduler = Scheduler(); | 168 gpu::GpuScheduler* scheduler = Scheduler(); |
162 if (!scheduler) | 169 if (!scheduler) |
163 return; | 170 return; |
164 | 171 |
165 scheduler->SetScheduled(is_scheduled); | 172 scheduler->SetScheduled(is_scheduled); |
166 } | 173 } |
167 | 174 |
168 void ImageTransportHelper::DeferToFence(base::Closure task) { | 175 void ImageTransportHelper::DeferToFence(base::Closure task) { |
169 gpu::GpuScheduler* scheduler = Scheduler(); | 176 gpu::GpuScheduler* scheduler = Scheduler(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 return helper_->Initialize(); | 271 return helper_->Initialize(); |
265 } | 272 } |
266 | 273 |
267 void PassThroughImageTransportSurface::Destroy() { | 274 void PassThroughImageTransportSurface::Destroy() { |
268 helper_->Destroy(); | 275 helper_->Destroy(); |
269 GLSurfaceAdapter::Destroy(); | 276 GLSurfaceAdapter::Destroy(); |
270 } | 277 } |
271 | 278 |
272 bool PassThroughImageTransportSurface::SwapBuffers() { | 279 bool PassThroughImageTransportSurface::SwapBuffers() { |
273 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); | 280 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); |
| 281 SendVSyncUpdateIfAvailable(); |
274 | 282 |
275 if (transport_) { | 283 if (transport_) { |
276 // Round trip to the browser UI thread, for throttling, by sending a dummy | 284 // Round trip to the browser UI thread, for throttling, by sending a dummy |
277 // SwapBuffers message. | 285 // SwapBuffers message. |
278 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 286 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
279 params.surface_handle = 0; | 287 params.surface_handle = 0; |
280 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 288 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
281 | 289 |
282 helper_->SetScheduled(false); | 290 helper_->SetScheduled(false); |
283 } | 291 } |
284 return result; | 292 return result; |
285 } | 293 } |
286 | 294 |
287 bool PassThroughImageTransportSurface::PostSubBuffer( | 295 bool PassThroughImageTransportSurface::PostSubBuffer( |
288 int x, int y, int width, int height) { | 296 int x, int y, int width, int height) { |
289 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); | 297 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); |
| 298 SendVSyncUpdateIfAvailable(); |
290 | 299 |
291 if (transport_) { | 300 if (transport_) { |
292 // Round trip to the browser UI thread, for throttling, by sending a dummy | 301 // Round trip to the browser UI thread, for throttling, by sending a dummy |
293 // PostSubBuffer message. | 302 // PostSubBuffer message. |
294 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | 303 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
295 params.surface_handle = 0; | 304 params.surface_handle = 0; |
296 params.x = x; | 305 params.x = x; |
297 params.y = y; | 306 params.y = y; |
298 params.width = width; | 307 params.width = width; |
299 params.height = height; | 308 params.height = height; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 Resize(new_size_); | 345 Resize(new_size_); |
337 } | 346 } |
338 } | 347 } |
339 | 348 |
340 gfx::Size PassThroughImageTransportSurface::GetSize() { | 349 gfx::Size PassThroughImageTransportSurface::GetSize() { |
341 return GLSurfaceAdapter::GetSize(); | 350 return GLSurfaceAdapter::GetSize(); |
342 } | 351 } |
343 | 352 |
344 PassThroughImageTransportSurface::~PassThroughImageTransportSurface() {} | 353 PassThroughImageTransportSurface::~PassThroughImageTransportSurface() {} |
345 | 354 |
| 355 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { |
| 356 base::TimeTicks timebase; |
| 357 base::TimeDelta interval; |
| 358 if (GetVSyncParameters(&timebase, &interval)) { |
| 359 helper_->SendUpdateVSyncParameters(timebase, interval); |
| 360 } |
| 361 } |
| 362 |
346 } // namespace content | 363 } // namespace content |
347 | 364 |
348 #endif // defined(ENABLE_GPU) | 365 #endif // defined(ENABLE_GPU) |
OLD | NEW |