discord-jadx/app/src/main/java/com/linecorp/apng/decoder/Apng.java

237 lines
7.2 KiB
Java

package com.linecorp.apng.decoder;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Trace;
import androidx.annotation.IntRange;
import com.linecorp.apng.decoder.ApngException;
import d0.t.k;
import d0.z.d.m;
import java.io.InputStream;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: Apng.kt */
public final class Apng {
public static final Companion Companion = new Companion(null);
public final Bitmap a;
@IntRange(from = 0, to = 2147483647L)
public final int b;
/* renamed from: c reason: collision with root package name */
public final int f2398c;
public final int d;
public final int e;
public final int f;
public final int[] g;
public final int h;
public final long i;
/* compiled from: Apng.kt */
public static final class Companion {
public Companion() {
}
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
}
public final Apng copy(Apng apng) throws ApngException {
m.checkNotNullParameter(apng, "apng");
DecodeResult decodeResult = new DecodeResult();
Trace.beginSection("Apng#copy");
try {
int copy = ApngDecoderJni.copy(Apng.access$getId$p(apng), decodeResult);
Trace.endSection();
if (copy >= 0) {
try {
return new Apng(copy, decodeResult.getWidth(), decodeResult.getHeight(), decodeResult.getFrameCount(), decodeResult.getFrameDurations(), decodeResult.getLoopCount(), decodeResult.getAllFrameByteCount());
} catch (Throwable th) {
throw new ApngException(th);
}
} else {
throw new ApngException(ApngException.ErrorCode.Companion.fromErrorCode$apng_drawable_release(copy), null, 2, null);
}
} catch (Throwable th2) {
Trace.endSection();
throw th2;
}
}
public final Apng decode(InputStream inputStream) throws ApngException {
m.checkNotNullParameter(inputStream, "stream");
DecodeResult decodeResult = new DecodeResult();
Trace.beginSection("Apng#decode");
try {
int decode = ApngDecoderJni.decode(inputStream, decodeResult);
Trace.endSection();
if (decode >= 0) {
try {
return new Apng(decode, decodeResult.getWidth(), decodeResult.getHeight(), decodeResult.getFrameCount(), decodeResult.getFrameDurations(), decodeResult.getLoopCount(), decodeResult.getAllFrameByteCount());
} catch (Throwable th) {
throw new ApngException(th);
}
} else {
throw new ApngException(ApngException.ErrorCode.Companion.fromErrorCode$apng_drawable_release(decode), null, 2, null);
}
} catch (Throwable th2) {
Trace.endSection();
throw th2;
}
}
public final boolean isApng(InputStream inputStream) throws ApngException {
m.checkNotNullParameter(inputStream, "stream");
try {
return ApngDecoderJni.isApng(inputStream);
} catch (Throwable th) {
throw new ApngException(th);
}
}
}
/* compiled from: Apng.kt */
public static final class DecodeResult {
private long allFrameByteCount;
private int frameCount;
private int[] frameDurations = new int[0];
private int height;
private int loopCount;
private int width;
public final long getAllFrameByteCount() {
return this.allFrameByteCount;
}
public final int getFrameCount() {
return this.frameCount;
}
public final int[] getFrameDurations() {
return this.frameDurations;
}
public final int getHeight() {
return this.height;
}
public final int getLoopCount() {
return this.loopCount;
}
public final int getWidth() {
return this.width;
}
public final void setAllFrameByteCount(long j) {
this.allFrameByteCount = j;
}
public final void setFrameCount(int i) {
this.frameCount = i;
}
public final void setFrameDurations(int[] iArr) {
m.checkNotNullParameter(iArr, "<set-?>");
this.frameDurations = iArr;
}
public final void setHeight(int i) {
this.height = i;
}
public final void setLoopCount(int i) {
this.loopCount = i;
}
public final void setWidth(int i) {
this.width = i;
}
}
public Apng(int i, int i2, int i3, @IntRange(from = 1, to = 2147483647L) int i4, int[] iArr, @IntRange(from = 0, to = 2147483647L) int i5, @IntRange(from = 0, to = 2147483647L) long j) {
m.checkNotNullParameter(iArr, "frameDurations");
this.f2398c = i;
this.d = i2;
this.e = i3;
this.f = i4;
this.g = iArr;
this.h = i5;
this.i = j;
Bitmap createBitmap = Bitmap.createBitmap(i2, i3, Bitmap.Config.ARGB_8888);
m.checkNotNullExpressionValue(createBitmap, "Bitmap.createBitmap(widt… Bitmap.Config.ARGB_8888)");
this.a = createBitmap;
Trace.beginSection("Apng#draw");
ApngDecoderJni.draw(i, 0, createBitmap);
Trace.endSection();
this.b = k.sum(iArr);
}
public static final /* synthetic */ int access$getId$p(Apng apng) {
return apng.f2398c;
}
public final Apng copy() {
return Companion.copy(this);
}
public final void drawWithIndex(int i, Canvas canvas, Rect rect, Rect rect2, Paint paint) {
m.checkNotNullParameter(canvas, "canvas");
m.checkNotNullParameter(rect2, "dst");
m.checkNotNullParameter(paint, "paint");
Trace.beginSection("Apng#draw");
ApngDecoderJni.draw(this.f2398c, i, this.a);
Trace.endSection();
canvas.drawBitmap(this.a, rect, rect2, paint);
}
public final void finalize() {
recycle();
}
public final long getAllFrameByteCount() {
return this.i;
}
public final int getByteCount() {
return this.a.getAllocationByteCount();
}
public final Bitmap.Config getConfig() {
Bitmap.Config config = this.a.getConfig();
m.checkNotNullExpressionValue(config, "bitmap.config");
return config;
}
public final int getDuration() {
return this.b;
}
public final int getFrameCount() {
return this.f;
}
public final int[] getFrameDurations() {
return this.g;
}
public final int getHeight() {
return this.e;
}
public final int getLoopCount() {
return this.h;
}
public final int getWidth() {
return this.d;
}
public final boolean isRecycled() {
return this.a.isRecycled();
}
public final void recycle() {
ApngDecoderJni.recycle(this.f2398c);
}
}