| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 return helper_->Initialize(); | 270 return helper_->Initialize(); |
| 264 } | 271 } |
| 265 | 272 |
| 266 void PassThroughImageTransportSurface::Destroy() { | 273 void PassThroughImageTransportSurface::Destroy() { |
| 267 helper_->Destroy(); | 274 helper_->Destroy(); |
| 268 GLSurfaceAdapter::Destroy(); | 275 GLSurfaceAdapter::Destroy(); |
| 269 } | 276 } |
| 270 | 277 |
| 271 bool PassThroughImageTransportSurface::SwapBuffers() { | 278 bool PassThroughImageTransportSurface::SwapBuffers() { |
| 272 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); | 279 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); |
| 280 SendVSyncUpdateIfAvailable(); |
| 273 | 281 |
| 274 if (transport_) { | 282 if (transport_) { |
| 275 // 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 |
| 276 // SwapBuffers message. | 284 // SwapBuffers message. |
| 277 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 285 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
| 278 params.surface_handle = 0; | 286 params.surface_handle = 0; |
| 279 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 287 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
| 280 | 288 |
| 281 helper_->SetScheduled(false); | 289 helper_->SetScheduled(false); |
| 282 } | 290 } |
| 283 return result; | 291 return result; |
| 284 } | 292 } |
| 285 | 293 |
| 286 bool PassThroughImageTransportSurface::PostSubBuffer( | 294 bool PassThroughImageTransportSurface::PostSubBuffer( |
| 287 int x, int y, int width, int height) { | 295 int x, int y, int width, int height) { |
| 288 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); | 296 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); |
| 297 SendVSyncUpdateIfAvailable(); |
| 289 | 298 |
| 290 if (transport_) { | 299 if (transport_) { |
| 291 // Round trip to the browser UI thread, for throttling, by sending a dummy | 300 // Round trip to the browser UI thread, for throttling, by sending a dummy |
| 292 // PostSubBuffer message. | 301 // PostSubBuffer message. |
| 293 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; | 302 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
| 294 params.surface_handle = 0; | 303 params.surface_handle = 0; |
| 295 params.x = x; | 304 params.x = x; |
| 296 params.y = y; | 305 params.y = y; |
| 297 params.width = width; | 306 params.width = width; |
| 298 params.height = height; | 307 params.height = height; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 Resize(new_size_); | 342 Resize(new_size_); |
| 334 } | 343 } |
| 335 } | 344 } |
| 336 | 345 |
| 337 gfx::Size PassThroughImageTransportSurface::GetSize() { | 346 gfx::Size PassThroughImageTransportSurface::GetSize() { |
| 338 return GLSurfaceAdapter::GetSize(); | 347 return GLSurfaceAdapter::GetSize(); |
| 339 } | 348 } |
| 340 | 349 |
| 341 PassThroughImageTransportSurface::~PassThroughImageTransportSurface() {} | 350 PassThroughImageTransportSurface::~PassThroughImageTransportSurface() {} |
| 342 | 351 |
| 352 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { |
| 353 #if defined(USE_AURA) |
| 354 base::TimeTicks timebase; |
| 355 base::TimeDelta interval; |
| 356 if (GetVSyncParameters(&timebase, &interval)) { |
| 357 helper_->SendUpdateVSyncParameters(timebase, interval); |
| 358 } |
| 359 #endif |
| 360 } |
| 361 |
| 343 } // namespace content | 362 } // namespace content |
| 344 | 363 |
| 345 #endif // defined(ENABLE_GPU) | 364 #endif // defined(ENABLE_GPU) |
| OLD | NEW |