Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Side by Side Diff: src/images/SkImageDecoder_libgif.cpp

Issue 12604006: Upstream Android modifications to the image encoders/decoders. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: minor fixes Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_libbmp.cpp ('k') | src/images/SkImageDecoder_libico.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkImageDecoder.h" 10 #include "SkImageDecoder.h"
11 #include "SkColor.h" 11 #include "SkColor.h"
12 #include "SkColorPriv.h" 12 #include "SkColorPriv.h"
13 #include "SkStream.h" 13 #include "SkStream.h"
14 #include "SkTemplates.h" 14 #include "SkTemplates.h"
15 #include "SkPackBits.h" 15 #include "SkPackBits.h"
16 16
17 #include "gif_lib.h" 17 #include "gif_lib.h"
18 18
19 class SkGIFImageDecoder : public SkImageDecoder { 19 class SkGIFImageDecoder : public SkImageDecoder {
20 public: 20 public:
21 virtual Format getFormat() const { 21 virtual Format getFormat() const SK_OVERRIDE {
22 return kGIF_Format; 22 return kGIF_Format;
23 } 23 }
24 24
25 protected: 25 protected:
26 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode mode); 26 virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode mode) SK_OVERRIDE ;
27
28 private:
29 typedef SkImageDecoder INHERITED;
27 }; 30 };
28 31
29 static const uint8_t gStartingIterlaceYValue[] = { 32 static const uint8_t gStartingIterlaceYValue[] = {
30 0, 4, 2, 1 33 0, 4, 2, 1
31 }; 34 };
32 static const uint8_t gDeltaIterlaceYValue[] = { 35 static const uint8_t gDeltaIterlaceYValue[] = {
33 8, 8, 4, 2 36 8, 8, 4, 2
34 }; 37 };
35 38
36 /* Implement the GIF interlace algorithm in an iterator. 39 /* Implement the GIF interlace algorithm in an iterator.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return error_return(gif, *bm, "ImageCount < 1"); 197 return error_return(gif, *bm, "ImageCount < 1");
195 } 198 }
196 199
197 width = gif->SWidth; 200 width = gif->SWidth;
198 height = gif->SHeight; 201 height = gif->SHeight;
199 if (width <= 0 || height <= 0 || 202 if (width <= 0 || height <= 0 ||
200 !this->chooseFromOneChoice(SkBitmap::kIndex8_Config, 203 !this->chooseFromOneChoice(SkBitmap::kIndex8_Config,
201 width, height)) { 204 width, height)) {
202 return error_return(gif, *bm, "chooseFromOneChoice"); 205 return error_return(gif, *bm, "chooseFromOneChoice");
203 } 206 }
207
208 if (SkImageDecoder::kDecodeBounds_Mode == mode) {
209 bm->setConfig(SkBitmap::kIndex8_Config, width, height);
210 return true;
211 }
212
213 // No Bitmap reuse supported for this format
214 if (!bm->isNull()) {
215 return false;
216 }
204 217
205 bm->setConfig(SkBitmap::kIndex8_Config, width, height); 218 bm->setConfig(SkBitmap::kIndex8_Config, width, height);
206 if (SkImageDecoder::kDecodeBounds_Mode == mode)
207 return true;
208
209 SavedImage* image = &gif->SavedImages[gif->ImageCount-1]; 219 SavedImage* image = &gif->SavedImages[gif->ImageCount-1];
210 const GifImageDesc& desc = image->ImageDesc; 220 const GifImageDesc& desc = image->ImageDesc;
211 221
212 // check for valid descriptor 222 // check for valid descriptor
213 if ( (desc.Top | desc.Left) < 0 || 223 if ( (desc.Top | desc.Left) < 0 ||
214 desc.Left + desc.Width > width || 224 desc.Left + desc.Width > width ||
215 desc.Top + desc.Height > height) { 225 desc.Top + desc.Height > height) {
216 return error_return(gif, *bm, "TopLeft"); 226 return error_return(gif, *bm, "TopLeft");
217 } 227 }
218 228
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 || 373 if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 ||
364 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 || 374 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
365 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) { 375 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) {
366 return SkNEW(SkGIFImageDecoder); 376 return SkNEW(SkGIFImageDecoder);
367 } 377 }
368 } 378 }
369 return NULL; 379 return NULL;
370 } 380 }
371 381
372 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libgif_dfactory); 382 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libgif_dfactory);
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libbmp.cpp ('k') | src/images/SkImageDecoder_libico.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698