Chromium Code Reviews| 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 // This tests out GIF decoder (SkImageDecoder_libgif.cpp) | 8 // This tests out GIF decoder (SkImageDecoder_libgif.cpp) |
| 9 // It is not used on these platforms: | 9 // It is not used on these platforms: |
| 10 #if (!defined(SK_BUILD_FOR_WIN32)) && \ | 10 #if (!defined(SK_BUILD_FOR_WIN32)) && \ |
| 11 (!defined(SK_BUILD_FOR_IOS)) && \ | 11 (!defined(SK_BUILD_FOR_IOS)) && \ |
| 12 (!defined(SK_BUILD_FOR_MAC)) | 12 (!defined(SK_BUILD_FOR_MAC)) |
| 13 | 13 |
| 14 #include "Test.h" | 14 #include "Test.h" |
| 15 #include "TestClassDef.h" | 15 #include "TestClassDef.h" |
| 16 #include "SkBitmap.h" | 16 #include "SkBitmap.h" |
| 17 #include "SkData.h" | 17 #include "SkData.h" |
| 18 #include "SkForceLinking.h" | 18 #include "SkForceLinking.h" |
| 19 #include "SkImage.h" | 19 #include "SkImage.h" |
| 20 #include "SkImageDecoder.h" | 20 #include "SkImageDecoder.h" |
| 21 #include "SkStream.h" | 21 #include "SkStream.h" |
| 22 | 22 |
| 23 __SK_FORCE_IMAGE_DECODER_LINKING; | 23 __SK_FORCE_IMAGE_DECODER_LINKING; |
| 24 | 24 |
|
robertphillips
2014/01/14 13:19:37
Maybe make these gGIFData, gGIFDataNoColormap and
tfarina
2014/01/21 23:37:43
Done.
| |
| 25 namespace { | 25 static unsigned char gifData[] = { |
| 26 unsigned char gifData[] = { | 26 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x03, 0x00, 0x03, 0x00, 0xe3, 0x08, |
| 27 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x03, 0x00, | 27 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, |
| 28 0x03, 0x00, 0xe3, 0x08, 0x00, 0x00, 0x00, 0x00, | 28 0xff, 0x80, 0x80, 0x80, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, |
| 29 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, | 29 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, |
| 30 0xff, 0x80, 0x80, 0x80, 0x00, 0xff, 0x00, 0x00, | 30 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, |
| 31 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, | 31 0xff, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x04, |
| 32 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 32 0x07, 0x50, 0x1c, 0x43, 0x40, 0x41, 0x23, 0x44, 0x00, 0x3b |
| 33 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 33 }; |
| 34 0xff, 0xff, 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, | 34 |
| 35 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x04, | 35 static unsigned char gifDataNoColormap[] = { |
| 36 0x07, 0x50, 0x1c, 0x43, 0x40, 0x41, 0x23, 0x44, | 36 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, |
| 37 0x00, 0x3b}; | 37 0x21, 0xf9, 0x04, 0x01, 0x0a, 0x00, 0x01, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, |
| 38 unsigned char gifDataNoColormap[] = { | 38 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x4c, 0x01, 0x00, 0x3b |
| 39 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, | 39 }; |
| 40 0x01, 0x00, 0x00, 0x00, 0x00, 0x21, 0xf9, 0x04, | 40 |
| 41 0x01, 0x0a, 0x00, 0x01, 0x00, 0x2c, 0x00, 0x00, | 41 static unsigned char interlacedGif[] = { |
| 42 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, | 42 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x09, 0x00, 0x09, 0x00, 0xe3, 0x08, 0x00, |
| 43 0x02, 0x4c, 0x01, 0x00, 0x3b}; | 43 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x80, |
| 44 unsigned char interlacedGif[] = { | 44 0x80, 0x80, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, |
| 45 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x09, 0x00, | 45 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, |
| 46 0x09, 0x00, 0xe3, 0x08, 0x00, 0x00, 0x00, 0x00, | 46 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, |
| 47 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, | 47 0x00, 0x09, 0x00, 0x09, 0x00, 0x40, 0x04, 0x1b, 0x50, 0x1c, 0x23, 0xe9, 0x44, |
| 48 0xff, 0x80, 0x80, 0x80, 0x00, 0xff, 0x00, 0x00, | 48 0x23, 0x60, 0x9d, 0x09, 0x28, 0x1e, 0xf8, 0x6d, 0x64, 0x56, 0x9d, 0x53, 0xa8, |
| 49 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, | 49 0x7e, 0xa8, 0x65, 0x94, 0x5c, 0xb0, 0x8a, 0x45, 0x04, 0x00, 0x3b |
| 50 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 50 }; |
| 51 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
| 52 0xff, 0xff, 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, | |
| 53 0x00, 0x00, 0x09, 0x00, 0x09, 0x00, 0x40, 0x04, | |
| 54 0x1b, 0x50, 0x1c, 0x23, 0xe9, 0x44, 0x23, 0x60, | |
| 55 0x9d, 0x09, 0x28, 0x1e, 0xf8, 0x6d, 0x64, 0x56, | |
| 56 0x9d, 0x53, 0xa8, 0x7e, 0xa8, 0x65, 0x94, 0x5c, | |
| 57 0xb0, 0x8a, 0x45, 0x04, 0x00, 0x3b}; | |
| 58 }; // namespace | |
| 59 | 51 |
| 60 static void test_gif_data_no_colormap(skiatest::Reporter* r, | 52 static void test_gif_data_no_colormap(skiatest::Reporter* r, |
| 61 void* data, size_t size) { | 53 void* data, |
| 54 size_t size) { | |
| 62 SkBitmap bm; | 55 SkBitmap bm; |
| 63 bool imageDecodeSuccess = SkImageDecoder::DecodeMemory( | 56 bool imageDecodeSuccess = SkImageDecoder::DecodeMemory( |
| 64 data, size, &bm); | 57 data, size, &bm); |
| 65 REPORTER_ASSERT(r, imageDecodeSuccess); | 58 REPORTER_ASSERT(r, imageDecodeSuccess); |
| 66 REPORTER_ASSERT(r, bm.width() == 1); | 59 REPORTER_ASSERT(r, bm.width() == 1); |
| 67 REPORTER_ASSERT(r, bm.height() == 1); | 60 REPORTER_ASSERT(r, bm.height() == 1); |
| 68 REPORTER_ASSERT(r, !(bm.empty())); | 61 REPORTER_ASSERT(r, !(bm.empty())); |
| 69 if (!(bm.empty())) { | 62 if (!(bm.empty())) { |
| 70 REPORTER_ASSERT(r, bm.getColor(0, 0) == 0x00000000); | 63 REPORTER_ASSERT(r, bm.getColor(0, 0) == 0x00000000); |
| 71 } | 64 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 // test short Gif. 80 is missing a few bytes. | 192 // test short Gif. 80 is missing a few bytes. |
| 200 test_gif_data_short(reporter, static_cast<void *>(gifData), 80); | 193 test_gif_data_short(reporter, static_cast<void *>(gifData), 80); |
| 201 // "libgif warning [DGifGetLine]" | 194 // "libgif warning [DGifGetLine]" |
| 202 | 195 |
| 203 test_interlaced_gif_data(reporter, static_cast<void *>(interlacedGif), | 196 test_interlaced_gif_data(reporter, static_cast<void *>(interlacedGif), |
| 204 100); // 100 is missing a few bytes | 197 100); // 100 is missing a few bytes |
| 205 // "libgif warning [interlace DGifGetLine]" | 198 // "libgif warning [interlace DGifGetLine]" |
| 206 } | 199 } |
| 207 | 200 |
| 208 #endif // !(SK_BUILD_FOR_WIN32||SK_BUILD_FOR_IOS||SK_BUILD_FOR_MAC) | 201 #endif // !(SK_BUILD_FOR_WIN32||SK_BUILD_FOR_IOS||SK_BUILD_FOR_MAC) |
| OLD | NEW |