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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 bm.eraseColor(SK_ColorYELLOW); | 89 bm.eraseColor(SK_ColorYELLOW); |
90 | 90 |
91 result = | 91 result = |
92 codec->getPixels(info, bm.getPixels(), bm.rowBytes(), NULL, NULL, NULL); | 92 codec->getPixels(info, bm.getPixels(), bm.rowBytes(), NULL, NULL, NULL); |
93 | 93 |
94 REPORTER_ASSERT(r, result == SkCodec::kSuccess); | 94 REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
95 // verify that re-decoding gives the same result. | 95 // verify that re-decoding gives the same result. |
96 compare_to_good_digest(r, digest, bm); | 96 compare_to_good_digest(r, digest, bm); |
97 | 97 |
98 SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(codec->getScanlineDecoder(i
nfo)); | 98 stream.reset(resource(path)); |
| 99 SkAutoTDelete<SkScanlineDecoder> scanlineDecoder( |
| 100 SkScanlineDecoder::NewFromStream(stream.detach())); |
99 if (supportsScanlineDecoding) { | 101 if (supportsScanlineDecoding) { |
100 bm.eraseColor(SK_ColorYELLOW); | 102 bm.eraseColor(SK_ColorYELLOW); |
101 REPORTER_ASSERT(r, scanlineDecoder); | 103 REPORTER_ASSERT(r, scanlineDecoder); |
102 | 104 |
103 // Regular decodes should not be affected by creating a scanline decoder | 105 REPORTER_ASSERT(r, scanlineDecoder->start(info) == SkCodec::kSuccess); |
104 result = codec->getPixels(info, bm.getPixels(), bm.rowBytes(), NULL, NUL
L, NULL); | |
105 REPORTER_ASSERT(r, SkCodec::kSuccess == result); | |
106 compare_to_good_digest(r, digest, bm); | |
107 | |
108 bm.eraseColor(SK_ColorYELLOW); | |
109 | 106 |
110 for (int y = 0; y < info.height(); y++) { | 107 for (int y = 0; y < info.height(); y++) { |
111 result = scanlineDecoder->getScanlines(bm.getAddr(0, y), 1, 0); | 108 result = scanlineDecoder->getScanlines(bm.getAddr(0, y), 1, 0); |
112 REPORTER_ASSERT(r, result == SkCodec::kSuccess); | 109 REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
113 } | 110 } |
114 // verify that scanline decoding gives the same result. | 111 // verify that scanline decoding gives the same result. |
115 compare_to_good_digest(r, digest, bm); | 112 compare_to_good_digest(r, digest, bm); |
116 } else { | 113 } else { |
117 REPORTER_ASSERT(r, !scanlineDecoder); | 114 REPORTER_ASSERT(r, !scanlineDecoder); |
118 } | 115 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 test_empty(r, "empty_images/zero-embedded.ico"); | 282 test_empty(r, "empty_images/zero-embedded.ico"); |
286 test_empty(r, "empty_images/zero-width.bmp"); | 283 test_empty(r, "empty_images/zero-width.bmp"); |
287 test_empty(r, "empty_images/zero-height.bmp"); | 284 test_empty(r, "empty_images/zero-height.bmp"); |
288 test_empty(r, "empty_images/zero-width.jpg"); | 285 test_empty(r, "empty_images/zero-width.jpg"); |
289 test_empty(r, "empty_images/zero-height.jpg"); | 286 test_empty(r, "empty_images/zero-height.jpg"); |
290 test_empty(r, "empty_images/zero-width.png"); | 287 test_empty(r, "empty_images/zero-width.png"); |
291 test_empty(r, "empty_images/zero-height.png"); | 288 test_empty(r, "empty_images/zero-height.png"); |
292 test_empty(r, "empty_images/zero-width.wbmp"); | 289 test_empty(r, "empty_images/zero-width.wbmp"); |
293 test_empty(r, "empty_images/zero-height.wbmp"); | 290 test_empty(r, "empty_images/zero-height.wbmp"); |
294 } | 291 } |
OLD | NEW |