OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
| 8 #include "SkTypes.h" |
| 9 |
8 // This tests out GIF decoder (SkImageDecoder_libgif.cpp) | 10 // This tests out GIF decoder (SkImageDecoder_libgif.cpp) |
9 // It is not used on these platforms: | 11 // It is not used on these platforms: |
10 #if (!defined(SK_BUILD_FOR_WIN32)) && \ | 12 #if (!defined(SK_BUILD_FOR_WIN32)) && \ |
11 (!defined(SK_BUILD_FOR_IOS)) && \ | 13 (!defined(SK_BUILD_FOR_IOS)) && \ |
12 (!defined(SK_BUILD_FOR_MAC)) | 14 (!defined(SK_BUILD_FOR_MAC)) |
13 | 15 |
| 16 #include "Resources.h" |
14 #include "SkBitmap.h" | 17 #include "SkBitmap.h" |
15 #include "SkData.h" | 18 #include "SkData.h" |
16 #include "SkForceLinking.h" | 19 #include "SkForceLinking.h" |
17 #include "SkImage.h" | 20 #include "SkImage.h" |
18 #include "SkImageDecoder.h" | 21 #include "SkImageDecoder.h" |
19 #include "SkStream.h" | 22 #include "SkStream.h" |
20 #include "Test.h" | 23 #include "Test.h" |
21 | 24 |
22 __SK_FORCE_IMAGE_DECODER_LINKING; | 25 __SK_FORCE_IMAGE_DECODER_LINKING; |
23 | 26 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 193 |
191 // test short Gif. 80 is missing a few bytes. | 194 // test short Gif. 80 is missing a few bytes. |
192 test_gif_data_short(reporter, static_cast<void *>(gGIFData), 80); | 195 test_gif_data_short(reporter, static_cast<void *>(gGIFData), 80); |
193 // "libgif warning [DGifGetLine]" | 196 // "libgif warning [DGifGetLine]" |
194 | 197 |
195 test_interlaced_gif_data(reporter, static_cast<void *>(gInterlacedGIF), | 198 test_interlaced_gif_data(reporter, static_cast<void *>(gInterlacedGIF), |
196 100); // 100 is missing a few bytes | 199 100); // 100 is missing a few bytes |
197 // "libgif warning [interlace DGifGetLine]" | 200 // "libgif warning [interlace DGifGetLine]" |
198 } | 201 } |
199 | 202 |
| 203 // Regression test for decoding a gif image with sampleSize of 4, which was |
| 204 // previously crashing. |
| 205 DEF_TEST(Gif_Sampled, r) { |
| 206 SkFILEStream fileStream(GetResourcePath("test640x479.gif").c_str()); |
| 207 REPORTER_ASSERT(r, fileStream.isValid()); |
| 208 if (!fileStream.isValid()) { |
| 209 return; |
| 210 } |
| 211 |
| 212 SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(&fileStream)); |
| 213 REPORTER_ASSERT(r, decoder); |
| 214 if (!decoder) { |
| 215 return; |
| 216 } |
| 217 decoder->setSampleSize(4); |
| 218 SkBitmap bm; |
| 219 const SkImageDecoder::Result result = decoder->decode(&fileStream, &bm, |
| 220 SkImageDecoder::kDecodePixels_Mode); |
| 221 REPORTER_ASSERT(r, result == SkImageDecoder::kSuccess); |
| 222 } |
| 223 |
200 #endif // !(SK_BUILD_FOR_WIN32||SK_BUILD_FOR_IOS||SK_BUILD_FOR_MAC) | 224 #endif // !(SK_BUILD_FOR_WIN32||SK_BUILD_FOR_IOS||SK_BUILD_FOR_MAC) |
OLD | NEW |