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

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

Issue 2295943002: ozone: Sort U and V plane when creating an image. (Closed)
Patch Set: Link to correct bug. Created 4 years, 3 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 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"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 case gfx::BufferFormat::YUV_420_BIPLANAR: 93 case gfx::BufferFormat::YUV_420_BIPLANAR:
94 case gfx::BufferFormat::UYVY_422: 94 case gfx::BufferFormat::UYVY_422:
95 NOTREACHED(); 95 NOTREACHED();
96 return 0; 96 return 0;
97 } 97 }
98 98
99 NOTREACHED(); 99 NOTREACHED();
100 return 0; 100 return 0;
101 } 101 }
102 102
103 #if !defined(ARCH_CPU_X86_FAMILY)
104 bool IsFormatCrCb(gfx::BufferFormat format) {
105 switch (format) {
106 case gfx::BufferFormat::YVU_420:
107 return true;
108 case gfx::BufferFormat::R_8:
109 case gfx::BufferFormat::BGR_565:
110 case gfx::BufferFormat::RGBA_8888:
111 case gfx::BufferFormat::RGBX_8888:
112 case gfx::BufferFormat::BGRA_8888:
113 case gfx::BufferFormat::BGRX_8888:
114 case gfx::BufferFormat::ATC:
115 case gfx::BufferFormat::ATCIA:
116 case gfx::BufferFormat::DXT1:
117 case gfx::BufferFormat::DXT5:
118 case gfx::BufferFormat::ETC1:
119 case gfx::BufferFormat::RGBA_4444:
120 case gfx::BufferFormat::YUV_420_BIPLANAR:
121 case gfx::BufferFormat::UYVY_422:
122 return false;
123 }
124 NOTREACHED();
125 return false;
126 }
127 #endif
128
103 } // namespace 129 } // namespace
104 130
105 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size, 131 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size,
106 unsigned internalformat) 132 unsigned internalformat)
107 : GLImageEGL(size), 133 : GLImageEGL(size),
108 internalformat_(internalformat), 134 internalformat_(internalformat),
109 has_image_flush_external_( 135 has_image_flush_external_(
110 gl::GLSurfaceEGL::HasEGLExtension("EGL_EXT_image_flush_external")) {} 136 gl::GLSurfaceEGL::HasEGLExtension("EGL_EXT_image_flush_external")) {}
111 137
112 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() {} 138 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() {}
(...skipping 28 matching lines...) Expand all
141 attrs.push_back(size_.height()); 167 attrs.push_back(size_.height());
142 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT); 168 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT);
143 attrs.push_back(FourCC(format)); 169 attrs.push_back(FourCC(format));
144 170
145 const EGLint kLinuxDrmModifiers[] = {EGL_LINUX_DRM_PLANE0_MODIFIER0_EXT, 171 const EGLint kLinuxDrmModifiers[] = {EGL_LINUX_DRM_PLANE0_MODIFIER0_EXT,
146 EGL_LINUX_DRM_PLANE1_MODIFIER0_EXT, 172 EGL_LINUX_DRM_PLANE1_MODIFIER0_EXT,
147 EGL_LINUX_DRM_PLANE2_MODIFIER0_EXT}; 173 EGL_LINUX_DRM_PLANE2_MODIFIER0_EXT};
148 bool has_dma_buf_import_modifier = gl::GLSurfaceEGL::HasEGLExtension( 174 bool has_dma_buf_import_modifier = gl::GLSurfaceEGL::HasEGLExtension(
149 "EGL_EXT_image_dma_buf_import_modifiers"); 175 "EGL_EXT_image_dma_buf_import_modifiers");
150 176
151 for (size_t plane = 0; 177 for (size_t attrs_plane = 0;
152 plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); 178 attrs_plane <
153 ++plane) { 179 gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat());
154 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3); 180 ++attrs_plane) {
155 attrs.push_back( 181 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + attrs_plane * 3);
156 pixmap->GetDmaBufFd(plane < pixmap->GetDmaBufFdCount() ? plane : 0)); 182
157 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3); 183 size_t pixmap_plane = attrs_plane;
158 attrs.push_back(pixmap->GetDmaBufOffset(plane)); 184
159 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3); 185 // TODO(dcastagna): Intel mesa flips V and U when the fourcc format is a
160 attrs.push_back(pixmap->GetDmaBufPitch(plane)); 186 // CrCb format therefore we don't need to.
187 // Once crbug.com/646137 is addressed this ifdef (but not its content) can be
188 // removed.
189 #if !defined(ARCH_CPU_X86_FAMILY)
190 // EGL_EXT_image_dma_buf_import always expects U and V as plane 1 and 2 in
191 // case of a YUV/YVU format. We swap U and V plane indexes for CrCb
192 // multi-planar formats.
193 if (IsFormatCrCb(format) &&
194 gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()) == 3 &&
195 attrs_plane) {
196 pixmap_plane = 3 - attrs_plane;
197 }
198 #endif
199 attrs.push_back(pixmap->GetDmaBufFd(
200 pixmap_plane < pixmap->GetDmaBufFdCount() ? pixmap_plane : 0));
201 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + attrs_plane * 3);
202 attrs.push_back(pixmap->GetDmaBufOffset(pixmap_plane));
203 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + attrs_plane * 3);
204 attrs.push_back(pixmap->GetDmaBufPitch(pixmap_plane));
161 if (has_dma_buf_import_modifier) { 205 if (has_dma_buf_import_modifier) {
162 uint64_t modifier = pixmap->GetDmaBufModifier(plane); 206 uint64_t modifier = pixmap->GetDmaBufModifier(pixmap_plane);
163 DCHECK(plane < arraysize(kLinuxDrmModifiers)); 207 DCHECK(attrs_plane < arraysize(kLinuxDrmModifiers));
164 attrs.push_back(kLinuxDrmModifiers[plane]); 208 attrs.push_back(kLinuxDrmModifiers[attrs_plane]);
165 attrs.push_back(modifier & 0xffffffff); 209 attrs.push_back(modifier & 0xffffffff);
166 attrs.push_back(kLinuxDrmModifiers[plane] + 1); 210 attrs.push_back(kLinuxDrmModifiers[attrs_plane] + 1);
167 attrs.push_back(static_cast<uint32_t>(modifier >> 32)); 211 attrs.push_back(static_cast<uint32_t>(modifier >> 32));
168 } 212 }
169 } 213 }
170 attrs.push_back(EGL_NONE); 214 attrs.push_back(EGL_NONE);
171 215
172 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT, 216 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT,
173 static_cast<EGLClientBuffer>(nullptr), 217 static_cast<EGLClientBuffer>(nullptr),
174 &attrs[0])) { 218 &attrs[0])) {
175 return false; 219 return false;
176 } 220 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 case gfx::BufferFormat::UYVY_422: 302 case gfx::BufferFormat::UYVY_422:
259 NOTREACHED(); 303 NOTREACHED();
260 return GL_NONE; 304 return GL_NONE;
261 } 305 }
262 306
263 NOTREACHED(); 307 NOTREACHED();
264 return GL_NONE; 308 return GL_NONE;
265 } 309 }
266 310
267 } // namespace ui 311 } // namespace ui
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