aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkImageCacherator.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-04-05 11:26:02 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-05 16:01:33 +0000
commit944feea3d345616d62750faba6875a35c8d6712b (patch)
tree1604e84732296197b870e0ae47b28447e7b390de /src/core/SkImageCacherator.cpp
parent740092ed60198022560cc8d445903aa6e7d5e3b4 (diff)
Avoid trans-coding images with gamma 2.2
Previously, these were decoded "AsIs". That feature went away (for simplicity). Unfortunately, that means that images with gamma 2.2 were being asked to decode to sRGB, incurring a costly (and destructive) conversion. Bug: skia: Change-Id: I6c8cdfefc052c82a4de37c697c2f659dcdd38d4d Reviewed-on: https://skia-review.googlesource.com/11352 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/core/SkImageCacherator.cpp')
-rw-r--r--src/core/SkImageCacherator.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp
index 98a813ffd9..d2bb14f1e3 100644
--- a/src/core/SkImageCacherator.cpp
+++ b/src/core/SkImageCacherator.cpp
@@ -430,17 +430,26 @@ SkImageInfo SkImageCacherator::buildCacheInfo(CachedFormat format) {
case kLegacy_CachedFormat:
return fInfo.makeColorSpace(nullptr);
case kLinearF16_CachedFormat:
- return fInfo
- .makeColorType(kRGBA_F16_SkColorType)
- .makeColorSpace(as_CSB(fInfo.colorSpace())->makeLinearGamma());
+ return fInfo.makeColorType(kRGBA_F16_SkColorType)
+ .makeColorSpace(as_CSB(fInfo.colorSpace())->makeLinearGamma());
case kSRGB8888_CachedFormat:
- return fInfo
- .makeColorType(kRGBA_8888_SkColorType)
- .makeColorSpace(as_CSB(fInfo.colorSpace())->makeSRGBGamma());
+ // If the transfer function is nearly (but not exactly) sRGB, we don't want the codec
+ // to bother trans-coding. It would be slow, and do more harm than good visually,
+ // so we make sure to leave the colorspace as-is.
+ if (fInfo.colorSpace()->gammaCloseToSRGB()) {
+ return fInfo.makeColorType(kRGBA_8888_SkColorType);
+ } else {
+ return fInfo.makeColorType(kRGBA_8888_SkColorType)
+ .makeColorSpace(as_CSB(fInfo.colorSpace())->makeSRGBGamma());
+ }
case kSBGR8888_CachedFormat:
- return fInfo
- .makeColorType(kBGRA_8888_SkColorType)
- .makeColorSpace(as_CSB(fInfo.colorSpace())->makeSRGBGamma());;
+ // See note above about not-quite-sRGB transfer functions.
+ if (fInfo.colorSpace()->gammaCloseToSRGB()) {
+ return fInfo.makeColorType(kBGRA_8888_SkColorType);
+ } else {
+ return fInfo.makeColorType(kBGRA_8888_SkColorType)
+ .makeColorSpace(as_CSB(fInfo.colorSpace())->makeSRGBGamma());
+ }
default:
SkDEBUGFAIL("Invalid cached format");
return fInfo;