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

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

Issue 2055483002: gl: Add YVU_420 support to GLImageOzoneNativePixmap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/gfx/buffer_format_util.h" 5 #include "ui/gfx/buffer_format_util.h"
6 #include "ui/gl/gl_image_ozone_native_pixmap.h" 6 #include "ui/gl/gl_image_ozone_native_pixmap.h"
7 7
8 #define FOURCC(a, b, c, d) \ 8 #define FOURCC(a, b, c, d) \
9 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \ 9 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \
10 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24)) 10 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24))
11 11
12 #define DRM_FORMAT_R8 FOURCC('R', '8', ' ', ' ') 12 #define DRM_FORMAT_R8 FOURCC('R', '8', ' ', ' ')
13 #define DRM_FORMAT_RGB565 FOURCC('R', 'G', '1', '6') 13 #define DRM_FORMAT_RGB565 FOURCC('R', 'G', '1', '6')
14 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4') 14 #define DRM_FORMAT_ARGB8888 FOURCC('A', 'R', '2', '4')
15 #define DRM_FORMAT_ABGR8888 FOURCC('A', 'B', '2', '4') 15 #define DRM_FORMAT_ABGR8888 FOURCC('A', 'B', '2', '4')
16 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4') 16 #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4')
17 #define DRM_FORMAT_XBGR8888 FOURCC('X', 'B', '2', '4') 17 #define DRM_FORMAT_XBGR8888 FOURCC('X', 'B', '2', '4')
18 #define DRM_FORMAT_YV12 FOURCC('Y', 'V', '1', '2')
18 19
19 namespace gl { 20 namespace gl {
20 namespace { 21 namespace {
21 22
22 bool ValidInternalFormat(unsigned internalformat, gfx::BufferFormat format) { 23 bool ValidInternalFormat(unsigned internalformat, gfx::BufferFormat format) {
23 switch (internalformat) { 24 switch (internalformat) {
24 case GL_RGB: 25 case GL_RGB:
25 return format == gfx::BufferFormat::BGR_565 || 26 return format == gfx::BufferFormat::BGR_565 ||
26 format == gfx::BufferFormat::RGBX_8888 || 27 format == gfx::BufferFormat::RGBX_8888 ||
27 format == gfx::BufferFormat::BGRX_8888; 28 format == gfx::BufferFormat::BGRX_8888;
29 case GL_RGB_YCRCB_420_CHROMIUM:
30 return format == gfx::BufferFormat::YVU_420;
28 case GL_RGBA: 31 case GL_RGBA:
29 return format == gfx::BufferFormat::RGBA_8888; 32 return format == gfx::BufferFormat::RGBA_8888;
30 case GL_BGRA_EXT: 33 case GL_BGRA_EXT:
31 return format == gfx::BufferFormat::BGRA_8888; 34 return format == gfx::BufferFormat::BGRA_8888;
32 case GL_RED_EXT: 35 case GL_RED_EXT:
33 return format == gfx::BufferFormat::R_8; 36 return format == gfx::BufferFormat::R_8;
34 default: 37 default:
35 return false; 38 return false;
36 } 39 }
37 } 40 }
38 41
39 bool ValidFormat(gfx::BufferFormat format) { 42 bool ValidFormat(gfx::BufferFormat format) {
40 switch (format) { 43 switch (format) {
41 case gfx::BufferFormat::R_8: 44 case gfx::BufferFormat::R_8:
42 case gfx::BufferFormat::BGR_565: 45 case gfx::BufferFormat::BGR_565:
43 case gfx::BufferFormat::RGBA_8888: 46 case gfx::BufferFormat::RGBA_8888:
44 case gfx::BufferFormat::RGBX_8888: 47 case gfx::BufferFormat::RGBX_8888:
45 case gfx::BufferFormat::BGRA_8888: 48 case gfx::BufferFormat::BGRA_8888:
46 case gfx::BufferFormat::BGRX_8888: 49 case gfx::BufferFormat::BGRX_8888:
50 case gfx::BufferFormat::YVU_420:
47 return true; 51 return true;
48 case gfx::BufferFormat::ATC: 52 case gfx::BufferFormat::ATC:
49 case gfx::BufferFormat::ATCIA: 53 case gfx::BufferFormat::ATCIA:
50 case gfx::BufferFormat::DXT1: 54 case gfx::BufferFormat::DXT1:
51 case gfx::BufferFormat::DXT5: 55 case gfx::BufferFormat::DXT5:
52 case gfx::BufferFormat::ETC1: 56 case gfx::BufferFormat::ETC1:
53 case gfx::BufferFormat::RGBA_4444: 57 case gfx::BufferFormat::RGBA_4444:
54 case gfx::BufferFormat::YVU_420:
55 case gfx::BufferFormat::YUV_420_BIPLANAR: 58 case gfx::BufferFormat::YUV_420_BIPLANAR:
56 case gfx::BufferFormat::UYVY_422: 59 case gfx::BufferFormat::UYVY_422:
57 return false; 60 return false;
58 } 61 }
59 62
60 NOTREACHED(); 63 NOTREACHED();
61 return false; 64 return false;
62 } 65 }
63 66
64 EGLint FourCC(gfx::BufferFormat format) { 67 EGLint FourCC(gfx::BufferFormat format) {
65 switch (format) { 68 switch (format) {
66 case gfx::BufferFormat::R_8: 69 case gfx::BufferFormat::R_8:
67 return DRM_FORMAT_R8; 70 return DRM_FORMAT_R8;
68 case gfx::BufferFormat::BGR_565: 71 case gfx::BufferFormat::BGR_565:
69 return DRM_FORMAT_RGB565; 72 return DRM_FORMAT_RGB565;
70 case gfx::BufferFormat::RGBA_8888: 73 case gfx::BufferFormat::RGBA_8888:
71 return DRM_FORMAT_ABGR8888; 74 return DRM_FORMAT_ABGR8888;
72 case gfx::BufferFormat::RGBX_8888: 75 case gfx::BufferFormat::RGBX_8888:
73 return DRM_FORMAT_XBGR8888; 76 return DRM_FORMAT_XBGR8888;
74 case gfx::BufferFormat::BGRA_8888: 77 case gfx::BufferFormat::BGRA_8888:
75 return DRM_FORMAT_ARGB8888; 78 return DRM_FORMAT_ARGB8888;
76 case gfx::BufferFormat::BGRX_8888: 79 case gfx::BufferFormat::BGRX_8888:
77 return DRM_FORMAT_XRGB8888; 80 return DRM_FORMAT_XRGB8888;
81 case gfx::BufferFormat::YVU_420:
82 return DRM_FORMAT_YV12;
78 case gfx::BufferFormat::ATC: 83 case gfx::BufferFormat::ATC:
79 case gfx::BufferFormat::ATCIA: 84 case gfx::BufferFormat::ATCIA:
80 case gfx::BufferFormat::DXT1: 85 case gfx::BufferFormat::DXT1:
81 case gfx::BufferFormat::DXT5: 86 case gfx::BufferFormat::DXT5:
82 case gfx::BufferFormat::ETC1: 87 case gfx::BufferFormat::ETC1:
83 case gfx::BufferFormat::RGBA_4444: 88 case gfx::BufferFormat::RGBA_4444:
84 case gfx::BufferFormat::YVU_420:
85 case gfx::BufferFormat::YUV_420_BIPLANAR: 89 case gfx::BufferFormat::YUV_420_BIPLANAR:
86 case gfx::BufferFormat::UYVY_422: 90 case gfx::BufferFormat::UYVY_422:
87 NOTREACHED(); 91 NOTREACHED();
88 return 0; 92 return 0;
89 } 93 }
90 94
91 NOTREACHED(); 95 NOTREACHED();
92 return 0; 96 return 0;
93 } 97 }
94 98
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 attrs.push_back(size_.width()); 134 attrs.push_back(size_.width());
131 attrs.push_back(EGL_HEIGHT); 135 attrs.push_back(EGL_HEIGHT);
132 attrs.push_back(size_.height()); 136 attrs.push_back(size_.height());
133 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT); 137 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT);
134 attrs.push_back(FourCC(format)); 138 attrs.push_back(FourCC(format));
135 139
136 for (size_t plane = 0; 140 for (size_t plane = 0;
137 plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); 141 plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat());
138 ++plane) { 142 ++plane) {
139 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3); 143 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3);
144 #if defined(ARCH_CPU_X86_FAMILY) && defined(OS_CHROMEOS)
145 // i965 driver expects all the fds to have the same value.
reveman 2016/06/08 21:48:30 Can we change the GLImageOzone native pixmap API t
Daniele Castagna 2016/06/09 00:26:24 Done as discussed.
146 attrs.push_back(pixmap->GetDmaBufFd(0));
147 #else
140 attrs.push_back(pixmap->GetDmaBufFd(plane)); 148 attrs.push_back(pixmap->GetDmaBufFd(plane));
149 #endif
141 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3); 150 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3);
142 attrs.push_back(0); 151 attrs.push_back(0);
143 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3); 152 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3);
144 attrs.push_back(pixmap->GetDmaBufPitch(plane)); 153 attrs.push_back(pixmap->GetDmaBufPitch(plane));
145 } 154 }
146 attrs.push_back(EGL_NONE); 155 attrs.push_back(EGL_NONE);
147 156
148 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT, 157 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT,
149 static_cast<EGLClientBuffer>(nullptr), 158 static_cast<EGLClientBuffer>(nullptr),
150 &attrs[0])) { 159 &attrs[0])) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 case gfx::BufferFormat::UYVY_422: 230 case gfx::BufferFormat::UYVY_422:
222 NOTREACHED(); 231 NOTREACHED();
223 return GL_NONE; 232 return GL_NONE;
224 } 233 }
225 234
226 NOTREACHED(); 235 NOTREACHED();
227 return GL_NONE; 236 return GL_NONE;
228 } 237 }
229 238
230 } // namespace gl 239 } // namespace gl
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698