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"
14 #if defined(OS_ANDROID)
15 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h"
18 #if defined(USE_OZONE)
19 #include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h"
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
,
31 #if defined(OS_ANDROID)
32 gfx::SURFACE_TEXTURE_BUFFER
,
34 #if defined(USE_OZONE)
35 gfx::OZONE_NATIVE_PIXMAP
,
37 gfx::SHARED_MEMORY_BUFFER
39 types
->assign(supported_types
, supported_types
+ arraysize(supported_types
));
43 scoped_ptr
<GpuMemoryBufferFactory
> GpuMemoryBufferFactory::Create(
44 gfx::GpuMemoryBufferType 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
);
52 #if defined(OS_ANDROID)
53 case gfx::SURFACE_TEXTURE_BUFFER
:
54 return make_scoped_ptr(new GpuMemoryBufferFactorySurfaceTexture
);
56 #if defined(USE_OZONE)
57 case gfx::OZONE_NATIVE_PIXMAP
:
58 return make_scoped_ptr(new GpuMemoryBufferFactoryOzoneNativePixmap
);
62 return scoped_ptr
<GpuMemoryBufferFactory
>();
66 } // namespace content