Prefer F16 in SkAndroidCodec for high precision images
Adapted from: https://googleplex-android-review.git.corp.google.com/#/c/1707531/ TBR=djsollen@google.com BUG=skia: Change-Id: I21b99e8452e728aed70e8913677c253c1ae9f751 Reviewed-on: https://skia-review.googlesource.com/6023 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
This commit is contained in:
parent
60c05f98aa
commit
8dcc84f7dc
@ -56,9 +56,13 @@ public:
|
||||
/**
|
||||
* @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);
|
||||
|
||||
|
@ -70,10 +70,13 @@ SkColorType SkAndroidCodec::computeOutputColorType(SkColorType requestedColorTyp
|
||||
}
|
||||
|
||||
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;
|
||||
@ -93,6 +96,8 @@ SkColorType SkAndroidCodec::computeOutputColorType(SkColorType requestedColorTyp
|
||||
return kRGB_565_SkColorType;
|
||||
}
|
||||
break;
|
||||
case kRGBA_F16_SkColorType:
|
||||
return kRGBA_F16_SkColorType;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -103,8 +108,8 @@ SkColorType SkAndroidCodec::computeOutputColorType(SkColorType requestedColorTyp
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user