| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2015 Google Inc. | 2  * Copyright 2015 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 "Resources.h" | 8 #include "Resources.h" | 
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" | 
| 10 #include "SkCodec.h" | 10 #include "SkCodec.h" | 
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 151         bm.eraseColor(SK_ColorYELLOW); | 151         bm.eraseColor(SK_ColorYELLOW); | 
| 152         REPORTER_ASSERT(r, scanlineDecoder); | 152         REPORTER_ASSERT(r, scanlineDecoder); | 
| 153 | 153 | 
| 154         REPORTER_ASSERT(r, scanlineDecoder->start(info) == SkCodec::kSuccess); | 154         REPORTER_ASSERT(r, scanlineDecoder->start(info) == SkCodec::kSuccess); | 
| 155 | 155 | 
| 156         for (int y = 0; y < info.height(); y++) { | 156         for (int y = 0; y < info.height(); y++) { | 
| 157             result = scanlineDecoder->getScanlines(bm.getAddr(0, y), 1, 0); | 157             result = scanlineDecoder->getScanlines(bm.getAddr(0, y), 1, 0); | 
| 158             REPORTER_ASSERT(r, result == SkCodec::kSuccess); | 158             REPORTER_ASSERT(r, result == SkCodec::kSuccess); | 
| 159         } | 159         } | 
| 160         // verify that scanline decoding gives the same result. | 160         // verify that scanline decoding gives the same result. | 
| 161         compare_to_good_digest(r, digest, bm); | 161         if (SkScanlineDecoder::kTopDown_SkScanlineOrder == scanlineDecoder->getS
     canlineOrder()) { | 
|  | 162             compare_to_good_digest(r, digest, bm); | 
|  | 163         } | 
| 162     } else { | 164     } else { | 
| 163         REPORTER_ASSERT(r, !scanlineDecoder); | 165         REPORTER_ASSERT(r, !scanlineDecoder); | 
| 164     } | 166     } | 
| 165 | 167 | 
| 166     // The rest of this function tests decoding subsets, and will decode an arbi
     trary number of | 168     // The rest of this function tests decoding subsets, and will decode an arbi
     trary number of | 
| 167     // random subsets. | 169     // random subsets. | 
| 168     // Do not attempt to decode subsets of an image of only once pixel, since th
     ere is no | 170     // Do not attempt to decode subsets of an image of only once pixel, since th
     ere is no | 
| 169     // meaningful subset. | 171     // meaningful subset. | 
| 170     if (size.width() * size.height() == 1) { | 172     if (size.width() * size.height() == 1) { | 
| 171         return; | 173         return; | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 202 DEF_TEST(Codec, r) { | 204 DEF_TEST(Codec, r) { | 
| 203     // WBMP | 205     // WBMP | 
| 204     check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false); | 206     check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false); | 
| 205 | 207 | 
| 206     // WEBP | 208     // WEBP | 
| 207     check(r, "baby_tux.webp", SkISize::Make(386, 395), false, true); | 209     check(r, "baby_tux.webp", SkISize::Make(386, 395), false, true); | 
| 208     check(r, "color_wheel.webp", SkISize::Make(128, 128), false, true); | 210     check(r, "color_wheel.webp", SkISize::Make(128, 128), false, true); | 
| 209     check(r, "yellow_rose.webp", SkISize::Make(400, 301), false, true); | 211     check(r, "yellow_rose.webp", SkISize::Make(400, 301), false, true); | 
| 210 | 212 | 
| 211     // BMP | 213     // BMP | 
| 212     check(r, "randPixels.bmp", SkISize::Make(8, 8), false, false); | 214     check(r, "randPixels.bmp", SkISize::Make(8, 8), true, false); | 
| 213 | 215 | 
| 214     // ICO | 216     // ICO | 
| 215     // These two tests examine interestingly different behavior: | 217     // These two tests examine interestingly different behavior: | 
| 216     // Decodes an embedded BMP image | 218     // Decodes an embedded BMP image | 
| 217     check(r, "color_wheel.ico", SkISize::Make(128, 128), false, false); | 219     check(r, "color_wheel.ico", SkISize::Make(128, 128), false, false); | 
| 218     // Decodes an embedded PNG image | 220     // Decodes an embedded PNG image | 
| 219     check(r, "google_chrome.ico", SkISize::Make(256, 256), false, false); | 221     check(r, "google_chrome.ico", SkISize::Make(256, 256), false, false); | 
| 220 | 222 | 
| 221     // GIF | 223     // GIF | 
| 222     check(r, "box.gif", SkISize::Make(200, 55), false, false); | 224     check(r, "box.gif", SkISize::Make(200, 55), false, false); | 
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 385     REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 387     REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 
| 386     result = decoder->start( | 388     result = decoder->start( | 
| 387         decoder->getInfo().makeColorType(kIndex_8_SkColorType)); | 389         decoder->getInfo().makeColorType(kIndex_8_SkColorType)); | 
| 388     REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 390     REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 
| 389 } | 391 } | 
| 390 | 392 | 
| 391 DEF_TEST(Codec_Params, r) { | 393 DEF_TEST(Codec_Params, r) { | 
| 392     test_invalid_parameters(r, "index8.png"); | 394     test_invalid_parameters(r, "index8.png"); | 
| 393     test_invalid_parameters(r, "mandrill.wbmp"); | 395     test_invalid_parameters(r, "mandrill.wbmp"); | 
| 394 } | 396 } | 
| OLD | NEW | 
|---|