Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ad12c43 authored by Leon Scroggins III's avatar Leon Scroggins III
Browse files

Implement AImageDecoder_getRepeatCount

Bug: 160984428
Test: Ia09c95173d7e53dc2c0f6d170c67a3f3360275b9
Change-Id: Ia1eac93d46a6cc3498a5289c28a5475b3aae3cba
parent 24ae7d7f
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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;
}
+1 −0
Original line number Diff line number Diff line
@@ -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