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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 target_task_runner); | 462 target_task_runner); |
463 filter->AddRoute(MSG_ROUTING_CONTROL, handler); | 463 filter->AddRoute(MSG_ROUTING_CONTROL, handler); |
464 | 464 |
465 GetIOLoopProxy()->PostTask( | 465 GetIOLoopProxy()->PostTask( |
466 FROM_HERE, | 466 FROM_HERE, |
467 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, | 467 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, |
468 gpu_host_id_, | 468 gpu_host_id_, |
469 filter)); | 469 filter)); |
470 } | 470 } |
471 | 471 |
| 472 void BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferAsync( |
| 473 const gfx::GpuMemoryBufferParams& params, |
| 474 const AllocateGpuMemoryBufferCallback& callback) { |
| 475 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 476 GetIOLoopProxy()->PostTask( |
| 477 FROM_HERE, |
| 478 base::Bind( |
| 479 &BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferAsyncOnIO, |
| 480 base::Unretained(this), |
| 481 params, |
| 482 callback)); |
| 483 } |
| 484 |
| 485 void BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferAsyncOnIO( |
| 486 const gfx::GpuMemoryBufferParams& params, |
| 487 const AllocateGpuMemoryBufferCallback& callback) { |
| 488 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
| 489 if (!host) { |
| 490 GpuMemoryBufferAllocatedAsyncOnIO(callback, gfx::GpuMemoryBufferHandle()); |
| 491 return; |
| 492 } |
| 493 |
| 494 host->AllocateGpuMemoryBuffer( |
| 495 params, |
| 496 base::Bind( |
| 497 &BrowserGpuChannelHostFactory::GpuMemoryBufferAllocatedAsyncOnIO, |
| 498 callback)); |
| 499 } |
| 500 |
| 501 // static |
| 502 void BrowserGpuChannelHostFactory::GpuMemoryBufferAllocatedAsyncOnIO( |
| 503 const AllocateGpuMemoryBufferCallback& callback, |
| 504 const gfx::GpuMemoryBufferHandle& handle) { |
| 505 BrowserThread::PostTask( |
| 506 BrowserThread::UI, |
| 507 FROM_HERE, |
| 508 base::Bind(&BrowserGpuChannelHostFactory::GpuMemoryBufferAllocatedAsync, |
| 509 callback, |
| 510 handle)); |
| 511 } |
| 512 |
| 513 // static |
| 514 void BrowserGpuChannelHostFactory::GpuMemoryBufferAllocatedAsync( |
| 515 const AllocateGpuMemoryBufferCallback& callback, |
| 516 const gfx::GpuMemoryBufferHandle& handle) { |
| 517 callback.Run(handle); |
| 518 } |
| 519 |
472 } // namespace content | 520 } // namespace content |
OLD | NEW |