Chromium Code Reviews| 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 if (supportsSubsetDecoding) { | 213 if (supportsSubsetDecoding) { |
| 214 REPORTER_ASSERT(r, result == SkCodec::kSuccess); | 214 REPORTER_ASSERT(r, result == SkCodec::kSuccess); |
| 215 // Webp is the only codec that supports subsets, and it will have mo dified the subset | 215 // Webp is the only codec that supports subsets, and it will have mo dified the subset |
| 216 // to have even left/top. | 216 // to have even left/top. |
| 217 REPORTER_ASSERT(r, SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTo p)); | 217 REPORTER_ASSERT(r, SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTo p)); |
| 218 } else { | 218 } else { |
| 219 // No subsets will work. | 219 // No subsets will work. |
| 220 REPORTER_ASSERT(r, result == SkCodec::kUnimplemented); | 220 REPORTER_ASSERT(r, result == SkCodec::kUnimplemented); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | |
| 224 // SkScaledCodec tests | |
| 225 { | |
| 226 SkAutoTDelete<SkStream> stream(resource(path)); | |
| 227 if (!stream) { | |
| 228 SkDebugf("Missing resource '%s'\n", path); | |
| 229 return; | |
| 230 } | |
| 231 SkAutoTDelete<SkCodec> codec(SkScaledCodec::NewFromStream(stream.detach( ))); | |
| 232 if (!codec) { | |
| 233 ERRORF(r, "Unable to decode '%s'", path); | |
| 234 return; | |
| 235 } | |
| 236 | |
| 237 SkImageInfo info = codec->getInfo().makeColorType(kN32_SkColorType); | |
| 238 REPORTER_ASSERT(r, info.dimensions() == size); | |
| 239 | |
| 240 // FIXME: We will be able to run this test on ICOs as well, after we hav e implemented | |
| 241 // scanline decoding for ICO. | |
| 242 if (SkEncodedFormat::kICO_SkEncodedFormat != codec->getEncodedFormat()) { | |
|
scroggo
2015/10/02 20:56:06
Another way you could do this - not sure if it's b
msarett
2015/10/05 14:26:51
Done.
| |
| 243 SkBitmap bm; | |
| 244 bm.allocPixels(info); | |
| 245 SkAutoLockPixels autoLockPixels(bm); | |
| 246 SkCodec::Result result = | |
| 247 codec->getPixels(info, bm.getPixels(), bm.rowBytes(), nullptr, n ullptr, nullptr); | |
|
scroggo
2015/10/02 20:56:06
nit: This is copied and pasted, so I know it's the
msarett
2015/10/05 14:26:51
I will refactor into a different method and check
| |
| 248 REPORTER_ASSERT(r, result == SkCodec::kSuccess); | |
| 249 | |
| 250 SkMD5::Digest digest; | |
| 251 md5(bm, &digest); | |
| 252 | |
| 253 // Verify that re-decoding gives the same result. | |
| 254 test_info(r, codec, info, SkCodec::kSuccess, &digest); | |
| 255 } | |
| 256 } | |
| 223 } | 257 } |
| 224 | 258 |
| 225 DEF_TEST(Codec, r) { | 259 DEF_TEST(Codec, r) { |
| 226 // WBMP | 260 // WBMP |
| 227 check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false); | 261 check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false); |
| 228 | 262 |
| 229 // WEBP | 263 // WEBP |
| 230 check(r, "baby_tux.webp", SkISize::Make(386, 395), false, true); | 264 check(r, "baby_tux.webp", SkISize::Make(386, 395), false, true); |
| 231 check(r, "color_wheel.webp", SkISize::Make(128, 128), false, true); | 265 check(r, "color_wheel.webp", SkISize::Make(128, 128), false, true); |
| 232 check(r, "yellow_rose.webp", SkISize::Make(400, 301), false, true); | 266 check(r, "yellow_rose.webp", SkISize::Make(400, 301), false, true); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 533 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
| 500 result = decoder->startScanlineDecode( | 534 result = decoder->startScanlineDecode( |
| 501 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); | 535 decoder->getInfo().makeColorType(kIndex_8_SkColorType)); |
| 502 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); | 536 REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result); |
| 503 } | 537 } |
| 504 | 538 |
| 505 DEF_TEST(Codec_Params, r) { | 539 DEF_TEST(Codec_Params, r) { |
| 506 test_invalid_parameters(r, "index8.png"); | 540 test_invalid_parameters(r, "index8.png"); |
| 507 test_invalid_parameters(r, "mandrill.wbmp"); | 541 test_invalid_parameters(r, "mandrill.wbmp"); |
| 508 } | 542 } |
| OLD | NEW |