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

Unified Diff: content/browser/gpu/browser_gpu_memory_buffer_manager.cc

Issue 701033005: content: Move type selection logic out of GpuMemoryBufferImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review feedback Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/common/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gpu/browser_gpu_memory_buffer_manager.cc
diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc
index b5bcebc05ea17c1a5adcc31d4063c462d094634b..fe8e7929abd66b63439bc757dfb365ef8437bc0a 100644
--- a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc
+++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc
@@ -16,6 +16,27 @@
namespace content {
namespace {
+// Note: To keep things simple this function will only return one out of two
+// types; the preferred GPU memory buffer type or the shared memory type.
+gfx::GpuMemoryBufferType GetPreferredGpuMemoryBufferTypeForConfiguration(
+ gfx::GpuMemoryBuffer::Format format,
+ gfx::GpuMemoryBuffer::Usage usage) {
+ // First check if this configuration is supported by the preferred type.
+ if (GpuMemoryBufferImpl::IsConfigurationSupported(
+ GpuMemoryBufferImpl::GetPreferredType(), format, usage)) {
+ return GpuMemoryBufferImpl::GetPreferredType();
+ }
+
+ // If configuration is not supported by the preferred type, use shared
+ // memory type if it supports this configuration.
+ if (GpuMemoryBufferImpl::IsConfigurationSupported(
+ gfx::SHARED_MEMORY_BUFFER, format, usage)) {
+ return gfx::SHARED_MEMORY_BUFFER;
+ }
+
+ return gfx::EMPTY_BUFFER;
+}
+
BrowserGpuMemoryBufferManager* g_gpu_memory_buffer_manager = nullptr;
// Global atomic to generate gpu memory buffer unique IDs.
@@ -88,6 +109,15 @@ void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForChildProcess(
const AllocationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ // Determine what GPU memory buffer type to use and early out if |format| and
+ // |usage| configuration is not supported.
+ gfx::GpuMemoryBufferType type =
+ GetPreferredGpuMemoryBufferTypeForConfiguration(format, usage);
+ if (type == gfx::EMPTY_BUFFER) {
+ callback.Run(gfx::GpuMemoryBufferHandle());
+ return;
+ }
+
gfx::GpuMemoryBufferId new_id = g_next_gpu_memory_buffer_id.GetNext();
BufferMap& buffers = clients_[child_client_id];
@@ -100,6 +130,7 @@ void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForChildProcess(
buffers[new_id] = gfx::EMPTY_BUFFER;
GpuMemoryBufferImpl::AllocateForChildProcess(
+ type,
new_id,
size,
format,
@@ -228,6 +259,8 @@ void BrowserGpuMemoryBufferManager::GpuMemoryBufferAllocatedForChildProcess(
void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferOnIO(
AllocateGpuMemoryBufferRequest* request) {
GpuMemoryBufferImpl::Create(
+ GetPreferredGpuMemoryBufferTypeForConfiguration(
+ request->format, request->usage),
g_next_gpu_memory_buffer_id.GetNext(),
request->size,
request->format,
« no previous file with comments | « no previous file | content/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698