| 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/browser/gpu/browser_gpu_channel_host_factory.h" | 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // so it won't cause additional jank. | 289 // so it won't cause additional jank. |
| 290 // TODO(piman): Make this asynchronous (http://crbug.com/125248). | 290 // TODO(piman): Make this asynchronous (http://crbug.com/125248). |
| 291 TRACE_EVENT0("browser", | 291 TRACE_EVENT0("browser", |
| 292 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer"); | 292 "BrowserGpuChannelHostFactory::CreateViewCommandBuffer"); |
| 293 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 293 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 294 request.event.Wait(); | 294 request.event.Wait(); |
| 295 return request.succeeded; | 295 return request.succeeded; |
| 296 } | 296 } |
| 297 | 297 |
| 298 void BrowserGpuChannelHostFactory::CreateImageOnIO( | 298 void BrowserGpuChannelHostFactory::CreateImageOnIO( |
| 299 gfx::PluginWindowHandle window, | 299 const gfx::GpuMemoryBufferHandle& handle, |
| 300 const gfx::Size& size, |
| 301 unsigned internalformat, |
| 300 int32 image_id, | 302 int32 image_id, |
| 301 const CreateImageCallback& callback) { | 303 const CreateImageCallback& callback) { |
| 302 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); | 304 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
| 303 if (!host) { | 305 if (!host) { |
| 304 ImageCreatedOnIO(callback, gfx::Size()); | 306 ImageCreatedOnIO(callback, false); |
| 305 return; | 307 return; |
| 306 } | 308 } |
| 307 | 309 |
| 308 host->CreateImage( | 310 host->CreateImage( |
| 309 window, | 311 handle, |
| 312 size, |
| 313 internalformat, |
| 310 gpu_client_id_, | 314 gpu_client_id_, |
| 311 image_id, | 315 image_id, |
| 312 base::Bind(&BrowserGpuChannelHostFactory::ImageCreatedOnIO, callback)); | 316 base::Bind(&BrowserGpuChannelHostFactory::ImageCreatedOnIO, callback)); |
| 313 } | 317 } |
| 314 | 318 |
| 315 // static | 319 // static |
| 316 void BrowserGpuChannelHostFactory::ImageCreatedOnIO( | 320 void BrowserGpuChannelHostFactory::ImageCreatedOnIO( |
| 317 const CreateImageCallback& callback, const gfx::Size size) { | 321 const CreateImageCallback& callback, bool succeeded) { |
| 318 BrowserThread::PostTask( | 322 BrowserThread::PostTask( |
| 319 BrowserThread::UI, | 323 BrowserThread::UI, |
| 320 FROM_HERE, | 324 FROM_HERE, |
| 321 base::Bind(&BrowserGpuChannelHostFactory::OnImageCreated, | 325 base::Bind(&BrowserGpuChannelHostFactory::OnImageCreated, |
| 322 callback, size)); | 326 callback, succeeded)); |
| 323 } | 327 } |
| 324 | 328 |
| 325 // static | 329 // static |
| 326 void BrowserGpuChannelHostFactory::OnImageCreated( | 330 void BrowserGpuChannelHostFactory::OnImageCreated( |
| 327 const CreateImageCallback& callback, const gfx::Size size) { | 331 const CreateImageCallback& callback, bool succeeded) { |
| 328 callback.Run(size); | 332 callback.Run(succeeded); |
| 329 } | 333 } |
| 330 | 334 |
| 331 void BrowserGpuChannelHostFactory::CreateImage( | 335 void BrowserGpuChannelHostFactory::CreateImage( |
| 332 gfx::PluginWindowHandle window, | 336 const gfx::GpuMemoryBufferHandle& handle, |
| 337 const gfx::Size& size, |
| 338 unsigned internalformat, |
| 333 int32 image_id, | 339 int32 image_id, |
| 334 const CreateImageCallback& callback) { | 340 const CreateImageCallback& callback) { |
| 335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 341 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 336 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind( | 342 GetIOLoopProxy()->PostTask(FROM_HERE, base::Bind( |
| 337 &BrowserGpuChannelHostFactory::CreateImageOnIO, | 343 &BrowserGpuChannelHostFactory::CreateImageOnIO, |
| 338 base::Unretained(this), | 344 base::Unretained(this), |
| 339 window, | 345 handle, |
| 346 size, |
| 347 internalformat, |
| 340 image_id, | 348 image_id, |
| 341 callback)); | 349 callback)); |
| 342 } | 350 } |
| 343 | 351 |
| 344 void BrowserGpuChannelHostFactory::DeleteImageOnIO( | 352 void BrowserGpuChannelHostFactory::DeleteImageOnIO( |
| 345 int32 image_id, int32 sync_point) { | 353 int32 image_id, int32 sync_point) { |
| 346 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); | 354 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
| 347 if (!host) { | 355 if (!host) { |
| 348 return; | 356 return; |
| 349 } | 357 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 const gfx::GpuMemoryBufferHandle& handle, | 558 const gfx::GpuMemoryBufferHandle& handle, |
| 551 int32 sync_point) { | 559 int32 sync_point) { |
| 552 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); | 560 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
| 553 if (!host) | 561 if (!host) |
| 554 return; | 562 return; |
| 555 | 563 |
| 556 host->DestroyGpuMemoryBuffer(handle, sync_point); | 564 host->DestroyGpuMemoryBuffer(handle, sync_point); |
| 557 } | 565 } |
| 558 | 566 |
| 559 } // namespace content | 567 } // namespace content |
| OLD | NEW |