[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / content / common / gpu / client / gpu_memory_buffer_impl_mac.cc
blob0e77f468d22d69f66008a601e8ecd685c9cd47ec
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
3 // found in the LICENSE file.
5 #include "content/common/gpu/client/gpu_memory_buffer_impl.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"
10 namespace content {
12 // static
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>();
24 return buffer.PassAs<GpuMemoryBufferImpl>();
27 return scoped_ptr<GpuMemoryBufferImpl>();
30 // static
31 void GpuMemoryBufferImpl::AllocateForChildProcess(
32 const gfx::Size& size,
33 unsigned internalformat,
34 unsigned usage,
35 base::ProcessHandle child_process,
36 const AllocationCallback& callback) {
37 if (GpuMemoryBufferImplShm::IsConfigurationSupported(
38 size, internalformat, usage)) {
39 GpuMemoryBufferImplShm::AllocateSharedMemoryForChildProcess(
40 size, internalformat, child_process, callback);
41 return;
44 callback.Run(gfx::GpuMemoryBufferHandle());
47 // static
48 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle(
49 gfx::GpuMemoryBufferHandle handle,
50 const gfx::Size& size,
51 unsigned internalformat) {
52 switch (handle.type) {
53 case gfx::SHARED_MEMORY_BUFFER: {
54 scoped_ptr<GpuMemoryBufferImplShm> buffer(
55 new GpuMemoryBufferImplShm(size, internalformat));
56 if (!buffer->InitializeFromHandle(handle))
57 return scoped_ptr<GpuMemoryBufferImpl>();
59 return buffer.PassAs<GpuMemoryBufferImpl>();
61 case gfx::IO_SURFACE_BUFFER: {
62 scoped_ptr<GpuMemoryBufferImplIOSurface> buffer(
63 new GpuMemoryBufferImplIOSurface(size, internalformat));
64 if (!buffer->InitializeFromHandle(handle))
65 return scoped_ptr<GpuMemoryBufferImpl>();
67 return buffer.PassAs<GpuMemoryBufferImpl>();
69 default:
70 return scoped_ptr<GpuMemoryBufferImpl>();
74 } // namespace content