diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 21:01:41 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 21:01:41 +0000 |
commit | 52e935d04c59135739c3a68fb6e19d313dc6d5ad (patch) | |
tree | 95f7ab178b045bef4456cbf92c6aa7e476becd99 /skia/images/SkImageDecoder_libgif.cpp | |
parent | 30fab79877b4bb067944b74d98346ac9bb6bfc7e (diff) | |
download | chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.zip chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.tar.gz chromium_src-52e935d04c59135739c3a68fb6e19d313dc6d5ad.tar.bz2 |
New drop of Skia. This is up to CL 121320.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6925 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/images/SkImageDecoder_libgif.cpp')
-rw-r--r-- | skia/images/SkImageDecoder_libgif.cpp | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/skia/images/SkImageDecoder_libgif.cpp b/skia/images/SkImageDecoder_libgif.cpp index 3b5e420..c894c9d 100644 --- a/skia/images/SkImageDecoder_libgif.cpp +++ b/skia/images/SkImageDecoder_libgif.cpp @@ -1,6 +1,6 @@ /* libs/graphics/images/SkImageDecoder_libgif.cpp ** -** Copyright 2006, Google Inc. +** Copyright 2006, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -145,11 +145,20 @@ static int find_transpIndex(const SavedImage& image, int colorCount) { return transpIndex; } +static bool error_return(GifFileType* gif, const SkBitmap& bm, + const char msg[]) { +#if 0 + SkDebugf("libgif error <%s> bitmap [%d %d] pixels %p colortable %p\n", + msg, bm.width(), bm.height(), bm.getPixels(), bm.getColorTable()); +#endif + return false; +} + bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, SkBitmap::Config prefConfig, Mode mode) { GifFileType* gif = DGifOpen(sk_stream, DecodeCallBackProc); if (NULL == gif) { - return false; + return error_return(gif, *bm, "DGifOpen"); } SkAutoTCallIProc<GifFileType, DGifCloseFile> acp(gif); @@ -165,17 +174,17 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, do { if (DGifGetRecordType(gif, &recType) == GIF_ERROR) { - return false; + return error_return(gif, *bm, "DGifGetRecordType"); } switch (recType) { case IMAGE_DESC_RECORD_TYPE: { if (DGifGetImageDesc(gif) == GIF_ERROR) { - return false; + return error_return(gif, *bm, "IMAGE_DESC_RECORD_TYPE"); } if (gif->ImageCount < 1) { // sanity check - return false; + return error_return(gif, *bm, "ImageCount < 1"); } width = gif->SWidth; @@ -183,7 +192,7 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, if (width <= 0 || height <= 0 || !this->chooseFromOneChoice(SkBitmap::kIndex8_Config, width, height)) { - return false; + return error_return(gif, *bm, "chooseFromOneChoice"); } bm->setConfig(SkBitmap::kIndex8_Config, width, height); @@ -197,7 +206,7 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, if ( (desc.Top | desc.Left) < 0 || desc.Left + desc.Width > width || desc.Top + desc.Height > height) { - return false; + return error_return(gif, *bm, "TopLeft"); } // now we decode the colortable @@ -205,7 +214,7 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, { const ColorMapObject* cmap = find_colormap(gif); if (NULL == cmap) { - return false; + return error_return(gif, *bm, "null cmap"); } colorCount = cmap->ColorCount; @@ -226,7 +235,7 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, SkAutoUnref aurts(ctable); if (!this->allocPixelRef(bm, ctable)) { - return false; + return error_return(gif, *bm, "allocPixelRef"); } } @@ -241,7 +250,7 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, // abort if either inner dimension is <= 0 if (innerWidth <= 0 || innerHeight <= 0) { - return false; + return error_return(gif, *bm, "non-pos inner width/height"); } // are we only a subset of the total bounds? @@ -266,7 +275,7 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, { uint8_t* row = scanline + iter.currY() * rowBytes; if (DGifGetLine(gif, row, innerWidth) == GIF_ERROR) { - return false; + return error_return(gif, *bm, "interlace DGifGetLine"); } iter.next(); } @@ -276,7 +285,7 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, // easy, non-interlace case for (int y = 0; y < innerHeight; y++) { if (DGifGetLine(gif, scanline, innerWidth) == GIF_ERROR) { - return false; + return error_return(gif, *bm, "DGifGetLine"); } scanline += rowBytes; } @@ -287,17 +296,17 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, case EXTENSION_RECORD_TYPE: if (DGifGetExtension(gif, &temp_save.Function, &extData) == GIF_ERROR) { - return false; + return error_return(gif, *bm, "DGifGetExtension"); } while (extData != NULL) { /* Create an extension block with our data */ if (AddExtensionBlock(&temp_save, extData[0], &extData[1]) == GIF_ERROR) { - return false; + return error_return(gif, *bm, "AddExtensionBlock"); } if (DGifGetExtensionNext(gif, &extData) == GIF_ERROR) { - return false; + return error_return(gif, *bm, "DGifGetExtensionNext"); } temp_save.Function = 0; } |