Commit b38caf4d authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

Replace gamma=1.961 ICC profile with kCGColorSpaceSRGB constant

This avoids re-parsing the ICC profile in the GPU process. The drawback
is that we go back to the behavior that we had (just a few weeks ago)
of ignoring the custom color profile for capture content.

Of note is that specifying AVCaptureColorSpace_sRGB to the capturer
results in the same gamma=1.961 color space (with the sRGB primaries).

Also of note is that the alternative constant of kCGColorSpaceITUR_709
is not used because it has a substantial difference from gamma=1.961
in darker colors.

Bug: 1143477, 959962
Change-Id: Id5d794ba05801cd6d54a79bd3a3f9cc292537eb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2515235
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarMarkus Handell <handellm@google.com>
Cr-Commit-Position: refs/heads/master@{#823598}
parent 1e298c28
......@@ -594,10 +594,27 @@ AVCaptureDeviceFormat* FindBestCaptureFormat(
handle.id.id = -1;
handle.type = gfx::GpuMemoryBufferType::IO_SURFACE_BUFFER;
handle.io_surface.reset(ioSurface, base::scoped_policy::RETAIN);
// The BT709_APPLE color space is stored as an ICC profile, which is parsed
// every frame in the GPU process. For this particularly common case, go back
// to ignoring the color profile, because doing so avoids doing an ICC profile
// parse.
// https://crbug.com/1143477 (CPU usage parsing ICC profile)
// https://crbug.com/959962 (ignoring color space)
gfx::ColorSpace overriddenColorSpace = colorSpace;
constexpr gfx::ColorSpace rec709Apple(
gfx::ColorSpace::PrimaryID::BT709,
gfx::ColorSpace::TransferID::BT709_APPLE,
gfx::ColorSpace::MatrixID::SMPTE170M, gfx::ColorSpace::RangeID::LIMITED);
if (colorSpace == rec709Apple) {
overriddenColorSpace = gfx::ColorSpace::CreateSRGB();
IOSurfaceSetValue(ioSurface, CFSTR("IOSurfaceColorSpace"),
kCGColorSpaceSRGB);
}
_lock.AssertAcquired();
_frameReceiver->ReceiveExternalGpuMemoryBufferFrame(
std::move(handle),
captureFormat, colorSpace, timestamp);
std::move(handle), captureFormat, overriddenColorSpace, timestamp);
return YES;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment