OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" | 5 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" |
6 | 6 |
7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
8 #include <GLES2/gl2extchromium.h> | 8 #include <GLES2/gl2extchromium.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "gpu/command_buffer/common/capabilities.h" | 11 #include "gpu/command_buffer/common/capabilities.h" |
12 | 12 |
13 namespace gpu { | 13 namespace gpu { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 gfx::BufferFormat BufferFormatForInternalFormat(unsigned internalformat) { | 17 gfx::BufferFormat BufferFormatForInternalFormat(unsigned internalformat) { |
18 switch (internalformat) { | 18 switch (internalformat) { |
19 case GL_RED_EXT: | 19 case GL_RED_EXT: |
20 return gfx::BufferFormat::R_8; | 20 return gfx::BufferFormat::R_8; |
| 21 case GL_RG_EXT: |
| 22 return gfx::BufferFormat::RG_88; |
21 case GL_RGB: | 23 case GL_RGB: |
22 return gfx::BufferFormat::BGRX_8888; | 24 return gfx::BufferFormat::BGRX_8888; |
23 case GL_RGBA: | 25 case GL_RGBA: |
24 return gfx::BufferFormat::RGBA_8888; | 26 return gfx::BufferFormat::RGBA_8888; |
25 case GL_BGRA_EXT: | 27 case GL_BGRA_EXT: |
26 return gfx::BufferFormat::BGRA_8888; | 28 return gfx::BufferFormat::BGRA_8888; |
27 case GL_ATC_RGB_AMD: | 29 case GL_ATC_RGB_AMD: |
28 return gfx::BufferFormat::ATC; | 30 return gfx::BufferFormat::ATC; |
29 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | 31 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
30 return gfx::BufferFormat::ATCIA; | 32 return gfx::BufferFormat::ATCIA; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 gfx::BufferFormat format) { | 67 gfx::BufferFormat format) { |
66 switch (format) { | 68 switch (format) { |
67 case gfx::BufferFormat::ATC: | 69 case gfx::BufferFormat::ATC: |
68 case gfx::BufferFormat::ATCIA: | 70 case gfx::BufferFormat::ATCIA: |
69 case gfx::BufferFormat::BGRA_8888: | 71 case gfx::BufferFormat::BGRA_8888: |
70 case gfx::BufferFormat::BGRX_8888: | 72 case gfx::BufferFormat::BGRX_8888: |
71 case gfx::BufferFormat::DXT1: | 73 case gfx::BufferFormat::DXT1: |
72 case gfx::BufferFormat::DXT5: | 74 case gfx::BufferFormat::DXT5: |
73 case gfx::BufferFormat::ETC1: | 75 case gfx::BufferFormat::ETC1: |
74 case gfx::BufferFormat::R_8: | 76 case gfx::BufferFormat::R_8: |
| 77 case gfx::BufferFormat::RG_88: |
75 case gfx::BufferFormat::RGBA_8888: | 78 case gfx::BufferFormat::RGBA_8888: |
76 case gfx::BufferFormat::YVU_420: | 79 case gfx::BufferFormat::YVU_420: |
77 case gfx::BufferFormat::YUV_420_BIPLANAR: | 80 case gfx::BufferFormat::YUV_420_BIPLANAR: |
78 case gfx::BufferFormat::UYVY_422: | 81 case gfx::BufferFormat::UYVY_422: |
79 return format == BufferFormatForInternalFormat(internalformat); | 82 return format == BufferFormatForInternalFormat(internalformat); |
80 case gfx::BufferFormat::BGR_565: | 83 case gfx::BufferFormat::BGR_565: |
81 case gfx::BufferFormat::RGBX_8888: | 84 case gfx::BufferFormat::RGBX_8888: |
82 return internalformat == GL_RGB; | 85 return internalformat == GL_RGB; |
83 case gfx::BufferFormat::RGBA_4444: | 86 case gfx::BufferFormat::RGBA_4444: |
84 return internalformat == GL_RGBA; | 87 return internalformat == GL_RGBA; |
(...skipping 12 matching lines...) Expand all Loading... |
97 case gfx::BufferFormat::BGRA_8888: | 100 case gfx::BufferFormat::BGRA_8888: |
98 case gfx::BufferFormat::BGRX_8888: | 101 case gfx::BufferFormat::BGRX_8888: |
99 return capabilities.texture_format_bgra8888; | 102 return capabilities.texture_format_bgra8888; |
100 case gfx::BufferFormat::DXT1: | 103 case gfx::BufferFormat::DXT1: |
101 return capabilities.texture_format_dxt1; | 104 return capabilities.texture_format_dxt1; |
102 case gfx::BufferFormat::DXT5: | 105 case gfx::BufferFormat::DXT5: |
103 return capabilities.texture_format_dxt5; | 106 return capabilities.texture_format_dxt5; |
104 case gfx::BufferFormat::ETC1: | 107 case gfx::BufferFormat::ETC1: |
105 return capabilities.texture_format_etc1; | 108 return capabilities.texture_format_etc1; |
106 case gfx::BufferFormat::R_8: | 109 case gfx::BufferFormat::R_8: |
| 110 case gfx::BufferFormat::RG_88: |
107 return capabilities.texture_rg; | 111 return capabilities.texture_rg; |
108 case gfx::BufferFormat::UYVY_422: | 112 case gfx::BufferFormat::UYVY_422: |
109 return capabilities.image_ycbcr_422; | 113 return capabilities.image_ycbcr_422; |
110 case gfx::BufferFormat::BGR_565: | 114 case gfx::BufferFormat::BGR_565: |
111 case gfx::BufferFormat::RGBA_4444: | 115 case gfx::BufferFormat::RGBA_4444: |
112 case gfx::BufferFormat::RGBA_8888: | 116 case gfx::BufferFormat::RGBA_8888: |
113 case gfx::BufferFormat::RGBX_8888: | 117 case gfx::BufferFormat::RGBX_8888: |
114 case gfx::BufferFormat::YVU_420: | 118 case gfx::BufferFormat::YVU_420: |
115 return true; | 119 return true; |
116 case gfx::BufferFormat::YUV_420_BIPLANAR: | 120 case gfx::BufferFormat::YUV_420_BIPLANAR: |
(...skipping 15 matching lines...) Expand all Loading... |
132 switch (format) { | 136 switch (format) { |
133 case gfx::BufferFormat::ATC: | 137 case gfx::BufferFormat::ATC: |
134 case gfx::BufferFormat::ATCIA: | 138 case gfx::BufferFormat::ATCIA: |
135 case gfx::BufferFormat::DXT1: | 139 case gfx::BufferFormat::DXT1: |
136 case gfx::BufferFormat::DXT5: | 140 case gfx::BufferFormat::DXT5: |
137 case gfx::BufferFormat::ETC1: | 141 case gfx::BufferFormat::ETC1: |
138 // Compressed images must have a width and height that's evenly divisible | 142 // Compressed images must have a width and height that's evenly divisible |
139 // by the block size. | 143 // by the block size. |
140 return size.width() % 4 == 0 && size.height() % 4 == 0; | 144 return size.width() % 4 == 0 && size.height() % 4 == 0; |
141 case gfx::BufferFormat::R_8: | 145 case gfx::BufferFormat::R_8: |
| 146 case gfx::BufferFormat::RG_88: |
142 case gfx::BufferFormat::BGR_565: | 147 case gfx::BufferFormat::BGR_565: |
143 case gfx::BufferFormat::RGBA_4444: | 148 case gfx::BufferFormat::RGBA_4444: |
144 case gfx::BufferFormat::RGBA_8888: | 149 case gfx::BufferFormat::RGBA_8888: |
145 case gfx::BufferFormat::RGBX_8888: | 150 case gfx::BufferFormat::RGBX_8888: |
146 case gfx::BufferFormat::BGRA_8888: | 151 case gfx::BufferFormat::BGRA_8888: |
147 case gfx::BufferFormat::BGRX_8888: | 152 case gfx::BufferFormat::BGRX_8888: |
148 return true; | 153 return true; |
149 case gfx::BufferFormat::YVU_420: | 154 case gfx::BufferFormat::YVU_420: |
150 case gfx::BufferFormat::YUV_420_BIPLANAR: | 155 case gfx::BufferFormat::YUV_420_BIPLANAR: |
151 // U and V planes are subsampled by a factor of 2. | 156 // U and V planes are subsampled by a factor of 2. |
152 return size.width() % 2 == 0 && size.height() % 2 == 0; | 157 return size.width() % 2 == 0 && size.height() % 2 == 0; |
153 case gfx::BufferFormat::UYVY_422: | 158 case gfx::BufferFormat::UYVY_422: |
154 return size.width() % 2 == 0; | 159 return size.width() % 2 == 0; |
155 } | 160 } |
156 | 161 |
157 NOTREACHED(); | 162 NOTREACHED(); |
158 return false; | 163 return false; |
159 } | 164 } |
160 | 165 |
161 } // namespace gpu | 166 } // namespace gpu |
OLD | NEW |