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 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 continue; | 1295 continue; |
1296 } | 1296 } |
1297 | 1297 |
1298 // Scanline decoding should not require a rewind. | 1298 // Scanline decoding should not require a rewind. |
1299 SkCodec::Result result = codec->startScanlineDecode(info); | 1299 SkCodec::Result result = codec->startScanlineDecode(info); |
1300 if (SkCodec::kSuccess != result) { | 1300 if (SkCodec::kSuccess != result) { |
1301 ERRORF(r, "Scanline decoding failed for %s with %i", file, result); | 1301 ERRORF(r, "Scanline decoding failed for %s with %i", file, result); |
1302 } | 1302 } |
1303 } | 1303 } |
1304 } | 1304 } |
| 1305 |
| 1306 // This test verifies that we fixed an assert statement that fired when reusing
a png codec |
| 1307 // after scaling. |
| 1308 DEF_TEST(Codec_reusePng, r) { |
| 1309 std::unique_ptr<SkStream> stream(GetResourceAsStream("plane.png")); |
| 1310 if (!stream) { |
| 1311 return; |
| 1312 } |
| 1313 |
| 1314 std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.r
elease())); |
| 1315 if (!codec) { |
| 1316 ERRORF(r, "Failed to create codec\n"); |
| 1317 return; |
| 1318 } |
| 1319 |
| 1320 SkAndroidCodec::AndroidOptions opts; |
| 1321 opts.fSampleSize = 5; |
| 1322 auto size = codec->getSampledDimensions(opts.fSampleSize); |
| 1323 auto info = codec->getInfo().makeWH(size.fWidth, size.fHeight).makeColorType
(kN32_SkColorType); |
| 1324 SkBitmap bm; |
| 1325 bm.allocPixels(info); |
| 1326 auto result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &
opts); |
| 1327 REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
| 1328 |
| 1329 info = codec->getInfo().makeColorType(kN32_SkColorType); |
| 1330 bm.allocPixels(info); |
| 1331 opts.fSampleSize = 1; |
| 1332 result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &opts)
; |
| 1333 REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
| 1334 } |
OLD | NEW |