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