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

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

Issue 2439703003: Update tokens for EGL_EXT_image_dma_buf_import_modifiers (Closed)
Patch Set: Fix the broken logic - move Initialize outside the for loop and don't return false if the retry suc… 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 | « third_party/khronos/EGL/eglext.h ('k') | 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Note: If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT 145 // Note: If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT
146 // target, the EGL will take a reference to the dma_buf. 146 // target, the EGL will take a reference to the dma_buf.
147 std::vector<EGLint> attrs; 147 std::vector<EGLint> attrs;
148 attrs.push_back(EGL_WIDTH); 148 attrs.push_back(EGL_WIDTH);
149 attrs.push_back(size_.width()); 149 attrs.push_back(size_.width());
150 attrs.push_back(EGL_HEIGHT); 150 attrs.push_back(EGL_HEIGHT);
151 attrs.push_back(size_.height()); 151 attrs.push_back(size_.height());
152 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT); 152 attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT);
153 attrs.push_back(FourCC(format)); 153 attrs.push_back(FourCC(format));
154 154
155 const EGLint kLinuxDrmModifiers[] = {EGL_LINUX_DRM_PLANE0_MODIFIER0_EXT, 155 const EGLint kLinuxDrmModifiers[] = {EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT,
156 EGL_LINUX_DRM_PLANE1_MODIFIER0_EXT, 156 EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT,
157 EGL_LINUX_DRM_PLANE2_MODIFIER0_EXT}; 157 EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT};
158 bool has_dma_buf_import_modifier = gl::GLSurfaceEGL::HasEGLExtension( 158 bool has_dma_buf_import_modifier = gl::GLSurfaceEGL::HasEGLExtension(
159 "EGL_EXT_image_dma_buf_import_modifiers"); 159 "EGL_EXT_image_dma_buf_import_modifiers");
160 160
161 for (size_t attrs_plane = 0; 161 for (size_t attrs_plane = 0;
162 attrs_plane < 162 attrs_plane <
163 gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()); 163 gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat());
164 ++attrs_plane) { 164 ++attrs_plane) {
165 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);
166 166
167 size_t pixmap_plane = attrs_plane; 167 size_t pixmap_plane = attrs_plane;
(...skipping 11 matching lines...) Expand all
179 attrs.push_back(modifier & 0xffffffff); 179 attrs.push_back(modifier & 0xffffffff);
180 attrs.push_back(kLinuxDrmModifiers[attrs_plane] + 1); 180 attrs.push_back(kLinuxDrmModifiers[attrs_plane] + 1);
181 attrs.push_back(static_cast<uint32_t>(modifier >> 32)); 181 attrs.push_back(static_cast<uint32_t>(modifier >> 32));
182 } 182 }
183 } 183 }
184 attrs.push_back(EGL_NONE); 184 attrs.push_back(EGL_NONE);
185 185
186 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT, 186 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT,
187 static_cast<EGLClientBuffer>(nullptr), 187 static_cast<EGLClientBuffer>(nullptr),
188 &attrs[0])) { 188 &attrs[0])) {
189 return false; 189 // TODO(hshi): remove this workaround after chrome uprevs and
190 // corresponding driver updates are made. https://crosbug.com/p/58718
191 if (has_dma_buf_import_modifier) {
192 // If driver rejects the new DMA-BUF import modifer tokens, then try
193 // again with the old token definition.
194 for (size_t i = 0; i < attrs.size(); i += 2) {
195 switch (attrs[i]) {
196 case EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT:
197 attrs[i] = EGL_LINUX_DRM_PLANE0_MODIFIER0_EXT;
198 break;
199 case EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT:
200 attrs[i] = EGL_LINUX_DRM_PLANE0_MODIFIER1_EXT;
201 break;
202 case EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT:
203 attrs[i] = EGL_LINUX_DRM_PLANE1_MODIFIER0_EXT;
204 break;
205 case EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT:
206 attrs[i] = EGL_LINUX_DRM_PLANE1_MODIFIER1_EXT;
207 break;
208 case EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT:
209 attrs[i] = EGL_LINUX_DRM_PLANE2_MODIFIER0_EXT;
210 break;
211 case EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT:
212 attrs[i] = EGL_LINUX_DRM_PLANE2_MODIFIER1_EXT;
213 break;
214 default:
215 break;
216 }
217 }
218 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT,
219 static_cast<EGLClientBuffer>(nullptr),
220 &attrs[0])) {
221 return false;
222 }
223 } else {
224 return false;
225 }
190 } 226 }
191 } 227 }
192 228
193 pixmap_ = pixmap; 229 pixmap_ = pixmap;
194 return true; 230 return true;
195 } 231 }
196 232
197 unsigned GLImageOzoneNativePixmap::GetInternalFormat() { 233 unsigned GLImageOzoneNativePixmap::GetInternalFormat() {
198 return internalformat_; 234 return internalformat_;
199 } 235 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 case gfx::BufferFormat::UYVY_422: 311 case gfx::BufferFormat::UYVY_422:
276 NOTREACHED(); 312 NOTREACHED();
277 return GL_NONE; 313 return GL_NONE;
278 } 314 }
279 315
280 NOTREACHED(); 316 NOTREACHED();
281 return GL_NONE; 317 return GL_NONE;
282 } 318 }
283 319
284 } // namespace ui 320 } // namespace ui
OLDNEW
« no previous file with comments | « third_party/khronos/EGL/eglext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698