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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 const int lines = codec->getScanlines(bm.getAddr(0, 0), 1, 0); | 213 const int lines = codec->getScanlines(bm.getAddr(0, 0), 1, 0); |
214 if (!isIncomplete) { | 214 if (!isIncomplete) { |
215 REPORTER_ASSERT(r, lines == 1); | 215 REPORTER_ASSERT(r, lines == 1); |
216 } | 216 } |
217 REPORTER_ASSERT(r, codec->getPixels(bm.info(), bm.getPixels(), bm.rowByt
es()) | 217 REPORTER_ASSERT(r, codec->getPixels(bm.info(), bm.getPixels(), bm.rowByt
es()) |
218 == expectedResult); | 218 == expectedResult); |
219 REPORTER_ASSERT(r, codec->getScanlines(bm.getAddr(0, 0), 1, 0) | 219 REPORTER_ASSERT(r, codec->getScanlines(bm.getAddr(0, 0), 1, 0) |
220 == 0); | 220 == 0); |
221 REPORTER_ASSERT(r, codec->skipScanlines(1) | 221 REPORTER_ASSERT(r, codec->skipScanlines(1) |
222 == 0); | 222 == 0); |
| 223 |
| 224 // Test partial scanline decodes |
| 225 if (supports_scaled_codec(path) && info.width() >= 3) { |
| 226 SkCodec::Options options; |
| 227 int width = info.width(); |
| 228 int height = info.height(); |
| 229 SkIRect subset = SkIRect::MakeXYWH(2 * (width / 3), 0, width / 3, he
ight); |
| 230 options.fSubset = ⊂ |
| 231 |
| 232 const SkCodec::Result partialStartResult = codec->startScanlineDecod
e(info, &options, |
| 233 nullptr, nullptr); |
| 234 REPORTER_ASSERT(r, partialStartResult == SkCodec::kSuccess); |
| 235 |
| 236 for (int y = 0; y < height; y++) { |
| 237 const int lines = codec->getScanlines(bm.getAddr(0, y), 1, 0); |
| 238 if (!isIncomplete) { |
| 239 REPORTER_ASSERT(r, 1 == lines); |
| 240 } |
| 241 } |
| 242 } |
223 } else { | 243 } else { |
224 REPORTER_ASSERT(r, startResult == SkCodec::kUnimplemented); | 244 REPORTER_ASSERT(r, startResult == SkCodec::kUnimplemented); |
225 } | 245 } |
226 | 246 |
227 // The rest of this function tests decoding subsets, and will decode an arbi
trary number of | 247 // The rest of this function tests decoding subsets, and will decode an arbi
trary number of |
228 // random subsets. | 248 // random subsets. |
229 // Do not attempt to decode subsets of an image of only once pixel, since th
ere is no | 249 // Do not attempt to decode subsets of an image of only once pixel, since th
ere is no |
230 // meaningful subset. | 250 // meaningful subset. |
231 if (size.width() * size.height() == 1) { | 251 if (size.width() * size.height() == 1) { |
232 return; | 252 return; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 609 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
590 result = decoder->startScanlineDecode( | 610 result = decoder->startScanlineDecode( |
591 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); | 611 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); |
592 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 612 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
593 } | 613 } |
594 | 614 |
595 DEF_TEST(Codec_Params, r) { | 615 DEF_TEST(Codec_Params, r) { |
596 test_invalid_parameters(r, "index8.png"); | 616 test_invalid_parameters(r, "index8.png"); |
597 test_invalid_parameters(r, "mandrill.wbmp"); | 617 test_invalid_parameters(r, "mandrill.wbmp"); |
598 } | 618 } |
OLD | NEW |