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

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: mac build fix 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/child_process_host_impl.cc » ('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..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,
« no previous file with comments | « no previous file | content/common/child_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698