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 "SkAndroidCodec.h" | 9 #include "SkAndroidCodec.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 bm.allocPixels(info); | 1325 bm.allocPixels(info); |
1326 auto result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &
opts); | 1326 auto result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &
opts); |
1327 REPORTER_ASSERT(r, result == SkCodec::kSuccess); | 1327 REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
1328 | 1328 |
1329 info = codec->getInfo().makeColorType(kN32_SkColorType); | 1329 info = codec->getInfo().makeColorType(kN32_SkColorType); |
1330 bm.allocPixels(info); | 1330 bm.allocPixels(info); |
1331 opts.fSampleSize = 1; | 1331 opts.fSampleSize = 1; |
1332 result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &opts)
; | 1332 result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &opts)
; |
1333 REPORTER_ASSERT(r, result == SkCodec::kSuccess); | 1333 REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
1334 } | 1334 } |
| 1335 |
| 1336 DEF_TEST(Codec_rowsDecoded, r) { |
| 1337 auto file = "plane_interlaced.png"; |
| 1338 std::unique_ptr<SkStream> stream(GetResourceAsStream(file)); |
| 1339 if (!stream) { |
| 1340 return; |
| 1341 } |
| 1342 |
| 1343 // This is enough to read the header etc, but no rows. |
| 1344 auto data = SkData::MakeFromStream(stream.get(), 99); |
| 1345 std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data)); |
| 1346 if (!codec) { |
| 1347 ERRORF(r, "Failed to create codec\n"); |
| 1348 return; |
| 1349 } |
| 1350 |
| 1351 auto info = codec->getInfo().makeColorType(kN32_SkColorType); |
| 1352 SkBitmap bm; |
| 1353 bm.allocPixels(info); |
| 1354 auto result = codec->startIncrementalDecode(info, bm.getPixels(), bm.rowByte
s()); |
| 1355 REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
| 1356 |
| 1357 // This is an arbitrary value. The important fact is that it is not zero, an
d rowsDecoded |
| 1358 // should get set to zero by incrementalDecode. |
| 1359 int rowsDecoded = 77; |
| 1360 result = codec->incrementalDecode(&rowsDecoded); |
| 1361 REPORTER_ASSERT(r, result == SkCodec::kIncompleteInput); |
| 1362 REPORTER_ASSERT(r, rowsDecoded == 0); |
| 1363 } |
OLD | NEW |