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

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

Issue 1375663002: Show GpuMemoryBuffer feature in chrome://gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cl formatted and removed "Formats"/"Native usage support" value pair Created 5 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_memory_buffer_manager.h" 5 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 continue; 417 continue;
418 418
419 GpuProcessHost* host = GpuProcessHost::FromID(buffer.second.gpu_host_id); 419 GpuProcessHost* host = GpuProcessHost::FromID(buffer.second.gpu_host_id);
420 if (host) 420 if (host)
421 host->DestroyGpuMemoryBuffer(buffer.first, client_id, 0); 421 host->DestroyGpuMemoryBuffer(buffer.first, client_id, 0);
422 } 422 }
423 423
424 clients_.erase(client_it); 424 clients_.erase(client_it);
425 } 425 }
426 426
427 bool BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBufferConfiguration(
428 gfx::BufferFormat format,
429 gfx::BufferUsage usage) const {
430 return native_configurations_.find(std::make_pair(format, usage)) !=
431 native_configurations_.end();
432 }
433
427 scoped_ptr<gfx::GpuMemoryBuffer> 434 scoped_ptr<gfx::GpuMemoryBuffer>
428 BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface( 435 BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface(
429 const gfx::Size& size, 436 const gfx::Size& size,
430 gfx::BufferFormat format, 437 gfx::BufferFormat format,
431 gfx::BufferUsage usage, 438 gfx::BufferUsage usage,
432 int32 surface_id) { 439 int32 surface_id) {
433 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); 440 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
434 441
435 CreateGpuMemoryBufferRequest request(size, format, usage, gpu_client_id_, 442 CreateGpuMemoryBufferRequest request(size, format, usage, gpu_client_id_,
436 surface_id); 443 surface_id);
437 BrowserThread::PostTask( 444 BrowserThread::PostTask(
438 BrowserThread::IO, FROM_HERE, 445 BrowserThread::IO, FROM_HERE,
439 base::Bind( 446 base::Bind(
440 &BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferOnIO, 447 &BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferOnIO,
441 base::Unretained(this), // Safe as we wait for result below. 448 base::Unretained(this), // Safe as we wait for result below.
442 base::Unretained(&request))); 449 base::Unretained(&request)));
443 450
444 // We're blocking the UI thread, which is generally undesirable. 451 // We're blocking the UI thread, which is generally undesirable.
445 TRACE_EVENT0( 452 TRACE_EVENT0(
446 "browser", 453 "browser",
447 "BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface"); 454 "BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface");
448 base::ThreadRestrictions::ScopedAllowWait allow_wait; 455 base::ThreadRestrictions::ScopedAllowWait allow_wait;
449 request.event.Wait(); 456 request.event.Wait();
450 return request.result.Pass(); 457 return request.result.Pass();
451 } 458 }
452 459
453 bool BrowserGpuMemoryBufferManager::IsNativeGpuMemoryBufferConfiguration(
454 gfx::BufferFormat format,
455 gfx::BufferUsage usage) const {
456 return native_configurations_.find(std::make_pair(format, usage)) !=
457 native_configurations_.end();
458 }
459
460 void BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferOnIO( 460 void BrowserGpuMemoryBufferManager::HandleCreateGpuMemoryBufferOnIO(
461 CreateGpuMemoryBufferRequest* request) { 461 CreateGpuMemoryBufferRequest* request) {
462 DCHECK_CURRENTLY_ON(BrowserThread::IO); 462 DCHECK_CURRENTLY_ON(BrowserThread::IO);
463 463
464 gfx::GpuMemoryBufferId new_id = content::GetNextGenericSharedMemoryId(); 464 gfx::GpuMemoryBufferId new_id = content::GetNextGenericSharedMemoryId();
465 465
466 // Use service side allocation for native configurations. 466 // Use service side allocation for native configurations.
467 if (IsNativeGpuMemoryBufferConfiguration(request->format, request->usage)) { 467 if (IsNativeGpuMemoryBufferConfiguration(request->format, request->usage)) {
468 // Note: Unretained is safe as this is only used for synchronous allocation 468 // Note: Unretained is safe as this is only used for synchronous allocation
469 // from a non-IO thread. 469 // from a non-IO thread.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 return gpu_client_tracing_id_; 705 return gpu_client_tracing_id_;
706 } 706 }
707 707
708 // In normal cases, |client_id| is a child process id, so we can perform 708 // In normal cases, |client_id| is a child process id, so we can perform
709 // the standard conversion. 709 // the standard conversion.
710 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( 710 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId(
711 client_id); 711 client_id);
712 } 712 }
713 713
714 } // namespace content 714 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/browser_gpu_memory_buffer_manager.h ('k') | content/browser/gpu/gpu_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698