diff options
author | Sam Judd <judds@google.com> | 2014-10-20 21:18:07 -0700 |
---|---|---|
committer | Sam Judd <judds@google.com> | 2014-10-21 08:29:28 -0700 |
commit | b4cc7fa5f667e4a56514823cf2ad85d7435b498a (patch) | |
tree | 4f9e275f848404c47be778e85d7dbe21861ffadc /third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java | |
parent | dc756490f3da974008078366b9e1dd5d34677729 (diff) | |
download | glide-b4cc7fa5f667e4a56514823cf2ad85d7435b498a.tar.gz |
Always decode gif frames in sequence.
Fixes #207.
Diffstat (limited to 'third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java')
-rw-r--r-- | third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java b/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java index 2ec8cb5b..df891af7 100644 --- a/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java +++ b/third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java @@ -120,7 +120,6 @@ public class GifDecoder { private int framePointer; private byte[] data; private GifHeader header; - private String id; private BitmapProvider bitmapProvider; private Bitmap previousImage; private boolean savePrevious; @@ -141,6 +140,11 @@ public class GifDecoder { * @param config The {@link android.graphics.Bitmap.Config} of the desired {@link android.graphics.Bitmap}. */ public Bitmap obtain(int width, int height, Bitmap.Config config); + + /** + * Releases the given Bitmap back to the pool. + */ + public void release(Bitmap bitmap); } public GifDecoder(BitmapProvider provider) { @@ -235,10 +239,6 @@ public class GifDecoder { return header.loopCount; } - public String getId() { - return id; - } - /** * Get the next frame in the animation sequence. * @@ -327,19 +327,17 @@ public class GifDecoder { } public void clear() { - id = null; header = null; data = null; mainPixels = null; mainScratch = null; + if (previousImage != null) { + bitmapProvider.release(previousImage); + } + previousImage = null; } public void setData(GifHeader header, byte[] data) { - setData(null, header, data); - } - - public void setData(String id, GifHeader header, byte[] data) { - this.id = id; this.header = header; this.data = data; this.status = STATUS_OK; @@ -496,8 +494,8 @@ public class GifDecoder { if (savePrevious && currentFrame.dispose == DISPOSAL_UNSPECIFIED || currentFrame.dispose == DISPOSAL_NONE) { if (previousImage == null) { previousImage = getNextBitmap(); - previousImage.setPixels(dest, 0, width, 0, 0, width, height); } + previousImage.setPixels(dest, 0, width, 0, 0, width, height); } // Set pixels for current image. |