aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/images
diff options
context:
space:
mode:
authorGravatar Takahiro.Aizawa <Takahiro.Aizawa@sonymobile.com>2015-06-15 02:52:46 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-15 02:52:46 -0700
commitb5b50a07abb454abaf6ab46db20c6db6f5ecf9f6 (patch)
tree39b221971fc0b5b1540d2c7fba9e6860fdada3b6 /src/images
parenteee0e4e9d343d8b6c5ae2da7f17196f00d8859bc (diff)
SkGIFMovie: Fix corrupted background color
The 'paintingColor' in onGetBitmap() was used to save the entire gif's background color while filling the 1st frame of a gif image, since it is 'static' qualified, so when re-entering this function for subsequent frames, this saved value will be used directly without re-obtaining it. But if asynchronous playing multi gif files in single process without being controlled, this 'static' will make the 'paintingColor' corrupted, because the different SkGIFMovie instances hold the same reference of 'paintingColor'. Signed-off-by: Lu Tong <lu.x.tong@sonymobile.com>; BUG=skia: Review URL: https://codereview.chromium.org/1184083002
Diffstat (limited to 'src/images')
-rw-r--r--src/images/SkMovie_gif.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/images/SkMovie_gif.cpp b/src/images/SkMovie_gif.cpp
index 40e5520def..380aca499a 100644
--- a/src/images/SkMovie_gif.cpp
+++ b/src/images/SkMovie_gif.cpp
@@ -35,6 +35,7 @@ private:
int fCurrIndex;
int fLastDrawIndex;
SkBitmap fBackup;
+ SkColor fPaintingColor;
};
static int Decode(GifFileType* fileType, GifByteType* out, int size) {
@@ -59,6 +60,7 @@ SkGIFMovie::SkGIFMovie(SkStream* stream)
}
fCurrIndex = -1;
fLastDrawIndex = -1;
+ fPaintingColor = SkPackARGB32(0, 0, 0, 0);
}
SkGIFMovie::~SkGIFMovie()
@@ -395,7 +397,6 @@ bool SkGIFMovie::onGetBitmap(SkBitmap* bm)
bgColor = SkColorSetARGB(0xFF, col.Red, col.Green, col.Blue);
}
- static SkColor paintingColor = SkPackARGB32(0, 0, 0, 0);
// draw each frames - not intelligent way
for (int i = startIndex; i <= lastIndex; i++) {
const SavedImage* cur = &fGIF->SavedImages[i];
@@ -404,17 +405,17 @@ bool SkGIFMovie::onGetBitmap(SkBitmap* bm)
int disposal;
getTransparencyAndDisposalMethod(cur, &trans, &disposal);
if (!trans && gif->SColorMap != NULL) {
- paintingColor = bgColor;
+ fPaintingColor = bgColor;
} else {
- paintingColor = SkColorSetARGB(0, 0, 0, 0);
+ fPaintingColor = SkColorSetARGB(0, 0, 0, 0);
}
- bm->eraseColor(paintingColor);
- fBackup.eraseColor(paintingColor);
+ bm->eraseColor(fPaintingColor);
+ fBackup.eraseColor(fPaintingColor);
} else {
// Dispose previous frame before move to next frame.
const SavedImage* prev = &fGIF->SavedImages[i-1];
- disposeFrameIfNeeded(bm, prev, cur, &fBackup, paintingColor);
+ disposeFrameIfNeeded(bm, prev, cur, &fBackup, fPaintingColor);
}
// Draw frame