Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package com.bumptech.glide.load.resource;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.util.Preconditions;
/* loaded from: classes.dex */
public class SimpleResource<T> implements Resource<T> {
protected final T a;
public SimpleResource(T t) {
Preconditions.a(t);
this.a = t;
}
@Override // com.bumptech.glide.load.engine.Resource
public void a() {
}
@Override // com.bumptech.glide.load.engine.Resource
public Class<T> b() {
return (Class<T>) this.a.getClass();
}
@Override // com.bumptech.glide.load.engine.Resource
public final T get() {
return this.a;
}
@Override // com.bumptech.glide.load.engine.Resource
public final int getSize() {
return 1;
}
}

View File

@@ -0,0 +1,27 @@
package com.bumptech.glide.load.resource;
import android.content.Context;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public final class UnitTransformation<T> implements Transformation<T> {
private static final Transformation<?> b = new UnitTransformation();
private UnitTransformation() {
}
public static <T> UnitTransformation<T> a() {
return (UnitTransformation) b;
}
@Override // com.bumptech.glide.load.Transformation
public Resource<T> a(Context context, Resource<T> resource, int i, int i2) {
return resource;
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
}
}

View File

@@ -0,0 +1,33 @@
package com.bumptech.glide.load.resource.bitmap;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.util.Preconditions;
import java.io.IOException;
/* loaded from: classes.dex */
public class BitmapDrawableDecoder<DataType> implements ResourceDecoder<DataType, BitmapDrawable> {
private final ResourceDecoder<DataType, Bitmap> a;
private final Resources b;
public BitmapDrawableDecoder(Resources resources, ResourceDecoder<DataType, Bitmap> resourceDecoder) {
Preconditions.a(resources);
this.b = resources;
Preconditions.a(resourceDecoder);
this.a = resourceDecoder;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(DataType datatype, Options options) throws IOException {
return this.a.a(datatype, options);
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<BitmapDrawable> a(DataType datatype, int i, int i2, Options options) throws IOException {
return LazyBitmapDrawableResource.a(this.b, this.a.a(datatype, i, i2, options));
}
}

View File

@@ -0,0 +1,31 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import com.bumptech.glide.load.EncodeStrategy;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceEncoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.io.File;
/* loaded from: classes.dex */
public class BitmapDrawableEncoder implements ResourceEncoder<BitmapDrawable> {
private final BitmapPool a;
private final ResourceEncoder<Bitmap> b;
public BitmapDrawableEncoder(BitmapPool bitmapPool, ResourceEncoder<Bitmap> resourceEncoder) {
this.a = bitmapPool;
this.b = resourceEncoder;
}
@Override // com.bumptech.glide.load.Encoder
public boolean a(Resource<BitmapDrawable> resource, File file, Options options) {
return this.b.a(new BitmapResource(resource.get().getBitmap(), this.a), file, options);
}
@Override // com.bumptech.glide.load.ResourceEncoder
public EncodeStrategy a(Options options) {
return this.b.a(options);
}
}

View File

@@ -0,0 +1,148 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import com.bumptech.glide.load.EncodeStrategy;
import com.bumptech.glide.load.Option;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceEncoder;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
/* loaded from: classes.dex */
public class BitmapEncoder implements ResourceEncoder<Bitmap> {
public static final Option<Integer> b = Option.a("com.bumptech.glide.load.resource.bitmap.BitmapEncoder.CompressionQuality", 90);
public static final Option<Bitmap.CompressFormat> c = Option.a("com.bumptech.glide.load.resource.bitmap.BitmapEncoder.CompressionFormat");
private final ArrayPool a;
public BitmapEncoder(ArrayPool arrayPool) {
this.a = arrayPool;
}
/* JADX WARN: Code restructure failed: missing block: B:35:0x0066, code lost:
if (r6 != null) goto L42;
*/
@Override // com.bumptech.glide.load.Encoder
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public boolean a(com.bumptech.glide.load.engine.Resource<android.graphics.Bitmap> r9, java.io.File r10, com.bumptech.glide.load.Options r11) {
/*
r8 = this;
java.lang.String r0 = "BitmapEncoder"
java.lang.Object r9 = r9.get()
android.graphics.Bitmap r9 = (android.graphics.Bitmap) r9
android.graphics.Bitmap$CompressFormat r1 = r8.a(r9, r11)
int r2 = r9.getWidth()
java.lang.Integer r2 = java.lang.Integer.valueOf(r2)
int r3 = r9.getHeight()
java.lang.Integer r3 = java.lang.Integer.valueOf(r3)
java.lang.String r4 = "encode: [%dx%d] %s"
com.bumptech.glide.util.pool.GlideTrace.a(r4, r2, r3, r1)
long r2 = com.bumptech.glide.util.LogTime.a() // Catch: java.lang.Throwable -> Lc0
com.bumptech.glide.load.Option<java.lang.Integer> r4 = com.bumptech.glide.load.resource.bitmap.BitmapEncoder.b // Catch: java.lang.Throwable -> Lc0
java.lang.Object r4 = r11.a(r4) // Catch: java.lang.Throwable -> Lc0
java.lang.Integer r4 = (java.lang.Integer) r4 // Catch: java.lang.Throwable -> Lc0
int r4 = r4.intValue() // Catch: java.lang.Throwable -> Lc0
r5 = 0
r6 = 0
java.io.FileOutputStream r7 = new java.io.FileOutputStream // Catch: java.lang.Throwable -> L57 java.io.IOException -> L59
r7.<init>(r10) // Catch: java.lang.Throwable -> L57 java.io.IOException -> L59
com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool r10 = r8.a // Catch: java.lang.Throwable -> L51 java.io.IOException -> L54
if (r10 == 0) goto L45
com.bumptech.glide.load.data.BufferedOutputStream r10 = new com.bumptech.glide.load.data.BufferedOutputStream // Catch: java.lang.Throwable -> L51 java.io.IOException -> L54
com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool r6 = r8.a // Catch: java.lang.Throwable -> L51 java.io.IOException -> L54
r10.<init>(r7, r6) // Catch: java.lang.Throwable -> L51 java.io.IOException -> L54
r6 = r10
goto L46
L45:
r6 = r7
L46:
r9.compress(r1, r4, r6) // Catch: java.lang.Throwable -> L57 java.io.IOException -> L59
r6.close() // Catch: java.lang.Throwable -> L57 java.io.IOException -> L59
r5 = 1
L4d:
r6.close() // Catch: java.io.IOException -> L69 java.lang.Throwable -> Lc0
goto L69
L51:
r9 = move-exception
r6 = r7
goto Lba
L54:
r10 = move-exception
r6 = r7
goto L5a
L57:
r9 = move-exception
goto Lba
L59:
r10 = move-exception
L5a:
r4 = 3
boolean r4 = android.util.Log.isLoggable(r0, r4) // Catch: java.lang.Throwable -> L57
if (r4 == 0) goto L66
java.lang.String r4 = "Failed to encode Bitmap"
android.util.Log.d(r0, r4, r10) // Catch: java.lang.Throwable -> L57
L66:
if (r6 == 0) goto L69
goto L4d
L69:
r10 = 2
boolean r10 = android.util.Log.isLoggable(r0, r10) // Catch: java.lang.Throwable -> Lc0
if (r10 == 0) goto Lb6
java.lang.StringBuilder r10 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> Lc0
r10.<init>() // Catch: java.lang.Throwable -> Lc0
java.lang.String r4 = "Compressed with type: "
r10.append(r4) // Catch: java.lang.Throwable -> Lc0
r10.append(r1) // Catch: java.lang.Throwable -> Lc0
java.lang.String r1 = " of size "
r10.append(r1) // Catch: java.lang.Throwable -> Lc0
int r1 = com.bumptech.glide.util.Util.a(r9) // Catch: java.lang.Throwable -> Lc0
r10.append(r1) // Catch: java.lang.Throwable -> Lc0
java.lang.String r1 = " in "
r10.append(r1) // Catch: java.lang.Throwable -> Lc0
double r1 = com.bumptech.glide.util.LogTime.a(r2) // Catch: java.lang.Throwable -> Lc0
r10.append(r1) // Catch: java.lang.Throwable -> Lc0
java.lang.String r1 = ", options format: "
r10.append(r1) // Catch: java.lang.Throwable -> Lc0
com.bumptech.glide.load.Option<android.graphics.Bitmap$CompressFormat> r1 = com.bumptech.glide.load.resource.bitmap.BitmapEncoder.c // Catch: java.lang.Throwable -> Lc0
java.lang.Object r11 = r11.a(r1) // Catch: java.lang.Throwable -> Lc0
r10.append(r11) // Catch: java.lang.Throwable -> Lc0
java.lang.String r11 = ", hasAlpha: "
r10.append(r11) // Catch: java.lang.Throwable -> Lc0
boolean r9 = r9.hasAlpha() // Catch: java.lang.Throwable -> Lc0
r10.append(r9) // Catch: java.lang.Throwable -> Lc0
java.lang.String r9 = r10.toString() // Catch: java.lang.Throwable -> Lc0
android.util.Log.v(r0, r9) // Catch: java.lang.Throwable -> Lc0
Lb6:
com.bumptech.glide.util.pool.GlideTrace.a()
return r5
Lba:
if (r6 == 0) goto Lbf
r6.close() // Catch: java.io.IOException -> Lbf java.lang.Throwable -> Lc0
Lbf:
throw r9 // Catch: java.lang.Throwable -> Lc0
Lc0:
r9 = move-exception
com.bumptech.glide.util.pool.GlideTrace.a()
throw r9
*/
throw new UnsupportedOperationException("Method not decompiled: com.bumptech.glide.load.resource.bitmap.BitmapEncoder.a(com.bumptech.glide.load.engine.Resource, java.io.File, com.bumptech.glide.load.Options):boolean");
}
private Bitmap.CompressFormat a(Bitmap bitmap, Options options) {
Bitmap.CompressFormat compressFormat = (Bitmap.CompressFormat) options.a(c);
if (compressFormat != null) {
return compressFormat;
}
if (bitmap.hasAlpha()) {
return Bitmap.CompressFormat.PNG;
}
return Bitmap.CompressFormat.JPEG;
}
@Override // com.bumptech.glide.load.ResourceEncoder
public EncodeStrategy a(Options options) {
return EncodeStrategy.TRANSFORMED;
}
}

View File

@@ -0,0 +1,54 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import com.bumptech.glide.load.engine.Initializable;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.util.Preconditions;
import com.bumptech.glide.util.Util;
/* loaded from: classes.dex */
public class BitmapResource implements Resource<Bitmap>, Initializable {
private final Bitmap a;
private final BitmapPool b;
public BitmapResource(Bitmap bitmap, BitmapPool bitmapPool) {
Preconditions.a(bitmap, "Bitmap must not be null");
this.a = bitmap;
Preconditions.a(bitmapPool, "BitmapPool must not be null");
this.b = bitmapPool;
}
public static BitmapResource a(Bitmap bitmap, BitmapPool bitmapPool) {
if (bitmap == null) {
return null;
}
return new BitmapResource(bitmap, bitmapPool);
}
@Override // com.bumptech.glide.load.engine.Resource
public Class<Bitmap> b() {
return Bitmap.class;
}
@Override // com.bumptech.glide.load.engine.Initializable
public void c() {
this.a.prepareToDraw();
}
@Override // com.bumptech.glide.load.engine.Resource
public int getSize() {
return Util.a(this.a);
}
@Override // com.bumptech.glide.load.engine.Resource
public void a() {
this.b.a(this.a);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.engine.Resource
public Bitmap get() {
return this.a;
}
}

View File

@@ -0,0 +1,31 @@
package com.bumptech.glide.load.resource.bitmap;
import android.content.Context;
import android.graphics.Bitmap;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.util.Util;
/* loaded from: classes.dex */
public abstract class BitmapTransformation implements Transformation<Bitmap> {
protected abstract Bitmap a(BitmapPool bitmapPool, Bitmap bitmap, int i, int i2);
@Override // com.bumptech.glide.load.Transformation
public final Resource<Bitmap> a(Context context, Resource<Bitmap> resource, int i, int i2) {
if (!Util.b(i, i2)) {
throw new IllegalArgumentException("Cannot apply transformation on width: " + i + " or height: " + i2 + " less than or equal to zero and not Target.SIZE_ORIGINAL");
}
BitmapPool d = Glide.b(context).d();
Bitmap bitmap = resource.get();
if (i == Integer.MIN_VALUE) {
i = bitmap.getWidth();
}
if (i2 == Integer.MIN_VALUE) {
i2 = bitmap.getHeight();
}
Bitmap a = a(d, bitmap, i, i2);
return bitmap.equals(a) ? resource : BitmapResource.a(a, d);
}
}

View File

@@ -0,0 +1,28 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.util.ByteBufferUtil;
import java.io.IOException;
import java.nio.ByteBuffer;
/* loaded from: classes.dex */
public class ByteBufferBitmapDecoder implements ResourceDecoder<ByteBuffer, Bitmap> {
private final Downsampler a;
public ByteBufferBitmapDecoder(Downsampler downsampler) {
this.a = downsampler;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(ByteBuffer byteBuffer, Options options) {
return this.a.a(byteBuffer);
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<Bitmap> a(ByteBuffer byteBuffer, int i, int i2, Options options) throws IOException {
return this.a.a(ByteBufferUtil.c(byteBuffer), i, i2, options);
}
}

View File

@@ -0,0 +1,31 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public class CenterCrop extends BitmapTransformation {
private static final byte[] b = "com.bumptech.glide.load.resource.bitmap.CenterCrop".getBytes(Key.a);
@Override // com.bumptech.glide.load.resource.bitmap.BitmapTransformation
protected Bitmap a(BitmapPool bitmapPool, Bitmap bitmap, int i, int i2) {
return TransformationUtils.a(bitmapPool, bitmap, i, i2);
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
return obj instanceof CenterCrop;
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
return "com.bumptech.glide.load.resource.bitmap.CenterCrop".hashCode();
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
messageDigest.update(b);
}
}

View File

@@ -0,0 +1,31 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public class CenterInside extends BitmapTransformation {
private static final byte[] b = "com.bumptech.glide.load.resource.bitmap.CenterInside".getBytes(Key.a);
@Override // com.bumptech.glide.load.resource.bitmap.BitmapTransformation
protected Bitmap a(BitmapPool bitmapPool, Bitmap bitmap, int i, int i2) {
return TransformationUtils.b(bitmapPool, bitmap, i, i2);
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
return obj instanceof CenterInside;
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
return "com.bumptech.glide.load.resource.bitmap.CenterInside".hashCode();
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
messageDigest.update(b);
}
}

View File

@@ -0,0 +1,31 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public class CircleCrop extends BitmapTransformation {
private static final byte[] b = "com.bumptech.glide.load.resource.bitmap.CircleCrop.1".getBytes(Key.a);
@Override // com.bumptech.glide.load.resource.bitmap.BitmapTransformation
protected Bitmap a(BitmapPool bitmapPool, Bitmap bitmap, int i, int i2) {
return TransformationUtils.c(bitmapPool, bitmap, i, i2);
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
return obj instanceof CircleCrop;
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
return "com.bumptech.glide.load.resource.bitmap.CircleCrop.1".hashCode();
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
messageDigest.update(b);
}
}

View File

@@ -0,0 +1,379 @@
package com.bumptech.glide.load.resource.bitmap;
import android.util.Log;
import com.bumptech.glide.load.ImageHeaderParser;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import com.bumptech.glide.util.Preconditions;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
/* loaded from: classes.dex */
public final class DefaultImageHeaderParser implements ImageHeaderParser {
static final byte[] a = "Exif\u0000\u0000".getBytes(Charset.forName("UTF-8"));
private static final int[] b = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
private static final class ByteBufferReader implements Reader {
private final ByteBuffer a;
ByteBufferReader(ByteBuffer byteBuffer) {
this.a = byteBuffer;
byteBuffer.order(ByteOrder.BIG_ENDIAN);
}
@Override // com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser.Reader
public int a() {
return ((c() << 8) & 65280) | (c() & 255);
}
@Override // com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser.Reader
public short b() {
return (short) (c() & 255);
}
@Override // com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser.Reader
public int c() {
if (this.a.remaining() < 1) {
return -1;
}
return this.a.get();
}
@Override // com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser.Reader
public int read(byte[] bArr, int i) {
int min = Math.min(i, this.a.remaining());
if (min == 0) {
return -1;
}
this.a.get(bArr, 0, min);
return min;
}
@Override // com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser.Reader
public long skip(long j) {
int min = (int) Math.min(this.a.remaining(), j);
ByteBuffer byteBuffer = this.a;
byteBuffer.position(byteBuffer.position() + min);
return min;
}
}
private static final class RandomAccessReader {
private final ByteBuffer a;
RandomAccessReader(byte[] bArr, int i) {
this.a = (ByteBuffer) ByteBuffer.wrap(bArr).order(ByteOrder.BIG_ENDIAN).limit(i);
}
void a(ByteOrder byteOrder) {
this.a.order(byteOrder);
}
int b(int i) {
if (a(i, 4)) {
return this.a.getInt(i);
}
return -1;
}
int a() {
return this.a.remaining();
}
short a(int i) {
if (a(i, 2)) {
return this.a.getShort(i);
}
return (short) -1;
}
private boolean a(int i, int i2) {
return this.a.remaining() - i >= i2;
}
}
private interface Reader {
int a() throws IOException;
short b() throws IOException;
int c() throws IOException;
int read(byte[] bArr, int i) throws IOException;
long skip(long j) throws IOException;
}
private static final class StreamReader implements Reader {
private final InputStream a;
StreamReader(InputStream inputStream) {
this.a = inputStream;
}
@Override // com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser.Reader
public int a() throws IOException {
return ((this.a.read() << 8) & 65280) | (this.a.read() & 255);
}
@Override // com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser.Reader
public short b() throws IOException {
return (short) (this.a.read() & 255);
}
@Override // com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser.Reader
public int c() throws IOException {
return this.a.read();
}
@Override // com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser.Reader
public int read(byte[] bArr, int i) throws IOException {
int i2 = i;
while (i2 > 0) {
int read = this.a.read(bArr, i - i2, i2);
if (read == -1) {
break;
}
i2 -= read;
}
return i - i2;
}
@Override // com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser.Reader
public long skip(long j) throws IOException {
if (j < 0) {
return 0L;
}
long j2 = j;
while (j2 > 0) {
long skip = this.a.skip(j2);
if (skip <= 0) {
if (this.a.read() == -1) {
break;
}
skip = 1;
}
j2 -= skip;
}
return j - j2;
}
}
private static int a(int i, int i2) {
return i + 2 + (i2 * 12);
}
private static boolean a(int i) {
return (i & 65496) == 65496 || i == 19789 || i == 18761;
}
private int b(Reader reader) throws IOException {
short b2;
int a2;
long j;
long skip;
do {
short b3 = reader.b();
if (b3 != 255) {
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Unknown segmentId=" + ((int) b3));
}
return -1;
}
b2 = reader.b();
if (b2 == 218) {
return -1;
}
if (b2 == 217) {
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Found MARKER_EOI in exif segment");
}
return -1;
}
a2 = reader.a() - 2;
if (b2 == 225) {
return a2;
}
j = a2;
skip = reader.skip(j);
} while (skip == j);
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Unable to skip enough data, type: " + ((int) b2) + ", wanted to skip: " + a2 + ", but actually skipped: " + skip);
}
return -1;
}
@Override // com.bumptech.glide.load.ImageHeaderParser
public ImageHeaderParser.ImageType a(InputStream inputStream) throws IOException {
Preconditions.a(inputStream);
return a(new StreamReader(inputStream));
}
@Override // com.bumptech.glide.load.ImageHeaderParser
public ImageHeaderParser.ImageType a(ByteBuffer byteBuffer) throws IOException {
Preconditions.a(byteBuffer);
return a(new ByteBufferReader(byteBuffer));
}
@Override // com.bumptech.glide.load.ImageHeaderParser
public int a(InputStream inputStream, ArrayPool arrayPool) throws IOException {
Preconditions.a(inputStream);
StreamReader streamReader = new StreamReader(inputStream);
Preconditions.a(arrayPool);
return a(streamReader, arrayPool);
}
private ImageHeaderParser.ImageType a(Reader reader) throws IOException {
int a2 = reader.a();
if (a2 == 65496) {
return ImageHeaderParser.ImageType.JPEG;
}
int a3 = ((a2 << 16) & (-65536)) | (reader.a() & 65535);
if (a3 == -1991225785) {
reader.skip(21L);
return reader.c() >= 3 ? ImageHeaderParser.ImageType.PNG_A : ImageHeaderParser.ImageType.PNG;
}
if ((a3 >> 8) == 4671814) {
return ImageHeaderParser.ImageType.GIF;
}
if (a3 != 1380533830) {
return ImageHeaderParser.ImageType.UNKNOWN;
}
reader.skip(4L);
if ((((reader.a() << 16) & (-65536)) | (reader.a() & 65535)) != 1464156752) {
return ImageHeaderParser.ImageType.UNKNOWN;
}
int a4 = ((reader.a() << 16) & (-65536)) | (reader.a() & 65535);
if ((a4 & (-256)) != 1448097792) {
return ImageHeaderParser.ImageType.UNKNOWN;
}
int i = a4 & 255;
if (i == 88) {
reader.skip(4L);
return (reader.c() & 16) != 0 ? ImageHeaderParser.ImageType.WEBP_A : ImageHeaderParser.ImageType.WEBP;
}
if (i == 76) {
reader.skip(4L);
return (reader.c() & 8) != 0 ? ImageHeaderParser.ImageType.WEBP_A : ImageHeaderParser.ImageType.WEBP;
}
return ImageHeaderParser.ImageType.WEBP;
}
private int a(Reader reader, ArrayPool arrayPool) throws IOException {
int a2 = reader.a();
if (!a(a2)) {
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Parser doesn't handle magic number: " + a2);
}
return -1;
}
int b2 = b(reader);
if (b2 == -1) {
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Failed to parse exif segment length, or exif segment not found");
}
return -1;
}
byte[] bArr = (byte[]) arrayPool.b(b2, byte[].class);
try {
return a(reader, bArr, b2);
} finally {
arrayPool.put(bArr);
}
}
private int a(Reader reader, byte[] bArr, int i) throws IOException {
int read = reader.read(bArr, i);
if (read != i) {
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Unable to read exif segment data, length: " + i + ", actually read: " + read);
}
return -1;
}
if (a(bArr, i)) {
return a(new RandomAccessReader(bArr, i));
}
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Missing jpeg exif preamble");
}
return -1;
}
private boolean a(byte[] bArr, int i) {
boolean z = bArr != null && i > a.length;
if (!z) {
return z;
}
int i2 = 0;
while (true) {
byte[] bArr2 = a;
if (i2 >= bArr2.length) {
return z;
}
if (bArr[i2] != bArr2[i2]) {
return false;
}
i2++;
}
}
private static int a(RandomAccessReader randomAccessReader) {
ByteOrder byteOrder;
short a2 = randomAccessReader.a(6);
if (a2 == 18761) {
byteOrder = ByteOrder.LITTLE_ENDIAN;
} else if (a2 != 19789) {
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Unknown endianness = " + ((int) a2));
}
byteOrder = ByteOrder.BIG_ENDIAN;
} else {
byteOrder = ByteOrder.BIG_ENDIAN;
}
randomAccessReader.a(byteOrder);
int b2 = randomAccessReader.b(10) + 6;
short a3 = randomAccessReader.a(b2);
for (int i = 0; i < a3; i++) {
int a4 = a(b2, i);
short a5 = randomAccessReader.a(a4);
if (a5 == 274) {
short a6 = randomAccessReader.a(a4 + 2);
if (a6 >= 1 && a6 <= 12) {
int b3 = randomAccessReader.b(a4 + 4);
if (b3 < 0) {
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Negative tiff component count");
}
} else {
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Got tagIndex=" + i + " tagType=" + ((int) a5) + " formatCode=" + ((int) a6) + " componentCount=" + b3);
}
int i2 = b3 + b[a6];
if (i2 > 4) {
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Got byte count > 4, not orientation, continuing, formatCode=" + ((int) a6));
}
} else {
int i3 = a4 + 8;
if (i3 >= 0 && i3 <= randomAccessReader.a()) {
if (i2 >= 0 && i2 + i3 <= randomAccessReader.a()) {
return randomAccessReader.a(i3);
}
if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Illegal number of bytes for TI tag data tagType=" + ((int) a5));
}
} else if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Illegal tagValueOffset=" + i3 + " tagType=" + ((int) a5));
}
}
}
} else if (Log.isLoggable("DfltImageHeaderParser", 3)) {
Log.d("DfltImageHeaderParser", "Got invalid format code = " + ((int) a6));
}
}
}
return -1;
}
}

View File

@@ -0,0 +1,125 @@
package com.bumptech.glide.load.resource.bitmap;
import com.bumptech.glide.load.Option;
/* loaded from: classes.dex */
public abstract class DownsampleStrategy {
public static final DownsampleStrategy a = new FitCenter();
public static final DownsampleStrategy b = new CenterOutside();
public static final DownsampleStrategy c;
public static final DownsampleStrategy d;
public static final DownsampleStrategy e;
public static final Option<DownsampleStrategy> f;
private static class AtLeast extends DownsampleStrategy {
AtLeast() {
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public SampleSizeRounding a(int i, int i2, int i3, int i4) {
return SampleSizeRounding.QUALITY;
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public float b(int i, int i2, int i3, int i4) {
if (Math.min(i2 / i4, i / i3) == 0) {
return 1.0f;
}
return 1.0f / Integer.highestOneBit(r1);
}
}
private static class AtMost extends DownsampleStrategy {
AtMost() {
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public SampleSizeRounding a(int i, int i2, int i3, int i4) {
return SampleSizeRounding.MEMORY;
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public float b(int i, int i2, int i3, int i4) {
int ceil = (int) Math.ceil(Math.max(i2 / i4, i / i3));
return 1.0f / (r2 << (Math.max(1, Integer.highestOneBit(ceil)) >= ceil ? 0 : 1));
}
}
private static class CenterInside extends DownsampleStrategy {
CenterInside() {
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public SampleSizeRounding a(int i, int i2, int i3, int i4) {
return SampleSizeRounding.QUALITY;
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public float b(int i, int i2, int i3, int i4) {
return Math.min(1.0f, DownsampleStrategy.a.b(i, i2, i3, i4));
}
}
private static class CenterOutside extends DownsampleStrategy {
CenterOutside() {
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public SampleSizeRounding a(int i, int i2, int i3, int i4) {
return SampleSizeRounding.QUALITY;
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public float b(int i, int i2, int i3, int i4) {
return Math.max(i3 / i, i4 / i2);
}
}
private static class FitCenter extends DownsampleStrategy {
FitCenter() {
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public SampleSizeRounding a(int i, int i2, int i3, int i4) {
return SampleSizeRounding.QUALITY;
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public float b(int i, int i2, int i3, int i4) {
return Math.min(i3 / i, i4 / i2);
}
}
private static class None extends DownsampleStrategy {
None() {
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public SampleSizeRounding a(int i, int i2, int i3, int i4) {
return SampleSizeRounding.QUALITY;
}
@Override // com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
public float b(int i, int i2, int i3, int i4) {
return 1.0f;
}
}
public enum SampleSizeRounding {
MEMORY,
QUALITY
}
static {
new AtLeast();
new AtMost();
c = new CenterInside();
d = new None();
e = b;
f = Option.a("com.bumptech.glide.load.resource.bitmap.Downsampler.DownsampleStrategy", e);
}
public abstract SampleSizeRounding a(int i, int i2, int i3, int i4);
public abstract float b(int i, int i2, int i3, int i4);
}

View File

@@ -0,0 +1,471 @@
package com.bumptech.glide.load.resource.bitmap;
import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.Log;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.ImageHeaderParser;
import com.bumptech.glide.load.ImageHeaderParserUtils;
import com.bumptech.glide.load.Option;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.DownsampleStrategy;
import com.bumptech.glide.util.LogTime;
import com.bumptech.glide.util.Preconditions;
import com.bumptech.glide.util.Util;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Queue;
import java.util.Set;
/* loaded from: classes.dex */
public final class Downsampler {
public static final Option<DecodeFormat> f = Option.a("com.bumptech.glide.load.resource.bitmap.Downsampler.DecodeFormat", DecodeFormat.DEFAULT);
public static final Option<Boolean> g;
public static final Option<Boolean> h;
private static final Set<String> i;
private static final DecodeCallbacks j;
private static final Set<ImageHeaderParser.ImageType> k;
private static final Queue<BitmapFactory.Options> l;
private final BitmapPool a;
private final DisplayMetrics b;
private final ArrayPool c;
private final List<ImageHeaderParser> d;
private final HardwareConfigState e = HardwareConfigState.a();
public interface DecodeCallbacks {
void a();
void a(BitmapPool bitmapPool, Bitmap bitmap) throws IOException;
}
static {
Option<DownsampleStrategy> option = DownsampleStrategy.f;
g = Option.a("com.bumptech.glide.load.resource.bitmap.Downsampler.FixBitmapSize", false);
h = Option.a("com.bumtpech.glide.load.resource.bitmap.Downsampler.AllowHardwareDecode");
i = Collections.unmodifiableSet(new HashSet(Arrays.asList("image/vnd.wap.wbmp", "image/x-ico")));
j = new DecodeCallbacks() { // from class: com.bumptech.glide.load.resource.bitmap.Downsampler.1
@Override // com.bumptech.glide.load.resource.bitmap.Downsampler.DecodeCallbacks
public void a() {
}
@Override // com.bumptech.glide.load.resource.bitmap.Downsampler.DecodeCallbacks
public void a(BitmapPool bitmapPool, Bitmap bitmap) {
}
};
k = Collections.unmodifiableSet(EnumSet.of(ImageHeaderParser.ImageType.JPEG, ImageHeaderParser.ImageType.PNG_A, ImageHeaderParser.ImageType.PNG));
l = Util.a(0);
}
public Downsampler(List<ImageHeaderParser> list, DisplayMetrics displayMetrics, BitmapPool bitmapPool, ArrayPool arrayPool) {
this.d = list;
Preconditions.a(displayMetrics);
this.b = displayMetrics;
Preconditions.a(bitmapPool);
this.a = bitmapPool;
Preconditions.a(arrayPool);
this.c = arrayPool;
}
private static int b(double d) {
if (d > 1.0d) {
d = 1.0d / d;
}
return (int) Math.round(d * 2.147483647E9d);
}
private static int c(double d) {
return (int) (d + 0.5d);
}
private static void c(BitmapFactory.Options options) {
d(options);
synchronized (l) {
l.offer(options);
}
}
private static void d(BitmapFactory.Options options) {
options.inTempStorage = null;
options.inDither = false;
options.inScaled = false;
options.inSampleSize = 1;
options.inPreferredConfig = null;
options.inJustDecodeBounds = false;
options.inDensity = 0;
options.inTargetDensity = 0;
options.outWidth = 0;
options.outHeight = 0;
options.outMimeType = null;
options.inBitmap = null;
options.inMutable = true;
}
public Resource<Bitmap> a(InputStream inputStream, int i2, int i3, Options options) throws IOException {
return a(inputStream, i2, i3, options, j);
}
public boolean a(InputStream inputStream) {
return true;
}
public boolean a(ByteBuffer byteBuffer) {
return true;
}
private static int[] b(InputStream inputStream, BitmapFactory.Options options, DecodeCallbacks decodeCallbacks, BitmapPool bitmapPool) throws IOException {
options.inJustDecodeBounds = true;
a(inputStream, options, decodeCallbacks, bitmapPool);
options.inJustDecodeBounds = false;
return new int[]{options.outWidth, options.outHeight};
}
public Resource<Bitmap> a(InputStream inputStream, int i2, int i3, Options options, DecodeCallbacks decodeCallbacks) throws IOException {
Preconditions.a(inputStream.markSupported(), "You must provide an InputStream that supports mark()");
byte[] bArr = (byte[]) this.c.b(65536, byte[].class);
BitmapFactory.Options a = a();
a.inTempStorage = bArr;
DecodeFormat decodeFormat = (DecodeFormat) options.a(f);
try {
return BitmapResource.a(a(inputStream, a, (DownsampleStrategy) options.a(DownsampleStrategy.f), decodeFormat, decodeFormat == DecodeFormat.PREFER_ARGB_8888_DISALLOW_HARDWARE ? false : options.a(h) != null && ((Boolean) options.a(h)).booleanValue(), i2, i3, ((Boolean) options.a(g)).booleanValue(), decodeCallbacks), this.a);
} finally {
c(a);
this.c.put(bArr);
}
}
private static boolean b(BitmapFactory.Options options) {
int i2;
int i3 = options.inTargetDensity;
return i3 > 0 && (i2 = options.inDensity) > 0 && i3 != i2;
}
private Bitmap a(InputStream inputStream, BitmapFactory.Options options, DownsampleStrategy downsampleStrategy, DecodeFormat decodeFormat, boolean z, int i2, int i3, boolean z2, DecodeCallbacks decodeCallbacks) throws IOException {
Downsampler downsampler;
int round;
int round2;
int i4;
long a = LogTime.a();
int[] b = b(inputStream, options, decodeCallbacks, this.a);
int i5 = b[0];
int i6 = b[1];
String str = options.outMimeType;
boolean z3 = (i5 == -1 || i6 == -1) ? false : z;
int a2 = ImageHeaderParserUtils.a(this.d, inputStream, this.c);
int a3 = TransformationUtils.a(a2);
boolean b2 = TransformationUtils.b(a2);
int i7 = i2 == Integer.MIN_VALUE ? i5 : i2;
int i8 = i3 == Integer.MIN_VALUE ? i6 : i3;
ImageHeaderParser.ImageType b3 = ImageHeaderParserUtils.b(this.d, inputStream, this.c);
a(b3, inputStream, decodeCallbacks, this.a, downsampleStrategy, a3, i5, i6, i7, i8, options);
a(inputStream, decodeFormat, z3, b2, options, i7, i8);
boolean z4 = Build.VERSION.SDK_INT >= 19;
if (options.inSampleSize == 1 || z4) {
downsampler = this;
if (downsampler.a(b3)) {
if (i5 < 0 || i6 < 0 || !z2 || !z4) {
float f2 = b(options) ? options.inTargetDensity / options.inDensity : 1.0f;
int i9 = options.inSampleSize;
float f3 = i9;
int ceil = (int) Math.ceil(i5 / f3);
int ceil2 = (int) Math.ceil(i6 / f3);
round = Math.round(ceil * f2);
round2 = Math.round(ceil2 * f2);
if (Log.isLoggable("Downsampler", 2)) {
Log.v("Downsampler", "Calculated target [" + round + "x" + round2 + "] for source [" + i5 + "x" + i6 + "], sampleSize: " + i9 + ", targetDensity: " + options.inTargetDensity + ", density: " + options.inDensity + ", density multiplier: " + f2);
}
} else {
round = i7;
round2 = i8;
}
if (round > 0 && round2 > 0) {
a(options, downsampler.a, round, round2);
}
}
} else {
downsampler = this;
}
Bitmap a4 = a(inputStream, options, decodeCallbacks, downsampler.a);
decodeCallbacks.a(downsampler.a, a4);
if (Log.isLoggable("Downsampler", 2)) {
i4 = a2;
a(i5, i6, str, options, a4, i2, i3, a);
} else {
i4 = a2;
}
Bitmap bitmap = null;
if (a4 != null) {
a4.setDensity(downsampler.b.densityDpi);
bitmap = TransformationUtils.a(downsampler.a, a4, i4);
if (!a4.equals(bitmap)) {
downsampler.a.a(a4);
}
}
return bitmap;
}
private static void a(ImageHeaderParser.ImageType imageType, InputStream inputStream, DecodeCallbacks decodeCallbacks, BitmapPool bitmapPool, DownsampleStrategy downsampleStrategy, int i2, int i3, int i4, int i5, int i6, BitmapFactory.Options options) throws IOException {
float b;
int min;
int i7;
int floor;
double floor2;
int i8;
if (i3 <= 0 || i4 <= 0) {
if (Log.isLoggable("Downsampler", 3)) {
Log.d("Downsampler", "Unable to determine dimensions for: " + imageType + " with target [" + i5 + "x" + i6 + "]");
return;
}
return;
}
if (i2 != 90 && i2 != 270) {
b = downsampleStrategy.b(i3, i4, i5, i6);
} else {
b = downsampleStrategy.b(i4, i3, i5, i6);
}
if (b > 0.0f) {
DownsampleStrategy.SampleSizeRounding a = downsampleStrategy.a(i3, i4, i5, i6);
if (a != null) {
float f2 = i3;
float f3 = i4;
int c = i3 / c(b * f2);
int c2 = i4 / c(b * f3);
if (a == DownsampleStrategy.SampleSizeRounding.MEMORY) {
min = Math.max(c, c2);
} else {
min = Math.min(c, c2);
}
if (Build.VERSION.SDK_INT > 23 || !i.contains(options.outMimeType)) {
int max = Math.max(1, Integer.highestOneBit(min));
i7 = (a != DownsampleStrategy.SampleSizeRounding.MEMORY || ((float) max) >= 1.0f / b) ? max : max << 1;
} else {
i7 = 1;
}
options.inSampleSize = i7;
if (imageType == ImageHeaderParser.ImageType.JPEG) {
float min2 = Math.min(i7, 8);
floor = (int) Math.ceil(f2 / min2);
i8 = (int) Math.ceil(f3 / min2);
int i9 = i7 / 8;
if (i9 > 0) {
floor /= i9;
i8 /= i9;
}
} else {
if (imageType != ImageHeaderParser.ImageType.PNG && imageType != ImageHeaderParser.ImageType.PNG_A) {
if (imageType != ImageHeaderParser.ImageType.WEBP && imageType != ImageHeaderParser.ImageType.WEBP_A) {
if (i3 % i7 == 0 && i4 % i7 == 0) {
floor = i3 / i7;
i8 = i4 / i7;
} else {
int[] b2 = b(inputStream, options, decodeCallbacks, bitmapPool);
int i10 = b2[0];
i8 = b2[1];
floor = i10;
}
} else if (Build.VERSION.SDK_INT >= 24) {
float f4 = i7;
floor = Math.round(f2 / f4);
i8 = Math.round(f3 / f4);
} else {
float f5 = i7;
floor = (int) Math.floor(f2 / f5);
floor2 = Math.floor(f3 / f5);
}
} else {
float f6 = i7;
floor = (int) Math.floor(f2 / f6);
floor2 = Math.floor(f3 / f6);
}
i8 = (int) floor2;
}
double b3 = downsampleStrategy.b(floor, i8, i5, i6);
if (Build.VERSION.SDK_INT >= 19) {
options.inTargetDensity = a(b3);
options.inDensity = b(b3);
}
if (b(options)) {
options.inScaled = true;
} else {
options.inTargetDensity = 0;
options.inDensity = 0;
}
if (Log.isLoggable("Downsampler", 2)) {
Log.v("Downsampler", "Calculate scaling, source: [" + i3 + "x" + i4 + "], target: [" + i5 + "x" + i6 + "], power of two scaled: [" + floor + "x" + i8 + "], exact scale factor: " + b + ", power of 2 sample size: " + i7 + ", adjusted scale factor: " + b3 + ", target density: " + options.inTargetDensity + ", density: " + options.inDensity);
return;
}
return;
}
throw new IllegalArgumentException("Cannot round with null rounding");
}
throw new IllegalArgumentException("Cannot scale with factor: " + b + " from: " + downsampleStrategy + ", source: [" + i3 + "x" + i4 + "], target: [" + i5 + "x" + i6 + "]");
}
private static int a(double d) {
return c((d / (r1 / r0)) * c(b(d) * d));
}
private boolean a(ImageHeaderParser.ImageType imageType) {
if (Build.VERSION.SDK_INT >= 19) {
return true;
}
return k.contains(imageType);
}
private void a(InputStream inputStream, DecodeFormat decodeFormat, boolean z, boolean z2, BitmapFactory.Options options, int i2, int i3) {
if (this.e.a(i2, i3, options, decodeFormat, z, z2)) {
return;
}
if (decodeFormat != DecodeFormat.PREFER_ARGB_8888 && decodeFormat != DecodeFormat.PREFER_ARGB_8888_DISALLOW_HARDWARE && Build.VERSION.SDK_INT != 16) {
boolean z3 = false;
try {
z3 = ImageHeaderParserUtils.b(this.d, inputStream, this.c).hasAlpha();
} catch (IOException e) {
if (Log.isLoggable("Downsampler", 3)) {
Log.d("Downsampler", "Cannot determine whether the image has alpha or not from header, format " + decodeFormat, e);
}
}
options.inPreferredConfig = z3 ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
if (options.inPreferredConfig == Bitmap.Config.RGB_565) {
options.inDither = true;
return;
}
return;
}
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
}
/* JADX WARN: Code restructure failed: missing block: B:25:?, code lost:
throw r1;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
private static android.graphics.Bitmap a(java.io.InputStream r6, android.graphics.BitmapFactory.Options r7, com.bumptech.glide.load.resource.bitmap.Downsampler.DecodeCallbacks r8, com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool r9) throws java.io.IOException {
/*
java.lang.String r0 = "Downsampler"
boolean r1 = r7.inJustDecodeBounds
if (r1 == 0) goto Lc
r1 = 10485760(0xa00000, float:1.469368E-38)
r6.mark(r1)
goto Lf
Lc:
r8.a()
Lf:
int r1 = r7.outWidth
int r2 = r7.outHeight
java.lang.String r3 = r7.outMimeType
java.util.concurrent.locks.Lock r4 = com.bumptech.glide.load.resource.bitmap.TransformationUtils.a()
r4.lock()
r4 = 0
android.graphics.Bitmap r8 = android.graphics.BitmapFactory.decodeStream(r6, r4, r7) // Catch: java.lang.Throwable -> L30 java.lang.IllegalArgumentException -> L32
java.util.concurrent.locks.Lock r9 = com.bumptech.glide.load.resource.bitmap.TransformationUtils.a()
r9.unlock()
boolean r7 = r7.inJustDecodeBounds
if (r7 == 0) goto L2f
r6.reset()
L2f:
return r8
L30:
r6 = move-exception
goto L5f
L32:
r5 = move-exception
java.io.IOException r1 = a(r5, r1, r2, r3, r7) // Catch: java.lang.Throwable -> L30
r2 = 3
boolean r2 = android.util.Log.isLoggable(r0, r2) // Catch: java.lang.Throwable -> L30
if (r2 == 0) goto L43
java.lang.String r2 = "Failed to decode with inBitmap, trying again without Bitmap re-use"
android.util.Log.d(r0, r2, r1) // Catch: java.lang.Throwable -> L30
L43:
android.graphics.Bitmap r0 = r7.inBitmap // Catch: java.lang.Throwable -> L30
if (r0 == 0) goto L5e
r6.reset() // Catch: java.lang.Throwable -> L30 java.io.IOException -> L5d
android.graphics.Bitmap r0 = r7.inBitmap // Catch: java.lang.Throwable -> L30 java.io.IOException -> L5d
r9.a(r0) // Catch: java.lang.Throwable -> L30 java.io.IOException -> L5d
r7.inBitmap = r4 // Catch: java.lang.Throwable -> L30 java.io.IOException -> L5d
android.graphics.Bitmap r6 = a(r6, r7, r8, r9) // Catch: java.lang.Throwable -> L30 java.io.IOException -> L5d
java.util.concurrent.locks.Lock r7 = com.bumptech.glide.load.resource.bitmap.TransformationUtils.a()
r7.unlock()
return r6
L5d:
throw r1 // Catch: java.lang.Throwable -> L30
L5e:
throw r1 // Catch: java.lang.Throwable -> L30
L5f:
java.util.concurrent.locks.Lock r7 = com.bumptech.glide.load.resource.bitmap.TransformationUtils.a()
r7.unlock()
throw r6
*/
throw new UnsupportedOperationException("Method not decompiled: com.bumptech.glide.load.resource.bitmap.Downsampler.a(java.io.InputStream, android.graphics.BitmapFactory$Options, com.bumptech.glide.load.resource.bitmap.Downsampler$DecodeCallbacks, com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool):android.graphics.Bitmap");
}
private static void a(int i2, int i3, String str, BitmapFactory.Options options, Bitmap bitmap, int i4, int i5, long j2) {
Log.v("Downsampler", "Decoded " + a(bitmap) + " from [" + i2 + "x" + i3 + "] " + str + " with inBitmap " + a(options) + " for [" + i4 + "x" + i5 + "], sample size: " + options.inSampleSize + ", density: " + options.inDensity + ", target density: " + options.inTargetDensity + ", thread: " + Thread.currentThread().getName() + ", duration: " + LogTime.a(j2));
}
private static String a(BitmapFactory.Options options) {
return a(options.inBitmap);
}
@TargetApi(19)
private static String a(Bitmap bitmap) {
String str;
if (bitmap == null) {
return null;
}
if (Build.VERSION.SDK_INT >= 19) {
str = " (" + bitmap.getAllocationByteCount() + ")";
} else {
str = "";
}
return "[" + bitmap.getWidth() + "x" + bitmap.getHeight() + "] " + bitmap.getConfig() + str;
}
private static IOException a(IllegalArgumentException illegalArgumentException, int i2, int i3, String str, BitmapFactory.Options options) {
return new IOException("Exception decoding bitmap, outWidth: " + i2 + ", outHeight: " + i3 + ", outMimeType: " + str + ", inBitmap: " + a(options), illegalArgumentException);
}
@TargetApi(26)
private static void a(BitmapFactory.Options options, BitmapPool bitmapPool, int i2, int i3) {
Bitmap.Config config;
if (Build.VERSION.SDK_INT < 26) {
config = null;
} else if (options.inPreferredConfig == Bitmap.Config.HARDWARE) {
return;
} else {
config = options.outConfig;
}
if (config == null) {
config = options.inPreferredConfig;
}
options.inBitmap = bitmapPool.b(i2, i3, config);
}
private static synchronized BitmapFactory.Options a() {
BitmapFactory.Options poll;
synchronized (Downsampler.class) {
synchronized (l) {
poll = l.poll();
}
if (poll == null) {
poll = new BitmapFactory.Options();
d(poll);
}
}
return poll;
}
}

View File

@@ -0,0 +1,72 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter;
import java.util.concurrent.locks.Lock;
/* loaded from: classes.dex */
final class DrawableToBitmapConverter {
private static final BitmapPool a = new BitmapPoolAdapter() { // from class: com.bumptech.glide.load.resource.bitmap.DrawableToBitmapConverter.1
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter, com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
public void a(Bitmap bitmap) {
}
};
static Resource<Bitmap> a(BitmapPool bitmapPool, Drawable drawable, int i, int i2) {
Bitmap bitmap;
Drawable current = drawable.getCurrent();
boolean z = false;
if (current instanceof BitmapDrawable) {
bitmap = ((BitmapDrawable) current).getBitmap();
} else if (current instanceof Animatable) {
bitmap = null;
} else {
bitmap = b(bitmapPool, current, i, i2);
z = true;
}
if (!z) {
bitmapPool = a;
}
return BitmapResource.a(bitmap, bitmapPool);
}
private static Bitmap b(BitmapPool bitmapPool, Drawable drawable, int i, int i2) {
if (i == Integer.MIN_VALUE && drawable.getIntrinsicWidth() <= 0) {
if (Log.isLoggable("DrawableToBitmap", 5)) {
Log.w("DrawableToBitmap", "Unable to draw " + drawable + " to Bitmap with Target.SIZE_ORIGINAL because the Drawable has no intrinsic width");
}
return null;
}
if (i2 == Integer.MIN_VALUE && drawable.getIntrinsicHeight() <= 0) {
if (Log.isLoggable("DrawableToBitmap", 5)) {
Log.w("DrawableToBitmap", "Unable to draw " + drawable + " to Bitmap with Target.SIZE_ORIGINAL because the Drawable has no intrinsic height");
}
return null;
}
if (drawable.getIntrinsicWidth() > 0) {
i = drawable.getIntrinsicWidth();
}
if (drawable.getIntrinsicHeight() > 0) {
i2 = drawable.getIntrinsicHeight();
}
Lock a2 = TransformationUtils.a();
a2.lock();
Bitmap a3 = bitmapPool.a(i, i2, Bitmap.Config.ARGB_8888);
try {
Canvas canvas = new Canvas(a3);
drawable.setBounds(0, 0, i, i2);
drawable.draw(canvas);
canvas.setBitmap(null);
return a3;
} finally {
a2.unlock();
}
}
}

View File

@@ -0,0 +1,67 @@
package com.bumptech.glide.load.resource.bitmap;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public class DrawableTransformation implements Transformation<Drawable> {
private final Transformation<Bitmap> b;
private final boolean c;
public DrawableTransformation(Transformation<Bitmap> transformation, boolean z) {
this.b = transformation;
this.c = z;
}
public Transformation<BitmapDrawable> a() {
return this;
}
@Override // com.bumptech.glide.load.Transformation
public Resource<Drawable> a(Context context, Resource<Drawable> resource, int i, int i2) {
BitmapPool d = Glide.b(context).d();
Drawable drawable = resource.get();
Resource<Bitmap> a = DrawableToBitmapConverter.a(d, drawable, i, i2);
if (a != null) {
Resource<Bitmap> a2 = this.b.a(context, a, i, i2);
if (!a2.equals(a)) {
return a(context, a2);
}
a2.a();
return resource;
}
if (!this.c) {
return resource;
}
throw new IllegalArgumentException("Unable to convert " + drawable + " to a Bitmap");
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
if (obj instanceof DrawableTransformation) {
return this.b.equals(((DrawableTransformation) obj).b);
}
return false;
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
return this.b.hashCode();
}
private Resource<Drawable> a(Context context, Resource<Bitmap> resource) {
return LazyBitmapDrawableResource.a(context.getResources(), resource);
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
this.b.a(messageDigest);
}
}

View File

@@ -0,0 +1,31 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public class FitCenter extends BitmapTransformation {
private static final byte[] b = "com.bumptech.glide.load.resource.bitmap.FitCenter".getBytes(Key.a);
@Override // com.bumptech.glide.load.resource.bitmap.BitmapTransformation
protected Bitmap a(BitmapPool bitmapPool, Bitmap bitmap, int i, int i2) {
return TransformationUtils.d(bitmapPool, bitmap, i, i2);
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
return obj instanceof FitCenter;
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
return "com.bumptech.glide.load.resource.bitmap.FitCenter".hashCode();
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
messageDigest.update(b);
}
}

View File

@@ -0,0 +1,59 @@
package com.bumptech.glide.load.resource.bitmap;
import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.util.Log;
import com.baidu.cloud.media.player.IMediaPlayer;
import com.bumptech.glide.load.DecodeFormat;
import java.io.File;
/* loaded from: classes.dex */
final class HardwareConfigState {
private static final File c = new File("/proc/self/fd");
private static volatile HardwareConfigState d;
private volatile int a;
private volatile boolean b = true;
private HardwareConfigState() {
}
static HardwareConfigState a() {
if (d == null) {
synchronized (HardwareConfigState.class) {
if (d == null) {
d = new HardwareConfigState();
}
}
}
return d;
}
private synchronized boolean b() {
int i = this.a + 1;
this.a = i;
if (i >= 50) {
this.a = 0;
int length = c.list().length;
this.b = length < 700;
if (!this.b && Log.isLoggable("Downsampler", 5)) {
Log.w("Downsampler", "Excluding HARDWARE bitmap config because we're over the file descriptor limit, file descriptors " + length + ", limit " + IMediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING);
}
}
return this.b;
}
@TargetApi(26)
boolean a(int i, int i2, BitmapFactory.Options options, DecodeFormat decodeFormat, boolean z, boolean z2) {
if (!z || Build.VERSION.SDK_INT < 26 || decodeFormat == DecodeFormat.PREFER_ARGB_8888_DISALLOW_HARDWARE || z2) {
return false;
}
boolean z3 = i >= 128 && i2 >= 128 && b();
if (z3) {
options.inPreferredConfig = Bitmap.Config.HARDWARE;
options.inMutable = false;
}
return z3;
}
}

View File

@@ -0,0 +1,57 @@
package com.bumptech.glide.load.resource.bitmap;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import com.bumptech.glide.load.engine.Initializable;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.util.Preconditions;
/* loaded from: classes.dex */
public final class LazyBitmapDrawableResource implements Resource<BitmapDrawable>, Initializable {
private final Resources a;
private final Resource<Bitmap> b;
private LazyBitmapDrawableResource(Resources resources, Resource<Bitmap> resource) {
Preconditions.a(resources);
this.a = resources;
Preconditions.a(resource);
this.b = resource;
}
public static Resource<BitmapDrawable> a(Resources resources, Resource<Bitmap> resource) {
if (resource == null) {
return null;
}
return new LazyBitmapDrawableResource(resources, resource);
}
@Override // com.bumptech.glide.load.engine.Resource
public Class<BitmapDrawable> b() {
return BitmapDrawable.class;
}
@Override // com.bumptech.glide.load.engine.Initializable
public void c() {
Resource<Bitmap> resource = this.b;
if (resource instanceof Initializable) {
((Initializable) resource).c();
}
}
@Override // com.bumptech.glide.load.engine.Resource
public int getSize() {
return this.b.getSize();
}
@Override // com.bumptech.glide.load.engine.Resource
public void a() {
this.b.a();
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.engine.Resource
public BitmapDrawable get() {
return new BitmapDrawable(this.a, this.b.get());
}
}

View File

@@ -0,0 +1,256 @@
package com.bumptech.glide.load.resource.bitmap;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public class RecyclableBufferedInputStream extends FilterInputStream {
private volatile byte[] a;
private int b;
private int c;
private int d;
private int e;
private final ArrayPool f;
static class InvalidMarkException extends IOException {
InvalidMarkException(String str) {
super(str);
}
}
public RecyclableBufferedInputStream(InputStream inputStream, ArrayPool arrayPool) {
this(inputStream, arrayPool, 65536);
}
private static IOException c() throws IOException {
throw new IOException("BufferedInputStream is closed");
}
public synchronized void a() {
this.c = this.a.length;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized int available() throws IOException {
InputStream inputStream;
inputStream = ((FilterInputStream) this).in;
if (this.a == null || inputStream == null) {
c();
throw null;
}
return (this.b - this.e) + inputStream.available();
}
public synchronized void b() {
if (this.a != null) {
this.f.put(this.a);
this.a = null;
}
}
@Override // java.io.FilterInputStream, java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
if (this.a != null) {
this.f.put(this.a);
this.a = null;
}
InputStream inputStream = ((FilterInputStream) this).in;
((FilterInputStream) this).in = null;
if (inputStream != null) {
inputStream.close();
}
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized void mark(int i) {
this.c = Math.max(this.c, i);
this.d = this.e;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public boolean markSupported() {
return true;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized int read() throws IOException {
byte[] bArr = this.a;
InputStream inputStream = ((FilterInputStream) this).in;
if (bArr == null || inputStream == null) {
c();
throw null;
}
if (this.e >= this.b && a(inputStream, bArr) == -1) {
return -1;
}
if (bArr != this.a && (bArr = this.a) == null) {
c();
throw null;
}
if (this.b - this.e <= 0) {
return -1;
}
int i = this.e;
this.e = i + 1;
return bArr[i] & 255;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized void reset() throws IOException {
if (this.a == null) {
throw new IOException("Stream is closed");
}
if (-1 == this.d) {
throw new InvalidMarkException("Mark has been invalidated, pos: " + this.e + " markLimit: " + this.c);
}
this.e = this.d;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized long skip(long j) throws IOException {
if (j < 1) {
return 0L;
}
byte[] bArr = this.a;
if (bArr == null) {
c();
throw null;
}
InputStream inputStream = ((FilterInputStream) this).in;
if (inputStream == null) {
c();
throw null;
}
if (this.b - this.e >= j) {
this.e = (int) (this.e + j);
return j;
}
long j2 = this.b - this.e;
this.e = this.b;
if (this.d == -1 || j > this.c) {
return j2 + inputStream.skip(j - j2);
}
if (a(inputStream, bArr) == -1) {
return j2;
}
if (this.b - this.e >= j - j2) {
this.e = (int) ((this.e + j) - j2);
return j;
}
long j3 = (j2 + this.b) - this.e;
this.e = this.b;
return j3;
}
RecyclableBufferedInputStream(InputStream inputStream, ArrayPool arrayPool, int i) {
super(inputStream);
this.d = -1;
this.f = arrayPool;
this.a = (byte[]) arrayPool.b(i, byte[].class);
}
private int a(InputStream inputStream, byte[] bArr) throws IOException {
int i = this.d;
if (i != -1) {
int i2 = this.e - i;
int i3 = this.c;
if (i2 < i3) {
if (i == 0 && i3 > bArr.length && this.b == bArr.length) {
int length = bArr.length * 2;
if (length > i3) {
length = i3;
}
byte[] bArr2 = (byte[]) this.f.b(length, byte[].class);
System.arraycopy(bArr, 0, bArr2, 0, bArr.length);
this.a = bArr2;
this.f.put(bArr);
bArr = bArr2;
} else {
int i4 = this.d;
if (i4 > 0) {
System.arraycopy(bArr, i4, bArr, 0, bArr.length - i4);
}
}
this.e -= this.d;
this.d = 0;
this.b = 0;
int i5 = this.e;
int read = inputStream.read(bArr, i5, bArr.length - i5);
int i6 = this.e;
if (read > 0) {
i6 += read;
}
this.b = i6;
return read;
}
}
int read2 = inputStream.read(bArr);
if (read2 > 0) {
this.d = -1;
this.e = 0;
this.b = read2;
}
return read2;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized int read(byte[] bArr, int i, int i2) throws IOException {
int i3;
int i4;
byte[] bArr2 = this.a;
if (bArr2 == null) {
c();
throw null;
}
if (i2 == 0) {
return 0;
}
InputStream inputStream = ((FilterInputStream) this).in;
if (inputStream != null) {
if (this.e < this.b) {
int i5 = this.b - this.e >= i2 ? i2 : this.b - this.e;
System.arraycopy(bArr2, this.e, bArr, i, i5);
this.e += i5;
if (i5 == i2 || inputStream.available() == 0) {
return i5;
}
i += i5;
i3 = i2 - i5;
} else {
i3 = i2;
}
while (true) {
if (this.d == -1 && i3 >= bArr2.length) {
i4 = inputStream.read(bArr, i, i3);
if (i4 == -1) {
return i3 != i2 ? i2 - i3 : -1;
}
} else {
if (a(inputStream, bArr2) == -1) {
return i3 != i2 ? i2 - i3 : -1;
}
if (bArr2 != this.a && (bArr2 = this.a) == null) {
c();
throw null;
}
i4 = this.b - this.e >= i3 ? i3 : this.b - this.e;
System.arraycopy(bArr2, this.e, bArr, i, i4);
this.e += i4;
}
i3 -= i4;
if (i3 == 0) {
return i2;
}
if (inputStream.available() == 0) {
return i2 - i3;
}
i += i4;
}
} else {
c();
throw null;
}
}
}

View File

@@ -0,0 +1,35 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.drawable.ResourceDrawableDecoder;
/* loaded from: classes.dex */
public class ResourceBitmapDecoder implements ResourceDecoder<Uri, Bitmap> {
private final ResourceDrawableDecoder a;
private final BitmapPool b;
public ResourceBitmapDecoder(ResourceDrawableDecoder resourceDrawableDecoder, BitmapPool bitmapPool) {
this.a = resourceDrawableDecoder;
this.b = bitmapPool;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(Uri uri, Options options) {
return "android.resource".equals(uri.getScheme());
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<Bitmap> a(Uri uri, int i, int i2, Options options) {
Resource<Drawable> a = this.a.a(uri, i, i2, options);
if (a == null) {
return null;
}
return DrawableToBitmapConverter.a(this.b, a.get(), i, i2);
}
}

View File

@@ -0,0 +1,41 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.util.Preconditions;
import com.bumptech.glide.util.Util;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public final class RoundedCorners extends BitmapTransformation {
private static final byte[] c = "com.bumptech.glide.load.resource.bitmap.RoundedCorners".getBytes(Key.a);
private final int b;
public RoundedCorners(int i) {
Preconditions.a(i > 0, "roundingRadius must be greater than 0.");
this.b = i;
}
@Override // com.bumptech.glide.load.resource.bitmap.BitmapTransformation
protected Bitmap a(BitmapPool bitmapPool, Bitmap bitmap, int i, int i2) {
return TransformationUtils.b(bitmapPool, bitmap, this.b);
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
return (obj instanceof RoundedCorners) && this.b == ((RoundedCorners) obj).b;
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
return Util.a("com.bumptech.glide.load.resource.bitmap.RoundedCorners".hashCode(), Util.b(this.b));
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
messageDigest.update(c);
messageDigest.update(ByteBuffer.allocate(4).putInt(this.b).array());
}
}

View File

@@ -0,0 +1,78 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.Downsampler;
import com.bumptech.glide.util.ExceptionCatchingInputStream;
import com.bumptech.glide.util.MarkEnforcingInputStream;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public class StreamBitmapDecoder implements ResourceDecoder<InputStream, Bitmap> {
private final Downsampler a;
private final ArrayPool b;
static class UntrustedCallbacks implements Downsampler.DecodeCallbacks {
private final RecyclableBufferedInputStream a;
private final ExceptionCatchingInputStream b;
UntrustedCallbacks(RecyclableBufferedInputStream recyclableBufferedInputStream, ExceptionCatchingInputStream exceptionCatchingInputStream) {
this.a = recyclableBufferedInputStream;
this.b = exceptionCatchingInputStream;
}
@Override // com.bumptech.glide.load.resource.bitmap.Downsampler.DecodeCallbacks
public void a() {
this.a.a();
}
@Override // com.bumptech.glide.load.resource.bitmap.Downsampler.DecodeCallbacks
public void a(BitmapPool bitmapPool, Bitmap bitmap) throws IOException {
IOException a = this.b.a();
if (a != null) {
if (bitmap == null) {
throw a;
}
bitmapPool.a(bitmap);
throw a;
}
}
}
public StreamBitmapDecoder(Downsampler downsampler, ArrayPool arrayPool) {
this.a = downsampler;
this.b = arrayPool;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(InputStream inputStream, Options options) {
return this.a.a(inputStream);
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<Bitmap> a(InputStream inputStream, int i, int i2, Options options) throws IOException {
RecyclableBufferedInputStream recyclableBufferedInputStream;
boolean z;
if (inputStream instanceof RecyclableBufferedInputStream) {
recyclableBufferedInputStream = (RecyclableBufferedInputStream) inputStream;
z = false;
} else {
recyclableBufferedInputStream = new RecyclableBufferedInputStream(inputStream, this.b);
z = true;
}
ExceptionCatchingInputStream b = ExceptionCatchingInputStream.b(recyclableBufferedInputStream);
try {
return this.a.a(new MarkEnforcingInputStream(b), i, i2, options, new UntrustedCallbacks(recyclableBufferedInputStream, b));
} finally {
b.b();
if (z) {
recyclableBufferedInputStream.b();
}
}
}
}

View File

@@ -0,0 +1,320 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.os.Build;
import android.util.Log;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.util.Preconditions;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/* loaded from: classes.dex */
public final class TransformationUtils {
private static final Paint c;
private static final Lock e;
private static final Paint a = new Paint(6);
private static final Paint b = new Paint(7);
private static final Set<String> d = new HashSet(Arrays.asList("XT1085", "XT1092", "XT1093", "XT1094", "XT1095", "XT1096", "XT1097", "XT1098", "XT1031", "XT1028", "XT937C", "XT1032", "XT1008", "XT1033", "XT1035", "XT1034", "XT939G", "XT1039", "XT1040", "XT1042", "XT1045", "XT1063", "XT1064", "XT1068", "XT1069", "XT1072", "XT1077", "XT1078", "XT1079"));
private static final class NoLock implements Lock {
NoLock() {
}
@Override // java.util.concurrent.locks.Lock
public void lock() {
}
@Override // java.util.concurrent.locks.Lock
public void lockInterruptibly() throws InterruptedException {
}
@Override // java.util.concurrent.locks.Lock
public Condition newCondition() {
throw new UnsupportedOperationException("Should not be called");
}
@Override // java.util.concurrent.locks.Lock
public boolean tryLock() {
return true;
}
@Override // java.util.concurrent.locks.Lock
public boolean tryLock(long j, TimeUnit timeUnit) throws InterruptedException {
return true;
}
@Override // java.util.concurrent.locks.Lock
public void unlock() {
}
}
static {
e = d.contains(Build.MODEL) ? new ReentrantLock() : new NoLock();
c = new Paint(7);
c.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
}
public static int a(int i) {
switch (i) {
case 3:
case 4:
return 180;
case 5:
case 6:
return 90;
case 7:
case 8:
return 270;
default:
return 0;
}
}
public static Lock a() {
return e;
}
public static Bitmap b(BitmapPool bitmapPool, Bitmap bitmap, int i, int i2) {
if (bitmap.getWidth() > i || bitmap.getHeight() > i2) {
if (Log.isLoggable("TransformationUtils", 2)) {
Log.v("TransformationUtils", "requested target size too big for input, fit centering instead");
}
return d(bitmapPool, bitmap, i, i2);
}
if (Log.isLoggable("TransformationUtils", 2)) {
Log.v("TransformationUtils", "requested target size larger or equal to input, returning input");
}
return bitmap;
}
public static boolean b(int i) {
switch (i) {
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
return true;
default:
return false;
}
}
public static Bitmap c(BitmapPool bitmapPool, Bitmap bitmap, int i, int i2) {
int min = Math.min(i, i2);
float f = min;
float f2 = f / 2.0f;
float width = bitmap.getWidth();
float height = bitmap.getHeight();
float max = Math.max(f / width, f / height);
float f3 = width * max;
float f4 = max * height;
float f5 = (f - f3) / 2.0f;
float f6 = (f - f4) / 2.0f;
RectF rectF = new RectF(f5, f6, f3 + f5, f4 + f6);
Bitmap a2 = a(bitmapPool, bitmap);
Bitmap a3 = bitmapPool.a(min, min, a(bitmap));
a3.setHasAlpha(true);
e.lock();
try {
Canvas canvas = new Canvas(a3);
canvas.drawCircle(f2, f2, f2, b);
canvas.drawBitmap(a2, (Rect) null, rectF, c);
a(canvas);
e.unlock();
if (!a2.equals(bitmap)) {
bitmapPool.a(a2);
}
return a3;
} catch (Throwable th) {
e.unlock();
throw th;
}
}
public static Bitmap d(BitmapPool bitmapPool, Bitmap bitmap, int i, int i2) {
if (bitmap.getWidth() == i && bitmap.getHeight() == i2) {
if (Log.isLoggable("TransformationUtils", 2)) {
Log.v("TransformationUtils", "requested target size matches input, returning input");
}
return bitmap;
}
float min = Math.min(i / bitmap.getWidth(), i2 / bitmap.getHeight());
int round = Math.round(bitmap.getWidth() * min);
int round2 = Math.round(bitmap.getHeight() * min);
if (bitmap.getWidth() == round && bitmap.getHeight() == round2) {
if (Log.isLoggable("TransformationUtils", 2)) {
Log.v("TransformationUtils", "adjusted target size matches input, returning input");
}
return bitmap;
}
Bitmap a2 = bitmapPool.a((int) (bitmap.getWidth() * min), (int) (bitmap.getHeight() * min), b(bitmap));
a(bitmap, a2);
if (Log.isLoggable("TransformationUtils", 2)) {
Log.v("TransformationUtils", "request: " + i + "x" + i2);
Log.v("TransformationUtils", "toFit: " + bitmap.getWidth() + "x" + bitmap.getHeight());
Log.v("TransformationUtils", "toReuse: " + a2.getWidth() + "x" + a2.getHeight());
StringBuilder sb = new StringBuilder();
sb.append("minPct: ");
sb.append(min);
Log.v("TransformationUtils", sb.toString());
}
Matrix matrix = new Matrix();
matrix.setScale(min, min);
a(bitmap, a2, matrix);
return a2;
}
public static Bitmap a(BitmapPool bitmapPool, Bitmap bitmap, int i, int i2) {
float width;
float f;
if (bitmap.getWidth() == i && bitmap.getHeight() == i2) {
return bitmap;
}
Matrix matrix = new Matrix();
float f2 = 0.0f;
if (bitmap.getWidth() * i2 > bitmap.getHeight() * i) {
width = i2 / bitmap.getHeight();
f = (i - (bitmap.getWidth() * width)) * 0.5f;
} else {
width = i / bitmap.getWidth();
f2 = (i2 - (bitmap.getHeight() * width)) * 0.5f;
f = 0.0f;
}
matrix.setScale(width, width);
matrix.postTranslate((int) (f + 0.5f), (int) (f2 + 0.5f));
Bitmap a2 = bitmapPool.a(i, i2, b(bitmap));
a(bitmap, a2);
a(bitmap, a2, matrix);
return a2;
}
public static Bitmap b(BitmapPool bitmapPool, Bitmap bitmap, int i) {
Preconditions.a(i > 0, "roundingRadius must be greater than 0.");
Bitmap.Config a2 = a(bitmap);
Bitmap a3 = a(bitmapPool, bitmap);
Bitmap a4 = bitmapPool.a(a3.getWidth(), a3.getHeight(), a2);
a4.setHasAlpha(true);
Shader.TileMode tileMode = Shader.TileMode.CLAMP;
BitmapShader bitmapShader = new BitmapShader(a3, tileMode, tileMode);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(bitmapShader);
RectF rectF = new RectF(0.0f, 0.0f, a4.getWidth(), a4.getHeight());
e.lock();
try {
Canvas canvas = new Canvas(a4);
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
float f = i;
canvas.drawRoundRect(rectF, f, f, paint);
a(canvas);
e.unlock();
if (!a3.equals(bitmap)) {
bitmapPool.a(a3);
}
return a4;
} catch (Throwable th) {
e.unlock();
throw th;
}
}
public static void a(Bitmap bitmap, Bitmap bitmap2) {
bitmap2.setHasAlpha(bitmap.hasAlpha());
}
public static Bitmap a(BitmapPool bitmapPool, Bitmap bitmap, int i) {
if (!b(i)) {
return bitmap;
}
Matrix matrix = new Matrix();
a(i, matrix);
RectF rectF = new RectF(0.0f, 0.0f, bitmap.getWidth(), bitmap.getHeight());
matrix.mapRect(rectF);
Bitmap a2 = bitmapPool.a(Math.round(rectF.width()), Math.round(rectF.height()), b(bitmap));
matrix.postTranslate(-rectF.left, -rectF.top);
a(bitmap, a2, matrix);
return a2;
}
private static Bitmap a(BitmapPool bitmapPool, Bitmap bitmap) {
Bitmap.Config a2 = a(bitmap);
if (a2.equals(bitmap.getConfig())) {
return bitmap;
}
Bitmap a3 = bitmapPool.a(bitmap.getWidth(), bitmap.getHeight(), a2);
new Canvas(a3).drawBitmap(bitmap, 0.0f, 0.0f, (Paint) null);
return a3;
}
private static Bitmap.Config b(Bitmap bitmap) {
return bitmap.getConfig() != null ? bitmap.getConfig() : Bitmap.Config.ARGB_8888;
}
private static Bitmap.Config a(Bitmap bitmap) {
if (Build.VERSION.SDK_INT >= 26 && Bitmap.Config.RGBA_F16.equals(bitmap.getConfig())) {
return Bitmap.Config.RGBA_F16;
}
return Bitmap.Config.ARGB_8888;
}
private static void a(Canvas canvas) {
canvas.setBitmap(null);
}
private static void a(Bitmap bitmap, Bitmap bitmap2, Matrix matrix) {
e.lock();
try {
Canvas canvas = new Canvas(bitmap2);
canvas.drawBitmap(bitmap, matrix, a);
a(canvas);
} finally {
e.unlock();
}
}
static void a(int i, Matrix matrix) {
switch (i) {
case 2:
matrix.setScale(-1.0f, 1.0f);
break;
case 3:
matrix.setRotate(180.0f);
break;
case 4:
matrix.setRotate(180.0f);
matrix.postScale(-1.0f, 1.0f);
break;
case 5:
matrix.setRotate(90.0f);
matrix.postScale(-1.0f, 1.0f);
break;
case 6:
matrix.setRotate(90.0f);
break;
case 7:
matrix.setRotate(-90.0f);
matrix.postScale(-1.0f, 1.0f);
break;
case 8:
matrix.setRotate(-90.0f);
break;
}
}
}

View File

@@ -0,0 +1,49 @@
package com.bumptech.glide.load.resource.bitmap;
import android.graphics.Bitmap;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.util.Util;
/* loaded from: classes.dex */
public final class UnitBitmapDecoder implements ResourceDecoder<Bitmap, Bitmap> {
private static final class NonOwnedBitmapResource implements Resource<Bitmap> {
private final Bitmap a;
NonOwnedBitmapResource(Bitmap bitmap) {
this.a = bitmap;
}
@Override // com.bumptech.glide.load.engine.Resource
public void a() {
}
@Override // com.bumptech.glide.load.engine.Resource
public Class<Bitmap> b() {
return Bitmap.class;
}
@Override // com.bumptech.glide.load.engine.Resource
public int getSize() {
return Util.a(this.a);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.engine.Resource
public Bitmap get() {
return this.a;
}
}
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(Bitmap bitmap, Options options) {
return true;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<Bitmap> a(Bitmap bitmap, int i, int i2, Options options) {
return new NonOwnedBitmapResource(bitmap);
}
}

View File

@@ -0,0 +1,169 @@
package com.bumptech.glide.load.resource.bitmap;
import android.annotation.TargetApi;
import android.content.res.AssetFileDescriptor;
import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import com.bumptech.glide.load.Option;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public class VideoDecoder<T> implements ResourceDecoder<T, Bitmap> {
public static final Option<Long> d = Option.a("com.bumptech.glide.load.resource.bitmap.VideoBitmapDecode.TargetFrame", -1L, new Option.CacheKeyUpdater<Long>() { // from class: com.bumptech.glide.load.resource.bitmap.VideoDecoder.1
private final ByteBuffer a = ByteBuffer.allocate(8);
@Override // com.bumptech.glide.load.Option.CacheKeyUpdater
public void a(byte[] bArr, Long l, MessageDigest messageDigest) {
messageDigest.update(bArr);
synchronized (this.a) {
this.a.position(0);
messageDigest.update(this.a.putLong(l.longValue()).array());
}
}
});
public static final Option<Integer> e = Option.a("com.bumptech.glide.load.resource.bitmap.VideoBitmapDecode.FrameOption", 2, new Option.CacheKeyUpdater<Integer>() { // from class: com.bumptech.glide.load.resource.bitmap.VideoDecoder.2
private final ByteBuffer a = ByteBuffer.allocate(4);
@Override // com.bumptech.glide.load.Option.CacheKeyUpdater
public void a(byte[] bArr, Integer num, MessageDigest messageDigest) {
if (num == null) {
return;
}
messageDigest.update(bArr);
synchronized (this.a) {
this.a.position(0);
messageDigest.update(this.a.putInt(num.intValue()).array());
}
}
});
private static final MediaMetadataRetrieverFactory f = new MediaMetadataRetrieverFactory();
private final MediaMetadataRetrieverInitializer<T> a;
private final BitmapPool b;
private final MediaMetadataRetrieverFactory c;
private static final class AssetFileDescriptorInitializer implements MediaMetadataRetrieverInitializer<AssetFileDescriptor> {
private AssetFileDescriptorInitializer() {
}
@Override // com.bumptech.glide.load.resource.bitmap.VideoDecoder.MediaMetadataRetrieverInitializer
public void a(MediaMetadataRetriever mediaMetadataRetriever, AssetFileDescriptor assetFileDescriptor) {
mediaMetadataRetriever.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength());
}
}
static class MediaMetadataRetrieverFactory {
MediaMetadataRetrieverFactory() {
}
public MediaMetadataRetriever a() {
return new MediaMetadataRetriever();
}
}
interface MediaMetadataRetrieverInitializer<T> {
void a(MediaMetadataRetriever mediaMetadataRetriever, T t);
}
static final class ParcelFileDescriptorInitializer implements MediaMetadataRetrieverInitializer<ParcelFileDescriptor> {
ParcelFileDescriptorInitializer() {
}
@Override // com.bumptech.glide.load.resource.bitmap.VideoDecoder.MediaMetadataRetrieverInitializer
public void a(MediaMetadataRetriever mediaMetadataRetriever, ParcelFileDescriptor parcelFileDescriptor) {
mediaMetadataRetriever.setDataSource(parcelFileDescriptor.getFileDescriptor());
}
}
VideoDecoder(BitmapPool bitmapPool, MediaMetadataRetrieverInitializer<T> mediaMetadataRetrieverInitializer) {
this(bitmapPool, mediaMetadataRetrieverInitializer, f);
}
public static ResourceDecoder<AssetFileDescriptor, Bitmap> a(BitmapPool bitmapPool) {
return new VideoDecoder(bitmapPool, new AssetFileDescriptorInitializer());
}
public static ResourceDecoder<ParcelFileDescriptor, Bitmap> b(BitmapPool bitmapPool) {
return new VideoDecoder(bitmapPool, new ParcelFileDescriptorInitializer());
}
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(T t, Options options) {
return true;
}
VideoDecoder(BitmapPool bitmapPool, MediaMetadataRetrieverInitializer<T> mediaMetadataRetrieverInitializer, MediaMetadataRetrieverFactory mediaMetadataRetrieverFactory) {
this.b = bitmapPool;
this.a = mediaMetadataRetrieverInitializer;
this.c = mediaMetadataRetrieverFactory;
}
@TargetApi(27)
private static Bitmap b(MediaMetadataRetriever mediaMetadataRetriever, long j, int i, int i2, int i3, DownsampleStrategy downsampleStrategy) {
try {
int parseInt = Integer.parseInt(mediaMetadataRetriever.extractMetadata(18));
int parseInt2 = Integer.parseInt(mediaMetadataRetriever.extractMetadata(19));
int parseInt3 = Integer.parseInt(mediaMetadataRetriever.extractMetadata(24));
if (parseInt3 == 90 || parseInt3 == 270) {
parseInt2 = parseInt;
parseInt = parseInt2;
}
float b = downsampleStrategy.b(parseInt, parseInt2, i2, i3);
return mediaMetadataRetriever.getScaledFrameAtTime(j, i, Math.round(parseInt * b), Math.round(b * parseInt2));
} catch (Throwable th) {
if (!Log.isLoggable("VideoDecoder", 3)) {
return null;
}
Log.d("VideoDecoder", "Exception trying to decode frame on oreo+", th);
return null;
}
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<Bitmap> a(T t, int i, int i2, Options options) throws IOException {
long longValue = ((Long) options.a(d)).longValue();
if (longValue < 0 && longValue != -1) {
throw new IllegalArgumentException("Requested frame must be non-negative, or DEFAULT_FRAME, given: " + longValue);
}
Integer num = (Integer) options.a(e);
if (num == null) {
num = 2;
}
DownsampleStrategy downsampleStrategy = (DownsampleStrategy) options.a(DownsampleStrategy.f);
if (downsampleStrategy == null) {
downsampleStrategy = DownsampleStrategy.e;
}
DownsampleStrategy downsampleStrategy2 = downsampleStrategy;
MediaMetadataRetriever a = this.c.a();
try {
try {
this.a.a(a, t);
Bitmap a2 = a(a, longValue, num.intValue(), i, i2, downsampleStrategy2);
a.release();
return BitmapResource.a(a2, this.b);
} catch (RuntimeException e2) {
throw new IOException(e2);
}
} catch (Throwable th) {
a.release();
throw th;
}
}
private static Bitmap a(MediaMetadataRetriever mediaMetadataRetriever, long j, int i, int i2, int i3, DownsampleStrategy downsampleStrategy) {
Bitmap b = (Build.VERSION.SDK_INT < 27 || i2 == Integer.MIN_VALUE || i3 == Integer.MIN_VALUE || downsampleStrategy == DownsampleStrategy.d) ? null : b(mediaMetadataRetriever, j, i, i2, i3, downsampleStrategy);
return b == null ? a(mediaMetadataRetriever, j, i) : b;
}
private static Bitmap a(MediaMetadataRetriever mediaMetadataRetriever, long j, int i) {
return mediaMetadataRetriever.getFrameAtTime(j, i);
}
}

View File

@@ -0,0 +1,35 @@
package com.bumptech.glide.load.resource.bytes;
import com.bumptech.glide.load.data.DataRewinder;
import java.nio.ByteBuffer;
/* loaded from: classes.dex */
public class ByteBufferRewinder implements DataRewinder<ByteBuffer> {
private final ByteBuffer a;
public static class Factory implements DataRewinder.Factory<ByteBuffer> {
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
public DataRewinder<ByteBuffer> a(ByteBuffer byteBuffer) {
return new ByteBufferRewinder(byteBuffer);
}
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
public Class<ByteBuffer> a() {
return ByteBuffer.class;
}
}
public ByteBufferRewinder(ByteBuffer byteBuffer) {
this.a = byteBuffer;
}
@Override // com.bumptech.glide.load.data.DataRewinder
public void b() {
}
@Override // com.bumptech.glide.load.data.DataRewinder
public ByteBuffer a() {
this.a.position(0);
return this.a;
}
}

View File

@@ -0,0 +1,33 @@
package com.bumptech.glide.load.resource.bytes;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.util.Preconditions;
/* loaded from: classes.dex */
public class BytesResource implements Resource<byte[]> {
private final byte[] a;
public BytesResource(byte[] bArr) {
Preconditions.a(bArr);
this.a = bArr;
}
@Override // com.bumptech.glide.load.engine.Resource
public void a() {
}
@Override // com.bumptech.glide.load.engine.Resource
public Class<byte[]> b() {
return byte[].class;
}
@Override // com.bumptech.glide.load.engine.Resource
public int getSize() {
return this.a.length;
}
@Override // com.bumptech.glide.load.engine.Resource
public byte[] get() {
return this.a;
}
}

View File

@@ -0,0 +1,53 @@
package com.bumptech.glide.load.resource.drawable;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
/* loaded from: classes.dex */
public final class DrawableDecoderCompat {
private static volatile boolean a = true;
public static Drawable a(Context context, Context context2, int i) {
return a(context, context2, i, null);
}
private static Drawable b(Context context, int i, Resources.Theme theme) {
return ResourcesCompat.a(context.getResources(), i, theme);
}
private static Drawable c(Context context, int i, Resources.Theme theme) {
if (theme != null) {
context = new ContextThemeWrapper(context, theme);
}
return AppCompatResources.c(context, i);
}
public static Drawable a(Context context, int i, Resources.Theme theme) {
return a(context, context, i, theme);
}
private static Drawable a(Context context, Context context2, int i, Resources.Theme theme) {
try {
if (a) {
return c(context2, i, theme);
}
} catch (Resources.NotFoundException unused) {
} catch (IllegalStateException e) {
if (!context.getPackageName().equals(context2.getPackageName())) {
return ContextCompat.c(context2, i);
}
throw e;
} catch (NoClassDefFoundError unused2) {
a = false;
}
if (theme == null) {
theme = context2.getTheme();
}
return b(context2, i, theme);
}
}

View File

@@ -0,0 +1,34 @@
package com.bumptech.glide.load.resource.drawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import com.bumptech.glide.load.engine.Initializable;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.util.Preconditions;
/* loaded from: classes.dex */
public abstract class DrawableResource<T extends Drawable> implements Resource<T>, Initializable {
protected final T a;
public DrawableResource(T t) {
Preconditions.a(t);
this.a = t;
}
@Override // com.bumptech.glide.load.engine.Initializable
public void c() {
T t = this.a;
if (t instanceof BitmapDrawable) {
((BitmapDrawable) t).getBitmap().prepareToDraw();
} else if (t instanceof GifDrawable) {
((GifDrawable) t).c().prepareToDraw();
}
}
@Override // com.bumptech.glide.load.engine.Resource
public final T get() {
Drawable.ConstantState constantState = this.a.getConstantState();
return constantState == null ? this.a : (T) constantState.newDrawable();
}
}

View File

@@ -0,0 +1,32 @@
package com.bumptech.glide.load.resource.drawable;
import android.graphics.drawable.Drawable;
import com.bumptech.glide.load.engine.Resource;
/* loaded from: classes.dex */
final class NonOwnedDrawableResource extends DrawableResource<Drawable> {
private NonOwnedDrawableResource(Drawable drawable) {
super(drawable);
}
static Resource<Drawable> a(Drawable drawable) {
if (drawable != null) {
return new NonOwnedDrawableResource(drawable);
}
return null;
}
@Override // com.bumptech.glide.load.engine.Resource
public void a() {
}
@Override // com.bumptech.glide.load.engine.Resource
public Class<Drawable> b() {
return this.a.getClass();
}
@Override // com.bumptech.glide.load.engine.Resource
public int getSize() {
return Math.max(1, this.a.getIntrinsicWidth() * this.a.getIntrinsicHeight() * 4);
}
}

View File

@@ -0,0 +1,63 @@
package com.bumptech.glide.load.resource.drawable;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import java.util.List;
/* loaded from: classes.dex */
public class ResourceDrawableDecoder implements ResourceDecoder<Uri, Drawable> {
private final Context a;
public ResourceDrawableDecoder(Context context) {
this.a = context.getApplicationContext();
}
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(Uri uri, Options options) {
return uri.getScheme().equals("android.resource");
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<Drawable> a(Uri uri, int i, int i2, Options options) {
int a = a(uri);
String authority = uri.getAuthority();
return NonOwnedDrawableResource.a(DrawableDecoderCompat.a(this.a, authority.equals(this.a.getPackageName()) ? this.a : a(uri, authority), a));
}
private Context a(Uri uri, String str) {
try {
return this.a.createPackageContext(str, 0);
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalArgumentException("Failed to obtain context or unrecognized Uri format for: " + uri, e);
}
}
private int a(Uri uri) {
Integer valueOf;
List<String> pathSegments = uri.getPathSegments();
if (pathSegments.size() == 2) {
String authority = uri.getAuthority();
valueOf = Integer.valueOf(this.a.getResources().getIdentifier(pathSegments.get(1), pathSegments.get(0), authority));
} else {
if (pathSegments.size() == 1) {
try {
valueOf = Integer.valueOf(pathSegments.get(0));
} catch (NumberFormatException unused) {
}
}
valueOf = null;
}
if (valueOf != null) {
if (valueOf.intValue() != 0) {
return valueOf.intValue();
}
throw new IllegalArgumentException("Failed to obtain resource id for: " + uri);
}
throw new IllegalArgumentException("Unrecognized Uri format: " + uri);
}
}

View File

@@ -0,0 +1,19 @@
package com.bumptech.glide.load.resource.drawable;
import android.graphics.drawable.Drawable;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
/* loaded from: classes.dex */
public class UnitDrawableDecoder implements ResourceDecoder<Drawable, Drawable> {
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(Drawable drawable, Options options) {
return true;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<Drawable> a(Drawable drawable, int i, int i2, Options options) {
return NonOwnedDrawableResource.a(drawable);
}
}

View File

@@ -0,0 +1,19 @@
package com.bumptech.glide.load.resource.file;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import java.io.File;
/* loaded from: classes.dex */
public class FileDecoder implements ResourceDecoder<File, File> {
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(File file, Options options) {
return true;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<File> a(File file, int i, int i2, Options options) {
return new FileResource(file);
}
}

View File

@@ -0,0 +1,11 @@
package com.bumptech.glide.load.resource.file;
import com.bumptech.glide.load.resource.SimpleResource;
import java.io.File;
/* loaded from: classes.dex */
public class FileResource extends SimpleResource<File> {
public FileResource(File file) {
super(file);
}
}

View File

@@ -0,0 +1,131 @@
package com.bumptech.glide.load.resource.gif;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import com.bumptech.glide.gifdecoder.GifDecoder;
import com.bumptech.glide.gifdecoder.GifHeader;
import com.bumptech.glide.gifdecoder.GifHeaderParser;
import com.bumptech.glide.gifdecoder.StandardGifDecoder;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.ImageHeaderParser;
import com.bumptech.glide.load.ImageHeaderParserUtils;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.UnitTransformation;
import com.bumptech.glide.util.LogTime;
import com.bumptech.glide.util.Util;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Queue;
/* loaded from: classes.dex */
public class ByteBufferGifDecoder implements ResourceDecoder<ByteBuffer, GifDrawable> {
private static final GifDecoderFactory f = new GifDecoderFactory();
private static final GifHeaderParserPool g = new GifHeaderParserPool();
private final Context a;
private final List<ImageHeaderParser> b;
private final GifHeaderParserPool c;
private final GifDecoderFactory d;
private final GifBitmapProvider e;
static class GifDecoderFactory {
GifDecoderFactory() {
}
GifDecoder a(GifDecoder.BitmapProvider bitmapProvider, GifHeader gifHeader, ByteBuffer byteBuffer, int i) {
return new StandardGifDecoder(bitmapProvider, gifHeader, byteBuffer, i);
}
}
public ByteBufferGifDecoder(Context context, List<ImageHeaderParser> list, BitmapPool bitmapPool, ArrayPool arrayPool) {
this(context, list, bitmapPool, arrayPool, g, f);
}
ByteBufferGifDecoder(Context context, List<ImageHeaderParser> list, BitmapPool bitmapPool, ArrayPool arrayPool, GifHeaderParserPool gifHeaderParserPool, GifDecoderFactory gifDecoderFactory) {
this.a = context.getApplicationContext();
this.b = list;
this.d = gifDecoderFactory;
this.e = new GifBitmapProvider(bitmapPool, arrayPool);
this.c = gifHeaderParserPool;
}
static class GifHeaderParserPool {
private final Queue<GifHeaderParser> a = Util.a(0);
GifHeaderParserPool() {
}
synchronized GifHeaderParser a(ByteBuffer byteBuffer) {
GifHeaderParser poll;
poll = this.a.poll();
if (poll == null) {
poll = new GifHeaderParser();
}
poll.a(byteBuffer);
return poll;
}
synchronized void a(GifHeaderParser gifHeaderParser) {
gifHeaderParser.a();
this.a.offer(gifHeaderParser);
}
}
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(ByteBuffer byteBuffer, Options options) throws IOException {
return !((Boolean) options.a(GifOptions.b)).booleanValue() && ImageHeaderParserUtils.a(this.b, byteBuffer) == ImageHeaderParser.ImageType.GIF;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public GifDrawableResource a(ByteBuffer byteBuffer, int i, int i2, Options options) {
GifHeaderParser a = this.c.a(byteBuffer);
try {
return a(byteBuffer, i, i2, a, options);
} finally {
this.c.a(a);
}
}
private GifDrawableResource a(ByteBuffer byteBuffer, int i, int i2, GifHeaderParser gifHeaderParser, Options options) {
long a = LogTime.a();
try {
GifHeader b = gifHeaderParser.b();
if (b.b() > 0 && b.c() == 0) {
Bitmap.Config config = options.a(GifOptions.a) == DecodeFormat.PREFER_RGB_565 ? Bitmap.Config.RGB_565 : Bitmap.Config.ARGB_8888;
GifDecoder a2 = this.d.a(this.e, b, byteBuffer, a(b, i, i2));
a2.a(config);
a2.b();
Bitmap a3 = a2.a();
if (a3 == null) {
return null;
}
GifDrawableResource gifDrawableResource = new GifDrawableResource(new GifDrawable(this.a, a2, UnitTransformation.a(), i, i2, a3));
if (Log.isLoggable("BufferGifDecoder", 2)) {
Log.v("BufferGifDecoder", "Decoded GIF from stream in " + LogTime.a(a));
}
return gifDrawableResource;
}
if (Log.isLoggable("BufferGifDecoder", 2)) {
Log.v("BufferGifDecoder", "Decoded GIF from stream in " + LogTime.a(a));
}
return null;
} finally {
if (Log.isLoggable("BufferGifDecoder", 2)) {
Log.v("BufferGifDecoder", "Decoded GIF from stream in " + LogTime.a(a));
}
}
}
private static int a(GifHeader gifHeader, int i, int i2) {
int min = Math.min(gifHeader.a() / i2, gifHeader.d() / i);
int max = Math.max(1, min == 0 ? 0 : Integer.highestOneBit(min));
if (Log.isLoggable("BufferGifDecoder", 2) && max > 1) {
Log.v("BufferGifDecoder", "Downsampling GIF, sampleSize: " + max + ", target dimens: [" + i + "x" + i2 + "], actual dimens: [" + gifHeader.d() + "x" + gifHeader.a() + "]");
}
return max;
}
}

View File

@@ -0,0 +1,60 @@
package com.bumptech.glide.load.resource.gif;
import android.graphics.Bitmap;
import com.bumptech.glide.gifdecoder.GifDecoder;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
/* loaded from: classes.dex */
public final class GifBitmapProvider implements GifDecoder.BitmapProvider {
private final BitmapPool a;
private final ArrayPool b;
public GifBitmapProvider(BitmapPool bitmapPool, ArrayPool arrayPool) {
this.a = bitmapPool;
this.b = arrayPool;
}
@Override // com.bumptech.glide.gifdecoder.GifDecoder.BitmapProvider
public Bitmap a(int i, int i2, Bitmap.Config config) {
return this.a.b(i, i2, config);
}
@Override // com.bumptech.glide.gifdecoder.GifDecoder.BitmapProvider
public byte[] b(int i) {
ArrayPool arrayPool = this.b;
return arrayPool == null ? new byte[i] : (byte[]) arrayPool.b(i, byte[].class);
}
@Override // com.bumptech.glide.gifdecoder.GifDecoder.BitmapProvider
public void a(Bitmap bitmap) {
this.a.a(bitmap);
}
@Override // com.bumptech.glide.gifdecoder.GifDecoder.BitmapProvider
public void a(byte[] bArr) {
ArrayPool arrayPool = this.b;
if (arrayPool == null) {
return;
}
arrayPool.put(bArr);
}
@Override // com.bumptech.glide.gifdecoder.GifDecoder.BitmapProvider
public int[] a(int i) {
ArrayPool arrayPool = this.b;
if (arrayPool == null) {
return new int[i];
}
return (int[]) arrayPool.b(i, int[].class);
}
@Override // com.bumptech.glide.gifdecoder.GifDecoder.BitmapProvider
public void a(int[] iArr) {
ArrayPool arrayPool = this.b;
if (arrayPool == null) {
return;
}
arrayPool.put(iArr);
}
}

View File

@@ -0,0 +1,239 @@
package com.bumptech.glide.load.resource.gif;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.view.Gravity;
import com.bumptech.glide.Glide;
import com.bumptech.glide.gifdecoder.GifDecoder;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.resource.gif.GifFrameLoader;
import com.bumptech.glide.util.Preconditions;
import java.nio.ByteBuffer;
/* loaded from: classes.dex */
public class GifDrawable extends Drawable implements GifFrameLoader.FrameCallback, Animatable {
private final GifState a;
private boolean b;
private boolean c;
private boolean d;
private boolean e;
private int f;
private int g;
private boolean h;
private Paint i;
private Rect j;
static final class GifState extends Drawable.ConstantState {
final GifFrameLoader a;
GifState(GifFrameLoader gifFrameLoader) {
this.a = gifFrameLoader;
}
@Override // android.graphics.drawable.Drawable.ConstantState
public int getChangingConfigurations() {
return 0;
}
@Override // android.graphics.drawable.Drawable.ConstantState
public Drawable newDrawable(Resources resources) {
return newDrawable();
}
@Override // android.graphics.drawable.Drawable.ConstantState
public Drawable newDrawable() {
return new GifDrawable(this);
}
}
public GifDrawable(Context context, GifDecoder gifDecoder, Transformation<Bitmap> transformation, int i, int i2, Bitmap bitmap) {
this(new GifState(new GifFrameLoader(Glide.b(context), gifDecoder, i, i2, transformation, bitmap)));
}
/* JADX WARN: Multi-variable type inference failed */
private Drawable.Callback h() {
Drawable.Callback callback = getCallback();
while (callback instanceof Drawable) {
callback = ((Drawable) callback).getCallback();
}
return callback;
}
private Rect i() {
if (this.j == null) {
this.j = new Rect();
}
return this.j;
}
private Paint j() {
if (this.i == null) {
this.i = new Paint(2);
}
return this.i;
}
private void k() {
this.f = 0;
}
private void l() {
Preconditions.a(!this.d, "You cannot start a recycled Drawable. Ensure thatyou clear any references to the Drawable when clearing the corresponding request.");
if (this.a.a.f() == 1) {
invalidateSelf();
} else {
if (this.b) {
return;
}
this.b = true;
this.a.a.a(this);
invalidateSelf();
}
}
private void m() {
this.b = false;
this.a.a.b(this);
}
public void a(Transformation<Bitmap> transformation, Bitmap bitmap) {
this.a.a.a(transformation, bitmap);
}
public ByteBuffer b() {
return this.a.a.b();
}
public Bitmap c() {
return this.a.a.e();
}
public int d() {
return this.a.a.f();
}
@Override // android.graphics.drawable.Drawable
public void draw(Canvas canvas) {
if (this.d) {
return;
}
if (this.h) {
Gravity.apply(119, getIntrinsicWidth(), getIntrinsicHeight(), getBounds(), i());
this.h = false;
}
canvas.drawBitmap(this.a.a.c(), (Rect) null, i(), j());
}
public int e() {
return this.a.a.d();
}
public int f() {
return this.a.a.h();
}
public void g() {
this.d = true;
this.a.a.a();
}
@Override // android.graphics.drawable.Drawable
public Drawable.ConstantState getConstantState() {
return this.a;
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicHeight() {
return this.a.a.g();
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicWidth() {
return this.a.a.i();
}
@Override // android.graphics.drawable.Drawable
public int getOpacity() {
return -2;
}
@Override // android.graphics.drawable.Animatable
public boolean isRunning() {
return this.b;
}
@Override // android.graphics.drawable.Drawable
protected void onBoundsChange(Rect rect) {
super.onBoundsChange(rect);
this.h = true;
}
@Override // android.graphics.drawable.Drawable
public void setAlpha(int i) {
j().setAlpha(i);
}
@Override // android.graphics.drawable.Drawable
public void setColorFilter(ColorFilter colorFilter) {
j().setColorFilter(colorFilter);
}
@Override // android.graphics.drawable.Drawable
public boolean setVisible(boolean z, boolean z2) {
Preconditions.a(!this.d, "Cannot change the visibility of a recycled resource. Ensure that you unset the Drawable from your View before changing the View's visibility.");
this.e = z;
if (!z) {
m();
} else if (this.c) {
l();
}
return super.setVisible(z, z2);
}
@Override // android.graphics.drawable.Animatable
public void start() {
this.c = true;
k();
if (this.e) {
l();
}
}
@Override // android.graphics.drawable.Animatable
public void stop() {
this.c = false;
m();
}
@Override // com.bumptech.glide.load.resource.gif.GifFrameLoader.FrameCallback
public void a() {
if (h() == null) {
stop();
invalidateSelf();
return;
}
invalidateSelf();
if (e() == d() - 1) {
this.f++;
}
int i = this.g;
if (i == -1 || this.f < i) {
return;
}
stop();
}
GifDrawable(GifState gifState) {
this.e = true;
this.g = -1;
Preconditions.a(gifState);
this.a = gifState;
}
}

View File

@@ -0,0 +1,31 @@
package com.bumptech.glide.load.resource.gif;
import android.util.Log;
import com.bumptech.glide.load.EncodeStrategy;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceEncoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.util.ByteBufferUtil;
import java.io.File;
import java.io.IOException;
/* loaded from: classes.dex */
public class GifDrawableEncoder implements ResourceEncoder<GifDrawable> {
@Override // com.bumptech.glide.load.ResourceEncoder
public EncodeStrategy a(Options options) {
return EncodeStrategy.SOURCE;
}
@Override // com.bumptech.glide.load.Encoder
public boolean a(Resource<GifDrawable> resource, File file, Options options) {
try {
ByteBufferUtil.a(resource.get().b(), file);
return true;
} catch (IOException e) {
if (Log.isLoggable("GifEncoder", 5)) {
Log.w("GifEncoder", "Failed to encode GIF drawable data", e);
}
return false;
}
}
}

View File

@@ -0,0 +1,32 @@
package com.bumptech.glide.load.resource.gif;
import com.bumptech.glide.load.engine.Initializable;
import com.bumptech.glide.load.resource.drawable.DrawableResource;
/* loaded from: classes.dex */
public class GifDrawableResource extends DrawableResource<GifDrawable> implements Initializable {
public GifDrawableResource(GifDrawable gifDrawable) {
super(gifDrawable);
}
@Override // com.bumptech.glide.load.engine.Resource
public void a() {
((GifDrawable) this.a).stop();
((GifDrawable) this.a).g();
}
@Override // com.bumptech.glide.load.engine.Resource
public Class<GifDrawable> b() {
return GifDrawable.class;
}
@Override // com.bumptech.glide.load.resource.drawable.DrawableResource, com.bumptech.glide.load.engine.Initializable
public void c() {
((GifDrawable) this.a).c().prepareToDraw();
}
@Override // com.bumptech.glide.load.engine.Resource
public int getSize() {
return ((GifDrawable) this.a).f();
}
}

View File

@@ -0,0 +1,50 @@
package com.bumptech.glide.load.resource.gif;
import android.content.Context;
import android.graphics.Bitmap;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import com.bumptech.glide.util.Preconditions;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public class GifDrawableTransformation implements Transformation<GifDrawable> {
private final Transformation<Bitmap> b;
public GifDrawableTransformation(Transformation<Bitmap> transformation) {
Preconditions.a(transformation);
this.b = transformation;
}
@Override // com.bumptech.glide.load.Transformation
public Resource<GifDrawable> a(Context context, Resource<GifDrawable> resource, int i, int i2) {
GifDrawable gifDrawable = resource.get();
Resource<Bitmap> bitmapResource = new BitmapResource(gifDrawable.c(), Glide.b(context).d());
Resource<Bitmap> a = this.b.a(context, bitmapResource, i, i2);
if (!bitmapResource.equals(a)) {
bitmapResource.a();
}
gifDrawable.a(this.b, a.get());
return resource;
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
if (obj instanceof GifDrawableTransformation) {
return this.b.equals(((GifDrawableTransformation) obj).b);
}
return false;
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
return this.b.hashCode();
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
this.b.a(messageDigest);
}
}

View File

@@ -0,0 +1,293 @@
package com.bumptech.glide.load.resource.gif;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.gifdecoder.GifDecoder;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.Transition;
import com.bumptech.glide.signature.ObjectKey;
import com.bumptech.glide.util.Preconditions;
import com.bumptech.glide.util.Util;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
class GifFrameLoader {
private final GifDecoder a;
private final Handler b;
private final List<FrameCallback> c;
final RequestManager d;
private final BitmapPool e;
private boolean f;
private boolean g;
private boolean h;
private RequestBuilder<Bitmap> i;
private DelayTarget j;
private boolean k;
private DelayTarget l;
private Bitmap m;
private DelayTarget n;
private OnEveryFrameListener o;
static class DelayTarget extends SimpleTarget<Bitmap> {
private final Handler d;
final int e;
private final long f;
private Bitmap g;
DelayTarget(Handler handler, int i, long j) {
this.d = handler;
this.e = i;
this.f = j;
}
@Override // com.bumptech.glide.request.target.Target
public /* bridge */ /* synthetic */ void a(Object obj, Transition transition) {
a((Bitmap) obj, (Transition<? super Bitmap>) transition);
}
Bitmap d() {
return this.g;
}
public void a(Bitmap bitmap, Transition<? super Bitmap> transition) {
this.g = bitmap;
this.d.sendMessageAtTime(this.d.obtainMessage(1, this), this.f);
}
}
public interface FrameCallback {
void a();
}
private class FrameLoaderCallback implements Handler.Callback {
FrameLoaderCallback() {
}
@Override // android.os.Handler.Callback
public boolean handleMessage(Message message) {
int i = message.what;
if (i == 1) {
GifFrameLoader.this.a((DelayTarget) message.obj);
return true;
}
if (i != 2) {
return false;
}
GifFrameLoader.this.d.a((Target<?>) message.obj);
return false;
}
}
interface OnEveryFrameListener {
void a();
}
GifFrameLoader(Glide glide, GifDecoder gifDecoder, int i, int i2, Transformation<Bitmap> transformation, Bitmap bitmap) {
this(glide.d(), Glide.e(glide.f()), gifDecoder, null, a(Glide.e(glide.f()), i, i2), transformation, bitmap);
}
private static Key j() {
return new ObjectKey(Double.valueOf(Math.random()));
}
private int k() {
return Util.a(c().getWidth(), c().getHeight(), c().getConfig());
}
private void l() {
if (!this.f || this.g) {
return;
}
if (this.h) {
Preconditions.a(this.n == null, "Pending target must be null when starting from the first frame");
this.a.f();
this.h = false;
}
DelayTarget delayTarget = this.n;
if (delayTarget != null) {
this.n = null;
a(delayTarget);
return;
}
this.g = true;
long uptimeMillis = SystemClock.uptimeMillis() + this.a.d();
this.a.b();
this.l = new DelayTarget(this.b, this.a.g(), uptimeMillis);
RequestBuilder<Bitmap> requestBuilder = this.i;
requestBuilder.a(RequestOptions.b(j()));
requestBuilder.a(this.a);
requestBuilder.a((RequestBuilder<Bitmap>) this.l);
}
private void m() {
Bitmap bitmap = this.m;
if (bitmap != null) {
this.e.a(bitmap);
this.m = null;
}
}
private void n() {
if (this.f) {
return;
}
this.f = true;
this.k = false;
l();
}
private void o() {
this.f = false;
}
void a(Transformation<Bitmap> transformation, Bitmap bitmap) {
Preconditions.a(transformation);
Preconditions.a(bitmap);
this.m = bitmap;
RequestBuilder<Bitmap> requestBuilder = this.i;
requestBuilder.a(new RequestOptions().a(transformation));
this.i = requestBuilder;
}
void b(FrameCallback frameCallback) {
this.c.remove(frameCallback);
if (this.c.isEmpty()) {
o();
}
}
Bitmap c() {
DelayTarget delayTarget = this.j;
return delayTarget != null ? delayTarget.d() : this.m;
}
int d() {
DelayTarget delayTarget = this.j;
if (delayTarget != null) {
return delayTarget.e;
}
return -1;
}
Bitmap e() {
return this.m;
}
int f() {
return this.a.c();
}
int g() {
return c().getHeight();
}
int h() {
return this.a.h() + k();
}
int i() {
return c().getWidth();
}
void a(FrameCallback frameCallback) {
if (!this.k) {
if (!this.c.contains(frameCallback)) {
boolean isEmpty = this.c.isEmpty();
this.c.add(frameCallback);
if (isEmpty) {
n();
return;
}
return;
}
throw new IllegalStateException("Cannot subscribe twice in a row");
}
throw new IllegalStateException("Cannot subscribe to a cleared frame loader");
}
ByteBuffer b() {
return this.a.e().asReadOnlyBuffer();
}
GifFrameLoader(BitmapPool bitmapPool, RequestManager requestManager, GifDecoder gifDecoder, Handler handler, RequestBuilder<Bitmap> requestBuilder, Transformation<Bitmap> transformation, Bitmap bitmap) {
this.c = new ArrayList();
this.d = requestManager;
handler = handler == null ? new Handler(Looper.getMainLooper(), new FrameLoaderCallback()) : handler;
this.e = bitmapPool;
this.b = handler;
this.i = requestBuilder;
this.a = gifDecoder;
a(transformation, bitmap);
}
void a() {
this.c.clear();
m();
o();
DelayTarget delayTarget = this.j;
if (delayTarget != null) {
this.d.a((Target<?>) delayTarget);
this.j = null;
}
DelayTarget delayTarget2 = this.l;
if (delayTarget2 != null) {
this.d.a((Target<?>) delayTarget2);
this.l = null;
}
DelayTarget delayTarget3 = this.n;
if (delayTarget3 != null) {
this.d.a((Target<?>) delayTarget3);
this.n = null;
}
this.a.clear();
this.k = true;
}
void a(DelayTarget delayTarget) {
OnEveryFrameListener onEveryFrameListener = this.o;
if (onEveryFrameListener != null) {
onEveryFrameListener.a();
}
this.g = false;
if (this.k) {
this.b.obtainMessage(2, delayTarget).sendToTarget();
return;
}
if (!this.f) {
this.n = delayTarget;
return;
}
if (delayTarget.d() != null) {
m();
DelayTarget delayTarget2 = this.j;
this.j = delayTarget;
for (int size = this.c.size() - 1; size >= 0; size--) {
this.c.get(size).a();
}
if (delayTarget2 != null) {
this.b.obtainMessage(2, delayTarget2).sendToTarget();
}
}
l();
}
private static RequestBuilder<Bitmap> a(RequestManager requestManager, int i, int i2) {
RequestBuilder<Bitmap> d = requestManager.d();
d.a(RequestOptions.b(DiskCacheStrategy.b).b(true).a(true).a(i, i2));
return d;
}
}

View File

@@ -0,0 +1,28 @@
package com.bumptech.glide.load.resource.gif;
import android.graphics.Bitmap;
import com.bumptech.glide.gifdecoder.GifDecoder;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
/* loaded from: classes.dex */
public final class GifFrameResourceDecoder implements ResourceDecoder<GifDecoder, Bitmap> {
private final BitmapPool a;
public GifFrameResourceDecoder(BitmapPool bitmapPool) {
this.a = bitmapPool;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(GifDecoder gifDecoder, Options options) {
return true;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<Bitmap> a(GifDecoder gifDecoder, int i, int i2, Options options) {
return BitmapResource.a(gifDecoder.a(), this.a);
}
}

View File

@@ -0,0 +1,10 @@
package com.bumptech.glide.load.resource.gif;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.Option;
/* loaded from: classes.dex */
public final class GifOptions {
public static final Option<DecodeFormat> a = Option.a("com.bumptech.glide.load.resource.gif.GifOptions.DecodeFormat", DecodeFormat.DEFAULT);
public static final Option<Boolean> b = Option.a("com.bumptech.glide.load.resource.gif.GifOptions.DisableAnimation", false);
}

View File

@@ -0,0 +1,63 @@
package com.bumptech.glide.load.resource.gif;
import android.util.Log;
import com.bumptech.glide.load.ImageHeaderParser;
import com.bumptech.glide.load.ImageHeaderParserUtils;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.List;
/* loaded from: classes.dex */
public class StreamGifDecoder implements ResourceDecoder<InputStream, GifDrawable> {
private final List<ImageHeaderParser> a;
private final ResourceDecoder<ByteBuffer, GifDrawable> b;
private final ArrayPool c;
public StreamGifDecoder(List<ImageHeaderParser> list, ResourceDecoder<ByteBuffer, GifDrawable> resourceDecoder, ArrayPool arrayPool) {
this.a = list;
this.b = resourceDecoder;
this.c = arrayPool;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(InputStream inputStream, Options options) throws IOException {
return !((Boolean) options.a(GifOptions.b)).booleanValue() && ImageHeaderParserUtils.b(this.a, inputStream, this.c) == ImageHeaderParser.ImageType.GIF;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<GifDrawable> a(InputStream inputStream, int i, int i2, Options options) throws IOException {
byte[] a = a(inputStream);
if (a == null) {
return null;
}
return this.b.a(ByteBuffer.wrap(a), i, i2, options);
}
private static byte[] a(InputStream inputStream) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(16384);
try {
byte[] bArr = new byte[16384];
while (true) {
int read = inputStream.read(bArr);
if (read != -1) {
byteArrayOutputStream.write(bArr, 0, read);
} else {
byteArrayOutputStream.flush();
return byteArrayOutputStream.toByteArray();
}
}
} catch (IOException e) {
if (!Log.isLoggable("StreamGifDecoder", 5)) {
return null;
}
Log.w("StreamGifDecoder", "Error reading data from stream", e);
return null;
}
}
}

View File

@@ -0,0 +1,30 @@
package com.bumptech.glide.load.resource.transcode;
import android.graphics.Bitmap;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.resource.bytes.BytesResource;
import java.io.ByteArrayOutputStream;
/* loaded from: classes.dex */
public class BitmapBytesTranscoder implements ResourceTranscoder<Bitmap, byte[]> {
private final Bitmap.CompressFormat a;
private final int b;
public BitmapBytesTranscoder() {
this(Bitmap.CompressFormat.JPEG, 100);
}
@Override // com.bumptech.glide.load.resource.transcode.ResourceTranscoder
public Resource<byte[]> a(Resource<Bitmap> resource, Options options) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
resource.get().compress(this.a, this.b, byteArrayOutputStream);
resource.a();
return new BytesResource(byteArrayOutputStream.toByteArray());
}
public BitmapBytesTranscoder(Bitmap.CompressFormat compressFormat, int i) {
this.a = compressFormat;
this.b = i;
}
}

View File

@@ -0,0 +1,24 @@
package com.bumptech.glide.load.resource.transcode;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.resource.bitmap.LazyBitmapDrawableResource;
import com.bumptech.glide.util.Preconditions;
/* loaded from: classes.dex */
public class BitmapDrawableTranscoder implements ResourceTranscoder<Bitmap, BitmapDrawable> {
private final Resources a;
public BitmapDrawableTranscoder(Resources resources) {
Preconditions.a(resources);
this.a = resources;
}
@Override // com.bumptech.glide.load.resource.transcode.ResourceTranscoder
public Resource<BitmapDrawable> a(Resource<Bitmap> resource, Options options) {
return LazyBitmapDrawableResource.a(this.a, resource);
}
}

View File

@@ -0,0 +1,42 @@
package com.bumptech.glide.load.resource.transcode;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import com.bumptech.glide.load.resource.gif.GifDrawable;
/* loaded from: classes.dex */
public final class DrawableBytesTranscoder implements ResourceTranscoder<Drawable, byte[]> {
private final BitmapPool a;
private final ResourceTranscoder<Bitmap, byte[]> b;
private final ResourceTranscoder<GifDrawable, byte[]> c;
public DrawableBytesTranscoder(BitmapPool bitmapPool, ResourceTranscoder<Bitmap, byte[]> resourceTranscoder, ResourceTranscoder<GifDrawable, byte[]> resourceTranscoder2) {
this.a = bitmapPool;
this.b = resourceTranscoder;
this.c = resourceTranscoder2;
}
/* JADX WARN: Multi-variable type inference failed */
private static Resource<GifDrawable> a(Resource<Drawable> resource) {
return resource;
}
@Override // com.bumptech.glide.load.resource.transcode.ResourceTranscoder
public Resource<byte[]> a(Resource<Drawable> resource, Options options) {
Drawable drawable = resource.get();
if (drawable instanceof BitmapDrawable) {
return this.b.a(BitmapResource.a(((BitmapDrawable) drawable).getBitmap(), this.a), options);
}
if (!(drawable instanceof GifDrawable)) {
return null;
}
ResourceTranscoder<GifDrawable, byte[]> resourceTranscoder = this.c;
a(resource);
return resourceTranscoder.a(resource, options);
}
}

View File

@@ -0,0 +1,15 @@
package com.bumptech.glide.load.resource.transcode;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.resource.bytes.BytesResource;
import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.util.ByteBufferUtil;
/* loaded from: classes.dex */
public class GifDrawableBytesTranscoder implements ResourceTranscoder<GifDrawable, byte[]> {
@Override // com.bumptech.glide.load.resource.transcode.ResourceTranscoder
public Resource<byte[]> a(Resource<GifDrawable> resource, Options options) {
return new BytesResource(ByteBufferUtil.b(resource.get().b()));
}
}

View File

@@ -0,0 +1,9 @@
package com.bumptech.glide.load.resource.transcode;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.engine.Resource;
/* loaded from: classes.dex */
public interface ResourceTranscoder<Z, R> {
Resource<R> a(Resource<Z> resource, Options options);
}

View File

@@ -0,0 +1,57 @@
package com.bumptech.glide.load.resource.transcode;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public class TranscoderRegistry {
private final List<Entry<?, ?>> a = new ArrayList();
private static final class Entry<Z, R> {
private final Class<Z> a;
private final Class<R> b;
final ResourceTranscoder<Z, R> c;
Entry(Class<Z> cls, Class<R> cls2, ResourceTranscoder<Z, R> resourceTranscoder) {
this.a = cls;
this.b = cls2;
this.c = resourceTranscoder;
}
public boolean a(Class<?> cls, Class<?> cls2) {
return this.a.isAssignableFrom(cls) && cls2.isAssignableFrom(this.b);
}
}
public synchronized <Z, R> void a(Class<Z> cls, Class<R> cls2, ResourceTranscoder<Z, R> resourceTranscoder) {
this.a.add(new Entry<>(cls, cls2, resourceTranscoder));
}
public synchronized <Z, R> List<Class<R>> b(Class<Z> cls, Class<R> cls2) {
ArrayList arrayList = new ArrayList();
if (cls2.isAssignableFrom(cls)) {
arrayList.add(cls2);
return arrayList;
}
Iterator<Entry<?, ?>> it = this.a.iterator();
while (it.hasNext()) {
if (it.next().a(cls, cls2)) {
arrayList.add(cls2);
}
}
return arrayList;
}
public synchronized <Z, R> ResourceTranscoder<Z, R> a(Class<Z> cls, Class<R> cls2) {
if (cls2.isAssignableFrom(cls)) {
return UnitTranscoder.a();
}
for (Entry<?, ?> entry : this.a) {
if (entry.a(cls, cls2)) {
return (ResourceTranscoder<Z, R>) entry.c;
}
}
throw new IllegalArgumentException("No transcoder registered to transcode from " + cls + " to " + cls2);
}
}

View File

@@ -0,0 +1,18 @@
package com.bumptech.glide.load.resource.transcode;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.engine.Resource;
/* loaded from: classes.dex */
public class UnitTranscoder<Z> implements ResourceTranscoder<Z, Z> {
private static final UnitTranscoder<?> a = new UnitTranscoder<>();
public static <Z> ResourceTranscoder<Z, Z> a() {
return a;
}
@Override // com.bumptech.glide.load.resource.transcode.ResourceTranscoder
public Resource<Z> a(Resource<Z> resource, Options options) {
return resource;
}
}