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

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

Issue 540443002: Enable sync allocation of GpuMemoryBuffers from the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: formatting Created 6 years, 3 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 // static 485 // static
486 void BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferOnIO( 486 void BrowserGpuChannelHostFactory::AllocateGpuMemoryBufferOnIO(
487 AllocateGpuMemoryBufferRequest* request) { 487 AllocateGpuMemoryBufferRequest* request) {
488 if (!GpuMemoryBufferImpl::IsFormatValid(request->internalformat) || 488 if (!GpuMemoryBufferImpl::IsFormatValid(request->internalformat) ||
489 !GpuMemoryBufferImpl::IsUsageValid(request->usage)) { 489 !GpuMemoryBufferImpl::IsUsageValid(request->usage)) {
490 request->result = scoped_ptr<gfx::GpuMemoryBuffer>(); 490 request->result = scoped_ptr<gfx::GpuMemoryBuffer>();
491 request->event.Signal(); 491 request->event.Signal();
492 return; 492 return;
493 } 493 }
494 494
495 request->result = GpuMemoryBufferImpl::Create( 495 GpuMemoryBufferImpl::Create(
496 gfx::Size(request->width, request->height), 496 gfx::Size(request->width, request->height),
497 request->internalformat, 497 request->internalformat,
498 request->usage).PassAs<gfx::GpuMemoryBuffer>(); 498 request->usage,
499 request->event.Signal(); 499 base::Bind(&BrowserGpuChannelHostFactory::GpuMemoryBufferImplCreatedOnIO,
500 base::Unretained(request)));
500 } 501 }
501 502
502 // static 503 // static
503 void BrowserGpuChannelHostFactory::DeleteGpuMemoryBufferOnIO( 504 void BrowserGpuChannelHostFactory::DeleteGpuMemoryBufferOnIO(
504 scoped_ptr<gfx::GpuMemoryBuffer> buffer) { 505 scoped_ptr<gfx::GpuMemoryBuffer> buffer) {
505 } 506 }
506 507
508 // static
509 void BrowserGpuChannelHostFactory::GpuMemoryBufferImplCreatedOnIO(
reveman 2014/09/09 17:18:26 I think this should be named "OnGpuMemoryBufferCre
alexst (slow to review) 2014/09/09 21:53:57 Yeah, the namespace is getting crowded, I'll add G
510 AllocateGpuMemoryBufferRequest* request,
511 scoped_ptr<GpuMemoryBufferImpl> buffer) {
512 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
reveman 2014/09/09 17:18:26 nit: blank line after this DCHECK to be consistent
alexst (slow to review) 2014/09/09 21:53:56 Done.
513 request->result = buffer.PassAs<gfx::GpuMemoryBuffer>();
514 request->event.Signal();
515 }
516
507 void BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated( 517 void BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated(
508 uint32 request_id, 518 uint32 request_id,
509 const gfx::GpuMemoryBufferHandle& handle) { 519 const gfx::GpuMemoryBufferHandle& handle) {
510 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 520 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
511 521
512 CreateGpuMemoryBufferCallbackMap::iterator iter = 522 CreateGpuMemoryBufferCallbackMap::iterator iter =
513 create_gpu_memory_buffer_requests_.find(request_id); 523 create_gpu_memory_buffer_requests_.find(request_id);
514 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); 524 DCHECK(iter != create_gpu_memory_buffer_requests_.end());
515 iter->second.Run(handle); 525 iter->second.Run(handle);
516 create_gpu_memory_buffer_requests_.erase(iter); 526 create_gpu_memory_buffer_requests_.erase(iter);
517 } 527 }
518 528
519 } // namespace content 529 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698