Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: content/browser/gpu/browser_gpu_channel_host_factory.cc

Issue 302603004: Plumb GpuMemoryBuffer allocation to GPU process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 size_t width,
475 size_t height,
476 unsigned internalformat,
477 unsigned usage,
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 handle,
485 width,
486 height,
487 internalformat,
488 usage,
489 callback));
490 }
491
492 void BrowserGpuChannelHostFactory::DestroyGpuMemoryBuffer(
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::DestroyGpuMemoryBufferOnIO,
499 base::Unretained(this),
500 handle,
501 sync_point));
502 }
503
504 void BrowserGpuChannelHostFactory::CreateGpuMemoryBufferOnIO(
505 const gfx::GpuMemoryBufferHandle& handle,
506 size_t width,
507 size_t height,
508 unsigned internalformat,
509 unsigned usage,
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 handle,
519 width,
520 height,
521 internalformat,
522 usage,
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::DestroyGpuMemoryBufferOnIO(
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->DestroyGpuMemoryBuffer(handle, sync_point);
555 }
556
472 } // namespace content 557 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698