landing https://codereview.appspot.com/7225077/ -- tweak for GIF 5.x api
git-svn-id: http://skia.googlecode.com/svn/trunk@7523 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/images/SkImageDecoder_libgif.cpp b/src/images/SkImageDecoder_libgif.cpp
index 3008130..f81c601 100644
--- a/src/images/SkImageDecoder_libgif.cpp
+++ b/src/images/SkImageDecoder_libgif.cpp
@@ -99,7 +99,11 @@
void CheckFreeExtension(SavedImage* Image) {
if (Image->ExtensionBlocks) {
+#if GIFLIB_MAJOR < 5
FreeExtension(Image);
+#else
+ GifFreeExtensions(&Image->ExtensionBlockCount, &Image->ExtensionBlocks);
+#endif
}
}
@@ -151,7 +155,11 @@
}
bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, Mode mode) {
+#if GIFLIB_MAJOR < 5
GifFileType* gif = DGifOpen(sk_stream, DecodeCallBackProc);
+#else
+ GifFileType* gif = DGifOpen(sk_stream, DecodeCallBackProc, NULL);
+#endif
if (NULL == gif) {
return error_return(gif, *bm, "DGifOpen");
}
@@ -166,6 +174,9 @@
int width, height;
GifRecordType recType;
GifByteType *extData;
+#if GIFLIB_MAJOR >= 5
+ int extFunction;
+#endif
int transpIndex = -1; // -1 means we don't have it (yet)
do {
@@ -296,21 +307,35 @@
} break;
case EXTENSION_RECORD_TYPE:
+#if GIFLIB_MAJOR < 5
if (DGifGetExtension(gif, &temp_save.Function,
&extData) == GIF_ERROR) {
+#else
+ if (DGifGetExtension(gif, &extFunction, &extData) == GIF_ERROR) {
+#endif
return error_return(gif, *bm, "DGifGetExtension");
}
while (extData != NULL) {
/* Create an extension block with our data */
+#if GIFLIB_MAJOR < 5
if (AddExtensionBlock(&temp_save, extData[0],
&extData[1]) == GIF_ERROR) {
+#else
+ if (GifAddExtensionBlock(&gif->ExtensionBlockCount,
+ &gif->ExtensionBlocks,
+ extFunction,
+ extData[0],
+ &extData[1]) == GIF_ERROR) {
+#endif
return error_return(gif, *bm, "AddExtensionBlock");
}
if (DGifGetExtensionNext(gif, &extData) == GIF_ERROR) {
return error_return(gif, *bm, "DGifGetExtensionNext");
}
+#if GIFLIB_MAJOR < 5
temp_save.Function = 0;
+#endif
}
break;