OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 "gpu/ipc/common/gpu_memory_buffer_support.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "build/build_config.h" | |
9 | |
10 #if defined(USE_OZONE) | |
11 #include "ui/ozone/public/client_native_pixmap_factory.h" | |
12 #endif | |
13 | |
14 namespace gpu { | |
15 | |
16 gfx::GpuMemoryBufferType GetNativeGpuMemoryBufferType() { | |
17 #if defined(OS_MACOSX) | |
18 return gfx::IO_SURFACE_BUFFER; | |
19 #endif | |
20 #if defined(OS_ANDROID) | |
dcheng
2016/03/23 23:42:12
elif? Or are these not mutually exclusive?
Fady Samuel
2016/03/23 23:49:54
They are mutually exclusive. Done.
| |
21 return gfx::SURFACE_TEXTURE_BUFFER; | |
22 #endif | |
23 #if defined(USE_OZONE) | |
24 return gfx::OZONE_NATIVE_PIXMAP; | |
25 #endif | |
26 return gfx::EMPTY_BUFFER; | |
27 } | |
28 | |
29 bool IsNativeGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format, | |
30 gfx::BufferUsage usage) { | |
31 #if defined(OS_MACOSX) | |
32 switch (usage) { | |
33 case gfx::BufferUsage::GPU_READ: | |
34 case gfx::BufferUsage::SCANOUT: | |
35 return format == gfx::BufferFormat::BGRA_8888 || | |
36 format == gfx::BufferFormat::RGBA_8888; | |
37 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | |
38 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | |
39 return format == gfx::BufferFormat::R_8 || | |
40 format == gfx::BufferFormat::BGRA_8888 || | |
41 format == gfx::BufferFormat::UYVY_422 || | |
42 format == gfx::BufferFormat::YUV_420_BIPLANAR; | |
43 } | |
44 NOTREACHED(); | |
45 return false; | |
46 #endif | |
dcheng
2016/03/23 23:42:12
Similar comment here about #elif
Fady Samuel
2016/03/23 23:49:54
Done.
| |
47 | |
48 #if defined(OS_ANDROID) | |
49 switch (usage) { | |
50 case gfx::BufferUsage::GPU_READ: | |
51 case gfx::BufferUsage::SCANOUT: | |
52 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | |
53 return false; | |
54 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | |
55 return format == gfx::BufferFormat::RGBA_8888; | |
56 } | |
57 NOTREACHED(); | |
58 return false; | |
59 #endif | |
60 | |
61 #if defined(USE_OZONE) | |
62 if (!ui::ClientNativePixmapFactory::GetInstance()) { | |
63 // unittests don't have to set ClientNativePixmapFactory. | |
64 return false; | |
65 } | |
66 return ui::ClientNativePixmapFactory::GetInstance()->IsConfigurationSupported( | |
67 format, usage); | |
68 #endif | |
69 | |
70 NOTREACHED(); | |
71 return false; | |
72 } | |
73 | |
74 } // namespace gpu | |
OLD | NEW |