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::CreateGpuMemoryBuffer( |
| 473 const gfx::GpuMemoryBufferHandle& handle, |
| 474 const gfx::Size& size, |
| 475 unsigned internalformat, |
| 476 unsigned usage, |
| 477 const CreateGpuMemoryBufferCallback& callback) { |
| 478 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 479 GetIOLoopProxy()->PostTask( |
| 480 FROM_HERE, |
| 481 base::Bind(&BrowserGpuChannelHostFactory::CreateGpuMemoryBufferOnIO, |
| 482 base::Unretained(this), |
| 483 handle, |
| 484 size, |
| 485 internalformat, |
| 486 usage, |
| 487 callback)); |
| 488 } |
| 489 |
| 490 void BrowserGpuChannelHostFactory::DestroyGpuMemoryBuffer( |
| 491 const gfx::GpuMemoryBufferHandle& handle, |
| 492 int32 sync_point) { |
| 493 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 494 GetIOLoopProxy()->PostTask( |
| 495 FROM_HERE, |
| 496 base::Bind(&BrowserGpuChannelHostFactory::DestroyGpuMemoryBufferOnIO, |
| 497 base::Unretained(this), |
| 498 handle, |
| 499 sync_point)); |
| 500 } |
| 501 |
| 502 void BrowserGpuChannelHostFactory::CreateGpuMemoryBufferOnIO( |
| 503 const gfx::GpuMemoryBufferHandle& handle, |
| 504 const gfx::Size& size, |
| 505 unsigned internalformat, |
| 506 unsigned usage, |
| 507 const CreateGpuMemoryBufferCallback& callback) { |
| 508 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
| 509 if (!host) { |
| 510 GpuMemoryBufferCreatedOnIO(callback, gfx::GpuMemoryBufferHandle()); |
| 511 return; |
| 512 } |
| 513 |
| 514 host->CreateGpuMemoryBuffer( |
| 515 handle, |
| 516 size, |
| 517 internalformat, |
| 518 usage, |
| 519 base::Bind(&BrowserGpuChannelHostFactory::GpuMemoryBufferCreatedOnIO, |
| 520 callback)); |
| 521 } |
| 522 |
| 523 // static |
| 524 void BrowserGpuChannelHostFactory::GpuMemoryBufferCreatedOnIO( |
| 525 const CreateGpuMemoryBufferCallback& callback, |
| 526 const gfx::GpuMemoryBufferHandle& handle) { |
| 527 BrowserThread::PostTask( |
| 528 BrowserThread::UI, |
| 529 FROM_HERE, |
| 530 base::Bind(&BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated, |
| 531 callback, |
| 532 handle)); |
| 533 } |
| 534 |
| 535 // static |
| 536 void BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated( |
| 537 const CreateGpuMemoryBufferCallback& callback, |
| 538 const gfx::GpuMemoryBufferHandle& handle) { |
| 539 callback.Run(handle); |
| 540 } |
| 541 |
| 542 void BrowserGpuChannelHostFactory::DestroyGpuMemoryBufferOnIO( |
| 543 const gfx::GpuMemoryBufferHandle& handle, |
| 544 int32 sync_point) { |
| 545 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
| 546 if (!host) { |
| 547 return; |
| 548 } |
| 549 |
| 550 host->DestroyGpuMemoryBuffer(handle, sync_point); |
| 551 } |
| 552 |
472 } // namespace content | 553 } // namespace content |
OLD | NEW |