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

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

Issue 1980183002: Workaround for Mac video flickering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 gl::YUVToRGBConverter* yuv_to_rgb_converter = 275 gl::YUVToRGBConverter* yuv_to_rgb_converter =
276 gl_context->GetYUVToRGBConverter(); 276 gl_context->GetYUVToRGBConverter();
277 DCHECK(yuv_to_rgb_converter); 277 DCHECK(yuv_to_rgb_converter);
278 278
279 gfx::ScopedSetGLToRealGLApi scoped_set_gl_api; 279 gfx::ScopedSetGLToRealGLApi scoped_set_gl_api;
280 280
281 // Note that state restoration is done explicitly instead of scoped binders to 281 // Note that state restoration is done explicitly instead of scoped binders to
282 // avoid https://crbug.com/601729. 282 // avoid https://crbug.com/601729.
283 GLint rgb_texture = 0; 283 GLint rgb_texture = 0;
284 GLuint y_texture = 0;
285 GLuint uv_texture = 0;
286 glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &rgb_texture); 284 glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &rgb_texture);
287 glGenTextures(1, &y_texture);
288 glGenTextures(1, &uv_texture);
289 base::ScopedClosureRunner destroy_resources_runner(base::BindBlock(^{ 285 base::ScopedClosureRunner destroy_resources_runner(base::BindBlock(^{
290 glDeleteTextures(1, &y_texture);
291 glDeleteTextures(1, &uv_texture);
292 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, rgb_texture); 286 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, rgb_texture);
293 })); 287 }));
294 288
295 CGLContextObj cgl_context = CGLGetCurrentContext(); 289 CGLContextObj cgl_context = CGLGetCurrentContext();
296 { 290 {
297 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, y_texture); 291 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, yuv_to_rgb_converter->y_texture());
298 CGLError cgl_error = CGLTexImageIOSurface2D( 292 CGLError cgl_error = CGLTexImageIOSurface2D(
299 cgl_context, GL_TEXTURE_RECTANGLE_ARB, GL_RED, size_.width(), 293 cgl_context, GL_TEXTURE_RECTANGLE_ARB, GL_RED, size_.width(),
300 size_.height(), GL_RED, GL_UNSIGNED_BYTE, io_surface_, 0); 294 size_.height(), GL_RED, GL_UNSIGNED_BYTE, io_surface_, 0);
301 if (cgl_error != kCGLNoError) { 295 if (cgl_error != kCGLNoError) {
302 LOG(ERROR) << "Error in CGLTexImageIOSurface2D for the Y plane. " 296 LOG(ERROR) << "Error in CGLTexImageIOSurface2D for the Y plane. "
303 << cgl_error; 297 << cgl_error;
304 return false; 298 return false;
305 } 299 }
306 } 300 }
307 { 301 {
308 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, uv_texture); 302 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, yuv_to_rgb_converter->uv_texture());
309 CGLError cgl_error = CGLTexImageIOSurface2D( 303 CGLError cgl_error = CGLTexImageIOSurface2D(
310 cgl_context, GL_TEXTURE_RECTANGLE_ARB, GL_RG, size_.width() / 2, 304 cgl_context, GL_TEXTURE_RECTANGLE_ARB, GL_RG, size_.width() / 2,
311 size_.height() / 2, GL_RG, GL_UNSIGNED_BYTE, io_surface_, 1); 305 size_.height() / 2, GL_RG, GL_UNSIGNED_BYTE, io_surface_, 1);
312 if (cgl_error != kCGLNoError) { 306 if (cgl_error != kCGLNoError) {
313 LOG(ERROR) << "Error in CGLTexImageIOSurface2D for the UV plane. " 307 LOG(ERROR) << "Error in CGLTexImageIOSurface2D for the UV plane. "
314 << cgl_error; 308 << cgl_error;
315 return false; 309 return false;
316 } 310 }
317 } 311 }
318 312
319 yuv_to_rgb_converter->CopyYUV420ToRGB( 313 yuv_to_rgb_converter->CopyYUV420ToRGB(
320 GL_TEXTURE_RECTANGLE_ARB, y_texture, uv_texture, size_, rgb_texture); 314 GL_TEXTURE_RECTANGLE_ARB,
315 size_,
316 rgb_texture);
321 return true; 317 return true;
322 } 318 }
323 319
324 bool GLImageIOSurface::CopyTexSubImage(unsigned target, 320 bool GLImageIOSurface::CopyTexSubImage(unsigned target,
325 const gfx::Point& offset, 321 const gfx::Point& offset,
326 const gfx::Rect& rect) { 322 const gfx::Rect& rect) {
327 return false; 323 return false;
328 } 324 }
329 325
330 bool GLImageIOSurface::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 326 bool GLImageIOSurface::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 return cv_pixel_buffer_; 363 return cv_pixel_buffer_;
368 } 364 }
369 365
370 // static 366 // static
371 unsigned GLImageIOSurface::GetInternalFormatForTesting( 367 unsigned GLImageIOSurface::GetInternalFormatForTesting(
372 gfx::BufferFormat format) { 368 gfx::BufferFormat format) {
373 DCHECK(ValidFormat(format)); 369 DCHECK(ValidFormat(format));
374 return TextureFormat(format); 370 return TextureFormat(format);
375 } 371 }
376 } // namespace gl 372 } // 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