Skip to content

Commit ee92824

Browse files
sansidsjudd
authored andcommitted
Automated g4 rollback of changelist 135717157.
*** Reason for rollback *** This breaks fireball *** Original change description *** Roll forward of [] Allow to use dynamically loaded ImageHeaderParser. New: fixed the usage of Glide by other clients (which where initially not caught by presubmit. Automated g4 rollback of changelist 133014089. *** Reason for rollback *** Roll forward: fixed the usage of Glide by other clients (which where initially not caught by presubmit. *** Original change description *** Automated g4 rollback of changelist 133011749. *** Reason for rollback *** TAP has detected that 500... *** ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135730013
1 parent af4263f commit ee92824

File tree

18 files changed

+168
-429
lines changed

18 files changed

+168
-429
lines changed

library/src/main/java/com/bumptech/glide/Glide.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import com.bumptech.glide.load.resource.bitmap.BitmapDrawableEncoder;
4949
import com.bumptech.glide.load.resource.bitmap.BitmapEncoder;
5050
import com.bumptech.glide.load.resource.bitmap.ByteBufferBitmapDecoder;
51-
import com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser;
5251
import com.bumptech.glide.load.resource.bitmap.Downsampler;
5352
import com.bumptech.glide.load.resource.bitmap.StreamBitmapDecoder;
5453
import com.bumptech.glide.load.resource.bitmap.VideoBitmapDecoder;
@@ -189,15 +188,12 @@ public static void tearDown() {
189188

190189
final Resources resources = context.getResources();
191190

192-
registry = new Registry();
193-
registry.register(new DefaultImageHeaderParser());
194-
195-
Downsampler downsampler = new Downsampler(registry.getImageHeaderParsers(),
196-
resources.getDisplayMetrics(), bitmapPool, arrayPool);
191+
Downsampler downsampler =
192+
new Downsampler(resources.getDisplayMetrics(), bitmapPool, arrayPool);
197193
ByteBufferGifDecoder byteBufferGifDecoder =
198-
new ByteBufferGifDecoder(context, registry.getImageHeaderParsers(), bitmapPool, arrayPool);
199-
200-
registry.register(ByteBuffer.class, new ByteBufferEncoder())
194+
new ByteBufferGifDecoder(context, bitmapPool, arrayPool);
195+
registry = new Registry()
196+
.register(ByteBuffer.class, new ByteBufferEncoder())
201197
.register(InputStream.class, new StreamEncoder(arrayPool))
202198
/* Bitmaps */
203199
.append(ByteBuffer.class, Bitmap.class,
@@ -218,7 +214,7 @@ public static void tearDown() {
218214
.register(BitmapDrawable.class, new BitmapDrawableEncoder(bitmapPool, new BitmapEncoder()))
219215
/* GIFs */
220216
.prepend(InputStream.class, GifDrawable.class,
221-
new StreamGifDecoder(registry.getImageHeaderParsers(), byteBufferGifDecoder, arrayPool))
217+
new StreamGifDecoder(byteBufferGifDecoder, arrayPool))
222218
.prepend(ByteBuffer.class, GifDrawable.class, byteBufferGifDecoder)
223219
.register(GifDrawable.class, new GifDrawableEncoder())
224220
/* GIF Frames */

library/src/main/java/com/bumptech/glide/Registry.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.support.v4.util.Pools.Pool;
44
import com.bumptech.glide.load.Encoder;
5-
import com.bumptech.glide.load.ImageHeaderParser;
65
import com.bumptech.glide.load.ResourceDecoder;
76
import com.bumptech.glide.load.ResourceEncoder;
87
import com.bumptech.glide.load.data.DataRewinder;
@@ -16,7 +15,6 @@
1615
import com.bumptech.glide.load.resource.transcode.ResourceTranscoder;
1716
import com.bumptech.glide.load.resource.transcode.TranscoderRegistry;
1817
import com.bumptech.glide.provider.EncoderRegistry;
19-
import com.bumptech.glide.provider.ImageHeaderParserRegistry;
2018
import com.bumptech.glide.provider.LoadPathCache;
2119
import com.bumptech.glide.provider.ModelToResourceClassCache;
2220
import com.bumptech.glide.provider.ResourceDecoderRegistry;
@@ -36,7 +34,6 @@ public class Registry {
3634
private final ResourceEncoderRegistry resourceEncoderRegistry;
3735
private final DataRewinderRegistry dataRewinderRegistry;
3836
private final TranscoderRegistry transcoderRegistry;
39-
private final ImageHeaderParserRegistry imageHeaderParserRegistry;
4037

4138
private final ModelToResourceClassCache modelToResourceClassCache =
4239
new ModelToResourceClassCache();
@@ -50,7 +47,6 @@ public Registry() {
5047
this.resourceEncoderRegistry = new ResourceEncoderRegistry();
5148
this.dataRewinderRegistry = new DataRewinderRegistry();
5249
this.transcoderRegistry = new TranscoderRegistry();
53-
this.imageHeaderParserRegistry = new ImageHeaderParserRegistry();
5450
}
5551

5652
public <Data> Registry register(Class<Data> dataClass, Encoder<Data> encoder) {
@@ -87,11 +83,6 @@ public <TResource, Transcode> Registry register(Class<TResource> resourceClass,
8783
return this;
8884
}
8985

90-
public Registry register(ImageHeaderParser parser) {
91-
imageHeaderParserRegistry.add(parser);
92-
return this;
93-
}
94-
9586
/**
9687
* Use the given factory to build a {@link com.bumptech.glide.load.model.ModelLoader} for models
9788
* of the given class. Generally the best use of this method is to replace one of the default
@@ -229,14 +220,6 @@ public <X> DataRewinder<X> getRewinder(X data) {
229220
return result;
230221
}
231222

232-
public List<ImageHeaderParser> getImageHeaderParsers() {
233-
List<ImageHeaderParser> result = imageHeaderParserRegistry.getParsers();
234-
if (result.isEmpty()) {
235-
throw new NoImageHeaderParserException();
236-
}
237-
return result;
238-
}
239-
240223
/**
241224
* Thrown when no {@link com.bumptech.glide.load.model.ModelLoader} is registered for a given
242225
* model class.
@@ -277,13 +260,4 @@ public MissingComponentException(String message) {
277260
super(message);
278261
}
279262
}
280-
281-
/**
282-
* Thrown when no {@link ImageHeaderParser} is registered.
283-
*/
284-
public static final class NoImageHeaderParserException extends MissingComponentException {
285-
public NoImageHeaderParserException() {
286-
super("Failed to find image header parser.");
287-
}
288-
}
289263
}

library/src/main/java/com/bumptech/glide/load/ImageHeaderParser.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

library/src/main/java/com/bumptech/glide/load/ImageHeaderParserUtils.java

Lines changed: 0 additions & 90 deletions
This file was deleted.

library/src/main/java/com/bumptech/glide/load/data/mediastore/ThumbFetcher.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ public static ThumbFetcher buildVideoFetcher(Context context, Uri uri) {
3939

4040
private static ThumbFetcher build(Context context, Uri uri, ThumbnailQuery query) {
4141
ArrayPool byteArrayPool = Glide.get(context).getArrayPool();
42-
ThumbnailStreamOpener opener = new ThumbnailStreamOpener(
43-
Glide.get(context).getRegistry().getImageHeaderParsers(), query, byteArrayPool,
44-
context.getContentResolver());
45-
return new ThumbFetcher(uri, opener);
42+
return new ThumbFetcher(
43+
uri, new ThumbnailStreamOpener(query, byteArrayPool, context.getContentResolver()));
4644
}
4745

4846
// Visible for testing.

library/src/main/java/com/bumptech/glide/load/data/mediastore/ThumbnailStreamOpener.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,27 @@
55
import android.net.Uri;
66
import android.text.TextUtils;
77
import android.util.Log;
8-
import com.bumptech.glide.load.ImageHeaderParser;
9-
import com.bumptech.glide.load.ImageHeaderParserUtils;
108
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
9+
import com.bumptech.glide.load.resource.bitmap.ImageHeaderParser;
1110
import java.io.File;
1211
import java.io.FileNotFoundException;
1312
import java.io.IOException;
1413
import java.io.InputStream;
15-
import java.util.List;
1614

1715
class ThumbnailStreamOpener {
1816
private static final String TAG = "ThumbStreamOpener";
1917
private static final FileService DEFAULT_SERVICE = new FileService();
20-
2118
private final FileService service;
2219
private final ThumbnailQuery query;
2320
private final ArrayPool byteArrayPool;
2421
private final ContentResolver contentResolver;
25-
private final List<ImageHeaderParser> parsers;
2622

2723
public ThumbnailStreamOpener(
28-
List<ImageHeaderParser> parsers, ThumbnailQuery query, ArrayPool byteArrayPool,
29-
ContentResolver contentResolver) {
30-
this(parsers, DEFAULT_SERVICE, query, byteArrayPool, contentResolver);
24+
ThumbnailQuery query, ArrayPool byteArrayPool, ContentResolver contentResolver) {
25+
this(DEFAULT_SERVICE, query, byteArrayPool, contentResolver);
3126
}
3227

3328
public ThumbnailStreamOpener(
34-
List<ImageHeaderParser> parsers,
3529
FileService service,
3630
ThumbnailQuery query,
3731
ArrayPool byteArrayPool,
@@ -40,28 +34,28 @@ public ThumbnailStreamOpener(
4034
this.query = query;
4135
this.byteArrayPool = byteArrayPool;
4236
this.contentResolver = contentResolver;
43-
this.parsers = parsers;
4437
}
4538

4639
public int getOrientation(Uri uri) {
40+
int orientation = ImageHeaderParser.UNKNOWN_ORIENTATION;
4741
InputStream is = null;
4842
try {
4943
is = contentResolver.openInputStream(uri);
50-
return ImageHeaderParserUtils.getOrientation(parsers, is, byteArrayPool);
44+
orientation = new ImageHeaderParser(is, byteArrayPool).getOrientation();
5145
} catch (IOException e) {
5246
if (Log.isLoggable(TAG, Log.DEBUG)) {
53-
Log.d(TAG, "Failed to open uri: " + uri, e);
47+
Log.d(TAG, "Failed to open uri: " + uri, e);
5448
}
5549
} finally {
5650
if (is != null) {
57-
try {
58-
is.close();
59-
} catch (IOException e) {
60-
// Ignored.
61-
}
51+
try {
52+
is.close();
53+
} catch (IOException e) {
54+
// Ignored.
55+
}
6256
}
6357
}
64-
return ImageHeaderParser.UNKNOWN_ORIENTATION;
58+
return orientation;
6559
}
6660

6761
public InputStream open(Uri uri) throws FileNotFoundException {

0 commit comments

Comments
 (0)