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

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

Issue 2001753002: Workaround for Mac video flickering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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 | ui/gl/yuv_to_rgb_converter.h » ('j') | 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 gl::YUVToRGBConverter* yuv_to_rgb_converter = 264 gl::YUVToRGBConverter* yuv_to_rgb_converter =
265 gl_context->GetYUVToRGBConverter(); 265 gl_context->GetYUVToRGBConverter();
266 DCHECK(yuv_to_rgb_converter); 266 DCHECK(yuv_to_rgb_converter);
267 267
268 gfx::ScopedSetGLToRealGLApi scoped_set_gl_api; 268 gfx::ScopedSetGLToRealGLApi scoped_set_gl_api;
269 269
270 // Note that state restoration is done explicitly instead of scoped binders to 270 // Note that state restoration is done explicitly instead of scoped binders to
271 // avoid https://crbug.com/601729. 271 // avoid https://crbug.com/601729.
272 GLint rgb_texture = 0; 272 GLint rgb_texture = 0;
273 GLuint y_texture = 0;
274 GLuint uv_texture = 0;
275 glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &rgb_texture); 273 glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &rgb_texture);
276 glGenTextures(1, &y_texture);
277 glGenTextures(1, &uv_texture);
278 base::ScopedClosureRunner destroy_resources_runner(base::BindBlock(^{ 274 base::ScopedClosureRunner destroy_resources_runner(base::BindBlock(^{
279 glDeleteTextures(1, &y_texture);
280 glDeleteTextures(1, &uv_texture);
281 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, rgb_texture); 275 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, rgb_texture);
282 })); 276 }));
283 277
284 CGLContextObj cgl_context = CGLGetCurrentContext(); 278 CGLContextObj cgl_context = CGLGetCurrentContext();
285 { 279 {
286 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, y_texture); 280 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, yuv_to_rgb_converter->y_texture());
287 CGLError cgl_error = CGLTexImageIOSurface2D( 281 CGLError cgl_error = CGLTexImageIOSurface2D(
288 cgl_context, GL_TEXTURE_RECTANGLE_ARB, GL_RED, size_.width(), 282 cgl_context, GL_TEXTURE_RECTANGLE_ARB, GL_RED, size_.width(),
289 size_.height(), GL_RED, GL_UNSIGNED_BYTE, io_surface_, 0); 283 size_.height(), GL_RED, GL_UNSIGNED_BYTE, io_surface_, 0);
290 if (cgl_error != kCGLNoError) { 284 if (cgl_error != kCGLNoError) {
291 LOG(ERROR) << "Error in CGLTexImageIOSurface2D for the Y plane. " 285 LOG(ERROR) << "Error in CGLTexImageIOSurface2D for the Y plane. "
292 << cgl_error; 286 << cgl_error;
293 return false; 287 return false;
294 } 288 }
295 } 289 }
296 { 290 {
297 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, uv_texture); 291 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, yuv_to_rgb_converter->uv_texture());
298 CGLError cgl_error = CGLTexImageIOSurface2D( 292 CGLError cgl_error = CGLTexImageIOSurface2D(
299 cgl_context, GL_TEXTURE_RECTANGLE_ARB, GL_RG, size_.width() / 2, 293 cgl_context, GL_TEXTURE_RECTANGLE_ARB, GL_RG, size_.width() / 2,
300 size_.height() / 2, GL_RG, GL_UNSIGNED_BYTE, io_surface_, 1); 294 size_.height() / 2, GL_RG, GL_UNSIGNED_BYTE, io_surface_, 1);
301 if (cgl_error != kCGLNoError) { 295 if (cgl_error != kCGLNoError) {
302 LOG(ERROR) << "Error in CGLTexImageIOSurface2D for the UV plane. " 296 LOG(ERROR) << "Error in CGLTexImageIOSurface2D for the UV plane. "
303 << cgl_error; 297 << cgl_error;
304 return false; 298 return false;
305 } 299 }
306 } 300 }
307 301
308 yuv_to_rgb_converter->CopyYUV420ToRGB( 302 yuv_to_rgb_converter->CopyYUV420ToRGB(
309 GL_TEXTURE_RECTANGLE_ARB, y_texture, uv_texture, size_, rgb_texture); 303 GL_TEXTURE_RECTANGLE_ARB,
304 size_,
305 rgb_texture);
310 return true; 306 return true;
311 } 307 }
312 308
313 bool GLImageIOSurface::CopyTexSubImage(unsigned target, 309 bool GLImageIOSurface::CopyTexSubImage(unsigned target,
314 const gfx::Point& offset, 310 const gfx::Point& offset,
315 const gfx::Rect& rect) { 311 const gfx::Rect& rect) {
316 return false; 312 return false;
317 } 313 }
318 314
319 bool GLImageIOSurface::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 315 bool GLImageIOSurface::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return cv_pixel_buffer_; 348 return cv_pixel_buffer_;
353 } 349 }
354 350
355 // static 351 // static
356 unsigned GLImageIOSurface::GetInternalFormatForTesting( 352 unsigned GLImageIOSurface::GetInternalFormatForTesting(
357 gfx::BufferFormat format) { 353 gfx::BufferFormat format) {
358 DCHECK(ValidFormat(format)); 354 DCHECK(ValidFormat(format));
359 return TextureFormat(format); 355 return TextureFormat(format);
360 } 356 }
361 } // namespace gl 357 } // namespace gl
OLDNEW
« no previous file with comments | « no previous file | ui/gl/yuv_to_rgb_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698