aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkCodecPriv.h
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-02-22 13:02:31 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-22 18:51:33 +0000
commite522f4c455d0d5dbe813f38d16c0d4cd46fa5dee (patch)
treee0be77c59c8b06ac3b284104ab946613f2b6bdd7 /src/codec/SkCodecPriv.h
parent416bbd97cee9e221577c729a8072fdb2057cbdf8 (diff)
Enable legacy premuls in SkColorSpaceXform
***Will allow for simplified Android framework code, they typically want a color correct transform followed by a gamma encoded premul. ***Chrome does the same, so this will make it easier to replace their codecs. ***Will decrease code size. Both types of premuls are moved off the fast path here - one is essentially unused in production and the other is not "encouraged". ***Will actually make the common case faster: sRGB->sRGB means no color xform, just premul in SkSwizzler. BUG=skia: CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD Change-Id: Ia4ec1d273b6f137151f951d37c0ebf975f6b9a3e Reviewed-on: https://skia-review.googlesource.com/8848 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/codec/SkCodecPriv.h')
-rw-r--r--src/codec/SkCodecPriv.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index 110cbdce3a..026120fe79 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -302,16 +302,23 @@ static inline bool needs_premul(const SkImageInfo& dstInfo, const SkEncodedInfo&
static inline bool needs_color_xform(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo,
bool needsPremul) {
+ // We never perform a color xform in legacy mode.
+ if (!dstInfo.colorSpace()) {
+ return false;
+ }
+
// F16 is by definition a linear space, so we always must perform a color xform.
bool isF16 = kRGBA_F16_SkColorType == dstInfo.colorType();
// Need a color xform when dst space does not match the src.
- bool srcDstNotEqual = !SkColorSpace::Equals(srcInfo.colorSpace(), dstInfo.colorSpace());
+ bool srcDstNotEqual =
+ !SkColorSpace_Base::EqualsIgnoreFlags(srcInfo.colorSpace(), dstInfo.colorSpace());
- // We never perform a color xform in legacy mode.
- bool isLegacy = nullptr == dstInfo.colorSpace();
+ // We provide the option for both legacy premuls and color correct premuls.
+ bool needsColorCorrectPremul =
+ needsPremul && !as_CSB(dstInfo.colorSpace())->nonLinearBlending();
- return !isLegacy && (needsPremul || isF16 || srcDstNotEqual);
+ return needsColorCorrectPremul || isF16 || srcDstNotEqual;
}
static inline SkAlphaType select_xform_alpha(SkAlphaType dstAlphaType, SkAlphaType srcAlphaType) {