/**
* @param requestedColorType Color type requested by the client
*
- * If it is possible to decode to requestedColorType, this returns
- * requestedColorType. Otherwise, this returns whichever color type
- * is suggested by the codec as the best match for the encoded data.
+ * |requestedColorType| may be overriden. We will default to kF16
+ * for high precision images and kIndex8 for GIF and WBMP.
+ *
+ * In the general case, if it is possible to decode to
+ * |requestedColorType|, this returns |requestedColorType|.
+ * Otherwise, this returns a color type that is an appropriate
+ * match for the the encoded data.
*/
SkColorType computeOutputColorType(SkColorType requestedColorType);
}
SkColorType suggestedColorType = this->getInfo().colorType();
+ bool highPrecision = fCodec->getEncodedInfo().bitsPerComponent() > 8;
switch (requestedColorType) {
case kARGB_4444_SkColorType:
- case kN32_SkColorType:
return kN32_SkColorType;
+ case kN32_SkColorType:
+ // F16 is the Android default for high precision images.
+ return highPrecision ? kRGBA_F16_SkColorType : kN32_SkColorType;
case kIndex_8_SkColorType:
if (kIndex_8_SkColorType == suggestedColorType) {
return kIndex_8_SkColorType;
return kRGB_565_SkColorType;
}
break;
+ case kRGBA_F16_SkColorType:
+ return kRGBA_F16_SkColorType;
default:
break;
}
return kN32_SkColorType;
}
- // This may be kN32_SkColorType or kIndex_8_SkColorType.
- return suggestedColorType;
+ // |suggestedColorType| may be kN32_SkColorType or kIndex_8_SkColorType.
+ return highPrecision ? kRGBA_F16_SkColorType : suggestedColorType;
}
SkAlphaType SkAndroidCodec::computeOutputAlphaType(bool requestedUnpremul) {