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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 205 } |
206 } | 206 } |
207 | 207 |
208 static void push_codec_srcs(Path path) { | 208 static void push_codec_srcs(Path path) { |
209 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 209 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
210 if (!encoded) { | 210 if (!encoded) { |
211 SkDebugf("Couldn't read %s.", path.c_str()); | 211 SkDebugf("Couldn't read %s.", path.c_str()); |
212 return; | 212 return; |
213 } | 213 } |
214 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 214 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
215 if (NULL == codec.get()) { | 215 if (nullptr == codec.get()) { |
216 SkDebugf("Couldn't create codec for %s.", path.c_str()); | 216 SkDebugf("Couldn't create codec for %s.", path.c_str()); |
217 return; | 217 return; |
218 } | 218 } |
219 | 219 |
220 // Choose scales for scaling tests. | 220 // Choose scales for scaling tests. |
221 // TODO (msarett): Add more scaling tests as we implement more flexible scal
ing. | 221 // TODO (msarett): Add more scaling tests as we implement more flexible scal
ing. |
222 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co
mpare with these | 222 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co
mpare with these |
223 // tests. SkImageDecoder supports downscales by integer fac
tors. | 223 // tests. SkImageDecoder supports downscales by integer fac
tors. |
224 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625,
0.75, 0.875 | 224 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625,
0.75, 0.875 |
225 // 0.1, 0.16, 0.2 etc allow us to test SkScaledCodec with sampleSize 10, 6,
5, etc | 225 // 0.1, 0.16, 0.2 etc allow us to test SkScaledCodec with sampleSize 10, 6,
5, etc |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 if (FLAGS_cpu) { | 411 if (FLAGS_cpu) { |
412 SINK("565", RasterSink, kRGB_565_SkColorType); | 412 SINK("565", RasterSink, kRGB_565_SkColorType); |
413 SINK("8888", RasterSink, kN32_SkColorType); | 413 SINK("8888", RasterSink, kN32_SkColorType); |
414 SINK("pdf", PDFSink); | 414 SINK("pdf", PDFSink); |
415 SINK("skp", SKPSink); | 415 SINK("skp", SKPSink); |
416 SINK("svg", SVGSink); | 416 SINK("svg", SVGSink); |
417 SINK("null", NullSink); | 417 SINK("null", NullSink); |
418 SINK("xps", XPSSink); | 418 SINK("xps", XPSSink); |
419 } | 419 } |
420 #undef SINK | 420 #undef SINK |
421 return NULL; | 421 return nullptr; |
422 } | 422 } |
423 | 423 |
424 static Sink* create_via(const char* tag, Sink* wrapped) { | 424 static Sink* create_via(const char* tag, Sink* wrapped) { |
425 #define VIA(t, via, ...) if (0 == strcmp(t, tag)) { return new via(__VA_ARGS__);
} | 425 #define VIA(t, via, ...) if (0 == strcmp(t, tag)) { return new via(__VA_ARGS__);
} |
426 VIA("twice", ViaTwice, wrapped); | 426 VIA("twice", ViaTwice, wrapped); |
427 VIA("pipe", ViaPipe, wrapped); | 427 VIA("pipe", ViaPipe, wrapped); |
428 VIA("serialize", ViaSerialization, wrapped); | 428 VIA("serialize", ViaSerialization, wrapped); |
429 VIA("2ndpic", ViaSecondPicture, wrapped); | 429 VIA("2ndpic", ViaSecondPicture, wrapped); |
430 VIA("sp", ViaSingletonPictures, wrapped); | 430 VIA("sp", ViaSingletonPictures, wrapped); |
431 VIA("tiles", ViaTiles, 256, 256, NULL, wrapped); | 431 VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped); |
432 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped); | 432 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped); |
433 | 433 |
434 if (FLAGS_matrix.count() == 4) { | 434 if (FLAGS_matrix.count() == 4) { |
435 SkMatrix m; | 435 SkMatrix m; |
436 m.reset(); | 436 m.reset(); |
437 m.setScaleX((SkScalar)atof(FLAGS_matrix[0])); | 437 m.setScaleX((SkScalar)atof(FLAGS_matrix[0])); |
438 m.setSkewX ((SkScalar)atof(FLAGS_matrix[1])); | 438 m.setSkewX ((SkScalar)atof(FLAGS_matrix[1])); |
439 m.setSkewY ((SkScalar)atof(FLAGS_matrix[2])); | 439 m.setSkewY ((SkScalar)atof(FLAGS_matrix[2])); |
440 m.setScaleY((SkScalar)atof(FLAGS_matrix[3])); | 440 m.setScaleY((SkScalar)atof(FLAGS_matrix[3])); |
441 VIA("matrix", ViaMatrix, m, wrapped); | 441 VIA("matrix", ViaMatrix, m, wrapped); |
442 VIA("upright", ViaUpright, m, wrapped); | 442 VIA("upright", ViaUpright, m, wrapped); |
443 } | 443 } |
444 | 444 |
445 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 445 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
446 VIA("androidsdk", ViaAndroidSDK, wrapped); | 446 VIA("androidsdk", ViaAndroidSDK, wrapped); |
447 #endif | 447 #endif |
448 | 448 |
449 #undef VIA | 449 #undef VIA |
450 return NULL; | 450 return nullptr; |
451 } | 451 } |
452 | 452 |
453 static void gather_sinks() { | 453 static void gather_sinks() { |
454 for (int i = 0; i < FLAGS_config.count(); i++) { | 454 for (int i = 0; i < FLAGS_config.count(); i++) { |
455 const char* config = FLAGS_config[i]; | 455 const char* config = FLAGS_config[i]; |
456 SkTArray<SkString> parts; | 456 SkTArray<SkString> parts; |
457 SkStrSplit(config, "-", &parts); | 457 SkStrSplit(config, "-", &parts); |
458 | 458 |
459 Sink* sink = NULL; | 459 Sink* sink = nullptr; |
460 for (int i = parts.count(); i-- > 0;) { | 460 for (int i = parts.count(); i-- > 0;) { |
461 const char* part = parts[i].c_str(); | 461 const char* part = parts[i].c_str(); |
462 Sink* next = (sink == NULL) ? create_sink(part) : create_via(part, s
ink); | 462 Sink* next = (sink == nullptr) ? create_sink(part) : create_via(part
, sink); |
463 if (next == NULL) { | 463 if (next == nullptr) { |
464 SkDebugf("Skipping %s: Don't understand '%s'.\n", config, part); | 464 SkDebugf("Skipping %s: Don't understand '%s'.\n", config, part); |
465 delete sink; | 465 delete sink; |
466 sink = NULL; | 466 sink = nullptr; |
467 break; | 467 break; |
468 } | 468 } |
469 sink = next; | 469 sink = next; |
470 } | 470 } |
471 if (sink) { | 471 if (sink) { |
472 push_sink(config, sink); | 472 push_sink(config, sink); |
473 } | 473 } |
474 } | 474 } |
475 } | 475 } |
476 | 476 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 png_write_rows(png, &row, 1); | 532 png_write_rows(png, &row, 1); |
533 } | 533 } |
534 png_write_end(png, info); | 534 png_write_end(png, info); |
535 | 535 |
536 png_destroy_write_struct(&png, &info); | 536 png_destroy_write_struct(&png, &info); |
537 fclose(f); | 537 fclose(f); |
538 return true; | 538 return true; |
539 } | 539 } |
540 | 540 |
541 static bool match(const char* needle, const char* haystack) { | 541 static bool match(const char* needle, const char* haystack) { |
542 return 0 == strcmp("_", needle) || NULL != strstr(haystack, needle); | 542 return 0 == strcmp("_", needle) || nullptr != strstr(haystack, needle); |
543 } | 543 } |
544 | 544 |
545 static ImplicitString is_blacklisted(const char* sink, const char* src, | 545 static ImplicitString is_blacklisted(const char* sink, const char* src, |
546 const char* srcOptions, const char* name) { | 546 const char* srcOptions, const char* name) { |
547 for (int i = 0; i < FLAGS_blacklist.count() - 3; i += 4) { | 547 for (int i = 0; i < FLAGS_blacklist.count() - 3; i += 4) { |
548 if (match(FLAGS_blacklist[i+0], sink) && | 548 if (match(FLAGS_blacklist[i+0], sink) && |
549 match(FLAGS_blacklist[i+1], src) && | 549 match(FLAGS_blacklist[i+1], src) && |
550 match(FLAGS_blacklist[i+2], srcOptions) && | 550 match(FLAGS_blacklist[i+2], srcOptions) && |
551 match(FLAGS_blacklist[i+3], name)) { | 551 match(FLAGS_blacklist[i+3], name)) { |
552 return SkStringPrintf("%s %s %s %s", | 552 return SkStringPrintf("%s %s %s %s", |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 task->sink.tag, | 641 task->sink.tag, |
642 task->src.tag, | 642 task->src.tag, |
643 task->src.options, | 643 task->src.options, |
644 name.c_str(), | 644 name.c_str(), |
645 FLAGS_readPath[0])); | 645 FLAGS_readPath[0])); |
646 } | 646 } |
647 | 647 |
648 if (!FLAGS_writePath.isEmpty()) { | 648 if (!FLAGS_writePath.isEmpty()) { |
649 const char* ext = task->sink->fileExtension(); | 649 const char* ext = task->sink->fileExtension(); |
650 if (data->getLength()) { | 650 if (data->getLength()) { |
651 WriteToDisk(*task, md5, ext, data, data->getLength(), NULL); | 651 WriteToDisk(*task, md5, ext, data, data->getLength(), nullpt
r); |
652 SkASSERT(bitmap.drawsNothing()); | 652 SkASSERT(bitmap.drawsNothing()); |
653 } else if (!bitmap.drawsNothing()) { | 653 } else if (!bitmap.drawsNothing()) { |
654 WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); | 654 WriteToDisk(*task, md5, ext, nullptr, 0, &bitmap); |
655 } | 655 } |
656 } | 656 } |
657 } | 657 } |
658 timer.end(); | 658 timer.end(); |
659 done(timer.fWall, task->sink.tag, task->src.tag, task->src.options, name
, note, log); | 659 done(timer.fWall, task->sink.tag, task->src.tag, task->src.options, name
, note, log); |
660 } | 660 } |
661 | 661 |
662 static void WriteToDisk(const Task& task, | 662 static void WriteToDisk(const Task& task, |
663 SkString md5, | 663 SkString md5, |
664 const char* ext, | 664 const char* ext, |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 intentionallyLeaked->start(); | 831 intentionallyLeaked->start(); |
832 } | 832 } |
833 | 833 |
834 #define PORTABLE_FONT_PREFIX "Toy Liberation " | 834 #define PORTABLE_FONT_PREFIX "Toy Liberation " |
835 | 835 |
836 static SkTypeface* create_from_name(const char familyName[], SkTypeface::Style s
tyle) { | 836 static SkTypeface* create_from_name(const char familyName[], SkTypeface::Style s
tyle) { |
837 if (familyName && strlen(familyName) > sizeof(PORTABLE_FONT_PREFIX) | 837 if (familyName && strlen(familyName) > sizeof(PORTABLE_FONT_PREFIX) |
838 && !strncmp(familyName, PORTABLE_FONT_PREFIX, sizeof(PORTABLE_FONT_P
REFIX) - 1)) { | 838 && !strncmp(familyName, PORTABLE_FONT_PREFIX, sizeof(PORTABLE_FONT_P
REFIX) - 1)) { |
839 return sk_tool_utils::create_portable_typeface(familyName, style); | 839 return sk_tool_utils::create_portable_typeface(familyName, style); |
840 } | 840 } |
841 return NULL; | 841 return nullptr; |
842 } | 842 } |
843 | 843 |
844 #undef PORTABLE_FONT_PREFIX | 844 #undef PORTABLE_FONT_PREFIX |
845 | 845 |
846 extern SkTypeface* (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style )
; | 846 extern SkTypeface* (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style )
; |
847 | 847 |
848 int dm_main(); | 848 int dm_main(); |
849 int dm_main() { | 849 int dm_main() { |
850 SetupCrashHandler(); | 850 SetupCrashHandler(); |
851 SkAutoGraphics ag; | 851 SkAutoGraphics ag; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 } | 910 } |
911 return 0; | 911 return 0; |
912 } | 912 } |
913 | 913 |
914 #if !defined(SK_BUILD_FOR_IOS) | 914 #if !defined(SK_BUILD_FOR_IOS) |
915 int main(int argc, char** argv) { | 915 int main(int argc, char** argv) { |
916 SkCommandLineFlags::Parse(argc, argv); | 916 SkCommandLineFlags::Parse(argc, argv); |
917 return dm_main(); | 917 return dm_main(); |
918 } | 918 } |
919 #endif | 919 #endif |
OLD | NEW |