Commit 5719dd9f authored by Reza.Zakerinasab's avatar Reza.Zakerinasab Committed by Commit Bot

Refactor GetSkImageInfo() helper in ImageBitmap

Bug: 898500
Change-Id: Iabfe264766e4c33b930df61b9269ed3f068b2ccb
Reviewed-on: https://chromium-review.googlesource.com/c/1298252Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Commit-Queue: Mohammad Reza Zakerinasab <zakerinasab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602471}
parent b7d4b4a1
...@@ -178,32 +178,10 @@ bool DstBufferSizeHasOverflow(const ImageBitmap::ParsedOptions& options) { ...@@ -178,32 +178,10 @@ bool DstBufferSizeHasOverflow(const ImageBitmap::ParsedOptions& options) {
return false; return false;
} }
SkImageInfo GetSkImageInfo(sk_sp<SkImage> skia_image) { SkImageInfo GetSkImageInfo(const scoped_refptr<StaticBitmapImage>& input) {
SkColorType color_type = kN32_SkColorType; auto image = input->PaintImageForCurrentFrame().GetSkImage();
sk_sp<SkColorSpace> color_space = skia_image->refColorSpace(); return SkImageInfo::Make(image->width(), image->height(), image->colorType(),
image->alphaType(), image->refColorSpace());
if (skia_image->colorType() == kRGBA_F16_SkColorType ||
(skia_image->colorSpace() && skia_image->colorSpace()->gammaIsLinear())) {
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 uint8 to non-linearly blended sRGB uint8. While
// the transition is happening, we'll strip the color space to force
// non-linearly blended sRGB uint8. (This nullptr will continue to mean
// non-linearly blended sRGB uint8 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(),
color_type, skia_image->alphaType(),
std::move(color_space));
}
SkImageInfo GetSkImageInfo(const scoped_refptr<StaticBitmapImage>& image) {
return GetSkImageInfo(image->PaintImageForCurrentFrame().GetSkImage());
} }
// This function results in a readback due to using SkImage::readPixels(). // This function results in a readback due to using SkImage::readPixels().
......
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