| OLD | NEW |
| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 204 |
| 205 bm->setConfig(SkBitmap::kIndex8_Config, width, height); |
| 205 if (SkImageDecoder::kDecodeBounds_Mode == mode) { | 206 if (SkImageDecoder::kDecodeBounds_Mode == mode) { |
| 206 bm->setConfig(SkBitmap::kIndex8_Config, width, height); | |
| 207 return true; | 207 return true; |
| 208 } | 208 } |
| 209 | 209 |
| 210 // No Bitmap reuse supported for this format | |
| 211 if (!bm->isNull()) { | |
| 212 return false; | |
| 213 } | |
| 214 | |
| 215 bm->setConfig(SkBitmap::kIndex8_Config, width, height); | |
| 216 SavedImage* image = &gif->SavedImages[gif->ImageCount-1]; | 210 SavedImage* image = &gif->SavedImages[gif->ImageCount-1]; |
| 217 const GifImageDesc& desc = image->ImageDesc; | 211 const GifImageDesc& desc = image->ImageDesc; |
| 218 | 212 |
| 219 // check for valid descriptor | 213 // check for valid descriptor |
| 220 if ( (desc.Top | desc.Left) < 0 || | 214 if ( (desc.Top | desc.Left) < 0 || |
| 221 desc.Left + desc.Width > width || | 215 desc.Left + desc.Width > width || |
| 222 desc.Top + desc.Height > height) { | 216 desc.Top + desc.Height > height) { |
| 223 return error_return(gif, *bm, "TopLeft"); | 217 return error_return(gif, *bm, "TopLeft"); |
| 224 } | 218 } |
| 225 | 219 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libgif_dfactory); | 380 static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libgif_dfactory); |
| 387 | 381 |
| 388 static SkImageDecoder::Format get_format_gif(SkStream* stream) { | 382 static SkImageDecoder::Format get_format_gif(SkStream* stream) { |
| 389 if (is_gif(stream)) { | 383 if (is_gif(stream)) { |
| 390 return SkImageDecoder::kGIF_Format; | 384 return SkImageDecoder::kGIF_Format; |
| 391 } | 385 } |
| 392 return SkImageDecoder::kUnknown_Format; | 386 return SkImageDecoder::kUnknown_Format; |
| 393 } | 387 } |
| 394 | 388 |
| 395 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_gif)
; | 389 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_gif)
; |
| OLD | NEW |