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

Unified Diff: ui/gfx/mac/io_surface.cc

Issue 2871893002: color: Ensure solid color IOSurface layers are sRGB (Closed)
Patch Set: Fix up deps Created 3 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 side-by-side diff with in-line comments
Download patch
« ui/gfx/BUILD.gn ('K') | « ui/gfx/BUILD.gn ('k') | ui/gfx/switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/mac/io_surface.cc
diff --git a/ui/gfx/mac/io_surface.cc b/ui/gfx/mac/io_surface.cc
index b10780249f693fcc976f75673616e67bf2cdf7e8..90dadff5dd1100e922b5953d115a89f68b93a763 100644
--- a/ui/gfx/mac/io_surface.cc
+++ b/ui/gfx/mac/io_surface.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <stdint.h>
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/mac/mac_util.h"
#include "base/mac/mach_logging.h"
@@ -14,6 +15,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/trace_event/trace_event.h"
#include "ui/gfx/buffer_format_util.h"
+#include "ui/gfx/switches.h"
namespace gfx {
@@ -187,16 +189,14 @@ IOSurfaceRef CreateIOSurface(const gfx::Size& size, gfx::BufferFormat format) {
DCHECK_EQ(kIOReturnSuccess, r);
}
- bool force_system_color_space = false;
+ bool force_color_space = false;
// Displaying an IOSurface that does not have a color space using an
- // AVSampleBufferDisplayLayer can result in a black screen. Specify the
- // main display's color profile by default, which will result in no color
- // correction being done for the main monitor (which is the behavior of not
- // specifying a color space).
+ // AVSampleBufferDisplayLayer can result in a black screen. Ensure that
+ // a color space always be specified.
Avi (use Gerrit) 2017/05/09 14:53:22 ... always is specified. ? I'm in an argument wit
ccameron 2017/05/09 16:18:25 This was intended to be the subjunctive mood ... b
// https://crbug.com/608879
if (format == gfx::BufferFormat::YUV_420_BIPLANAR)
- force_system_color_space = true;
+ force_color_space = true;
// On Sierra, all IOSurfaces are color corrected as though they are in sRGB
// color space by default. Prior to Sierra, IOSurfaces were not color
@@ -205,10 +205,20 @@ IOSurfaceRef CreateIOSurface(const gfx::Size& size, gfx::BufferFormat format) {
// color space.
// https://crbug.com/654488
if (base::mac::IsAtLeastOS10_12())
- force_system_color_space = true;
-
- if (force_system_color_space) {
- CGColorSpaceRef color_space = base::mac::GetSystemColorSpace();
+ force_color_space = true;
+
+ // Ensure that all IOSurfaces start as sRGB when color correct rendering
+ // is enabled.
+ static bool color_correct_rendering_enabled =
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableColorCorrectRendering);
+ if (color_correct_rendering_enabled)
+ force_color_space = true;
+
+ if (force_color_space) {
+ CGColorSpaceRef color_space = color_correct_rendering_enabled
+ ? base::mac::GetSRGBColorSpace()
+ : base::mac::GetSystemColorSpace();
base::ScopedCFTypeRef<CFDataRef> color_space_icc(
CGColorSpaceCopyICCProfile(color_space));
// Note that nullptr is an acceptable input to IOSurfaceSetValue.
« ui/gfx/BUILD.gn ('K') | « ui/gfx/BUILD.gn ('k') | ui/gfx/switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698