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

Side by Side Diff: content/common/gpu/client/gpu_memory_buffer_impl_win.cc

Issue 263553009: content: Cleanup GpuMemoryBuffer allocation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove use of ChildProcessHostImpl and use base::CheckedNumeric 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_shm.h" 7 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 // static
11 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create( 12 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create(
13 const gfx::Size& size,
14 unsigned internalformat) {
15 scoped_ptr<GpuMemoryBufferImplShm> buffer(
16 new GpuMemoryBufferImplShm(size, internalformat));
17 if (!buffer->Initialize())
18 return scoped_ptr<GpuMemoryBufferImpl>();
19
20 return buffer.PassAs<GpuMemoryBufferImpl>();
21 }
22
23 // static
24 void GpuMemoryBufferImpl::AllocateForChildProcess(
25 const gfx::Size& size,
26 unsigned internalformat,
27 base::ProcessHandle child_process,
28 gfx::GpuMemoryBufferHandle* handle) {
29 GpuMemoryBufferImplShm::AllocateSharedMemoryForChildProcess(
30 size, internalformat, child_process, handle);
31 }
32
33 // static
34 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle(
12 gfx::GpuMemoryBufferHandle handle, 35 gfx::GpuMemoryBufferHandle handle,
13 gfx::Size size, 36 const gfx::Size& size,
14 unsigned internalformat) { 37 unsigned internalformat) {
15 switch (handle.type) { 38 switch (handle.type) {
16 case gfx::SHARED_MEMORY_BUFFER: { 39 case gfx::SHARED_MEMORY_BUFFER: {
17 scoped_ptr<GpuMemoryBufferImplShm> buffer( 40 scoped_ptr<GpuMemoryBufferImplShm> buffer(
18 new GpuMemoryBufferImplShm(size, internalformat)); 41 new GpuMemoryBufferImplShm(size, internalformat));
19 if (!buffer->Initialize(handle)) 42 if (!buffer->InitializeFromHandle(handle))
20 return scoped_ptr<GpuMemoryBufferImpl>(); 43 return scoped_ptr<GpuMemoryBufferImpl>();
21 44
22 return buffer.PassAs<GpuMemoryBufferImpl>(); 45 return buffer.PassAs<GpuMemoryBufferImpl>();
23 } 46 }
24 default: 47 default:
25 return scoped_ptr<GpuMemoryBufferImpl>(); 48 return scoped_ptr<GpuMemoryBufferImpl>();
26 } 49 }
27 } 50 }
28 51
29 } // namespace content 52 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698