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

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

Issue 2334143003: ozone: Sort U and V plane when creating an image. (Closed)
Patch Set: Add missing attribute. 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 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))
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 case gfx::BufferFormat::YUV_420_BIPLANAR: 89 case gfx::BufferFormat::YUV_420_BIPLANAR:
90 case gfx::BufferFormat::UYVY_422: 90 case gfx::BufferFormat::UYVY_422:
91 NOTREACHED(); 91 NOTREACHED();
92 return 0; 92 return 0;
93 } 93 }
94 94
95 NOTREACHED(); 95 NOTREACHED();
96 return 0; 96 return 0;
97 } 97 }
98 98
99 #if !defined(ARCH_CPU_X86_FAMILY)
100 bool IsFormatCrCb(gfx::BufferFormat format) {
101 switch (format) {
102 case gfx::BufferFormat::YVU_420:
103 return true;
104 case gfx::BufferFormat::R_8:
105 case gfx::BufferFormat::BGR_565:
106 case gfx::BufferFormat::RGBA_8888:
107 case gfx::BufferFormat::RGBX_8888:
108 case gfx::BufferFormat::BGRA_8888:
109 case gfx::BufferFormat::BGRX_8888:
110 case gfx::BufferFormat::ATC:
111 case gfx::BufferFormat::ATCIA:
112 case gfx::BufferFormat::DXT1:
113 case gfx::BufferFormat::DXT5:
114 case gfx::BufferFormat::ETC1:
115 case gfx::BufferFormat::RGBA_4444:
116 case gfx::BufferFormat::YUV_420_BIPLANAR:
117 case gfx::BufferFormat::UYVY_422:
118 return false;
119 }
120 NOTREACHED();
121 return false;
122 }
123 #endif
124
99 } // namespace 125 } // namespace
100 126
101 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size, 127 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size,
102 unsigned internalformat) 128 unsigned internalformat)
103 : GLImageEGL(size), internalformat_(internalformat) {} 129 : GLImageEGL(size), internalformat_(internalformat) {}
104 130
105 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() { 131 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() {
106 } 132 }
107 133
108 bool GLImageOzoneNativePixmap::Initialize(ui::NativePixmap* pixmap, 134 bool GLImageOzoneNativePixmap::Initialize(ui::NativePixmap* pixmap,
(...skipping 21 matching lines...) Expand all
130 // Note: If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT 156 // Note: If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT
131 // target, the EGL will take a reference to the dma_buf. 157 // target, the EGL will take a reference to the dma_buf.
132 std::vector<EGLint> attrs; 158 std::vector<EGLint> attrs;
133 attrs.push_back(EGL_WIDTH); 159 attrs.push_back(EGL_WIDTH);
134 attrs.push_back(size_.width()); 160 attrs.push_back(size_.width());
135 attrs.push_back(EGL_HEIGHT); 161 attrs.push_back(EGL_HEIGHT);
136 attrs.push_back(size_.height()); 162 attrs.push_back(size_.height());
137 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT); 163 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT);
138 attrs.push_back(FourCC(format)); 164 attrs.push_back(FourCC(format));
139 165
140 for (size_t plane = 0; 166 for (size_t attrs_plane = 0;
141 plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); 167 attrs_plane <
142 ++plane) { 168 gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat());
143 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3); 169 ++attrs_plane) {
144 attrs.push_back( 170 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + attrs_plane * 3);
145 pixmap->GetDmaBufFd(plane < pixmap->GetDmaBufFdCount() ? plane : 0)); 171
146 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3); 172 size_t pixmap_plane = attrs_plane;
147 attrs.push_back(pixmap->GetDmaBufOffset(plane)); 173
148 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3); 174 // TODO(dcastagna): Intel mesa flips V and U when the fourcc format is a
149 attrs.push_back(pixmap->GetDmaBufPitch(plane)); 175 // CrCb format therefore we don't need to.
176 // Once crbug.com/646137 is addressed this ifdef (but not its content) can be
177 // removed.
178 #if !defined(ARCH_CPU_X86_FAMILY)
179 // EGL_EXT_image_dma_buf_import always expects U and V as plane 1 and 2 in
180 // case of a YUV/YVU format. We swap U and V plane indexes for CrCb
181 // multi-planar formats.
182 if (IsFormatCrCb(format) &&
183 gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()) == 3 &&
184 attrs_plane) {
185 pixmap_plane = 3 - attrs_plane;
186 }
187 #endif
188 attrs.push_back(pixmap->GetDmaBufFd(
189 pixmap_plane < pixmap->GetDmaBufFdCount() ? pixmap_plane : 0));
190 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + attrs_plane * 3);
191 attrs.push_back(pixmap->GetDmaBufOffset(pixmap_plane));
192 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + attrs_plane * 3);
193 attrs.push_back(pixmap->GetDmaBufPitch(pixmap_plane));
150 } 194 }
151 attrs.push_back(EGL_NONE); 195 attrs.push_back(EGL_NONE);
152 196
153 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT, 197 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT,
154 static_cast<EGLClientBuffer>(nullptr), 198 static_cast<EGLClientBuffer>(nullptr),
155 &attrs[0])) { 199 &attrs[0])) {
156 return false; 200 return false;
157 } 201 }
158 } 202 }
159 203
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 case gfx::BufferFormat::UYVY_422: 270 case gfx::BufferFormat::UYVY_422:
227 NOTREACHED(); 271 NOTREACHED();
228 return GL_NONE; 272 return GL_NONE;
229 } 273 }
230 274
231 NOTREACHED(); 275 NOTREACHED();
232 return GL_NONE; 276 return GL_NONE;
233 } 277 }
234 278
235 } // namespace gl 279 } // 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