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

Unified Diff: content/common/gpu/client/gpu_memory_buffer_impl_linux.cc

Issue 263553009: content: Cleanup GpuMemoryBuffer allocation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac build fix Created 6 years, 7 months 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 ffd4e381c7d9276e27d51e5c9d027ecca96dd33c..8da027bbb5b0bb475b10e31c3b8ed5fdfe4a708d 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl_linux.cc
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_linux.cc
@@ -8,15 +8,51 @@
namespace content {
+// static
scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create(
+ const gfx::Size& size,
+ unsigned internalformat,
+ unsigned usage) {
+ if (GpuMemoryBufferImplShm::IsConfigurationSupported(
+ size, internalformat, usage)) {
+ scoped_ptr<GpuMemoryBufferImplShm> buffer(
+ new GpuMemoryBufferImplShm(size, internalformat));
+ if (!buffer->Initialize())
+ return scoped_ptr<GpuMemoryBufferImpl>();
+
+ return buffer.PassAs<GpuMemoryBufferImpl>();
+ }
+
+ return scoped_ptr<GpuMemoryBufferImpl>();
+}
+
+// static
+void GpuMemoryBufferImpl::AllocateForChildProcess(
+ const gfx::Size& size,
+ unsigned internalformat,
+ unsigned usage,
+ base::ProcessHandle child_process,
+ gfx::GpuMemoryBufferHandle* handle) {
+ if (GpuMemoryBufferImplShm::IsConfigurationSupported(
+ size, internalformat, usage)) {
+ GpuMemoryBufferImplShm::AllocateSharedMemoryForChildProcess(
+ size, internalformat, child_process, handle);
+ return;
+ }
+
+ handle->type = gfx::EMPTY_BUFFER;
+}
+
+// static
+scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle(
gfx::GpuMemoryBufferHandle handle,
- gfx::Size size,
+ const gfx::Size& size,
unsigned internalformat) {
switch (handle.type) {
case gfx::SHARED_MEMORY_BUFFER: {
scoped_ptr<GpuMemoryBufferImplShm> buffer(
new GpuMemoryBufferImplShm(size, internalformat));
- if (!buffer->Initialize(handle))
+ if (!buffer->InitializeFromHandle(handle))
return scoped_ptr<GpuMemoryBufferImpl>();
return buffer.PassAs<GpuMemoryBufferImpl>();

Powered by Google App Engine
This is Rietveld 408576698