Chromium Code Reviews| 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..f0410f54b5d31129d68bd7969e66f5943b2e3e29 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, |
| @@ -227,7 +258,10 @@ void BrowserGpuMemoryBufferManager::GpuMemoryBufferAllocatedForChildProcess( |
| // static |
| void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferOnIO( |
| AllocateGpuMemoryBufferRequest* request) { |
| + |
|
reveman
2014/11/11 19:07:45
hm, this blank line should not be here.
|
| GpuMemoryBufferImpl::Create( |
| + GetPreferredGpuMemoryBufferTypeForConfiguration( |
|
alexst (slow to review)
2014/11/11 18:49:23
Should this early out in BrowserGpuMemoryBufferMan
reveman
2014/11/11 19:07:44
I think we should consider it a browser bug if thi
|
| + request->format, request->usage), |
| g_next_gpu_memory_buffer_id.GetNext(), |
| request->size, |
| request->format, |