Skip to content

Commit

Permalink
clear all pixels when dispose is 3 but previousImage is null (#2521)
Browse files Browse the repository at this point in the history
* clear all pixels when dispose is 3 but previousImage is null

* Separate conditions and explain why we need to drop the prev image

* release previousImage for re-use
  • Loading branch information
michaeimm authored and sjudd committed Oct 31, 2017
1 parent 85c2176 commit c3d0530
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,20 @@ private Bitmap setPixels(GifFrame currentFrame, GifFrame previousFrame) {
// Final location of blended pixels.
final int[] dest = mainScratch;

// clear all pixels when meet first frame
// clear all pixels when meet first frame and drop prev image from last loop
if (previousFrame == null) {
if (previousImage != null) {
bitmapProvider.release(previousImage);
}
previousImage = null;
Arrays.fill(dest, COLOR_TRANSPARENT_BLACK);
}

// clear all pixels when dispose is 3 but previousImage is null.
// When DISPOSAL_PREVIOUS and previousImage didn't be set, new frame should draw on
// a empty image
if (previousFrame != null && previousFrame.dispose == DISPOSAL_PREVIOUS
&& previousImage == null) {
Arrays.fill(dest, COLOR_TRANSPARENT_BLACK);
}

Expand Down

0 comments on commit c3d0530

Please sign in to comment.