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

Unified Diff: content/common/gpu/client/gpu_memory_buffer_impl_mac.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_mac.cc
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_mac.cc b/content/common/gpu/client/gpu_memory_buffer_impl_mac.cc
index 1c8e5521a01e678e32b4c84d3cb69be2689604bb..35831b54ca4d576cdab55c121fa9de816871bb0d 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl_mac.cc
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_mac.cc
@@ -9,15 +9,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>();
@@ -25,7 +61,7 @@ scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create(
case gfx::IO_SURFACE_BUFFER: {
scoped_ptr<GpuMemoryBufferImplIOSurface> buffer(
new GpuMemoryBufferImplIOSurface(size, internalformat));
- if (!buffer->Initialize(handle))
+ if (!buffer->InitializeFromHandle(handle))
return scoped_ptr<GpuMemoryBufferImpl>();
return buffer.PassAs<GpuMemoryBufferImpl>();
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_linux.cc ('k') | content/common/gpu/client/gpu_memory_buffer_impl_shm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698