OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 #include "DMJsonWriter.h" | 9 #include "DMJsonWriter.h" |
10 #include "DMSrcSink.h" | 10 #include "DMSrcSink.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 break; | 241 break; |
242 case CodecSrc::kStripe_Mode: | 242 case CodecSrc::kStripe_Mode: |
243 folder.append("stripe"); | 243 folder.append("stripe"); |
244 break; | 244 break; |
245 case CodecSrc::kCroppedScanline_Mode: | 245 case CodecSrc::kCroppedScanline_Mode: |
246 folder.append("crop"); | 246 folder.append("crop"); |
247 break; | 247 break; |
248 case CodecSrc::kSubset_Mode: | 248 case CodecSrc::kSubset_Mode: |
249 folder.append("codec_subset"); | 249 folder.append("codec_subset"); |
250 break; | 250 break; |
251 case CodecSrc::kGen_Mode: | |
252 folder.append("gen"); | |
253 break; | |
254 } | 251 } |
255 | 252 |
256 switch (dstColorType) { | 253 switch (dstColorType) { |
257 case CodecSrc::kGrayscale_Always_DstColorType: | 254 case CodecSrc::kGrayscale_Always_DstColorType: |
258 folder.append("_kGray8"); | 255 folder.append("_kGray8"); |
259 break; | 256 break; |
260 case CodecSrc::kIndex8_Always_DstColorType: | 257 case CodecSrc::kIndex8_Always_DstColorType: |
261 folder.append("_kIndex8"); | 258 folder.append("_kIndex8"); |
262 break; | 259 break; |
263 default: | 260 default: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 } | 321 } |
325 | 322 |
326 if (1 != sampleSize) { | 323 if (1 != sampleSize) { |
327 folder.appendf("_%.3f", 1.0f / (float) sampleSize); | 324 folder.appendf("_%.3f", 1.0f / (float) sampleSize); |
328 } | 325 } |
329 | 326 |
330 AndroidCodecSrc* src = new AndroidCodecSrc(path, mode, dstColorType, dstAlph aType, sampleSize); | 327 AndroidCodecSrc* src = new AndroidCodecSrc(path, mode, dstColorType, dstAlph aType, sampleSize); |
331 push_src("image", folder, src); | 328 push_src("image", folder, src); |
332 } | 329 } |
333 | 330 |
331 static void push_image_gen_src(Path path, ImageGenSrc::Mode mode, SkAlphaType al phaType, bool isGpu) { | |
scroggo
2016/03/07 13:04:30
nit: 100 chars
msarett
2016/03/08 23:20:17
Done.
| |
332 SkString folder; | |
333 switch (mode) { | |
334 case ImageGenSrc::kCodec_Mode: | |
335 folder.append("gen_codec"); | |
336 break; | |
337 case ImageGenSrc::kCG_Mode: | |
338 folder.append("gen_cg"); | |
339 break; | |
340 } | |
341 | |
342 if (isGpu) { | |
343 folder.append("_gpu"); | |
344 } else { | |
345 switch (alphaType) { | |
346 case kOpaque_SkAlphaType: | |
347 folder.append("_opaque"); | |
348 break; | |
349 case kPremul_SkAlphaType: | |
350 folder.append("_premul"); | |
351 break; | |
352 case kUnpremul_SkAlphaType: | |
353 folder.append("_unpremul"); | |
354 break; | |
355 default: | |
356 break; | |
357 } | |
358 } | |
359 | |
360 ImageGenSrc* src = new ImageGenSrc(path, mode, alphaType, isGpu); | |
361 push_src("image", folder, src); | |
362 } | |
363 | |
334 static void push_codec_srcs(Path path) { | 364 static void push_codec_srcs(Path path) { |
335 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 365 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
336 if (!encoded) { | 366 if (!encoded) { |
337 SkDebugf("Couldn't read %s.", path.c_str()); | 367 SkDebugf("Couldn't read %s.", path.c_str()); |
338 return; | 368 return; |
339 } | 369 } |
340 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 370 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
341 if (nullptr == codec.get()) { | 371 if (nullptr == codec.get()) { |
342 SkDebugf("Couldn't create codec for %s.", path.c_str()); | 372 SkDebugf("Couldn't create codec for %s.", path.c_str()); |
343 return; | 373 return; |
344 } | 374 } |
345 | 375 |
346 // Native Scales | 376 // Native Scales |
347 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co mpare with these | 377 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co mpare with these |
348 // tests. SkImageDecoder supports downscales by integer fac tors. | 378 // tests. SkImageDecoder supports downscales by integer fac tors. |
349 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 | 379 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 |
350 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f }; | 380 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f }; |
351 | 381 |
352 SkTArray<CodecSrc::Mode> nativeModes; | 382 SkTArray<CodecSrc::Mode> nativeModes; |
353 nativeModes.push_back(CodecSrc::kCodec_Mode); | 383 nativeModes.push_back(CodecSrc::kCodec_Mode); |
354 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode); | 384 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode); |
355 nativeModes.push_back(CodecSrc::kGen_Mode); | |
356 switch (codec->getEncodedFormat()) { | 385 switch (codec->getEncodedFormat()) { |
357 case SkEncodedFormat::kJPEG_SkEncodedFormat: | 386 case SkEncodedFormat::kJPEG_SkEncodedFormat: |
358 nativeModes.push_back(CodecSrc::kScanline_Mode); | 387 nativeModes.push_back(CodecSrc::kScanline_Mode); |
359 nativeModes.push_back(CodecSrc::kStripe_Mode); | 388 nativeModes.push_back(CodecSrc::kStripe_Mode); |
360 nativeModes.push_back(CodecSrc::kCroppedScanline_Mode); | 389 nativeModes.push_back(CodecSrc::kCroppedScanline_Mode); |
361 break; | 390 break; |
362 case SkEncodedFormat::kWEBP_SkEncodedFormat: | 391 case SkEncodedFormat::kWEBP_SkEncodedFormat: |
363 nativeModes.push_back(CodecSrc::kSubset_Mode); | 392 nativeModes.push_back(CodecSrc::kSubset_Mode); |
364 break; | 393 break; |
365 case SkEncodedFormat::kRAW_SkEncodedFormat: | 394 case SkEncodedFormat::kRAW_SkEncodedFormat: |
(...skipping 21 matching lines...) Expand all Loading... | |
387 } | 416 } |
388 | 417 |
389 SkTArray<SkAlphaType> alphaModes; | 418 SkTArray<SkAlphaType> alphaModes; |
390 alphaModes.push_back(kPremul_SkAlphaType); | 419 alphaModes.push_back(kPremul_SkAlphaType); |
391 alphaModes.push_back(kUnpremul_SkAlphaType); | 420 alphaModes.push_back(kUnpremul_SkAlphaType); |
392 if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) { | 421 if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) { |
393 alphaModes.push_back(kOpaque_SkAlphaType); | 422 alphaModes.push_back(kOpaque_SkAlphaType); |
394 } | 423 } |
395 | 424 |
396 for (CodecSrc::Mode mode : nativeModes) { | 425 for (CodecSrc::Mode mode : nativeModes) { |
397 // SkCodecImageGenerator only runs for the default colorType | |
398 // recommended by SkCodec. There is no need to generate multiple | |
399 // tests for different colorTypes. | |
400 // TODO (msarett): Add scaling support to SkCodecImageGenerator. | |
401 if (CodecSrc::kGen_Mode == mode) { | |
402 // FIXME: The gpu backend does not draw kGray sources correctly. (sk bug.com/4822) | |
403 if (kGray_8_SkColorType != codec->getInfo().colorType()) { | |
404 push_codec_src(path, mode, CodecSrc::kGetFromCanvas_DstColorType , | |
405 codec->getInfo().alphaType(), 1.0f); | |
406 } | |
407 continue; | |
408 } | |
409 | |
410 for (float scale : nativeScales) { | 426 for (float scale : nativeScales) { |
411 for (CodecSrc::DstColorType colorType : colorTypes) { | 427 for (CodecSrc::DstColorType colorType : colorTypes) { |
412 for (SkAlphaType alphaType : alphaModes) { | 428 for (SkAlphaType alphaType : alphaModes) { |
413 // Only test kCroppedScanline_Mode when the alpha type is op aque. The test is | 429 // Only test kCroppedScanline_Mode when the alpha type is op aque. The test is |
414 // slow and won't be interestingly different with different alpha types. | 430 // slow and won't be interestingly different with different alpha types. |
415 if (CodecSrc::kCroppedScanline_Mode == mode && | 431 if (CodecSrc::kCroppedScanline_Mode == mode && |
416 kOpaque_SkAlphaType != alphaType) { | 432 kOpaque_SkAlphaType != alphaType) { |
417 continue; | 433 continue; |
418 } | 434 } |
419 | 435 |
(...skipping 25 matching lines...) Expand all Loading... | |
445 for (SkAlphaType alphaType : alphaModes) { | 461 for (SkAlphaType alphaType : alphaModes) { |
446 push_android_codec_src(path, AndroidCodecSrc::kFullImage_Mode, c olorType, | 462 push_android_codec_src(path, AndroidCodecSrc::kFullImage_Mode, c olorType, |
447 alphaType, sampleSize); | 463 alphaType, sampleSize); |
448 if (subset) { | 464 if (subset) { |
449 push_android_codec_src(path, AndroidCodecSrc::kDivisor_Mode, colorType, | 465 push_android_codec_src(path, AndroidCodecSrc::kDivisor_Mode, colorType, |
450 alphaType, sampleSize); | 466 alphaType, sampleSize); |
451 } | 467 } |
452 } | 468 } |
453 } | 469 } |
454 } | 470 } |
471 | |
472 // Push image generator GPU test. | |
473 // FIXME: The gpu backend does not draw kGray sources correctly. (skbug.com/ 4822) | |
474 if (kGray_8_SkColorType != codec->getInfo().colorType()) { | |
475 push_image_gen_src(path, ImageGenSrc::kCodec_Mode, codec->getInfo().alph aType(), true); | |
476 } | |
477 | |
478 // Push image generator CPU tests. | |
479 for (SkAlphaType alphaType : alphaModes) { | |
480 push_image_gen_src(path, ImageGenSrc::kCodec_Mode, alphaType, false); | |
481 | |
482 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) | |
483 if (kWEBP_SkEncodedFormat != codec->getEncodedFormat() && | |
484 kWBMP_SkEncodedFormat != codec->getEncodedFormat() && | |
485 kUnpremul_SkAlphaType != alphaType) | |
486 { | |
487 push_image_gen_src(path, ImageGenSrc::kCG_Mode, alphaType, false); | |
488 } | |
489 #endif | |
490 } | |
455 } | 491 } |
456 | 492 |
457 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, | 493 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, |
458 CodecSrc::DstColorType dstColorType) { | 494 CodecSrc::DstColorType dstColorType) { |
459 switch (strategy) { | 495 switch (strategy) { |
460 case SkBitmapRegionDecoder::kCanvas_Strategy: | 496 case SkBitmapRegionDecoder::kCanvas_Strategy: |
461 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { | 497 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { |
462 return true; | 498 return true; |
463 } | 499 } |
464 return false; | 500 return false; |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1293 Reporter* reporter, | 1329 Reporter* reporter, |
1294 GrContextFactory* fac tory); | 1330 GrContextFactory* fac tory); |
1295 } // namespace skiatest | 1331 } // namespace skiatest |
1296 | 1332 |
1297 #if !defined(SK_BUILD_FOR_IOS) | 1333 #if !defined(SK_BUILD_FOR_IOS) |
1298 int main(int argc, char** argv) { | 1334 int main(int argc, char** argv) { |
1299 SkCommandLineFlags::Parse(argc, argv); | 1335 SkCommandLineFlags::Parse(argc, argv); |
1300 return dm_main(); | 1336 return dm_main(); |
1301 } | 1337 } |
1302 #endif | 1338 #endif |
OLD | NEW |