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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 break; | 235 break; |
236 case CodecSrc::kCodecZeroInit_Mode: | 236 case CodecSrc::kCodecZeroInit_Mode: |
237 folder.append("codec_zero_init"); | 237 folder.append("codec_zero_init"); |
238 break; | 238 break; |
239 case CodecSrc::kScanline_Mode: | 239 case CodecSrc::kScanline_Mode: |
240 folder.append("scanline"); | 240 folder.append("scanline"); |
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: |
| 246 folder.append("crop"); |
| 247 break; |
245 case CodecSrc::kSubset_Mode: | 248 case CodecSrc::kSubset_Mode: |
246 folder.append("codec_subset"); | 249 folder.append("codec_subset"); |
247 break; | 250 break; |
248 case CodecSrc::kGen_Mode: | 251 case CodecSrc::kGen_Mode: |
249 folder.append("gen"); | 252 folder.append("gen"); |
250 break; | 253 break; |
251 } | 254 } |
252 | 255 |
253 switch (dstColorType) { | 256 switch (dstColorType) { |
254 case CodecSrc::kGrayscale_Always_DstColorType: | 257 case CodecSrc::kGrayscale_Always_DstColorType: |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 SkDebugf("Couldn't create codec for %s.", path.c_str()); | 342 SkDebugf("Couldn't create codec for %s.", path.c_str()); |
340 return; | 343 return; |
341 } | 344 } |
342 | 345 |
343 // Native Scales | 346 // Native Scales |
344 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co
mpare with these | 347 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co
mpare with these |
345 // tests. SkImageDecoder supports downscales by integer fac
tors. | 348 // tests. SkImageDecoder supports downscales by integer fac
tors. |
346 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625,
0.75, 0.875 | 349 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625,
0.75, 0.875 |
347 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f,
0.875f, 1.0f }; | 350 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f,
0.875f, 1.0f }; |
348 | 351 |
349 const CodecSrc::Mode nativeModes[] = { CodecSrc::kCodec_Mode, CodecSrc::kCod
ecZeroInit_Mode, | 352 SkTArray<CodecSrc::Mode> nativeModes; |
350 CodecSrc::kScanline_Mode, CodecSrc::kStripe_Mode, CodecSrc::kSubset_
Mode, | 353 nativeModes.push_back(CodecSrc::kCodec_Mode); |
351 CodecSrc::kGen_Mode }; | 354 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode); |
| 355 nativeModes.push_back(CodecSrc::kGen_Mode); |
| 356 switch (codec->getEncodedFormat()) { |
| 357 case SkEncodedFormat::kJPEG_SkEncodedFormat: |
| 358 nativeModes.push_back(CodecSrc::kScanline_Mode); |
| 359 nativeModes.push_back(CodecSrc::kStripe_Mode); |
| 360 nativeModes.push_back(CodecSrc::kCroppedScanline_Mode); |
| 361 break; |
| 362 case SkEncodedFormat::kWEBP_SkEncodedFormat: |
| 363 nativeModes.push_back(CodecSrc::kSubset_Mode); |
| 364 break; |
| 365 default: |
| 366 nativeModes.push_back(CodecSrc::kScanline_Mode); |
| 367 nativeModes.push_back(CodecSrc::kStripe_Mode); |
| 368 break; |
| 369 } |
352 | 370 |
353 CodecSrc::DstColorType colorTypes[3]; | 371 SkTArray<CodecSrc::DstColorType> colorTypes; |
354 uint32_t numColorTypes; | 372 colorTypes.push_back(CodecSrc::kGetFromCanvas_DstColorType); |
355 switch (codec->getInfo().colorType()) { | 373 switch (codec->getInfo().colorType()) { |
356 case kGray_8_SkColorType: | 374 case kGray_8_SkColorType: |
357 colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType; | 375 colorTypes.push_back(CodecSrc::kGrayscale_Always_DstColorType); |
358 colorTypes[1] = CodecSrc::kGrayscale_Always_DstColorType; | |
359 if (kWBMP_SkEncodedFormat == codec->getEncodedFormat()) { | 376 if (kWBMP_SkEncodedFormat == codec->getEncodedFormat()) { |
360 colorTypes[2] = CodecSrc::kIndex8_Always_DstColorType; | 377 colorTypes.push_back(CodecSrc::kIndex8_Always_DstColorType); |
361 numColorTypes = 3; | |
362 } else { | |
363 numColorTypes = 2; | |
364 } | 378 } |
365 break; | 379 break; |
366 case kIndex_8_SkColorType: | 380 case kIndex_8_SkColorType: |
367 colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType; | 381 colorTypes.push_back(CodecSrc::kIndex8_Always_DstColorType); |
368 colorTypes[1] = CodecSrc::kIndex8_Always_DstColorType; | |
369 numColorTypes = 2; | |
370 break; | 382 break; |
371 default: | 383 default: |
372 colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType; | |
373 numColorTypes = 1; | |
374 break; | 384 break; |
375 } | 385 } |
376 | 386 |
377 SkTArray<SkAlphaType> alphaModes; | 387 SkTArray<SkAlphaType> alphaModes; |
378 alphaModes.push_back(kPremul_SkAlphaType); | 388 alphaModes.push_back(kPremul_SkAlphaType); |
379 alphaModes.push_back(kUnpremul_SkAlphaType); | 389 alphaModes.push_back(kUnpremul_SkAlphaType); |
380 if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) { | 390 if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) { |
381 alphaModes.push_back(kOpaque_SkAlphaType); | 391 alphaModes.push_back(kOpaque_SkAlphaType); |
382 } | 392 } |
383 | 393 |
384 for (CodecSrc::Mode mode : nativeModes) { | 394 for (CodecSrc::Mode mode : nativeModes) { |
385 // SkCodecImageGenerator only runs for the default colorType | 395 // SkCodecImageGenerator only runs for the default colorType |
386 // recommended by SkCodec. There is no need to generate multiple | 396 // recommended by SkCodec. There is no need to generate multiple |
387 // tests for different colorTypes. | 397 // tests for different colorTypes. |
388 // TODO (msarett): Add scaling support to SkCodecImageGenerator. | 398 // TODO (msarett): Add scaling support to SkCodecImageGenerator. |
389 if (CodecSrc::kGen_Mode == mode) { | 399 if (CodecSrc::kGen_Mode == mode) { |
390 // FIXME: The gpu backend does not draw kGray sources correctly. (sk
bug.com/4822) | 400 // FIXME: The gpu backend does not draw kGray sources correctly. (sk
bug.com/4822) |
391 if (kGray_8_SkColorType != codec->getInfo().colorType()) { | 401 if (kGray_8_SkColorType != codec->getInfo().colorType()) { |
392 push_codec_src(path, mode, CodecSrc::kGetFromCanvas_DstColorType
, | 402 push_codec_src(path, mode, CodecSrc::kGetFromCanvas_DstColorType
, |
393 codec->getInfo().alphaType(), 1.0f); | 403 codec->getInfo().alphaType(), 1.0f); |
394 } | 404 } |
395 continue; | 405 continue; |
396 } | 406 } |
397 | 407 |
398 for (float scale : nativeScales) { | 408 for (float scale : nativeScales) { |
399 for (uint32_t i = 0; i < numColorTypes; i++) { | 409 for (CodecSrc::DstColorType colorType : colorTypes) { |
400 for (SkAlphaType alphaType : alphaModes) { | 410 for (SkAlphaType alphaType : alphaModes) { |
401 push_codec_src(path, mode, colorTypes[i], alphaType, scale); | 411 // Only test kCroppedScanline_Mode when the alpha type is op
aque. The test is |
| 412 // slow and won't be interestingly different with different
alpha types. |
| 413 if (CodecSrc::kCroppedScanline_Mode == mode && |
| 414 kOpaque_SkAlphaType != alphaType) { |
| 415 continue; |
| 416 } |
| 417 |
| 418 push_codec_src(path, mode, colorType, alphaType, scale); |
402 } | 419 } |
403 } | 420 } |
404 } | 421 } |
405 } | 422 } |
406 | 423 |
407 // https://bug.skia.org/4428 | 424 // https://bug.skia.org/4428 |
408 bool subset = false; | 425 bool subset = false; |
409 // The following image types are supported by BitmapRegionDecoder, | 426 // The following image types are supported by BitmapRegionDecoder, |
410 // so we will test full image decodes and subset decodes. | 427 // so we will test full image decodes and subset decodes. |
411 static const char* const exts[] = { | 428 static const char* const exts[] = { |
412 "jpg", "jpeg", "png", "webp", | 429 "jpg", "jpeg", "png", "webp", |
413 "JPG", "JPEG", "PNG", "WEBP", | 430 "JPG", "JPEG", "PNG", "WEBP", |
414 }; | 431 }; |
415 for (const char* ext : exts) { | 432 for (const char* ext : exts) { |
416 if (path.endsWith(ext)) { | 433 if (path.endsWith(ext)) { |
417 subset = true; | 434 subset = true; |
418 break; | 435 break; |
419 } | 436 } |
420 } | 437 } |
421 | 438 |
422 const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | 439 const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
423 | 440 |
424 for (int sampleSize : sampleSizes) { | 441 for (int sampleSize : sampleSizes) { |
425 for (uint32_t i = 0; i < numColorTypes; i++) { | 442 for (CodecSrc::DstColorType colorType : colorTypes) { |
426 for (SkAlphaType alphaType : alphaModes) { | 443 for (SkAlphaType alphaType : alphaModes) { |
427 push_android_codec_src(path, AndroidCodecSrc::kFullImage_Mode, c
olorTypes[i], | 444 push_android_codec_src(path, AndroidCodecSrc::kFullImage_Mode, c
olorType, |
428 alphaType, sampleSize); | 445 alphaType, sampleSize); |
429 if (subset) { | 446 if (subset) { |
430 push_android_codec_src(path, AndroidCodecSrc::kDivisor_Mode,
colorTypes[i], | 447 push_android_codec_src(path, AndroidCodecSrc::kDivisor_Mode,
colorType, |
431 alphaType, sampleSize); | 448 alphaType, sampleSize); |
432 } | 449 } |
433 } | 450 } |
434 } | 451 } |
435 } | 452 } |
436 } | 453 } |
437 | 454 |
438 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, | 455 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, |
439 CodecSrc::DstColorType dstColorType) { | 456 CodecSrc::DstColorType dstColorType) { |
440 switch (strategy) { | 457 switch (strategy) { |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 Reporter* reporter, | 1291 Reporter* reporter, |
1275 GrContextFactory* fac
tory); | 1292 GrContextFactory* fac
tory); |
1276 } // namespace skiatest | 1293 } // namespace skiatest |
1277 | 1294 |
1278 #if !defined(SK_BUILD_FOR_IOS) | 1295 #if !defined(SK_BUILD_FOR_IOS) |
1279 int main(int argc, char** argv) { | 1296 int main(int argc, char** argv) { |
1280 SkCommandLineFlags::Parse(argc, argv); | 1297 SkCommandLineFlags::Parse(argc, argv); |
1281 return dm_main(); | 1298 return dm_main(); |
1282 } | 1299 } |
1283 #endif | 1300 #endif |
OLD | NEW |