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

Side by Side Diff: ui/ozone/gl/gl_image_ozone_native_pixmap.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/gl/test/gl_image_test_support.cc ('k') | ui/ozone/platform/drm/common/drm_util.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 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 "ui/ozone/gl/gl_image_ozone_native_pixmap.h" 5 #include "ui/ozone/gl/gl_image_ozone_native_pixmap.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ui/gfx/buffer_format_util.h" 9 #include "ui/gfx/buffer_format_util.h"
10 #include "ui/gl/gl_surface_egl.h" 10 #include "ui/gl/gl_surface_egl.h"
11 11
12 #define FOURCC(a, b, c, d) \ 12 #define FOURCC(a, b, c, d) \
13 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \ 13 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \
14 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24)) 14 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24))
15 15
16 #define DRM_FORMAT_R8 FOURCC('R', '8', ' ', ' ') 16 #define DRM_FORMAT_R8 FOURCC('R', '8', ' ', ' ')
17 #define DRM_FORMAT_GR88 FOURCC('G', 'R', '8', '8') 17 #define DRM_FORMAT_GR88 FOURCC('G', 'R', '8', '8')
18 #define DRM_FORMAT_RGB565 FOURCC('R', 'G', '1', '6') 18 #define DRM_FORMAT_RGB565 FOURCC('R', 'G', '1', '6')
19 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4') 19 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4')
20 #define DRM_FORMAT_ABGR8888 FOURCC('A', 'B', '2', '4') 20 #define DRM_FORMAT_ABGR8888 FOURCC('A', 'B', '2', '4')
21 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4') 21 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4')
22 #define DRM_FORMAT_XBGR8888 FOURCC('X', 'B', '2', '4') 22 #define DRM_FORMAT_XBGR8888 FOURCC('X', 'B', '2', '4')
23 #define DRM_FORMAT_YV12 FOURCC('Y', 'V', '1', '2') 23 #define DRM_FORMAT_YV12 FOURCC('Y', 'V', '1', '2')
24 #define DRM_FORMAT_NV12 FOURCC('N', 'V', '1', '2') 24 #define DRM_FORMAT_NV12 FOURCC('N', 'V', '1', '2')
25 #define DRM_FORMAT_UYVY FOURCC('U', 'Y', 'V', 'Y')
26 #define DRM_FORMAT_YUYV FOURCC('Y', 'U', 'Y', 'V')
25 27
26 namespace ui { 28 namespace ui {
27 namespace { 29 namespace {
28 30
29 bool ValidInternalFormat(unsigned internalformat, gfx::BufferFormat format) { 31 bool ValidInternalFormat(unsigned internalformat, gfx::BufferFormat format) {
30 switch (internalformat) { 32 switch (internalformat) {
31 case GL_RGB: 33 case GL_RGB:
32 return format == gfx::BufferFormat::BGR_565 || 34 return format == gfx::BufferFormat::BGR_565 ||
33 format == gfx::BufferFormat::RGBX_8888 || 35 format == gfx::BufferFormat::RGBX_8888 ||
34 format == gfx::BufferFormat::BGRX_8888; 36 format == gfx::BufferFormat::BGRX_8888;
35 case GL_RGB_YCRCB_420_CHROMIUM: 37 case GL_RGB_YCRCB_420_CHROMIUM:
36 return format == gfx::BufferFormat::YVU_420; 38 return format == gfx::BufferFormat::YVU_420;
37 case GL_RGB_YCBCR_420V_CHROMIUM: 39 case GL_RGB_YCBCR_420V_CHROMIUM:
38 return format == gfx::BufferFormat::YUV_420_BIPLANAR; 40 return format == gfx::BufferFormat::YUV_420_BIPLANAR;
41 case GL_RGB_YCBCR_422_CHROMIUM:
42 return format == gfx::BufferFormat::YUYV_422;
39 case GL_RGBA: 43 case GL_RGBA:
40 return format == gfx::BufferFormat::RGBA_8888; 44 return format == gfx::BufferFormat::RGBA_8888;
41 case GL_BGRA_EXT: 45 case GL_BGRA_EXT:
42 return format == gfx::BufferFormat::BGRA_8888; 46 return format == gfx::BufferFormat::BGRA_8888;
43 case GL_RED_EXT: 47 case GL_RED_EXT:
44 return format == gfx::BufferFormat::R_8; 48 return format == gfx::BufferFormat::R_8;
45 case GL_RG_EXT: 49 case GL_RG_EXT:
46 return format == gfx::BufferFormat::RG_88; 50 return format == gfx::BufferFormat::RG_88;
47 default: 51 default:
48 return false; 52 return false;
49 } 53 }
50 } 54 }
51 55
52 bool ValidFormat(gfx::BufferFormat format) { 56 bool ValidFormat(gfx::BufferFormat format) {
53 switch (format) { 57 switch (format) {
54 case gfx::BufferFormat::R_8: 58 case gfx::BufferFormat::R_8:
55 case gfx::BufferFormat::RG_88: 59 case gfx::BufferFormat::RG_88:
56 case gfx::BufferFormat::BGR_565: 60 case gfx::BufferFormat::BGR_565:
57 case gfx::BufferFormat::RGBA_8888: 61 case gfx::BufferFormat::RGBA_8888:
58 case gfx::BufferFormat::RGBX_8888: 62 case gfx::BufferFormat::RGBX_8888:
59 case gfx::BufferFormat::BGRA_8888: 63 case gfx::BufferFormat::BGRA_8888:
60 case gfx::BufferFormat::BGRX_8888: 64 case gfx::BufferFormat::BGRX_8888:
61 case gfx::BufferFormat::YVU_420: 65 case gfx::BufferFormat::YVU_420:
62 case gfx::BufferFormat::YUV_420_BIPLANAR: 66 case gfx::BufferFormat::YUV_420_BIPLANAR:
67 case gfx::BufferFormat::UYVY_422:
68 case gfx::BufferFormat::YUYV_422:
63 return true; 69 return true;
64 case gfx::BufferFormat::ATC: 70 case gfx::BufferFormat::ATC:
65 case gfx::BufferFormat::ATCIA: 71 case gfx::BufferFormat::ATCIA:
66 case gfx::BufferFormat::DXT1: 72 case gfx::BufferFormat::DXT1:
67 case gfx::BufferFormat::DXT5: 73 case gfx::BufferFormat::DXT5:
68 case gfx::BufferFormat::ETC1: 74 case gfx::BufferFormat::ETC1:
69 case gfx::BufferFormat::RGBA_4444: 75 case gfx::BufferFormat::RGBA_4444:
70 case gfx::BufferFormat::UYVY_422:
71 return false; 76 return false;
72 } 77 }
73 78
74 NOTREACHED(); 79 NOTREACHED();
75 return false; 80 return false;
76 } 81 }
77 82
78 EGLint FourCC(gfx::BufferFormat format) { 83 EGLint FourCC(gfx::BufferFormat format) {
79 switch (format) { 84 switch (format) {
80 case gfx::BufferFormat::R_8: 85 case gfx::BufferFormat::R_8:
81 return DRM_FORMAT_R8; 86 return DRM_FORMAT_R8;
82 case gfx::BufferFormat::RG_88: 87 case gfx::BufferFormat::RG_88:
83 return DRM_FORMAT_GR88; 88 return DRM_FORMAT_GR88;
84 case gfx::BufferFormat::BGR_565: 89 case gfx::BufferFormat::BGR_565:
85 return DRM_FORMAT_RGB565; 90 return DRM_FORMAT_RGB565;
86 case gfx::BufferFormat::RGBA_8888: 91 case gfx::BufferFormat::RGBA_8888:
87 return DRM_FORMAT_ABGR8888; 92 return DRM_FORMAT_ABGR8888;
88 case gfx::BufferFormat::RGBX_8888: 93 case gfx::BufferFormat::RGBX_8888:
89 return DRM_FORMAT_XBGR8888; 94 return DRM_FORMAT_XBGR8888;
90 case gfx::BufferFormat::BGRA_8888: 95 case gfx::BufferFormat::BGRA_8888:
91 return DRM_FORMAT_ARGB8888; 96 return DRM_FORMAT_ARGB8888;
92 case gfx::BufferFormat::BGRX_8888: 97 case gfx::BufferFormat::BGRX_8888:
93 return DRM_FORMAT_XRGB8888; 98 return DRM_FORMAT_XRGB8888;
94 case gfx::BufferFormat::YVU_420: 99 case gfx::BufferFormat::YVU_420:
95 return DRM_FORMAT_YV12; 100 return DRM_FORMAT_YV12;
96 case gfx::BufferFormat::YUV_420_BIPLANAR: 101 case gfx::BufferFormat::YUV_420_BIPLANAR:
97 return DRM_FORMAT_NV12; 102 return DRM_FORMAT_NV12;
103 case gfx::BufferFormat::UYVY_422:
104 return DRM_FORMAT_UYVY;
105 case gfx::BufferFormat::YUYV_422:
106 return DRM_FORMAT_YUYV;
98 case gfx::BufferFormat::ATC: 107 case gfx::BufferFormat::ATC:
99 case gfx::BufferFormat::ATCIA: 108 case gfx::BufferFormat::ATCIA:
100 case gfx::BufferFormat::DXT1: 109 case gfx::BufferFormat::DXT1:
101 case gfx::BufferFormat::DXT5: 110 case gfx::BufferFormat::DXT5:
102 case gfx::BufferFormat::ETC1: 111 case gfx::BufferFormat::ETC1:
103 case gfx::BufferFormat::RGBA_4444: 112 case gfx::BufferFormat::RGBA_4444:
104 case gfx::BufferFormat::UYVY_422: 113
105 NOTREACHED(); 114 NOTREACHED();
106 return 0; 115 return 0;
107 } 116 }
108 117
109 NOTREACHED(); 118 NOTREACHED();
110 return 0; 119 return 0;
111 } 120 }
112 121
113 } // namespace 122 } // namespace
114 123
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 return GL_RGB_YCRCB_420_CHROMIUM; 272 return GL_RGB_YCRCB_420_CHROMIUM;
264 case gfx::BufferFormat::YUV_420_BIPLANAR: 273 case gfx::BufferFormat::YUV_420_BIPLANAR:
265 return GL_RGB_YCBCR_420V_CHROMIUM; 274 return GL_RGB_YCBCR_420V_CHROMIUM;
266 case gfx::BufferFormat::ATC: 275 case gfx::BufferFormat::ATC:
267 case gfx::BufferFormat::ATCIA: 276 case gfx::BufferFormat::ATCIA:
268 case gfx::BufferFormat::DXT1: 277 case gfx::BufferFormat::DXT1:
269 case gfx::BufferFormat::DXT5: 278 case gfx::BufferFormat::DXT5:
270 case gfx::BufferFormat::ETC1: 279 case gfx::BufferFormat::ETC1:
271 case gfx::BufferFormat::RGBA_4444: 280 case gfx::BufferFormat::RGBA_4444:
272 case gfx::BufferFormat::UYVY_422: 281 case gfx::BufferFormat::UYVY_422:
282 case gfx::BufferFormat::YUYV_422:
273 NOTREACHED(); 283 NOTREACHED();
274 return GL_NONE; 284 return GL_NONE;
275 } 285 }
276 286
277 NOTREACHED(); 287 NOTREACHED();
278 return GL_NONE; 288 return GL_NONE;
279 } 289 }
280 290
281 } // namespace ui 291 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gl/test/gl_image_test_support.cc ('k') | ui/ozone/platform/drm/common/drm_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698