Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: ui/gl/gl_image_memory.cc

Issue 2636433003: [NotForReview] Enable YUV video overlay on Skylake ChromeOS.
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/mojo/buffer_types_traits.h ('k') | ui/gl/test/gl_image_test_support.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "ui/gl/gl_image_memory.h" 5 #include "ui/gl/gl_image_memory.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 case gfx::BufferFormat::BGR_565: 49 case gfx::BufferFormat::BGR_565:
50 case gfx::BufferFormat::RGBA_4444: 50 case gfx::BufferFormat::RGBA_4444:
51 case gfx::BufferFormat::RGBX_8888: 51 case gfx::BufferFormat::RGBX_8888:
52 case gfx::BufferFormat::RGBA_8888: 52 case gfx::BufferFormat::RGBA_8888:
53 case gfx::BufferFormat::BGRX_8888: 53 case gfx::BufferFormat::BGRX_8888:
54 case gfx::BufferFormat::BGRA_8888: 54 case gfx::BufferFormat::BGRA_8888:
55 return true; 55 return true;
56 case gfx::BufferFormat::YVU_420: 56 case gfx::BufferFormat::YVU_420:
57 case gfx::BufferFormat::YUV_420_BIPLANAR: 57 case gfx::BufferFormat::YUV_420_BIPLANAR:
58 case gfx::BufferFormat::UYVY_422: 58 case gfx::BufferFormat::UYVY_422:
59 case gfx::BufferFormat::YUYV_422:
59 return false; 60 return false;
60 } 61 }
61 62
62 NOTREACHED(); 63 NOTREACHED();
63 return false; 64 return false;
64 } 65 }
65 66
66 bool IsCompressedFormat(gfx::BufferFormat format) { 67 bool IsCompressedFormat(gfx::BufferFormat format) {
67 switch (format) { 68 switch (format) {
68 case gfx::BufferFormat::ATC: 69 case gfx::BufferFormat::ATC:
69 case gfx::BufferFormat::ATCIA: 70 case gfx::BufferFormat::ATCIA:
70 case gfx::BufferFormat::DXT1: 71 case gfx::BufferFormat::DXT1:
71 case gfx::BufferFormat::DXT5: 72 case gfx::BufferFormat::DXT5:
72 case gfx::BufferFormat::ETC1: 73 case gfx::BufferFormat::ETC1:
73 return true; 74 return true;
74 case gfx::BufferFormat::R_8: 75 case gfx::BufferFormat::R_8:
75 case gfx::BufferFormat::RG_88: 76 case gfx::BufferFormat::RG_88:
76 case gfx::BufferFormat::BGR_565: 77 case gfx::BufferFormat::BGR_565:
77 case gfx::BufferFormat::RGBA_4444: 78 case gfx::BufferFormat::RGBA_4444:
78 case gfx::BufferFormat::RGBX_8888: 79 case gfx::BufferFormat::RGBX_8888:
79 case gfx::BufferFormat::RGBA_8888: 80 case gfx::BufferFormat::RGBA_8888:
80 case gfx::BufferFormat::BGRX_8888: 81 case gfx::BufferFormat::BGRX_8888:
81 case gfx::BufferFormat::BGRA_8888: 82 case gfx::BufferFormat::BGRA_8888:
82 return false; 83 return false;
83 case gfx::BufferFormat::YVU_420: 84 case gfx::BufferFormat::YVU_420:
84 case gfx::BufferFormat::YUV_420_BIPLANAR: 85 case gfx::BufferFormat::YUV_420_BIPLANAR:
85 case gfx::BufferFormat::UYVY_422: 86 case gfx::BufferFormat::UYVY_422:
87 case gfx::BufferFormat::YUYV_422:
86 NOTREACHED(); 88 NOTREACHED();
87 return false; 89 return false;
88 } 90 }
89 91
90 NOTREACHED(); 92 NOTREACHED();
91 return false; 93 return false;
92 } 94 }
93 95
94 GLenum TextureFormat(gfx::BufferFormat format) { 96 GLenum TextureFormat(gfx::BufferFormat format) {
95 switch (format) { 97 switch (format) {
(...skipping 16 matching lines...) Expand all
112 return GL_RGBA; 114 return GL_RGBA;
113 case gfx::BufferFormat::BGRA_8888: 115 case gfx::BufferFormat::BGRA_8888:
114 return GL_BGRA_EXT; 116 return GL_BGRA_EXT;
115 case gfx::BufferFormat::BGR_565: 117 case gfx::BufferFormat::BGR_565:
116 case gfx::BufferFormat::RGBX_8888: 118 case gfx::BufferFormat::RGBX_8888:
117 case gfx::BufferFormat::BGRX_8888: 119 case gfx::BufferFormat::BGRX_8888:
118 return GL_RGB; 120 return GL_RGB;
119 case gfx::BufferFormat::YVU_420: 121 case gfx::BufferFormat::YVU_420:
120 case gfx::BufferFormat::YUV_420_BIPLANAR: 122 case gfx::BufferFormat::YUV_420_BIPLANAR:
121 case gfx::BufferFormat::UYVY_422: 123 case gfx::BufferFormat::UYVY_422:
124 case gfx::BufferFormat::YUYV_422:
122 NOTREACHED(); 125 NOTREACHED();
123 return 0; 126 return 0;
124 } 127 }
125 128
126 NOTREACHED(); 129 NOTREACHED();
127 return 0; 130 return 0;
128 } 131 }
129 132
130 GLenum DataFormat(gfx::BufferFormat format) { 133 GLenum DataFormat(gfx::BufferFormat format) {
131 switch (format) { 134 switch (format) {
132 case gfx::BufferFormat::RGBX_8888: 135 case gfx::BufferFormat::RGBX_8888:
133 return GL_RGBA; 136 return GL_RGBA;
134 case gfx::BufferFormat::BGRX_8888: 137 case gfx::BufferFormat::BGRX_8888:
135 return GL_BGRA_EXT; 138 return GL_BGRA_EXT;
136 case gfx::BufferFormat::BGR_565: 139 case gfx::BufferFormat::BGR_565:
137 case gfx::BufferFormat::RGBA_4444: 140 case gfx::BufferFormat::RGBA_4444:
138 case gfx::BufferFormat::RGBA_8888: 141 case gfx::BufferFormat::RGBA_8888:
139 case gfx::BufferFormat::BGRA_8888: 142 case gfx::BufferFormat::BGRA_8888:
140 case gfx::BufferFormat::R_8: 143 case gfx::BufferFormat::R_8:
141 case gfx::BufferFormat::RG_88: 144 case gfx::BufferFormat::RG_88:
142 case gfx::BufferFormat::ATC: 145 case gfx::BufferFormat::ATC:
143 case gfx::BufferFormat::ATCIA: 146 case gfx::BufferFormat::ATCIA:
144 case gfx::BufferFormat::DXT1: 147 case gfx::BufferFormat::DXT1:
145 case gfx::BufferFormat::DXT5: 148 case gfx::BufferFormat::DXT5:
146 case gfx::BufferFormat::ETC1: 149 case gfx::BufferFormat::ETC1:
147 return TextureFormat(format); 150 return TextureFormat(format);
148 case gfx::BufferFormat::YVU_420: 151 case gfx::BufferFormat::YVU_420:
149 case gfx::BufferFormat::YUV_420_BIPLANAR: 152 case gfx::BufferFormat::YUV_420_BIPLANAR:
150 case gfx::BufferFormat::UYVY_422: 153 case gfx::BufferFormat::UYVY_422:
154 case gfx::BufferFormat::YUYV_422:
151 NOTREACHED(); 155 NOTREACHED();
152 return 0; 156 return 0;
153 } 157 }
154 158
155 NOTREACHED(); 159 NOTREACHED();
156 return 0; 160 return 0;
157 } 161 }
158 162
159 GLenum DataType(gfx::BufferFormat format) { 163 GLenum DataType(gfx::BufferFormat format) {
160 switch (format) { 164 switch (format) {
161 case gfx::BufferFormat::BGR_565: 165 case gfx::BufferFormat::BGR_565:
162 return GL_UNSIGNED_SHORT_5_6_5_REV; 166 return GL_UNSIGNED_SHORT_5_6_5_REV;
163 case gfx::BufferFormat::RGBA_4444: 167 case gfx::BufferFormat::RGBA_4444:
164 return GL_UNSIGNED_SHORT_4_4_4_4; 168 return GL_UNSIGNED_SHORT_4_4_4_4;
165 case gfx::BufferFormat::RGBX_8888: 169 case gfx::BufferFormat::RGBX_8888:
166 case gfx::BufferFormat::RGBA_8888: 170 case gfx::BufferFormat::RGBA_8888:
167 case gfx::BufferFormat::BGRX_8888: 171 case gfx::BufferFormat::BGRX_8888:
168 case gfx::BufferFormat::BGRA_8888: 172 case gfx::BufferFormat::BGRA_8888:
169 case gfx::BufferFormat::R_8: 173 case gfx::BufferFormat::R_8:
170 case gfx::BufferFormat::RG_88: 174 case gfx::BufferFormat::RG_88:
171 return GL_UNSIGNED_BYTE; 175 return GL_UNSIGNED_BYTE;
172 case gfx::BufferFormat::ATC: 176 case gfx::BufferFormat::ATC:
173 case gfx::BufferFormat::ATCIA: 177 case gfx::BufferFormat::ATCIA:
174 case gfx::BufferFormat::DXT1: 178 case gfx::BufferFormat::DXT1:
175 case gfx::BufferFormat::DXT5: 179 case gfx::BufferFormat::DXT5:
176 case gfx::BufferFormat::ETC1: 180 case gfx::BufferFormat::ETC1:
177 case gfx::BufferFormat::YVU_420: 181 case gfx::BufferFormat::YVU_420:
178 case gfx::BufferFormat::YUV_420_BIPLANAR: 182 case gfx::BufferFormat::YUV_420_BIPLANAR:
179 case gfx::BufferFormat::UYVY_422: 183 case gfx::BufferFormat::UYVY_422:
184 case gfx::BufferFormat::YUYV_422:
180 NOTREACHED(); 185 NOTREACHED();
181 return 0; 186 return 0;
182 } 187 }
183 188
184 NOTREACHED(); 189 NOTREACHED();
185 return 0; 190 return 0;
186 } 191 }
187 192
188 GLint DataRowLength(size_t stride, gfx::BufferFormat format) { 193 GLint DataRowLength(size_t stride, gfx::BufferFormat format) {
189 switch (format) { 194 switch (format) {
190 case gfx::BufferFormat::RG_88: 195 case gfx::BufferFormat::RG_88:
191 case gfx::BufferFormat::BGR_565: 196 case gfx::BufferFormat::BGR_565:
192 case gfx::BufferFormat::RGBA_4444: 197 case gfx::BufferFormat::RGBA_4444:
193 return base::checked_cast<GLint>(stride) / 2; 198 return base::checked_cast<GLint>(stride) / 2;
194 case gfx::BufferFormat::RGBX_8888: 199 case gfx::BufferFormat::RGBX_8888:
195 case gfx::BufferFormat::RGBA_8888: 200 case gfx::BufferFormat::RGBA_8888:
196 case gfx::BufferFormat::BGRX_8888: 201 case gfx::BufferFormat::BGRX_8888:
197 case gfx::BufferFormat::BGRA_8888: 202 case gfx::BufferFormat::BGRA_8888:
198 return base::checked_cast<GLint>(stride) / 4; 203 return base::checked_cast<GLint>(stride) / 4;
199 case gfx::BufferFormat::R_8: 204 case gfx::BufferFormat::R_8:
200 return base::checked_cast<GLint>(stride); 205 return base::checked_cast<GLint>(stride);
201 case gfx::BufferFormat::ATC: 206 case gfx::BufferFormat::ATC:
202 case gfx::BufferFormat::ATCIA: 207 case gfx::BufferFormat::ATCIA:
203 case gfx::BufferFormat::DXT1: 208 case gfx::BufferFormat::DXT1:
204 case gfx::BufferFormat::DXT5: 209 case gfx::BufferFormat::DXT5:
205 case gfx::BufferFormat::ETC1: 210 case gfx::BufferFormat::ETC1:
206 case gfx::BufferFormat::YVU_420: 211 case gfx::BufferFormat::YVU_420:
207 case gfx::BufferFormat::YUV_420_BIPLANAR: 212 case gfx::BufferFormat::YUV_420_BIPLANAR:
208 case gfx::BufferFormat::UYVY_422: 213 case gfx::BufferFormat::UYVY_422:
214 case gfx::BufferFormat::YUYV_422:
209 NOTREACHED(); 215 NOTREACHED();
210 return 0; 216 return 0;
211 } 217 }
212 218
213 NOTREACHED(); 219 NOTREACHED();
214 return 0; 220 return 0;
215 } 221 }
216 222
217 template <typename F> 223 template <typename F>
218 std::unique_ptr<uint8_t[]> GLES2RGBData(const gfx::Size& size, 224 std::unique_ptr<uint8_t[]> GLES2RGBData(const gfx::Size& size,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 334 }
329 case gfx::BufferFormat::ATC: 335 case gfx::BufferFormat::ATC:
330 case gfx::BufferFormat::ATCIA: 336 case gfx::BufferFormat::ATCIA:
331 case gfx::BufferFormat::DXT1: 337 case gfx::BufferFormat::DXT1:
332 case gfx::BufferFormat::DXT5: 338 case gfx::BufferFormat::DXT5:
333 case gfx::BufferFormat::ETC1: 339 case gfx::BufferFormat::ETC1:
334 return nullptr; // No data conversion needed 340 return nullptr; // No data conversion needed
335 case gfx::BufferFormat::YVU_420: 341 case gfx::BufferFormat::YVU_420:
336 case gfx::BufferFormat::YUV_420_BIPLANAR: 342 case gfx::BufferFormat::YUV_420_BIPLANAR:
337 case gfx::BufferFormat::UYVY_422: 343 case gfx::BufferFormat::UYVY_422:
344 case gfx::BufferFormat::YUYV_422:
338 NOTREACHED(); 345 NOTREACHED();
339 return nullptr; 346 return nullptr;
340 } 347 }
341 348
342 NOTREACHED(); 349 NOTREACHED();
343 return nullptr; 350 return nullptr;
344 } 351 }
345 352
346 } // namespace 353 } // namespace
347 354
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 return false; 497 return false;
491 } 498 }
492 499
493 // static 500 // static
494 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) { 501 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) {
495 DCHECK(ValidFormat(format)); 502 DCHECK(ValidFormat(format));
496 return TextureFormat(format); 503 return TextureFormat(format);
497 } 504 }
498 505
499 } // namespace gl 506 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gfx/mojo/buffer_types_traits.h ('k') | ui/gl/test/gl_image_test_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698