Merge "Implement AImageDecoder_getRepeatCount"

This commit is contained in:
TreeHugger Robot
2020-10-14 17:21:17 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 0 deletions

View File

@@ -353,3 +353,18 @@ bool AImageDecoder_isAnimated(AImageDecoder* decoder) {
ImageDecoder* imageDecoder = toDecoder(decoder);
return imageDecoder->mCodec->codec()->getFrameCount() > 1;
}
int32_t AImageDecoder_getRepeatCount(AImageDecoder* decoder) {
if (!decoder) return ANDROID_IMAGE_DECODER_BAD_PARAMETER;
ImageDecoder* imageDecoder = toDecoder(decoder);
const int count = imageDecoder->mCodec->codec()->getRepetitionCount();
// Skia should not report anything out of range, but defensively treat
// negative and too big as INFINITE.
if (count == SkCodec::kRepetitionCountInfinite || count < 0
|| count > std::numeric_limits<int32_t>::max()) {
return ANDROID_IMAGE_DECODER_INFINITE;
}
return count;
}

View File

@@ -14,6 +14,7 @@ LIBJNIGRAPHICS {
AImageDecoder_computeSampledSize; # introduced=30
AImageDecoder_setCrop; # introduced=30
AImageDecoder_isAnimated; # introduced=31
AImageDecoder_getRepeatCount; # introduced=31
AImageDecoderHeaderInfo_getWidth; # introduced=30
AImageDecoderHeaderInfo_getHeight; # introduced=30
AImageDecoderHeaderInfo_getMimeType; # introduced=30