Do not return Index8 from SkAndroidCodec::computeOutputColorType
Given that this is the only known use of Index8 color type, this is essentially an experimental delete. Bug: skia:6620 Change-Id: Ib363d237e0217f6e7f461a62e54d32892c428095 Reviewed-on: https://skia-review.googlesource.com/10586 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
This commit is contained in:
parent
d7c681d6a7
commit
b6f4767294
@ -173,6 +173,9 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
|
|||||||
return "Cannot decode (full) region.";
|
return "Cannot decode (full) region.";
|
||||||
}
|
}
|
||||||
alpha8_to_gray8(&bitmap);
|
alpha8_to_gray8(&bitmap);
|
||||||
|
|
||||||
|
// Verify that we no longer support kIndex8 from this API.
|
||||||
|
SkASSERT(kIndex_8_SkColorType != bitmap.colorType());
|
||||||
canvas->drawBitmap(bitmap, 0, 0);
|
canvas->drawBitmap(bitmap, 0, 0);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -229,6 +232,7 @@ Error BRDSrc::draw(SkCanvas* canvas) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
alpha8_to_gray8(&bitmap);
|
alpha8_to_gray8(&bitmap);
|
||||||
|
SkASSERT(kIndex_8_SkColorType != bitmap.colorType());
|
||||||
canvas->drawBitmapRect(bitmap,
|
canvas->drawBitmapRect(bitmap,
|
||||||
SkRect::MakeXYWH((SkScalar) scaledBorder, (SkScalar) scaledBorder,
|
SkRect::MakeXYWH((SkScalar) scaledBorder, (SkScalar) scaledBorder,
|
||||||
(SkScalar) (subsetWidth / fSampleSize),
|
(SkScalar) (subsetWidth / fSampleSize),
|
||||||
|
@ -105,39 +105,19 @@ SkAndroidCodec* SkAndroidCodec::NewFromData(sk_sp<SkData> data, SkPngChunkReader
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkColorType SkAndroidCodec::computeOutputColorType(SkColorType requestedColorType) {
|
SkColorType SkAndroidCodec::computeOutputColorType(SkColorType requestedColorType) {
|
||||||
// The legacy GIF and WBMP decoders always decode to kIndex_8_SkColorType.
|
|
||||||
// We will maintain this behavior when we can.
|
|
||||||
const SkColorType suggestedColorType = this->getInfo().colorType();
|
|
||||||
switch ((SkEncodedImageFormat) this->getEncodedFormat()) {
|
|
||||||
case SkEncodedImageFormat::kGIF:
|
|
||||||
if (suggestedColorType == kIndex_8_SkColorType) {
|
|
||||||
return kIndex_8_SkColorType;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SkEncodedImageFormat::kWBMP:
|
|
||||||
return kIndex_8_SkColorType;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool highPrecision = fCodec->getEncodedInfo().bitsPerComponent() > 8;
|
bool highPrecision = fCodec->getEncodedInfo().bitsPerComponent() > 8;
|
||||||
switch (requestedColorType) {
|
switch (requestedColorType) {
|
||||||
case kARGB_4444_SkColorType:
|
case kARGB_4444_SkColorType:
|
||||||
return kN32_SkColorType;
|
return kN32_SkColorType;
|
||||||
case 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:
|
case kIndex_8_SkColorType:
|
||||||
if (kIndex_8_SkColorType == suggestedColorType) {
|
|
||||||
return kIndex_8_SkColorType;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case kAlpha_8_SkColorType:
|
case kAlpha_8_SkColorType:
|
||||||
// Fall through to kGray_8. Before kGray_8_SkColorType existed,
|
// Fall through to kGray_8. Before kGray_8_SkColorType existed,
|
||||||
// we allowed clients to request kAlpha_8 when they wanted a
|
// we allowed clients to request kAlpha_8 when they wanted a
|
||||||
// grayscale decode.
|
// grayscale decode.
|
||||||
case kGray_8_SkColorType:
|
case kGray_8_SkColorType:
|
||||||
if (kGray_8_SkColorType == suggestedColorType) {
|
if (kGray_8_SkColorType == this->getInfo().colorType()) {
|
||||||
return kGray_8_SkColorType;
|
return kGray_8_SkColorType;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -152,14 +132,8 @@ SkColorType SkAndroidCodec::computeOutputColorType(SkColorType requestedColorTyp
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Android has limited support for kGray_8 (using kAlpha_8). We will not
|
// F16 is the Android default for high precision images.
|
||||||
// use kGray_8 for Android unless they specifically ask for it.
|
return highPrecision ? kRGBA_F16_SkColorType : kN32_SkColorType;
|
||||||
if (kGray_8_SkColorType == suggestedColorType) {
|
|
||||||
return kN32_SkColorType;
|
|
||||||
}
|
|
||||||
|
|
||||||
// |suggestedColorType| may be kN32_SkColorType or kIndex_8_SkColorType.
|
|
||||||
return highPrecision ? kRGBA_F16_SkColorType : suggestedColorType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SkAlphaType SkAndroidCodec::computeOutputAlphaType(bool requestedUnpremul) {
|
SkAlphaType SkAndroidCodec::computeOutputAlphaType(bool requestedUnpremul) {
|
||||||
|
Loading…
Reference in New Issue
Block a user