Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / common / gpu / client / gpu_memory_buffer_impl_win.cc
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.
4
5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
6
7 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
8
9 namespace content {
10
11 // static
12 void GpuMemoryBufferImpl::Create(gfx::GpuMemoryBufferId id,
13                                  const gfx::Size& size,
14                                  Format format,
15                                  Usage usage,
16                                  int client_id,
17                                  const CreationCallback& callback) {
18   if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
19           size, format, usage)) {
20     GpuMemoryBufferImplSharedMemory::Create(id, size, format, callback);
21     return;
22   }
23
24   callback.Run(scoped_ptr<GpuMemoryBufferImpl>());
25 }
26
27 // static
28 void GpuMemoryBufferImpl::AllocateForChildProcess(
29     gfx::GpuMemoryBufferId id,
30     const gfx::Size& size,
31     Format format,
32     Usage usage,
33     base::ProcessHandle child_process,
34     int child_client_id,
35     const AllocationCallback& callback) {
36   if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
37           size, format, usage)) {
38     GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
39         id, size, format, child_process, callback);
40     return;
41   }
42
43   callback.Run(gfx::GpuMemoryBufferHandle());
44 }
45
46 // static
47 void GpuMemoryBufferImpl::DeletedByChildProcess(
48     gfx::GpuMemoryBufferType type,
49     gfx::GpuMemoryBufferId id,
50     base::ProcessHandle child_process,
51     int child_client_id,
52     uint32 sync_point) {
53 }
54
55 // static
56 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle(
57     const gfx::GpuMemoryBufferHandle& handle,
58     const gfx::Size& size,
59     Format format,
60     const DestructionCallback& callback) {
61   switch (handle.type) {
62     case gfx::SHARED_MEMORY_BUFFER:
63       return GpuMemoryBufferImplSharedMemory::CreateFromHandle(
64           handle, size, format, callback);
65     default:
66       return scoped_ptr<GpuMemoryBufferImpl>();
67   }
68 }
69
70 }  // namespace content