Change computeOutputColorType() to mimic old behavior
This will prevent behavior changes in BitmapFactory when switching from SkImageDecoder to SkAndroidCodec. We will only choose kGray8 if it is explicitly requested (and also supported). Additionally, we will always decode GIFS and WBMPS to kIndex8. BUG=skia: Review URL: https://codereview.chromium.org/1519843002
This commit is contained in:
parent
061aaa79f7
commit
457f54df1e
@ -51,6 +51,13 @@ SkAndroidCodec* SkAndroidCodec::NewFromData(SkData* data, SkPngChunkReader* chun
|
|||||||
}
|
}
|
||||||
|
|
||||||
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.
|
||||||
|
SkEncodedFormat format = this->getEncodedFormat();
|
||||||
|
if (kGIF_SkEncodedFormat == format || kWBMP_SkEncodedFormat == format) {
|
||||||
|
return kIndex_8_SkColorType;
|
||||||
|
}
|
||||||
|
|
||||||
SkColorType suggestedColorType = this->getInfo().colorType();
|
SkColorType suggestedColorType = this->getInfo().colorType();
|
||||||
switch (requestedColorType) {
|
switch (requestedColorType) {
|
||||||
case kARGB_4444_SkColorType:
|
case kARGB_4444_SkColorType:
|
||||||
@ -79,6 +86,13 @@ SkColorType SkAndroidCodec::computeOutputColorType(SkColorType requestedColorTyp
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Android has limited support for kGray_8 (using kAlpha_8). We will not
|
||||||
|
// use kGray_8 for Android unless they specifically ask for it.
|
||||||
|
if (kGray_8_SkColorType == suggestedColorType) {
|
||||||
|
return kN32_SkColorType;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This may be kN32_SkColorType or kIndex_8_SkColorType.
|
||||||
return suggestedColorType;
|
return suggestedColorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user