Commit abcd38e0 authored by Mike Klein's avatar Mike Klein Committed by Commit Bot

avoid linearly-blended sRGB in image_bitmap

We're (unintentionally?) triggering linear sRGB 8888 drawing
here by copying the color space directly off the source image
for our resized surfaces.

That we don't notice this is a testament to the perfect
round tripping of our from_srgb and to_srgb conversion functions.

I'm trying to land https://skia-review.googlesource.com/c/skia/+/132261
to intentionally break linearly blended sRGB 8888, to flush out
accidental uses just like this one.  With that CL applied, our drawing
pipeline for linear-blended sRGB 8888 is intentionally _very_ broken,
and will do broken things like linearize sources but not linearize the
destination or re-encode the result of the blend.

We caught this with layout tests,
https://test-results.appspot.com/data/layout_results/linux_trusty_blink_rel/30657/layout-test-results/results.html

Change-Id: I5814c43d861deab8a2720790fb826ed2f0a9b2bf
Reviewed-on: https://chromium-review.googlesource.com/1089135Reviewed-by: default avatarMohammad Reza Zakerinasab <zakerinasab@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564994}
parent 770f56fa
...@@ -159,13 +159,26 @@ bool DstBufferSizeHasOverflow(const ImageBitmap::ParsedOptions& options) { ...@@ -159,13 +159,26 @@ bool DstBufferSizeHasOverflow(const ImageBitmap::ParsedOptions& options) {
SkImageInfo GetSkImageInfo(sk_sp<SkImage> skia_image) { SkImageInfo GetSkImageInfo(sk_sp<SkImage> skia_image) {
SkColorType color_type = kN32_SkColorType; SkColorType color_type = kN32_SkColorType;
sk_sp<SkColorSpace> color_space = skia_image->refColorSpace();
if (skia_image->colorType() == kRGBA_F16_SkColorType || if (skia_image->colorType() == kRGBA_F16_SkColorType ||
(skia_image->colorSpace() && skia_image->colorSpace()->gammaIsLinear())) { (skia_image->colorSpace() && skia_image->colorSpace()->gammaIsLinear())) {
color_type = kRGBA_F16_SkColorType; color_type = kRGBA_F16_SkColorType;
} }
if (color_type == kN32_SkColorType && skia_image->colorSpace() &&
skia_image->colorSpace()->isSRGB()) {
// Skia is in the middle of transitioning this scenario from meaning
// linearly blended sRGB 8888 to non-linearly blended sRGB 8888. While the
// transition is happening, we'll strip the color space to force
// non-linearly blended sRGB 8888. (This nullptr will continue to mean
// non-linearly blended sRGB 8888 after the transition too, so there's
// really no harm leaving this indefinitely.)
color_space.reset(nullptr);
}
return SkImageInfo::Make(skia_image->width(), skia_image->height(), return SkImageInfo::Make(skia_image->width(), skia_image->height(),
color_type, skia_image->alphaType(), color_type, skia_image->alphaType(),
skia_image->refColorSpace()); std::move(color_space));
} }
SkImageInfo GetSkImageInfo(const scoped_refptr<StaticBitmapImage>& image) { SkImageInfo GetSkImageInfo(const scoped_refptr<StaticBitmapImage>& image) {
......
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