Support Float32 output from SkColorSpaceXform
* Adds Float32 support to SkColorSpaceXform
* Changes API to allows clients to ask for F32, updates clients to
new API
* Adds Sk4f_load4 and Sk4f_store4 to SkNx
* Make use of new xform in SkGr.cpp
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2339233003
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Committed: https://skia.googlesource.com/skia/+/43d6651111374b5d1e4ddd9030dcf079b448ec47
Review-Url: https://codereview.chromium.org/2339233003
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index 8876b72..830f153 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -144,6 +144,20 @@
return nullptr != colorTable ? colorTable->readColors() : nullptr;
}
+static inline SkColorSpaceXform::ColorFormat select_xform_format(SkColorType colorType) {
+ switch (colorType) {
+ case kRGBA_8888_SkColorType:
+ return SkColorSpaceXform::kRGBA_8888_ColorFormat;
+ case kBGRA_8888_SkColorType:
+ return SkColorSpaceXform::kBGRA_8888_ColorFormat;
+ case kRGBA_F16_SkColorType:
+ return SkColorSpaceXform::kRGBA_F16_ColorFormat;
+ default:
+ SkASSERT(false);
+ return SkColorSpaceXform::kRGBA_8888_ColorFormat;
+ }
+}
+
/*
* Given that the encoded image uses a color table, return the fill value
*/
@@ -162,7 +176,7 @@
SkASSERT(colorXform);
uint64_t dstColor;
uint32_t srcColor = colorPtr[fillIndex];
- colorXform->apply(&dstColor, &srcColor, 1, colorType, alphaType);
+ colorXform->apply(&dstColor, &srcColor, 1, select_xform_format(colorType), alphaType);
return dstColor;
}
default:
@@ -343,7 +357,7 @@
return !isLegacy && (needsPremul || isF16 || srcDstNotEqual);
}
-static inline SkAlphaType select_alpha_xform(SkAlphaType dstAlphaType, SkAlphaType srcAlphaType) {
+static inline SkAlphaType select_xform_alpha(SkAlphaType dstAlphaType, SkAlphaType srcAlphaType) {
return (kOpaque_SkAlphaType == srcAlphaType) ? kOpaque_SkAlphaType : dstAlphaType;
}