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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // compute their colors based on uninitialized values. | 320 // compute their colors based on uninitialized values. |
321 continue; | 321 continue; |
322 } | 322 } |
323 | 323 |
324 for (uint32_t i = 0; i < numColorTypes; i++) { | 324 for (uint32_t i = 0; i < numColorTypes; i++) { |
325 push_codec_src(path, CodecSrc::kScaledCodec_Mode, colorTypes[i], sca
le); | 325 push_codec_src(path, CodecSrc::kScaledCodec_Mode, colorTypes[i], sca
le); |
326 } | 326 } |
327 } | 327 } |
328 } | 328 } |
329 | 329 |
330 static bool codec_supported(const char* ext) { | 330 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, |
331 // FIXME: Once other versions of SkCodec are available, we can add them to t
his | 331 CodecSrc::DstColorType dstColorType) { |
332 // list (and eventually we can remove this check once they are all supported
). | 332 switch (strategy) { |
| 333 case SkBitmapRegionDecoder::kCanvas_Strategy: |
| 334 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { |
| 335 return true; |
| 336 } |
| 337 return false; |
| 338 case SkBitmapRegionDecoder::kOriginal_Strategy: |
| 339 switch (dstColorType) { |
| 340 case CodecSrc::kGetFromCanvas_DstColorType: |
| 341 case CodecSrc::kIndex8_Always_DstColorType: |
| 342 case CodecSrc::kGrayscale_Always_DstColorType: |
| 343 return true; |
| 344 default: |
| 345 return false; |
| 346 } |
| 347 default: |
| 348 SkASSERT(false); |
| 349 return false; |
| 350 } |
| 351 } |
| 352 |
| 353 static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy, |
| 354 CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleS
ize) { |
| 355 SkString folder; |
| 356 switch (strategy) { |
| 357 case SkBitmapRegionDecoder::kCanvas_Strategy: |
| 358 folder.append("brd_canvas"); |
| 359 break; |
| 360 case SkBitmapRegionDecoder::kOriginal_Strategy: |
| 361 folder.append("brd_sample"); |
| 362 break; |
| 363 default: |
| 364 SkASSERT(false); |
| 365 return; |
| 366 } |
| 367 |
| 368 switch (mode) { |
| 369 case BRDSrc::kFullImage_Mode: |
| 370 break; |
| 371 case BRDSrc::kDivisor_Mode: |
| 372 folder.append("_divisor"); |
| 373 break; |
| 374 default: |
| 375 SkASSERT(false); |
| 376 return; |
| 377 } |
| 378 |
| 379 switch (dstColorType) { |
| 380 case CodecSrc::kGetFromCanvas_DstColorType: |
| 381 break; |
| 382 case CodecSrc::kIndex8_Always_DstColorType: |
| 383 folder.append("_kIndex"); |
| 384 break; |
| 385 case CodecSrc::kGrayscale_Always_DstColorType: |
| 386 folder.append("_kGray"); |
| 387 break; |
| 388 default: |
| 389 SkASSERT(false); |
| 390 return; |
| 391 } |
| 392 |
| 393 if (1 != sampleSize) { |
| 394 folder.appendf("_%.3f", BRDSrc::GetScale(sampleSize)); |
| 395 } |
| 396 |
| 397 BRDSrc* src = new BRDSrc(path, strategy, mode, dstColorType, sampleSize); |
| 398 push_src("image", folder, src); |
| 399 } |
| 400 |
| 401 static void push_brd_srcs(Path path) { |
| 402 |
| 403 const SkBitmapRegionDecoder::Strategy strategies[] = { |
| 404 SkBitmapRegionDecoder::kCanvas_Strategy, |
| 405 SkBitmapRegionDecoder::kOriginal_Strategy |
| 406 }; |
| 407 |
| 408 // We will only test to one backend (8888), but we will test all of the |
| 409 // color types that we need to decode to on this backend. |
| 410 const CodecSrc::DstColorType dstColorTypes[] = { |
| 411 CodecSrc::kGetFromCanvas_DstColorType, |
| 412 CodecSrc::kIndex8_Always_DstColorType, |
| 413 CodecSrc::kGrayscale_Always_DstColorType, |
| 414 }; |
| 415 |
| 416 const BRDSrc::Mode modes[] = { |
| 417 BRDSrc::kFullImage_Mode, |
| 418 BRDSrc::kDivisor_Mode |
| 419 }; |
| 420 |
| 421 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 422 |
| 423 for (SkBitmapRegionDecoder::Strategy strategy : strategies) { |
| 424 for (CodecSrc::DstColorType dstColorType : dstColorTypes) { |
| 425 if (brd_color_type_supported(strategy, dstColorType)) { |
| 426 for (BRDSrc::Mode mode : modes) { |
| 427 for (uint32_t sampleSize : sampleSizes) { |
| 428 push_brd_src(path, strategy, dstColorType, mode, sampleS
ize); |
| 429 } |
| 430 } |
| 431 } |
| 432 } |
| 433 } |
| 434 } |
| 435 |
| 436 static bool brd_supported(const char* ext) { |
333 static const char* const exts[] = { | 437 static const char* const exts[] = { |
334 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp", | 438 "jpg", "jpeg", "png", "webp", |
335 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP", | 439 "JPG", "JPEG", "PNG", "WEBP", |
336 }; | 440 }; |
337 | 441 |
338 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 442 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
339 if (0 == strcmp(exts[i], ext)) { | 443 if (0 == strcmp(exts[i], ext)) { |
340 return true; | 444 return true; |
341 } | 445 } |
342 } | 446 } |
343 return false; | 447 return false; |
344 } | 448 } |
345 | 449 |
(...skipping 18 matching lines...) Expand all Loading... |
364 }; | 468 }; |
365 for (int i = 0; i < FLAGS_images.count(); i++) { | 469 for (int i = 0; i < FLAGS_images.count(); i++) { |
366 const char* flag = FLAGS_images[i]; | 470 const char* flag = FLAGS_images[i]; |
367 if (sk_isdir(flag)) { | 471 if (sk_isdir(flag)) { |
368 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { | 472 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |
369 SkOSFile::Iter it(flag, exts[j]); | 473 SkOSFile::Iter it(flag, exts[j]); |
370 for (SkString file; it.next(&file); ) { | 474 for (SkString file; it.next(&file); ) { |
371 SkString path = SkOSPath::Join(flag, file.c_str()); | 475 SkString path = SkOSPath::Join(flag, file.c_str()); |
372 push_src("image", "decode", new ImageSrc(path)); // Decode e
ntire image | 476 push_src("image", "decode", new ImageSrc(path)); // Decode e
ntire image |
373 push_src("image", "subset", new ImageSrc(path, 2)); // Decod
e into 2x2 subsets | 477 push_src("image", "subset", new ImageSrc(path, 2)); // Decod
e into 2x2 subsets |
374 if (codec_supported(exts[j])) { | 478 push_codec_srcs(path); |
375 push_codec_srcs(path); | 479 if (brd_supported(exts[j])) { |
| 480 push_brd_srcs(path); |
376 } | 481 } |
377 } | 482 } |
378 } | 483 } |
379 } else if (sk_exists(flag)) { | 484 } else if (sk_exists(flag)) { |
380 // assume that FLAGS_images[i] is a valid image if it is a file. | 485 // assume that FLAGS_images[i] is a valid image if it is a file. |
381 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
age. | 486 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
age. |
382 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2
x 2 subsets | 487 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2
x 2 subsets |
383 push_codec_srcs(flag); | 488 push_codec_srcs(flag); |
| 489 push_brd_srcs(flag); |
384 } | 490 } |
385 } | 491 } |
386 } | 492 } |
387 | 493 |
388 static GrGLStandard get_gpu_api() { | 494 static GrGLStandard get_gpu_api() { |
389 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 495 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
390 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 496 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
391 return kNone_GrGLStandard; | 497 return kNone_GrGLStandard; |
392 } | 498 } |
393 | 499 |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 } | 1065 } |
960 return 0; | 1066 return 0; |
961 } | 1067 } |
962 | 1068 |
963 #if !defined(SK_BUILD_FOR_IOS) | 1069 #if !defined(SK_BUILD_FOR_IOS) |
964 int main(int argc, char** argv) { | 1070 int main(int argc, char** argv) { |
965 SkCommandLineFlags::Parse(argc, argv); | 1071 SkCommandLineFlags::Parse(argc, argv); |
966 return dm_main(); | 1072 return dm_main(); |
967 } | 1073 } |
968 #endif | 1074 #endif |
OLD | NEW |