Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / common / gpu / gpu_memory_buffer_factory.cc
blob2c5bd395c59e2a0610cdd37644bc1361ce56b747
1 // Copyright 2014 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/gpu_memory_buffer_factory.h"
7 #include "base/logging.h"
8 #include "content/common/gpu/gpu_memory_buffer_factory_shared_memory.h"
10 #if defined(OS_MACOSX)
11 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h"
12 #endif
14 #if defined(OS_ANDROID)
15 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h"
16 #endif
18 #if defined(USE_OZONE)
19 #include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h"
20 #endif
22 namespace content {
24 // static
25 void GpuMemoryBufferFactory::GetSupportedTypes(
26 std::vector<gfx::GpuMemoryBufferType>* types) {
27 const gfx::GpuMemoryBufferType supported_types[] = {
28 #if defined(OS_MACOSX)
29 gfx::IO_SURFACE_BUFFER,
30 #endif
31 #if defined(OS_ANDROID)
32 gfx::SURFACE_TEXTURE_BUFFER,
33 #endif
34 #if defined(USE_OZONE)
35 gfx::OZONE_NATIVE_PIXMAP,
36 #endif
37 gfx::SHARED_MEMORY_BUFFER
39 types->assign(supported_types, supported_types + arraysize(supported_types));
42 // static
43 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create(
44 gfx::GpuMemoryBufferType type) {
45 switch (type) {
46 case gfx::SHARED_MEMORY_BUFFER:
47 return make_scoped_ptr(new GpuMemoryBufferFactorySharedMemory);
48 #if defined(OS_MACOSX)
49 case gfx::IO_SURFACE_BUFFER:
50 return make_scoped_ptr(new GpuMemoryBufferFactoryIOSurface);
51 #endif
52 #if defined(OS_ANDROID)
53 case gfx::SURFACE_TEXTURE_BUFFER:
54 return make_scoped_ptr(new GpuMemoryBufferFactorySurfaceTexture);
55 #endif
56 #if defined(USE_OZONE)
57 case gfx::OZONE_NATIVE_PIXMAP:
58 return make_scoped_ptr(new GpuMemoryBufferFactoryOzoneNativePixmap);
59 #endif
60 default:
61 NOTREACHED();
62 return scoped_ptr<GpuMemoryBufferFactory>();
66 } // namespace content