package com.bumptech.glide.load.engine; import android.util.Log; import androidx.core.util.Pools$Pool; import com.bumptech.glide.load.Options; import com.bumptech.glide.load.ResourceDecoder; import com.bumptech.glide.load.data.DataRewinder; import com.bumptech.glide.load.resource.transcode.ResourceTranscoder; import com.bumptech.glide.util.Preconditions; import java.io.IOException; import java.util.ArrayList; import java.util.List; /* loaded from: classes.dex */ public class DecodePath { private final Class a; private final List> b; private final ResourceTranscoder c; private final Pools$Pool> d; private final String e; interface DecodeCallback { Resource a(Resource resource); } public DecodePath(Class cls, Class cls2, Class cls3, List> list, ResourceTranscoder resourceTranscoder, Pools$Pool> pools$Pool) { this.a = cls; this.b = list; this.c = resourceTranscoder; this.d = pools$Pool; this.e = "Failed DecodePath{" + cls.getSimpleName() + "->" + cls2.getSimpleName() + "->" + cls3.getSimpleName() + "}"; } public Resource a(DataRewinder dataRewinder, int i, int i2, Options options, DecodeCallback decodeCallback) throws GlideException { return this.c.a(decodeCallback.a(a(dataRewinder, i, i2, options)), options); } public String toString() { return "DecodePath{ dataClass=" + this.a + ", decoders=" + this.b + ", transcoder=" + this.c + '}'; } private Resource a(DataRewinder dataRewinder, int i, int i2, Options options) throws GlideException { List a = this.d.a(); Preconditions.a(a); List list = a; try { return a(dataRewinder, i, i2, options, list); } finally { this.d.a(list); } } private Resource a(DataRewinder dataRewinder, int i, int i2, Options options, List list) throws GlideException { int size = this.b.size(); Resource resource = null; for (int i3 = 0; i3 < size; i3++) { ResourceDecoder resourceDecoder = this.b.get(i3); try { if (resourceDecoder.a(dataRewinder.a(), options)) { resource = resourceDecoder.a(dataRewinder.a(), i, i2, options); } } catch (IOException | OutOfMemoryError | RuntimeException e) { if (Log.isLoggable("DecodePath", 2)) { Log.v("DecodePath", "Failed to decode data for " + resourceDecoder, e); } list.add(e); } if (resource != null) { break; } } if (resource != null) { return resource; } throw new GlideException(this.e, new ArrayList(list)); } }