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

Side by Side Diff: ui/gl/gl_image_io_surface.mm

Issue 2831733003: Fix blits from multisampled renderbuffers to alpha:false WebGL back buffer. (Closed)
Patch Set: Add PLATFORM_EXPORT to fix link failure on Windows. Created 3 years, 8 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 | « ui/gl/gl_image_io_surface.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/gl/gl_image_io_surface.h" 5 #include "ui/gl/gl_image_io_surface.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/mac/bind_objc_block.h" 10 #include "base/mac/bind_objc_block.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 case gfx::BufferFormat::YUV_420_BIPLANAR: 161 case gfx::BufferFormat::YUV_420_BIPLANAR:
162 NOTREACHED(); 162 NOTREACHED();
163 return 0; 163 return 0;
164 } 164 }
165 165
166 NOTREACHED(); 166 NOTREACHED();
167 return 0; 167 return 0;
168 } 168 }
169 169
170 // When an IOSurface is bound to a texture with internalformat "GL_RGB", many 170 // When an IOSurface is bound to a texture with internalformat "GL_RGB", many
171 // OpenGL operations are broken. Therefore, never allow an IOSurface to be bound 171 // OpenGL operations are broken. Therefore, don't allow an IOSurface to be bound
172 // with GL_RGB. https://crbug.com/595948. 172 // with GL_RGB unless overridden via BindTexImageWithInternalformat.
173 // crbug.com/595948, crbug.com/699566.
173 GLenum ConvertRequestedInternalFormat(GLenum internalformat) { 174 GLenum ConvertRequestedInternalFormat(GLenum internalformat) {
174 if (internalformat == GL_RGB) 175 if (internalformat == GL_RGB)
175 return GL_RGBA; 176 return GL_RGBA;
176 return internalformat; 177 return internalformat;
177 } 178 }
178 179
179 } // namespace 180 } // namespace
180 181
181 GLImageIOSurface::GLImageIOSurface(const gfx::Size& size, 182 GLImageIOSurface::GLImageIOSurface(const gfx::Size& size,
182 unsigned internalformat) 183 unsigned internalformat)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 231
231 gfx::Size GLImageIOSurface::GetSize() { 232 gfx::Size GLImageIOSurface::GetSize() {
232 return size_; 233 return size_;
233 } 234 }
234 235
235 unsigned GLImageIOSurface::GetInternalFormat() { 236 unsigned GLImageIOSurface::GetInternalFormat() {
236 return internalformat_; 237 return internalformat_;
237 } 238 }
238 239
239 bool GLImageIOSurface::BindTexImage(unsigned target) { 240 bool GLImageIOSurface::BindTexImage(unsigned target) {
241 return BindTexImageWithInternalformat(target, 0);
242 }
243
244 bool GLImageIOSurface::BindTexImageWithInternalformat(unsigned target,
245 unsigned internalformat) {
240 DCHECK(thread_checker_.CalledOnValidThread()); 246 DCHECK(thread_checker_.CalledOnValidThread());
241 TRACE_EVENT0("gpu", "GLImageIOSurface::BindTexImage"); 247 TRACE_EVENT0("gpu", "GLImageIOSurface::BindTexImage");
242 base::TimeTicks start_time = base::TimeTicks::Now(); 248 base::TimeTicks start_time = base::TimeTicks::Now();
243 249
244 // YUV_420_BIPLANAR is not supported by BindTexImage. 250 // YUV_420_BIPLANAR is not supported by BindTexImage.
245 // CopyTexImage is supported by this format as that performs conversion to RGB 251 // CopyTexImage is supported by this format as that performs conversion to RGB
246 // as part of the copy operation. 252 // as part of the copy operation.
247 if (format_ == gfx::BufferFormat::YUV_420_BIPLANAR) 253 if (format_ == gfx::BufferFormat::YUV_420_BIPLANAR)
248 return false; 254 return false;
249 255
250 if (target != GL_TEXTURE_RECTANGLE_ARB) { 256 if (target != GL_TEXTURE_RECTANGLE_ARB) {
251 // This might be supported in the future. For now, perform strict 257 // This might be supported in the future. For now, perform strict
252 // validation so we know what's going on. 258 // validation so we know what's going on.
253 LOG(ERROR) << "IOSurface requires TEXTURE_RECTANGLE_ARB target"; 259 LOG(ERROR) << "IOSurface requires TEXTURE_RECTANGLE_ARB target";
254 return false; 260 return false;
255 } 261 }
256 262
257 CGLContextObj cgl_context = 263 CGLContextObj cgl_context =
258 static_cast<CGLContextObj>(GLContext::GetCurrent()->GetHandle()); 264 static_cast<CGLContextObj>(GLContext::GetCurrent()->GetHandle());
259 265
260 DCHECK(io_surface_); 266 DCHECK(io_surface_);
261 CGLError cgl_error = 267
262 CGLTexImageIOSurface2D(cgl_context, target, TextureFormat(format_), 268 GLenum texture_format =
263 size_.width(), size_.height(), DataFormat(format_), 269 internalformat ? internalformat : TextureFormat(format_);
264 DataType(format_), io_surface_.get(), 0); 270 CGLError cgl_error = CGLTexImageIOSurface2D(
271 cgl_context, target, texture_format, size_.width(), size_.height(),
272 DataFormat(format_), DataType(format_), io_surface_.get(), 0);
265 if (cgl_error != kCGLNoError) { 273 if (cgl_error != kCGLNoError) {
266 LOG(ERROR) << "Error in CGLTexImageIOSurface2D: " 274 LOG(ERROR) << "Error in CGLTexImageIOSurface2D: "
267 << CGLErrorString(cgl_error); 275 << CGLErrorString(cgl_error);
268 return false; 276 return false;
269 } 277 }
270 278
271 UMA_HISTOGRAM_TIMES("GPU.IOSurface.TexImageTime", 279 UMA_HISTOGRAM_TIMES("GPU.IOSurface.TexImageTime",
272 base::TimeTicks::Now() - start_time); 280 base::TimeTicks::Now() - start_time);
273 return true; 281 return true;
274 } 282 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 417 }
410 418
411 // static 419 // static
412 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) { 420 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) {
413 if (!image || image->GetType() != Type::IOSURFACE) 421 if (!image || image->GetType() != Type::IOSURFACE)
414 return nullptr; 422 return nullptr;
415 return static_cast<GLImageIOSurface*>(image); 423 return static_cast<GLImageIOSurface*>(image);
416 } 424 }
417 425
418 } // namespace gl 426 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_io_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698