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

Side by Side Diff: ui/ozone/gl/gl_image_ozone_native_pixmap.cc

Issue 2376293003: gpu: support RG_88 GpuMemoryBuffer (Closed)
Patch Set: resolve hubbe's review Created 4 years, 2 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
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_RGB565 FOURCC('R', 'G', '1', '6') 18 #define DRM_FORMAT_RGB565 FOURCC('R', 'G', '1', '6')
18 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4') 19 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4')
19 #define DRM_FORMAT_ABGR8888 FOURCC('A', 'B', '2', '4') 20 #define DRM_FORMAT_ABGR8888 FOURCC('A', 'B', '2', '4')
20 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4') 21 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4')
21 #define DRM_FORMAT_XBGR8888 FOURCC('X', 'B', '2', '4') 22 #define DRM_FORMAT_XBGR8888 FOURCC('X', 'B', '2', '4')
22 #define DRM_FORMAT_YV12 FOURCC('Y', 'V', '1', '2') 23 #define DRM_FORMAT_YV12 FOURCC('Y', 'V', '1', '2')
23 #define DRM_FORMAT_NV12 FOURCC('N', 'V', '1', '2') 24 #define DRM_FORMAT_NV12 FOURCC('N', 'V', '1', '2')
24 25
25 namespace ui { 26 namespace ui {
26 namespace { 27 namespace {
27 28
28 bool ValidInternalFormat(unsigned internalformat, gfx::BufferFormat format) { 29 bool ValidInternalFormat(unsigned internalformat, gfx::BufferFormat format) {
29 switch (internalformat) { 30 switch (internalformat) {
30 case GL_RGB: 31 case GL_RGB:
31 return format == gfx::BufferFormat::BGR_565 || 32 return format == gfx::BufferFormat::BGR_565 ||
32 format == gfx::BufferFormat::RGBX_8888 || 33 format == gfx::BufferFormat::RGBX_8888 ||
33 format == gfx::BufferFormat::BGRX_8888; 34 format == gfx::BufferFormat::BGRX_8888;
34 case GL_RGB_YCRCB_420_CHROMIUM: 35 case GL_RGB_YCRCB_420_CHROMIUM:
35 return format == gfx::BufferFormat::YVU_420; 36 return format == gfx::BufferFormat::YVU_420;
36 case GL_RGB_YCBCR_420V_CHROMIUM: 37 case GL_RGB_YCBCR_420V_CHROMIUM:
37 return format == gfx::BufferFormat::YUV_420_BIPLANAR; 38 return format == gfx::BufferFormat::YUV_420_BIPLANAR;
38 case GL_RGBA: 39 case GL_RGBA:
39 return format == gfx::BufferFormat::RGBA_8888; 40 return format == gfx::BufferFormat::RGBA_8888;
40 case GL_BGRA_EXT: 41 case GL_BGRA_EXT:
41 return format == gfx::BufferFormat::BGRA_8888; 42 return format == gfx::BufferFormat::BGRA_8888;
42 case GL_RED_EXT: 43 case GL_RED_EXT:
43 return format == gfx::BufferFormat::R_8; 44 return format == gfx::BufferFormat::R_8;
45 case GL_RG_EXT:
46 return format == gfx::BufferFormat::RG_88;
44 default: 47 default:
45 return false; 48 return false;
46 } 49 }
47 } 50 }
48 51
49 bool ValidFormat(gfx::BufferFormat format) { 52 bool ValidFormat(gfx::BufferFormat format) {
50 switch (format) { 53 switch (format) {
51 case gfx::BufferFormat::R_8: 54 case gfx::BufferFormat::R_8:
55 case gfx::BufferFormat::RG_88:
52 case gfx::BufferFormat::BGR_565: 56 case gfx::BufferFormat::BGR_565:
53 case gfx::BufferFormat::RGBA_8888: 57 case gfx::BufferFormat::RGBA_8888:
54 case gfx::BufferFormat::RGBX_8888: 58 case gfx::BufferFormat::RGBX_8888:
55 case gfx::BufferFormat::BGRA_8888: 59 case gfx::BufferFormat::BGRA_8888:
56 case gfx::BufferFormat::BGRX_8888: 60 case gfx::BufferFormat::BGRX_8888:
57 case gfx::BufferFormat::YVU_420: 61 case gfx::BufferFormat::YVU_420:
58 case gfx::BufferFormat::YUV_420_BIPLANAR: 62 case gfx::BufferFormat::YUV_420_BIPLANAR:
59 return true; 63 return true;
60 case gfx::BufferFormat::ATC: 64 case gfx::BufferFormat::ATC:
61 case gfx::BufferFormat::ATCIA: 65 case gfx::BufferFormat::ATCIA:
62 case gfx::BufferFormat::DXT1: 66 case gfx::BufferFormat::DXT1:
63 case gfx::BufferFormat::DXT5: 67 case gfx::BufferFormat::DXT5:
64 case gfx::BufferFormat::ETC1: 68 case gfx::BufferFormat::ETC1:
65 case gfx::BufferFormat::RGBA_4444: 69 case gfx::BufferFormat::RGBA_4444:
66 case gfx::BufferFormat::UYVY_422: 70 case gfx::BufferFormat::UYVY_422:
67 return false; 71 return false;
68 } 72 }
69 73
70 NOTREACHED(); 74 NOTREACHED();
71 return false; 75 return false;
72 } 76 }
73 77
74 EGLint FourCC(gfx::BufferFormat format) { 78 EGLint FourCC(gfx::BufferFormat format) {
75 switch (format) { 79 switch (format) {
76 case gfx::BufferFormat::R_8: 80 case gfx::BufferFormat::R_8:
77 return DRM_FORMAT_R8; 81 return DRM_FORMAT_R8;
82 case gfx::BufferFormat::RG_88:
83 return DRM_FORMAT_GR88;
78 case gfx::BufferFormat::BGR_565: 84 case gfx::BufferFormat::BGR_565:
79 return DRM_FORMAT_RGB565; 85 return DRM_FORMAT_RGB565;
80 case gfx::BufferFormat::RGBA_8888: 86 case gfx::BufferFormat::RGBA_8888:
81 return DRM_FORMAT_ABGR8888; 87 return DRM_FORMAT_ABGR8888;
82 case gfx::BufferFormat::RGBX_8888: 88 case gfx::BufferFormat::RGBX_8888:
83 return DRM_FORMAT_XBGR8888; 89 return DRM_FORMAT_XBGR8888;
84 case gfx::BufferFormat::BGRA_8888: 90 case gfx::BufferFormat::BGRA_8888:
85 return DRM_FORMAT_ARGB8888; 91 return DRM_FORMAT_ARGB8888;
86 case gfx::BufferFormat::BGRX_8888: 92 case gfx::BufferFormat::BGRX_8888:
87 return DRM_FORMAT_XRGB8888; 93 return DRM_FORMAT_XRGB8888;
(...skipping 15 matching lines...) Expand all
103 NOTREACHED(); 109 NOTREACHED();
104 return 0; 110 return 0;
105 } 111 }
106 112
107 #if !defined(ARCH_CPU_X86_FAMILY) 113 #if !defined(ARCH_CPU_X86_FAMILY)
108 bool IsFormatCrCb(gfx::BufferFormat format) { 114 bool IsFormatCrCb(gfx::BufferFormat format) {
109 switch (format) { 115 switch (format) {
110 case gfx::BufferFormat::YVU_420: 116 case gfx::BufferFormat::YVU_420:
111 return true; 117 return true;
112 case gfx::BufferFormat::R_8: 118 case gfx::BufferFormat::R_8:
119 case gfx::BufferFormat::RG_88:
113 case gfx::BufferFormat::BGR_565: 120 case gfx::BufferFormat::BGR_565:
114 case gfx::BufferFormat::RGBA_8888: 121 case gfx::BufferFormat::RGBA_8888:
115 case gfx::BufferFormat::RGBX_8888: 122 case gfx::BufferFormat::RGBX_8888:
116 case gfx::BufferFormat::BGRA_8888: 123 case gfx::BufferFormat::BGRA_8888:
117 case gfx::BufferFormat::BGRX_8888: 124 case gfx::BufferFormat::BGRX_8888:
118 case gfx::BufferFormat::ATC: 125 case gfx::BufferFormat::ATC:
119 case gfx::BufferFormat::ATCIA: 126 case gfx::BufferFormat::ATCIA:
120 case gfx::BufferFormat::DXT1: 127 case gfx::BufferFormat::DXT1:
121 case gfx::BufferFormat::DXT5: 128 case gfx::BufferFormat::DXT5:
122 case gfx::BufferFormat::ETC1: 129 case gfx::BufferFormat::ETC1:
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 287 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914
281 } 288 }
282 289
283 // static 290 // static
284 unsigned GLImageOzoneNativePixmap::GetInternalFormatForTesting( 291 unsigned GLImageOzoneNativePixmap::GetInternalFormatForTesting(
285 gfx::BufferFormat format) { 292 gfx::BufferFormat format) {
286 DCHECK(ValidFormat(format)); 293 DCHECK(ValidFormat(format));
287 switch (format) { 294 switch (format) {
288 case gfx::BufferFormat::R_8: 295 case gfx::BufferFormat::R_8:
289 return GL_RED_EXT; 296 return GL_RED_EXT;
297 case gfx::BufferFormat::RG_88:
298 return GL_RG_EXT;
290 case gfx::BufferFormat::BGR_565: 299 case gfx::BufferFormat::BGR_565:
291 case gfx::BufferFormat::RGBX_8888: 300 case gfx::BufferFormat::RGBX_8888:
292 case gfx::BufferFormat::BGRX_8888: 301 case gfx::BufferFormat::BGRX_8888:
293 return GL_RGB; 302 return GL_RGB;
294 case gfx::BufferFormat::RGBA_8888: 303 case gfx::BufferFormat::RGBA_8888:
295 return GL_RGBA; 304 return GL_RGBA;
296 case gfx::BufferFormat::BGRA_8888: 305 case gfx::BufferFormat::BGRA_8888:
297 return GL_BGRA_EXT; 306 return GL_BGRA_EXT;
298 case gfx::BufferFormat::YVU_420: 307 case gfx::BufferFormat::YVU_420:
299 return GL_RGB_YCRCB_420_CHROMIUM; 308 return GL_RGB_YCRCB_420_CHROMIUM;
300 case gfx::BufferFormat::ATC: 309 case gfx::BufferFormat::ATC:
301 case gfx::BufferFormat::ATCIA: 310 case gfx::BufferFormat::ATCIA:
302 case gfx::BufferFormat::DXT1: 311 case gfx::BufferFormat::DXT1:
303 case gfx::BufferFormat::DXT5: 312 case gfx::BufferFormat::DXT5:
304 case gfx::BufferFormat::ETC1: 313 case gfx::BufferFormat::ETC1:
305 case gfx::BufferFormat::RGBA_4444: 314 case gfx::BufferFormat::RGBA_4444:
306 case gfx::BufferFormat::YUV_420_BIPLANAR: 315 case gfx::BufferFormat::YUV_420_BIPLANAR:
307 case gfx::BufferFormat::UYVY_422: 316 case gfx::BufferFormat::UYVY_422:
308 NOTREACHED(); 317 NOTREACHED();
309 return GL_NONE; 318 return GL_NONE;
310 } 319 }
311 320
312 NOTREACHED(); 321 NOTREACHED();
313 return GL_NONE; 322 return GL_NONE;
314 } 323 }
315 324
316 } // namespace ui 325 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gl/test/gl_image_test_support.cc ('k') | ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698