Fix color xforms for Index8 bmps
Thanks to Gold for catching this.
BUG=skia:4895
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4426
Change-Id: Icc816d933e9e2fd312858a5430fa21a47722563e
Reviewed-on: https://skia-review.googlesource.com/4426
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index f210303..a13cdbb 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -11,6 +11,7 @@
#include "SkColorPriv.h"
#include "SkColorSpaceXform.h"
#include "SkColorTable.h"
+#include "SkEncodedInfo.h"
#include "SkImageInfo.h"
#include "SkTypes.h"
@@ -152,6 +153,12 @@
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
default:
SkASSERT(false);
return SkColorSpaceXform::kRGBA_8888_ColorFormat;
@@ -362,6 +369,11 @@
return (kOpaque_SkAlphaType == srcAlphaType) ? kOpaque_SkAlphaType : dstAlphaType;
}
+static inline bool apply_xform_on_decode(SkColorType dstColorType, SkEncodedInfo::Color srcColor) {
+ // We will apply the color xform when reading the color table, unless F16 is requested.
+ return SkEncodedInfo::kPalette_Color != srcColor || kRGBA_F16_SkColorType == dstColorType;
+}
+
/*
* Alpha Type Conversions
* - kOpaque to kOpaque, kUnpremul, kPremul is valid