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

Unified Diff: content/common/gpu/client/gpu_memory_buffer_impl_linux.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
Index: content/common/gpu/client/gpu_memory_buffer_impl_linux.cc
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_linux.cc b/content/common/gpu/client/gpu_memory_buffer_impl_linux.cc
index 3c144f37ccf6b6159d2ba9692fffccf3b23b9e87..ef508984646ac8a79b0c99e04c99bcf1ba1b0621 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl_linux.cc
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_linux.cc
@@ -4,28 +4,56 @@
#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
+#include "base/logging.h"
#include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
namespace content {
// static
-void GpuMemoryBufferImpl::Create(gfx::GpuMemoryBufferId id,
+void GpuMemoryBufferImpl::GetSupportedTypes(
+ std::vector<gfx::GpuMemoryBufferType>* types) {
+ const gfx::GpuMemoryBufferType supported_types[] = {
+ gfx::SHARED_MEMORY_BUFFER
+ };
+ types->assign(supported_types, supported_types + arraysize(supported_types));
+}
+
+// static
+bool GpuMemoryBufferImpl::IsConfigurationSupported(
+ gfx::GpuMemoryBufferType type,
+ Format format,
+ Usage usage) {
+ switch (type) {
+ case gfx::SHARED_MEMORY_BUFFER:
+ return GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) &&
+ GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage);
+ default:
+ NOTREACHED();
+ return false;
+ }
+}
+
+// static
+void GpuMemoryBufferImpl::Create(gfx::GpuMemoryBufferType type,
+ gfx::GpuMemoryBufferId id,
const gfx::Size& size,
Format format,
Usage usage,
int client_id,
const CreationCallback& callback) {
- if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
- size, format, usage)) {
- GpuMemoryBufferImplSharedMemory::Create(id, size, format, callback);
- return;
+ switch (type) {
+ case gfx::SHARED_MEMORY_BUFFER:
+ GpuMemoryBufferImplSharedMemory::Create(id, size, format, callback);
+ break;
+ default:
+ NOTREACHED();
+ break;
}
-
- callback.Run(scoped_ptr<GpuMemoryBufferImpl>());
}
// static
void GpuMemoryBufferImpl::AllocateForChildProcess(
+ gfx::GpuMemoryBufferType type,
gfx::GpuMemoryBufferId id,
const gfx::Size& size,
Format format,
@@ -33,14 +61,15 @@ void GpuMemoryBufferImpl::AllocateForChildProcess(
base::ProcessHandle child_process,
int child_client_id,
const AllocationCallback& callback) {
- if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
- size, format, usage)) {
- GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
- id, size, format, child_process, callback);
- return;
+ switch (type) {
+ case gfx::SHARED_MEMORY_BUFFER:
+ GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
+ id, size, format, child_process, callback);
+ break;
+ default:
+ NOTREACHED();
+ break;
}
-
- callback.Run(gfx::GpuMemoryBufferHandle());
}
// static
@@ -50,6 +79,13 @@ void GpuMemoryBufferImpl::DeletedByChildProcess(
base::ProcessHandle child_process,
int child_client_id,
uint32 sync_point) {
+ switch (type) {
+ case gfx::SHARED_MEMORY_BUFFER:
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
}
// static
@@ -63,6 +99,7 @@ scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle(
return GpuMemoryBufferImplSharedMemory::CreateFromHandle(
handle, size, format, callback);
default:
+ NOTREACHED();
return scoped_ptr<GpuMemoryBufferImpl>();
}
}

Powered by Google App Engine
This is Rietveld 408576698