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

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

Issue 2413853003: ozone: Don't sort YV channels for CrCb formats. (Closed)
Patch Set: 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
« 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 case gfx::BufferFormat::RGBA_4444: 103 case gfx::BufferFormat::RGBA_4444:
104 case gfx::BufferFormat::UYVY_422: 104 case gfx::BufferFormat::UYVY_422:
105 NOTREACHED(); 105 NOTREACHED();
106 return 0; 106 return 0;
107 } 107 }
108 108
109 NOTREACHED(); 109 NOTREACHED();
110 return 0; 110 return 0;
111 } 111 }
112 112
113 #if !defined(ARCH_CPU_X86_FAMILY)
114 bool IsFormatCrCb(gfx::BufferFormat format) {
115 switch (format) {
116 case gfx::BufferFormat::YVU_420:
117 return true;
118 case gfx::BufferFormat::R_8:
119 case gfx::BufferFormat::RG_88:
120 case gfx::BufferFormat::BGR_565:
121 case gfx::BufferFormat::RGBA_8888:
122 case gfx::BufferFormat::RGBX_8888:
123 case gfx::BufferFormat::BGRA_8888:
124 case gfx::BufferFormat::BGRX_8888:
125 case gfx::BufferFormat::ATC:
126 case gfx::BufferFormat::ATCIA:
127 case gfx::BufferFormat::DXT1:
128 case gfx::BufferFormat::DXT5:
129 case gfx::BufferFormat::ETC1:
130 case gfx::BufferFormat::RGBA_4444:
131 case gfx::BufferFormat::YUV_420_BIPLANAR:
132 case gfx::BufferFormat::UYVY_422:
133 return false;
134 }
135 NOTREACHED();
136 return false;
137 }
138 #endif
139
140 } // namespace 113 } // namespace
141 114
142 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size, 115 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size,
143 unsigned internalformat) 116 unsigned internalformat)
144 : GLImageEGL(size), 117 : GLImageEGL(size),
145 internalformat_(internalformat), 118 internalformat_(internalformat),
146 has_image_flush_external_( 119 has_image_flush_external_(
147 gl::GLSurfaceEGL::HasEGLExtension("EGL_EXT_image_flush_external")) {} 120 gl::GLSurfaceEGL::HasEGLExtension("EGL_EXT_image_flush_external")) {}
148 121
149 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() {} 122 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() {}
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 "EGL_EXT_image_dma_buf_import_modifiers"); 159 "EGL_EXT_image_dma_buf_import_modifiers");
187 160
188 for (size_t attrs_plane = 0; 161 for (size_t attrs_plane = 0;
189 attrs_plane < 162 attrs_plane <
190 gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); 163 gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat());
191 ++attrs_plane) { 164 ++attrs_plane) {
192 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + attrs_plane * 3); 165 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + attrs_plane * 3);
193 166
194 size_t pixmap_plane = attrs_plane; 167 size_t pixmap_plane = attrs_plane;
195 168
196 // TODO(dcastagna): Intel mesa flips V and U when the fourcc format is a
197 // CrCb format therefore we don't need to.
198 // Once crbug.com/646137 is addressed this ifdef (but not its content) can be
199 // removed.
200 #if !defined(ARCH_CPU_X86_FAMILY)
201 // EGL_EXT_image_dma_buf_import always expects U and V as plane 1 and 2 in
202 // case of a YUV/YVU format. We swap U and V plane indexes for CrCb
203 // multi-planar formats.
204 if (IsFormatCrCb(format) &&
205 gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()) == 3 &&
206 attrs_plane) {
207 pixmap_plane = 3 - attrs_plane;
208 }
209 #endif
210 attrs.push_back(pixmap->GetDmaBufFd( 169 attrs.push_back(pixmap->GetDmaBufFd(
211 pixmap_plane < pixmap->GetDmaBufFdCount() ? pixmap_plane : 0)); 170 pixmap_plane < pixmap->GetDmaBufFdCount() ? pixmap_plane : 0));
212 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + attrs_plane * 3); 171 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + attrs_plane * 3);
213 attrs.push_back(pixmap->GetDmaBufOffset(pixmap_plane)); 172 attrs.push_back(pixmap->GetDmaBufOffset(pixmap_plane));
214 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + attrs_plane * 3); 173 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + attrs_plane * 3);
215 attrs.push_back(pixmap->GetDmaBufPitch(pixmap_plane)); 174 attrs.push_back(pixmap->GetDmaBufPitch(pixmap_plane));
216 if (has_dma_buf_import_modifier) { 175 if (has_dma_buf_import_modifier) {
217 uint64_t modifier = pixmap->GetDmaBufModifier(pixmap_plane); 176 uint64_t modifier = pixmap->GetDmaBufModifier(pixmap_plane);
218 DCHECK(attrs_plane < arraysize(kLinuxDrmModifiers)); 177 DCHECK(attrs_plane < arraysize(kLinuxDrmModifiers));
219 attrs.push_back(kLinuxDrmModifiers[attrs_plane]); 178 attrs.push_back(kLinuxDrmModifiers[attrs_plane]);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 case gfx::BufferFormat::UYVY_422: 275 case gfx::BufferFormat::UYVY_422:
317 NOTREACHED(); 276 NOTREACHED();
318 return GL_NONE; 277 return GL_NONE;
319 } 278 }
320 279
321 NOTREACHED(); 280 NOTREACHED();
322 return GL_NONE; 281 return GL_NONE;
323 } 282 }
324 283
325 } // namespace ui 284 } // 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