discord-jadx/app/src/main/java/c/f/h/a/b/a.java

235 lines
7.0 KiB
Java

package c.f.h.a.b;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import androidx.annotation.IntRange;
import c.f.h.a.a.c;
import c.f.h.a.a.d;
import c.f.h.a.b.e.b;
import c.f.h.a.b.e.c;
import com.facebook.common.references.CloseableReference;
import com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory;
import java.util.Objects;
/* compiled from: BitmapAnimationBackend */
public class a implements c.f.h.a.a.a, c.b {
public final PlatformBitmapFactory a;
public final b b;
/* renamed from: c reason: collision with root package name */
public final d f414c;
public final c d;
public final c.f.h.a.b.e.a e;
public final b f;
public final Paint g;
public Rect h;
public int i;
public int j;
public Bitmap.Config k = Bitmap.Config.ARGB_8888;
public a(PlatformBitmapFactory platformBitmapFactory, b bVar, d dVar, c cVar, c.f.h.a.b.e.a aVar, b bVar2) {
this.a = platformBitmapFactory;
this.b = bVar;
this.f414c = dVar;
this.d = cVar;
this.e = aVar;
this.f = bVar2;
this.g = new Paint(6);
n();
}
@Override // c.f.h.a.a.d
public int a() {
return this.f414c.a();
}
@Override // c.f.h.a.a.d
public int b() {
return this.f414c.b();
}
@Override // c.f.h.a.a.c.b
public void c() {
this.b.clear();
}
@Override // c.f.h.a.a.a
public void clear() {
this.b.clear();
}
@Override // c.f.h.a.a.a
public void d(ColorFilter colorFilter) {
this.g.setColorFilter(colorFilter);
}
@Override // c.f.h.a.a.d
public int e(int i) {
return this.f414c.e(i);
}
@Override // c.f.h.a.a.a
public void f(@IntRange(from = 0, to = 255) int i) {
this.g.setAlpha(i);
}
@Override // c.f.h.a.a.a
public int g() {
return this.j;
}
@Override // c.f.h.a.a.a
public void h(Rect rect) {
this.h = rect;
c.f.h.a.b.f.b bVar = (c.f.h.a.b.f.b) this.d;
c.f.j.a.c.a aVar = (c.f.j.a.c.a) bVar.b;
if (!c.f.j.a.c.a.a(aVar.f430c, rect).equals(aVar.d)) {
aVar = new c.f.j.a.c.a(aVar.a, aVar.b, rect, aVar.i);
}
if (aVar != bVar.b) {
bVar.b = aVar;
bVar.f417c = new c.f.j.a.c.d(aVar, bVar.d);
}
n();
}
@Override // c.f.h.a.a.a
public int i() {
return this.i;
}
@Override // c.f.h.a.a.a
public boolean j(Drawable drawable, Canvas canvas, int i) {
b bVar;
int i2 = i;
boolean l = l(canvas, i2, 0);
c.f.h.a.b.e.a aVar = this.e;
if (!(aVar == null || (bVar = this.f) == null)) {
b bVar2 = this.b;
c.f.h.a.b.e.d dVar = (c.f.h.a.b.e.d) aVar;
int i3 = 1;
while (i3 <= dVar.a) {
int a = (i2 + i3) % a();
c.f.d.e.a.h(2);
c.f.h.a.b.e.c cVar = (c.f.h.a.b.e.c) bVar;
Objects.requireNonNull(cVar);
int hashCode = (hashCode() * 31) + a;
synchronized (cVar.e) {
if (cVar.e.get(hashCode) != null) {
int i4 = c.f.d.e.a.a;
} else if (bVar2.c(a)) {
int i5 = c.f.d.e.a.a;
} else {
c.a aVar2 = new c.a(this, bVar2, a, hashCode);
cVar.e.put(hashCode, aVar2);
cVar.d.execute(aVar2);
}
}
i3++;
i2 = i;
}
}
return l;
}
public final boolean k(int i, CloseableReference<Bitmap> closeableReference, Canvas canvas, int i2) {
if (!CloseableReference.z(closeableReference)) {
return false;
}
if (this.h == null) {
canvas.drawBitmap(closeableReference.w(), 0.0f, 0.0f, this.g);
} else {
canvas.drawBitmap(closeableReference.w(), (Rect) null, this.h, this.g);
}
if (i2 == 3) {
return true;
}
this.b.e(i, closeableReference, i2);
return true;
}
public final boolean l(Canvas canvas, int i, int i2) {
boolean z2;
int i3 = 2;
boolean z3 = true;
CloseableReference closeableReference = null;
if (i2 == 0) {
closeableReference = this.b.d(i);
z2 = k(i, closeableReference, canvas, 0);
i3 = 1;
} else if (i2 == 1) {
closeableReference = this.b.a(i, this.i, this.j);
if (!m(i, closeableReference) || !k(i, closeableReference, canvas, 1)) {
z3 = false;
}
z2 = z3;
} else if (i2 == 2) {
try {
closeableReference = this.a.a(this.i, this.j, this.k);
if (!m(i, closeableReference) || !k(i, closeableReference, canvas, 2)) {
z3 = false;
}
z2 = z3;
i3 = 3;
} catch (RuntimeException e) {
c.f.d.e.a.l(a.class, "Failed to create frame bitmap", e);
Class<CloseableReference> cls = CloseableReference.i;
return false;
}
} else if (i2 != 3) {
Class<CloseableReference> cls2 = CloseableReference.i;
return false;
} else {
try {
closeableReference = this.b.f(i);
z2 = k(i, closeableReference, canvas, 3);
i3 = -1;
} catch (Throwable th) {
Class<CloseableReference> cls3 = CloseableReference.i;
if (closeableReference != null) {
closeableReference.close();
}
throw th;
}
}
Class<CloseableReference> cls4 = CloseableReference.i;
if (closeableReference != null) {
closeableReference.close();
}
return (z2 || i3 == -1) ? z2 : l(canvas, i, i3);
}
public final boolean m(int i, CloseableReference<Bitmap> closeableReference) {
if (!CloseableReference.z(closeableReference)) {
return false;
}
boolean a = ((c.f.h.a.b.f.b) this.d).a(i, closeableReference.w());
if (!a) {
closeableReference.close();
}
return a;
}
public final void n() {
int width = ((c.f.j.a.c.a) ((c.f.h.a.b.f.b) this.d).b).f430c.getWidth();
this.i = width;
int i = -1;
if (width == -1) {
Rect rect = this.h;
this.i = rect == null ? -1 : rect.width();
}
int height = ((c.f.j.a.c.a) ((c.f.h.a.b.f.b) this.d).b).f430c.getHeight();
this.j = height;
if (height == -1) {
Rect rect2 = this.h;
if (rect2 != null) {
i = rect2.height();
}
this.j = i;
}
}
}