| OLD | NEW |
| 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" |
| 11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/trace_event/memory_allocator_dump.h" | 13 #include "base/trace_event/memory_allocator_dump.h" |
| 14 #include "base/trace_event/memory_dump_manager.h" | 14 #include "base/trace_event/memory_dump_manager.h" |
| 15 #include "base/trace_event/process_memory_dump.h" | 15 #include "base/trace_event/process_memory_dump.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "ui/gfx/icc_profile.h" | |
| 18 #include "ui/gl/gl_bindings.h" | 17 #include "ui/gl/gl_bindings.h" |
| 19 #include "ui/gl/gl_context.h" | 18 #include "ui/gl/gl_context.h" |
| 20 #include "ui/gl/scoped_binders.h" | 19 #include "ui/gl/scoped_binders.h" |
| 21 #include "ui/gl/yuv_to_rgb_converter.h" | 20 #include "ui/gl/yuv_to_rgb_converter.h" |
| 22 | 21 |
| 23 // Note that this must be included after gl_bindings.h to avoid conflicts. | 22 // Note that this must be included after gl_bindings.h to avoid conflicts. |
| 24 #include <OpenGL/CGLIOSurface.h> | 23 #include <OpenGL/CGLIOSurface.h> |
| 25 #include <Quartz/Quartz.h> | 24 #include <Quartz/Quartz.h> |
| 26 #include <stddef.h> | 25 #include <stddef.h> |
| 27 | 26 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 } | 410 } |
| 412 | 411 |
| 413 base::ScopedCFTypeRef<CVPixelBufferRef> GLImageIOSurface::cv_pixel_buffer() { | 412 base::ScopedCFTypeRef<CVPixelBufferRef> GLImageIOSurface::cv_pixel_buffer() { |
| 414 return cv_pixel_buffer_; | 413 return cv_pixel_buffer_; |
| 415 } | 414 } |
| 416 | 415 |
| 417 GLImage::Type GLImageIOSurface::GetType() const { | 416 GLImage::Type GLImageIOSurface::GetType() const { |
| 418 return Type::IOSURFACE; | 417 return Type::IOSURFACE; |
| 419 } | 418 } |
| 420 | 419 |
| 421 void GLImageIOSurface::SetColorSpaceForScanout( | |
| 422 const gfx::ColorSpace& color_space) { | |
| 423 GLImage::SetColorSpaceForScanout(color_space); | |
| 424 | |
| 425 // Retrieve the ICC profile data. | |
| 426 gfx::ICCProfile icc_profile; | |
| 427 if (!color_space.GetAsFullRangeRGB().GetICCProfile(&icc_profile)) { | |
| 428 LOG(ERROR) << "Failed to set color space for scanout: no ICC profile."; | |
| 429 return; | |
| 430 } | |
| 431 | |
| 432 // Package it as a CFDataRef and send it to the IOSurface. | |
| 433 base::ScopedCFTypeRef<CFDataRef> cf_data_icc_profile(CFDataCreate( | |
| 434 nullptr, reinterpret_cast<const UInt8*>(icc_profile.GetData().data()), | |
| 435 icc_profile.GetData().size())); | |
| 436 IOSurfaceSetValue(io_surface_, CFSTR("IOSurfaceColorSpace"), | |
| 437 cf_data_icc_profile); | |
| 438 } | |
| 439 | |
| 440 // static | 420 // static |
| 441 unsigned GLImageIOSurface::GetInternalFormatForTesting( | 421 unsigned GLImageIOSurface::GetInternalFormatForTesting( |
| 442 gfx::BufferFormat format) { | 422 gfx::BufferFormat format) { |
| 443 DCHECK(ValidFormat(format)); | 423 DCHECK(ValidFormat(format)); |
| 444 return TextureFormat(format); | 424 return TextureFormat(format); |
| 445 } | 425 } |
| 446 | 426 |
| 447 // static | 427 // static |
| 448 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) { | 428 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) { |
| 449 if (!image || image->GetType() != Type::IOSURFACE) | 429 if (!image || image->GetType() != Type::IOSURFACE) |
| 450 return nullptr; | 430 return nullptr; |
| 451 return static_cast<GLImageIOSurface*>(image); | 431 return static_cast<GLImageIOSurface*>(image); |
| 452 } | 432 } |
| 453 | 433 |
| 454 } // namespace gl | 434 } // namespace gl |
| OLD | NEW |