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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" 5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
6 6
7 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h" 7 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h"
8 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h" 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 // static
12 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create( 13 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create(
14 const gfx::Size& size,
15 unsigned internalformat,
16 unsigned usage) {
17 if (GpuMemoryBufferImplShm::IsConfigurationSupported(
18 size, internalformat, usage)) {
19 scoped_ptr<GpuMemoryBufferImplShm> buffer(
20 new GpuMemoryBufferImplShm(size, internalformat));
21 if (!buffer->Initialize())
22 return scoped_ptr<GpuMemoryBufferImpl>();
23
24 return buffer.PassAs<GpuMemoryBufferImpl>();
25 }
26
27 return scoped_ptr<GpuMemoryBufferImpl>();
28 }
29
30 // static
31 void GpuMemoryBufferImpl::AllocateForChildProcess(
32 const gfx::Size& size,
33 unsigned internalformat,
34 unsigned usage,
35 base::ProcessHandle child_process,
36 gfx::GpuMemoryBufferHandle* handle) {
37 if (GpuMemoryBufferImplShm::IsConfigurationSupported(
38 size, internalformat, usage)) {
39 GpuMemoryBufferImplShm::AllocateSharedMemoryForChildProcess(
40 size, internalformat, child_process, handle);
41 return;
42 }
43
44 handle->type = gfx::EMPTY_BUFFER;
45 }
46
47 // static
48 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle(
13 gfx::GpuMemoryBufferHandle handle, 49 gfx::GpuMemoryBufferHandle handle,
14 gfx::Size size, 50 const gfx::Size& size,
15 unsigned internalformat) { 51 unsigned internalformat) {
16 switch (handle.type) { 52 switch (handle.type) {
17 case gfx::SHARED_MEMORY_BUFFER: { 53 case gfx::SHARED_MEMORY_BUFFER: {
18 scoped_ptr<GpuMemoryBufferImplShm> buffer( 54 scoped_ptr<GpuMemoryBufferImplShm> buffer(
19 new GpuMemoryBufferImplShm(size, internalformat)); 55 new GpuMemoryBufferImplShm(size, internalformat));
20 if (!buffer->Initialize(handle)) 56 if (!buffer->InitializeFromHandle(handle))
21 return scoped_ptr<GpuMemoryBufferImpl>(); 57 return scoped_ptr<GpuMemoryBufferImpl>();
22 58
23 return buffer.PassAs<GpuMemoryBufferImpl>(); 59 return buffer.PassAs<GpuMemoryBufferImpl>();
24 } 60 }
25 case gfx::IO_SURFACE_BUFFER: { 61 case gfx::IO_SURFACE_BUFFER: {
26 scoped_ptr<GpuMemoryBufferImplIOSurface> buffer( 62 scoped_ptr<GpuMemoryBufferImplIOSurface> buffer(
27 new GpuMemoryBufferImplIOSurface(size, internalformat)); 63 new GpuMemoryBufferImplIOSurface(size, internalformat));
28 if (!buffer->Initialize(handle)) 64 if (!buffer->InitializeFromHandle(handle))
29 return scoped_ptr<GpuMemoryBufferImpl>(); 65 return scoped_ptr<GpuMemoryBufferImpl>();
30 66
31 return buffer.PassAs<GpuMemoryBufferImpl>(); 67 return buffer.PassAs<GpuMemoryBufferImpl>();
32 } 68 }
33 default: 69 default:
34 return scoped_ptr<GpuMemoryBufferImpl>(); 70 return scoped_ptr<GpuMemoryBufferImpl>();
35 } 71 }
36 } 72 }
37 73
38 } // namespace content 74 } // namespace content
OLDNEW
« 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