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

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: 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
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"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return error_return(gif, *bm, "ImageCount < 1"); 194 return error_return(gif, *bm, "ImageCount < 1");
195 } 195 }
196 196
197 width = gif->SWidth; 197 width = gif->SWidth;
198 height = gif->SHeight; 198 height = gif->SHeight;
199 if (width <= 0 || height <= 0 || 199 if (width <= 0 || height <= 0 ||
200 !this->chooseFromOneChoice(SkBitmap::kIndex8_Config, 200 !this->chooseFromOneChoice(SkBitmap::kIndex8_Config,
201 width, height)) { 201 width, height)) {
202 return error_return(gif, *bm, "chooseFromOneChoice"); 202 return error_return(gif, *bm, "chooseFromOneChoice");
203 } 203 }
204
205 if (SkImageDecoder::kDecodeBounds_Mode == mode) {
206 bm->setConfig(SkBitmap::kIndex8_Config, width, height);
207 return true;
208 }
209
210 // No Bitmap reuse supported for this format
211 if (!bm->isNull()) {
212 return false;
213 }
204 214
205 bm->setConfig(SkBitmap::kIndex8_Config, width, height); 215 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]; 216 SavedImage* image = &gif->SavedImages[gif->ImageCount-1];
210 const GifImageDesc& desc = image->ImageDesc; 217 const GifImageDesc& desc = image->ImageDesc;
211 218
212 // check for valid descriptor 219 // check for valid descriptor
213 if ( (desc.Top | desc.Left) < 0 || 220 if ( (desc.Top | desc.Left) < 0 ||
214 desc.Left + desc.Width > width || 221 desc.Left + desc.Width > width ||
215 desc.Top + desc.Height > height) { 222 desc.Top + desc.Height > height) {
216 return error_return(gif, *bm, "TopLeft"); 223 return error_return(gif, *bm, "TopLeft");
217 } 224 }
218 225
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 || 370 if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 ||
364 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 || 371 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
365 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) { 372 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0) {
366 return SkNEW(SkGIFImageDecoder); 373 return SkNEW(SkGIFImageDecoder);
367 } 374 }
368 } 375 }
369 return NULL; 376 return NULL;
370 } 377 }
371 378
372 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libgif_dfactory); 379 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libgif_dfactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698