[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / content / common / gpu / client / gpu_memory_buffer_impl_linux.cc
blobd885f3f8676d78d45cf0aaf14fd96a98a34076c2
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_shm.h"
9 namespace content {
11 // static
12 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create(
13 const gfx::Size& size,
14 unsigned internalformat,
15 unsigned usage) {
16 if (GpuMemoryBufferImplShm::IsConfigurationSupported(
17 size, internalformat, usage)) {
18 scoped_ptr<GpuMemoryBufferImplShm> buffer(
19 new GpuMemoryBufferImplShm(size, internalformat));
20 if (!buffer->Initialize())
21 return scoped_ptr<GpuMemoryBufferImpl>();
23 return buffer.PassAs<GpuMemoryBufferImpl>();
26 return scoped_ptr<GpuMemoryBufferImpl>();
29 // static
30 void GpuMemoryBufferImpl::AllocateForChildProcess(
31 const gfx::Size& size,
32 unsigned internalformat,
33 unsigned usage,
34 base::ProcessHandle child_process,
35 const AllocationCallback& callback) {
36 if (GpuMemoryBufferImplShm::IsConfigurationSupported(
37 size, internalformat, usage)) {
38 GpuMemoryBufferImplShm::AllocateSharedMemoryForChildProcess(
39 size, internalformat, child_process, callback);
40 return;
43 callback.Run(gfx::GpuMemoryBufferHandle());
46 // static
47 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle(
48 gfx::GpuMemoryBufferHandle handle,
49 const gfx::Size& size,
50 unsigned internalformat) {
51 switch (handle.type) {
52 case gfx::SHARED_MEMORY_BUFFER: {
53 scoped_ptr<GpuMemoryBufferImplShm> buffer(
54 new GpuMemoryBufferImplShm(size, internalformat));
55 if (!buffer->InitializeFromHandle(handle))
56 return scoped_ptr<GpuMemoryBufferImpl>();
58 return buffer.PassAs<GpuMemoryBufferImpl>();
60 default:
61 return scoped_ptr<GpuMemoryBufferImpl>();
65 } // namespace content