}
if (this->colorXform() && !fXformOnDecode) {
- SkColorSpaceXform::ColorFormat dstFormat = select_xform_format(dstColorType);
+ SkColorSpaceXform::ColorFormat dstFormat = select_xform_format_ct(dstColorType);
SkColorSpaceXform::ColorFormat srcFormat = SkColorSpaceXform::kBGRA_8888_ColorFormat;
SkAlphaType xformAlphaType = select_xform_alpha(dstAlphaType,
this->getInfo().alphaType());
const SkPMColor* colorPtr = get_color_ptr(fColorTable.get());
if (colorPtr) {
return get_color_table_fill_value(dstInfo.colorType(), dstInfo.alphaType(), colorPtr, 0,
- this->colorXform());
+ this->colorXform(), false);
}
return INHERITED::onGetFillValue(dstInfo);
}
* Given that the encoded image uses a color table, return the fill value
*/
static inline uint64_t get_color_table_fill_value(SkColorType dstColorType, SkAlphaType alphaType,
- const SkPMColor* colorPtr, uint8_t fillIndex, SkColorSpaceXform* colorXform) {
+ const SkPMColor* colorPtr, uint8_t fillIndex, SkColorSpaceXform* colorXform, bool isRGBA) {
SkASSERT(nullptr != colorPtr);
switch (dstColorType) {
case kRGBA_8888_SkColorType:
SkASSERT(colorXform);
uint64_t dstColor;
uint32_t srcColor = colorPtr[fillIndex];
+ SkColorSpaceXform::ColorFormat srcFormat =
+ isRGBA ? SkColorSpaceXform::kRGBA_8888_ColorFormat
+ : SkColorSpaceXform::kBGRA_8888_ColorFormat;
SkAssertResult(colorXform->apply(select_xform_format(dstColorType), &dstColor,
- SkColorSpaceXform::kRGBA_8888_ColorFormat, &srcColor, 1, alphaType));
+ srcFormat, &srcColor, 1, alphaType));
return dstColor;
}
default:
}
static inline bool apply_xform_on_decode(SkColorType dstColorType, SkEncodedInfo::Color srcColor) {
- // We will apply the color xform when reading the color table if a form of 8888 is requested.
- return SkEncodedInfo::kPalette_Color != srcColor ||
- (kRGBA_8888_SkColorType != dstColorType &&
- kBGRA_8888_SkColorType != dstColorType &&
- kIndex_8_SkColorType != dstColorType);
+ // We will apply the color xform when reading the color table unless F16 is requested.
+ return SkEncodedInfo::kPalette_Color != srcColor || kRGBA_F16_SkColorType == dstColorType;
}
/*
}
}
+static inline SkColorSpaceXform::ColorFormat select_xform_format_ct(SkColorType colorType) {
+ switch (colorType) {
+ case kRGBA_8888_SkColorType:
+ return SkColorSpaceXform::kRGBA_8888_ColorFormat;
+ case kBGRA_8888_SkColorType:
+ return SkColorSpaceXform::kBGRA_8888_ColorFormat;
+ case kRGB_565_SkColorType:
+ case kIndex_8_SkColorType:
+#ifdef SK_PMCOLOR_IS_RGBA
+ return SkColorSpaceXform::kRGBA_8888_ColorFormat;
+#else
+ return SkColorSpaceXform::kBGRA_8888_ColorFormat;
+#endif
+ default:
+ SkASSERT(false);
+ return SkColorSpaceXform::kRGBA_8888_ColorFormat;
+ }
+}
+
#endif // SkCodecPriv_DEFINED
fCurrColorTable.reset(new SkColorTable(&color, 1));
} else if (this->colorXform() && !fXformOnDecode) {
SkPMColor dstColors[256];
- const SkColorSpaceXform::ColorFormat dstFormat = select_xform_format(dstInfo.colorType());
+ const SkColorSpaceXform::ColorFormat dstFormat =
+ select_xform_format_ct(dstInfo.colorType());
const SkColorSpaceXform::ColorFormat srcFormat = select_xform_format(kXformSrcColorType);
const SkAlphaType xformAlphaType = select_xform_alpha(dstInfo.alphaType(),
this->getInfo().alphaType());
if (this->colorXform() &&
!apply_xform_on_decode(dstInfo.colorType(), this->getEncodedInfo().color())) {
- const SkColorSpaceXform::ColorFormat dstFormat = select_xform_format(dstInfo.colorType());
+ const SkColorSpaceXform::ColorFormat dstFormat =
+ select_xform_format_ct(dstInfo.colorType());
const SkColorSpaceXform::ColorFormat srcFormat = select_xform_format(kXformSrcColorType);
const SkAlphaType xformAlphaType = select_xform_alpha(dstInfo.alphaType(),
this->getInfo().alphaType());
SkAlphaType alphaType = select_xform_alpha(dstInfo.alphaType(),
this->getInfo().alphaType());
return get_color_table_fill_value(dstInfo.colorType(), alphaType, colorPtr, 0,
- this->colorXform());
+ this->colorXform(), true);
}
return INHERITED::onGetFillValue(dstInfo);
}
return SkColorSpaceXform::kBGRA_8888_ColorFormat;
case kRGBA_F16_SkColorType:
return SkColorSpaceXform::kRGBA_F16_ColorFormat;
- case kIndex_8_SkColorType:
-#ifdef SK_PMCOLOR_IS_RGBA
- return SkColorSpaceXform::kRGBA_8888_ColorFormat;
-#else
- return SkColorSpaceXform::kBGRA_8888_ColorFormat;
-#endif
case kRGB_565_SkColorType:
return SkColorSpaceXform::kBGR_565_ColorFormat;
default: