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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 "this list, no image is written for that result."); | 66 "this list, no image is written for that result."); |
67 | 67 |
68 DEFINE_int32(shards, 1, "We're splitting source data into this many shards."); | 68 DEFINE_int32(shards, 1, "We're splitting source data into this many shards."); |
69 DEFINE_int32(shard, 0, "Which shard do I run?"); | 69 DEFINE_int32(shard, 0, "Which shard do I run?"); |
70 DEFINE_bool(simpleCodec, false, "Only decode images to native scale"); | 70 DEFINE_bool(simpleCodec, false, "Only decode images to native scale"); |
71 | 71 |
72 using namespace DM; | 72 using namespace DM; |
73 | 73 |
74 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 74 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
75 | 75 |
| 76 static const SkMSec kStartMs = SkTime::GetMSecs(); |
| 77 |
| 78 static FILE* gVLog; |
| 79 |
| 80 template <typename... Args> |
| 81 static void vlog(const char* fmt, Args&&... args) { |
| 82 if (gVLog) { |
| 83 fprintf(gVLog, "%s\t", HumanizeMs(SkTime::GetMSecs() - kStartMs).c_str()
); |
| 84 fprintf(gVLog, fmt, args...); |
| 85 fflush(gVLog); |
| 86 } |
| 87 } |
| 88 |
| 89 template <typename... Args> |
| 90 static void info(const char* fmt, Args&&... args) { |
| 91 vlog(fmt, args...); |
| 92 if (!FLAGS_quiet) { |
| 93 printf(fmt, args...); |
| 94 } |
| 95 } |
| 96 static void info(const char* fmt) { |
| 97 if (!FLAGS_quiet) { |
| 98 printf("%s", fmt); // Clang warns printf(fmt) is insecure. |
| 99 } |
| 100 } |
| 101 |
76 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); | 102 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); |
77 static SkTArray<SkString> gFailures; | 103 static SkTArray<SkString> gFailures; |
78 | 104 |
79 static void fail(const SkString& err) { | 105 static void fail(const SkString& err) { |
80 SkAutoMutexAcquire lock(gFailuresMutex); | 106 SkAutoMutexAcquire lock(gFailuresMutex); |
81 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); | 107 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); |
82 gFailures.push_back(err); | 108 gFailures.push_back(err); |
83 } | 109 } |
84 | 110 |
85 | 111 |
86 // We use a spinlock to make locking this in a signal handler _somewhat_ safe. | 112 // We use a spinlock to make locking this in a signal handler _somewhat_ safe. |
87 static SkSpinlock gMutex; | 113 static SkSpinlock gMutex; |
88 static int32_t gPending; | 114 static int32_t gPending; |
89 static SkTArray<SkString> gRunning; | 115 static SkTArray<SkString> gRunning; |
90 | 116 |
91 static void done(const char* config, const char* src, const char* srcOptions, co
nst char* name) { | 117 static void done(const char* config, const char* src, const char* srcOptions, co
nst char* name) { |
92 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name); | 118 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name); |
| 119 vlog("done %s\n", id.c_str()); |
93 int pending; | 120 int pending; |
94 { | 121 { |
95 SkAutoTAcquire<SkSpinlock> lock(gMutex); | 122 SkAutoTAcquire<SkSpinlock> lock(gMutex); |
96 for (int i = 0; i < gRunning.count(); i++) { | 123 for (int i = 0; i < gRunning.count(); i++) { |
97 if (gRunning[i] == id) { | 124 if (gRunning[i] == id) { |
98 gRunning.removeShuffle(i); | 125 gRunning.removeShuffle(i); |
99 break; | 126 break; |
100 } | 127 } |
101 } | 128 } |
102 pending = --gPending; | 129 pending = --gPending; |
103 } | 130 } |
104 // We write our dm.json file every once in a while in case we crash. | 131 // We write our dm.json file every once in a while in case we crash. |
105 // Notice this also handles the final dm.json when pending == 0. | 132 // Notice this also handles the final dm.json when pending == 0. |
106 if (pending % 500 == 0) { | 133 if (pending % 500 == 0) { |
107 JsonWriter::DumpJson(); | 134 JsonWriter::DumpJson(); |
108 } | 135 } |
109 } | 136 } |
110 | 137 |
111 static void start(const char* config, const char* src, const char* srcOptions, c
onst char* name) { | 138 static void start(const char* config, const char* src, const char* srcOptions, c
onst char* name) { |
112 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name); | 139 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name); |
| 140 vlog("start %s\n", id.c_str()); |
113 SkAutoTAcquire<SkSpinlock> lock(gMutex); | 141 SkAutoTAcquire<SkSpinlock> lock(gMutex); |
114 gRunning.push_back(id); | 142 gRunning.push_back(id); |
115 } | 143 } |
116 | 144 |
117 static void print_status() { | 145 static void print_status() { |
118 static SkMSec start_ms = SkTime::GetMSecs(); | |
119 | |
120 int curr = sk_tools::getCurrResidentSetSizeMB(), | 146 int curr = sk_tools::getCurrResidentSetSizeMB(), |
121 peak = sk_tools::getMaxResidentSetSizeMB(); | 147 peak = sk_tools::getMaxResidentSetSizeMB(); |
122 SkString elapsed = HumanizeMs(SkTime::GetMSecs() - start_ms); | 148 SkString elapsed = HumanizeMs(SkTime::GetMSecs() - kStartMs); |
123 | 149 |
124 SkAutoTAcquire<SkSpinlock> lock(gMutex); | 150 SkAutoTAcquire<SkSpinlock> lock(gMutex); |
125 SkDebugf("\n%s elapsed, %d active, %d queued, %dMB RAM, %dMB peak\n", | 151 info("\n%s elapsed, %d active, %d queued, %dMB RAM, %dMB peak\n", |
126 elapsed.c_str(), gRunning.count(), gPending - gRunning.count(), cur
r, peak); | 152 elapsed.c_str(), gRunning.count(), gPending - gRunning.count(), curr, p
eak); |
127 for (auto& task : gRunning) { | 153 for (auto& task : gRunning) { |
128 SkDebugf("\t%s\n", task.c_str()); | 154 info("\t%s\n", task.c_str()); |
129 } | 155 } |
130 } | 156 } |
131 | 157 |
132 // Yo dawg, I heard you like signals so I caught a signal in your | 158 // Yo dawg, I heard you like signals so I caught a signal in your |
133 // signal handler so you can handle signals while you handle signals. | 159 // signal handler so you can handle signals while you handle signals. |
134 // Let's not get into that situation. Only print if we're the first ones to get
a crash signal. | 160 // Let's not get into that situation. Only print if we're the first ones to get
a crash signal. |
135 static std::atomic<bool> in_signal_handler{false}; | 161 static std::atomic<bool> in_signal_handler{false}; |
136 | 162 |
137 #if defined(SK_BUILD_FOR_WIN32) | 163 #if defined(SK_BUILD_FOR_WIN32) |
138 static LONG WINAPI handler(EXCEPTION_POINTERS* e) { | 164 static LONG WINAPI handler(EXCEPTION_POINTERS* e) { |
139 static const struct { | 165 static const struct { |
140 const char* name; | 166 const char* name; |
141 DWORD code; | 167 DWORD code; |
142 } kExceptions[] = { | 168 } kExceptions[] = { |
143 #define _(E) {#E, E} | 169 #define _(E) {#E, E} |
144 _(EXCEPTION_ACCESS_VIOLATION), | 170 _(EXCEPTION_ACCESS_VIOLATION), |
145 _(EXCEPTION_BREAKPOINT), | 171 _(EXCEPTION_BREAKPOINT), |
146 _(EXCEPTION_INT_DIVIDE_BY_ZERO), | 172 _(EXCEPTION_INT_DIVIDE_BY_ZERO), |
147 _(EXCEPTION_STACK_OVERFLOW), | 173 _(EXCEPTION_STACK_OVERFLOW), |
148 // TODO: more? | 174 // TODO: more? |
149 #undef _ | 175 #undef _ |
150 }; | 176 }; |
151 | 177 |
152 if (!in_signal_handler.exchange(true)) { | 178 if (!in_signal_handler.exchange(true)) { |
153 const DWORD code = e->ExceptionRecord->ExceptionCode; | 179 const DWORD code = e->ExceptionRecord->ExceptionCode; |
154 SkDebugf("\nCaught exception %u", code); | 180 info("\nCaught exception %u", code); |
155 for (const auto& exception : kExceptions) { | 181 for (const auto& exception : kExceptions) { |
156 if (exception.code == code) { | 182 if (exception.code == code) { |
157 SkDebugf(" %s", exception.name); | 183 info(" %s", exception.name); |
158 } | 184 } |
159 } | 185 } |
160 SkDebugf("\n"); | 186 info("\n"); |
161 print_status(); | 187 print_status(); |
162 } | 188 } |
163 // Execute default exception handler... hopefully, exit. | 189 // Execute default exception handler... hopefully, exit. |
164 return EXCEPTION_EXECUTE_HANDLER; | 190 return EXCEPTION_EXECUTE_HANDLER; |
165 } | 191 } |
166 static void setup_crash_handler() { SetUnhandledExceptionFilter(handler); } | 192 static void setup_crash_handler() { SetUnhandledExceptionFilter(handler); } |
167 | 193 |
168 #elif !defined(SK_BUILD_FOR_ANDROID) | 194 #elif !defined(SK_BUILD_FOR_ANDROID) |
169 #include <execinfo.h> | 195 #include <execinfo.h> |
170 #include <signal.h> | 196 #include <signal.h> |
171 #include <stdlib.h> | 197 #include <stdlib.h> |
172 | 198 |
173 static void setup_crash_handler() { | 199 static void setup_crash_handler() { |
174 const int kSignals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV }; | 200 const int kSignals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV }; |
175 for (int sig : kSignals) { | 201 for (int sig : kSignals) { |
176 signal(sig, [](int sig) { | 202 signal(sig, [](int sig) { |
177 if (!in_signal_handler.exchange(true)) { | 203 if (!in_signal_handler.exchange(true)) { |
178 SkAutoTAcquire<SkSpinlock> lock(gMutex); | 204 SkAutoTAcquire<SkSpinlock> lock(gMutex); |
179 SkDebugf("\nCaught signal %d [%s], was running:\n", sig, str
signal(sig)); | 205 info("\nCaught signal %d [%s], was running:\n", sig, strsign
al(sig)); |
180 for (auto& task : gRunning) { | 206 for (auto& task : gRunning) { |
181 SkDebugf("\t%s\n", task.c_str()); | 207 info("\t%s\n", task.c_str()); |
182 } | 208 } |
183 | 209 |
184 void* stack[64]; | 210 void* stack[64]; |
185 int count = backtrace(stack, SK_ARRAY_COUNT(stack)); | 211 int count = backtrace(stack, SK_ARRAY_COUNT(stack)); |
186 char** symbols = backtrace_symbols(stack, count); | 212 char** symbols = backtrace_symbols(stack, count); |
187 SkDebugf("\nStack trace:\n"); | 213 info("\nStack trace:\n"); |
188 for (int i = 0; i < count; i++) { | 214 for (int i = 0; i < count; i++) { |
189 SkDebugf(" %s\n", symbols[i]); | 215 info(" %s\n", symbols[i]); |
190 } | 216 } |
191 } | 217 } |
192 _Exit(sig); | 218 _Exit(sig); |
193 }); | 219 }); |
194 } | 220 } |
195 } | 221 } |
196 | 222 |
197 #else // Android | 223 #else // Android |
198 static void setup_crash_handler() {} | 224 static void setup_crash_handler() {} |
199 #endif | 225 #endif |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 261 } |
236 | 262 |
237 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 263 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
238 | 264 |
239 static SkTHashSet<SkString> gUninterestingHashes; | 265 static SkTHashSet<SkString> gUninterestingHashes; |
240 | 266 |
241 static void gather_uninteresting_hashes() { | 267 static void gather_uninteresting_hashes() { |
242 if (!FLAGS_uninterestingHashesFile.isEmpty()) { | 268 if (!FLAGS_uninterestingHashesFile.isEmpty()) { |
243 SkAutoTUnref<SkData> data(SkData::NewFromFileName(FLAGS_uninterestingHas
hesFile[0])); | 269 SkAutoTUnref<SkData> data(SkData::NewFromFileName(FLAGS_uninterestingHas
hesFile[0])); |
244 if (!data) { | 270 if (!data) { |
245 SkDebugf("WARNING: unable to read uninteresting hashes from %s\n", | 271 info("WARNING: unable to read uninteresting hashes from %s\n", |
246 FLAGS_uninterestingHashesFile[0]); | 272 FLAGS_uninterestingHashesFile[0]); |
247 return; | 273 return; |
248 } | 274 } |
249 SkTArray<SkString> hashes; | 275 SkTArray<SkString> hashes; |
250 SkStrSplit((const char*)data->data(), "\n", &hashes); | 276 SkStrSplit((const char*)data->data(), "\n", &hashes); |
251 for (const SkString& hash : hashes) { | 277 for (const SkString& hash : hashes) { |
252 gUninterestingHashes.add(hash); | 278 gUninterestingHashes.add(hash); |
253 } | 279 } |
254 SkDebugf("FYI: loaded %d distinct uninteresting hashes from %d lines\n", | 280 info("FYI: loaded %d distinct uninteresting hashes from %d lines\n", |
255 gUninterestingHashes.count(), hashes.count()); | 281 gUninterestingHashes.count(), hashes.count()); |
256 } | 282 } |
257 } | 283 } |
258 | 284 |
259 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 285 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
260 | 286 |
261 struct TaggedSrc : public SkAutoTDelete<Src> { | 287 struct TaggedSrc : public SkAutoTDelete<Src> { |
262 SkString tag; | 288 SkString tag; |
263 SkString options; | 289 SkString options; |
264 }; | 290 }; |
265 | 291 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 folder.appendf("_%.3f", 1.0f / (float) sampleSize); | 422 folder.appendf("_%.3f", 1.0f / (float) sampleSize); |
397 } | 423 } |
398 | 424 |
399 AndroidCodecSrc* src = new AndroidCodecSrc(path, mode, dstColorType, dstAlph
aType, sampleSize); | 425 AndroidCodecSrc* src = new AndroidCodecSrc(path, mode, dstColorType, dstAlph
aType, sampleSize); |
400 push_src("image", folder, src); | 426 push_src("image", folder, src); |
401 } | 427 } |
402 | 428 |
403 static void push_codec_srcs(Path path) { | 429 static void push_codec_srcs(Path path) { |
404 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 430 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
405 if (!encoded) { | 431 if (!encoded) { |
406 SkDebugf("Couldn't read %s.", path.c_str()); | 432 info("Couldn't read %s.", path.c_str()); |
407 return; | 433 return; |
408 } | 434 } |
409 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 435 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
410 if (nullptr == codec.get()) { | 436 if (nullptr == codec.get()) { |
411 SkDebugf("Couldn't create codec for %s.", path.c_str()); | 437 info("Couldn't create codec for %s.", path.c_str()); |
412 return; | 438 return; |
413 } | 439 } |
414 | 440 |
415 // Native Scales | 441 // Native Scales |
416 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625,
0.75, 0.875 | 442 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625,
0.75, 0.875 |
417 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f,
0.875f, 1.0f }; | 443 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f,
0.875f, 1.0f }; |
418 | 444 |
419 SkTArray<CodecSrc::Mode> nativeModes; | 445 SkTArray<CodecSrc::Mode> nativeModes; |
420 nativeModes.push_back(CodecSrc::kCodec_Mode); | 446 nativeModes.push_back(CodecSrc::kCodec_Mode); |
421 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode); | 447 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 } | 723 } |
698 SkISize size() const override { return SkISize::Make(16, 16); } | 724 SkISize size() const override { return SkISize::Make(16, 16); } |
699 Name name() const override { return "justOneRect"; } | 725 Name name() const override { return "justOneRect"; } |
700 } justOneRect; | 726 } justOneRect; |
701 | 727 |
702 SkBitmap bitmap; | 728 SkBitmap bitmap; |
703 SkDynamicMemoryWStream stream; | 729 SkDynamicMemoryWStream stream; |
704 SkString log; | 730 SkString log; |
705 Error err = sink->draw(justOneRect, &bitmap, &stream, &log); | 731 Error err = sink->draw(justOneRect, &bitmap, &stream, &log); |
706 if (err.isFatal()) { | 732 if (err.isFatal()) { |
707 SkDebugf("Could not run %s: %s\n", config.getTag().c_str(), err.c_str())
; | 733 info("Could not run %s: %s\n", config.getTag().c_str(), err.c_str()); |
708 exit(1); | 734 exit(1); |
709 } | 735 } |
710 | 736 |
711 TaggedSink& ts = gSinks.push_back(); | 737 TaggedSink& ts = gSinks.push_back(); |
712 ts.reset(sink.detach()); | 738 ts.reset(sink.detach()); |
713 ts.tag = config.getTag(); | 739 ts.tag = config.getTag(); |
714 } | 740 } |
715 | 741 |
716 static bool gpu_supported() { | 742 static bool gpu_supported() { |
717 #if SK_SUPPORT_GPU | 743 #if SK_SUPPORT_GPU |
718 return FLAGS_gpu; | 744 return FLAGS_gpu; |
719 #else | 745 #else |
720 return false; | 746 return false; |
721 #endif | 747 #endif |
722 } | 748 } |
723 | 749 |
724 static Sink* create_sink(const SkCommandLineConfig* config) { | 750 static Sink* create_sink(const SkCommandLineConfig* config) { |
725 #if SK_SUPPORT_GPU | 751 #if SK_SUPPORT_GPU |
726 if (gpu_supported()) { | 752 if (gpu_supported()) { |
727 if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) { | 753 if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) { |
728 GrContextFactory::GLContextType contextType = gpuConfig->getContextT
ype(); | 754 GrContextFactory::GLContextType contextType = gpuConfig->getContextT
ype(); |
729 GrContextFactory::GLContextOptions contextOptions = | 755 GrContextFactory::GLContextOptions contextOptions = |
730 GrContextFactory::kNone_GLContextOptions; | 756 GrContextFactory::kNone_GLContextOptions; |
731 if (gpuConfig->getUseNVPR()) { | 757 if (gpuConfig->getUseNVPR()) { |
732 contextOptions = static_cast<GrContextFactory::GLContextOptions>
( | 758 contextOptions = static_cast<GrContextFactory::GLContextOptions>
( |
733 contextOptions | GrContextFactory::kEnableNVPR_GLContextOpti
ons); | 759 contextOptions | GrContextFactory::kEnableNVPR_GLContextOpti
ons); |
734 } | 760 } |
735 GrContextFactory testFactory; | 761 GrContextFactory testFactory; |
736 if (!testFactory.get(contextType, contextOptions)) { | 762 if (!testFactory.get(contextType, contextOptions)) { |
737 SkDebugf("WARNING: can not create GPU context for config '%s'. " | 763 info("WARNING: can not create GPU context for config '%s'. " |
738 "GM tests will be skipped.\n", gpuConfig->getTag().c_st
r()); | 764 "GM tests will be skipped.\n", gpuConfig->getTag().c_str())
; |
739 return nullptr; | 765 return nullptr; |
740 } | 766 } |
741 return new GPUSink(contextType, contextOptions, gpuConfig->getSample
s(), | 767 return new GPUSink(contextType, contextOptions, gpuConfig->getSample
s(), |
742 gpuConfig->getUseDIText(), FLAGS_gpu_threading); | 768 gpuConfig->getUseDIText(), FLAGS_gpu_threading); |
743 } | 769 } |
744 } | 770 } |
745 #endif | 771 #endif |
746 | 772 |
747 #define SINK(t, sink, ...) if (config->getBackend().equals(t)) { return new sink
(__VA_ARGS__); } | 773 #define SINK(t, sink, ...) if (config->getBackend().equals(t)) { return new sink
(__VA_ARGS__); } |
748 | 774 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 return nullptr; | 822 return nullptr; |
797 } | 823 } |
798 | 824 |
799 static void gather_sinks() { | 825 static void gather_sinks() { |
800 SkCommandLineConfigArray configs; | 826 SkCommandLineConfigArray configs; |
801 ParseConfigs(FLAGS_config, &configs); | 827 ParseConfigs(FLAGS_config, &configs); |
802 for (int i = 0; i < configs.count(); i++) { | 828 for (int i = 0; i < configs.count(); i++) { |
803 const SkCommandLineConfig& config = *configs[i]; | 829 const SkCommandLineConfig& config = *configs[i]; |
804 Sink* sink = create_sink(&config); | 830 Sink* sink = create_sink(&config); |
805 if (sink == nullptr) { | 831 if (sink == nullptr) { |
806 SkDebugf("Skipping config %s: Don't understand '%s'.\n", config.getT
ag().c_str(), | 832 info("Skipping config %s: Don't understand '%s'.\n", config.getTag()
.c_str(), |
807 config.getTag().c_str()); | 833 config.getTag().c_str()); |
808 continue; | 834 continue; |
809 } | 835 } |
810 | 836 |
811 const SkTArray<SkString>& parts = config.getViaParts(); | 837 const SkTArray<SkString>& parts = config.getViaParts(); |
812 for (int j = parts.count(); j-- > 0;) { | 838 for (int j = parts.count(); j-- > 0;) { |
813 const SkString& part = parts[j]; | 839 const SkString& part = parts[j]; |
814 Sink* next = create_via(part, sink); | 840 Sink* next = create_via(part, sink); |
815 if (next == nullptr) { | 841 if (next == nullptr) { |
816 SkDebugf("Skipping config %s: Don't understand '%s'.\n", config.
getTag().c_str(), | 842 info("Skipping config %s: Don't understand '%s'.\n", config.getT
ag().c_str(), |
817 part.c_str()); | 843 part.c_str()); |
818 delete sink; | 844 delete sink; |
819 sink = nullptr; | 845 sink = nullptr; |
820 break; | 846 break; |
821 } | 847 } |
822 sink = next; | 848 sink = next; |
823 } | 849 } |
824 if (sink) { | 850 if (sink) { |
825 push_sink(config, sink); | 851 push_sink(config, sink); |
826 } | 852 } |
827 } | 853 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 SkString name = task.src->name(); | 1005 SkString name = task.src->name(); |
980 | 1006 |
981 SkString log; | 1007 SkString log; |
982 if (!FLAGS_dryRun) { | 1008 if (!FLAGS_dryRun) { |
983 SkBitmap bitmap; | 1009 SkBitmap bitmap; |
984 SkDynamicMemoryWStream stream; | 1010 SkDynamicMemoryWStream stream; |
985 start(task.sink.tag.c_str(), task.src.tag.c_str(), | 1011 start(task.sink.tag.c_str(), task.src.tag.c_str(), |
986 task.src.options.c_str(), name.c_str()); | 1012 task.src.options.c_str(), name.c_str()); |
987 Error err = task.sink->draw(*task.src, &bitmap, &stream, &log); | 1013 Error err = task.sink->draw(*task.src, &bitmap, &stream, &log); |
988 if (!log.isEmpty()) { | 1014 if (!log.isEmpty()) { |
989 SkDebugf("%s %s %s %s:\n%s\n", task.sink.tag.c_str() | 1015 info("%s %s %s %s:\n%s\n", task.sink.tag.c_str() |
990 , task.src.tag.c_str() | 1016 , task.src.tag.c_str() |
991 , task.src.options.c_str() | 1017 , task.src.options.c_str() |
992 , name.c_str() | 1018 , name.c_str() |
993 , log.c_str()); | 1019 , log.c_str()); |
994 } | 1020 } |
995 if (!err.isEmpty()) { | 1021 if (!err.isEmpty()) { |
996 if (err.isFatal()) { | 1022 if (err.isFatal()) { |
997 fail(SkStringPrintf("%s %s %s %s: %s", | 1023 fail(SkStringPrintf("%s %s %s %s: %s", |
998 task.sink.tag.c_str(), | 1024 task.sink.tag.c_str(), |
999 task.src.tag.c_str(), | 1025 task.src.tag.c_str(), |
1000 task.src.options.c_str(), | 1026 task.src.options.c_str(), |
1001 name.c_str(), | 1027 name.c_str(), |
1002 err.c_str())); | 1028 err.c_str())); |
1003 } else { | 1029 } else { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 } | 1245 } |
1220 | 1246 |
1221 #undef PORTABLE_FONT_PREFIX | 1247 #undef PORTABLE_FONT_PREFIX |
1222 | 1248 |
1223 extern SkTypeface* (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style )
; | 1249 extern SkTypeface* (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style )
; |
1224 | 1250 |
1225 int dm_main(); | 1251 int dm_main(); |
1226 int dm_main() { | 1252 int dm_main() { |
1227 setup_crash_handler(); | 1253 setup_crash_handler(); |
1228 | 1254 |
| 1255 if (FLAGS_verbose && !FLAGS_writePath.isEmpty()) { |
| 1256 sk_mkdir(FLAGS_writePath[0]); |
| 1257 gVLog = freopen(SkOSPath::Join(FLAGS_writePath[0], "verbose.log").c_str(
), "w", stderr); |
| 1258 } |
| 1259 |
1229 JsonWriter::DumpJson(); // It's handy for the bots to assume this is ~never
missing. | 1260 JsonWriter::DumpJson(); // It's handy for the bots to assume this is ~never
missing. |
1230 SkAutoGraphics ag; | 1261 SkAutoGraphics ag; |
1231 SkTaskGroup::Enabler enabled(FLAGS_threads); | 1262 SkTaskGroup::Enabler enabled(FLAGS_threads); |
1232 gCreateTypefaceDelegate = &create_from_name; | 1263 gCreateTypefaceDelegate = &create_from_name; |
1233 | 1264 |
1234 { | 1265 { |
1235 SkString testResourcePath = GetResourcePath("color_wheel.png"); | 1266 SkString testResourcePath = GetResourcePath("color_wheel.png"); |
1236 SkFILEStream testResource(testResourcePath.c_str()); | 1267 SkFILEStream testResource(testResourcePath.c_str()); |
1237 if (!testResource.isValid()) { | 1268 if (!testResource.isValid()) { |
1238 SkDebugf("Some resources are missing. Do you need to set --resource
Path?\n"); | 1269 info("Some resources are missing. Do you need to set --resourcePath
?\n"); |
1239 } | 1270 } |
1240 } | 1271 } |
1241 gather_gold(); | 1272 gather_gold(); |
1242 gather_uninteresting_hashes(); | 1273 gather_uninteresting_hashes(); |
1243 | 1274 |
1244 if (!gather_srcs()) { | 1275 if (!gather_srcs()) { |
1245 return 1; | 1276 return 1; |
1246 } | 1277 } |
1247 gather_sinks(); | 1278 gather_sinks(); |
1248 gather_tests(); | 1279 gather_tests(); |
1249 | 1280 |
1250 gPending = gSrcs.count() * gSinks.count() + gParallelTests.count() + gSerial
Tests.count(); | 1281 gPending = gSrcs.count() * gSinks.count() + gParallelTests.count() + gSerial
Tests.count(); |
1251 SkDebugf("%d srcs * %d sinks + %d tests == %d tasks", | 1282 info("%d srcs * %d sinks + %d tests == %d tasks", |
1252 gSrcs.count(), gSinks.count(), gParallelTests.count() + gSerialTest
s.count(), gPending); | 1283 gSrcs.count(), gSinks.count(), gParallelTests.count() + gSerialTests.co
unt(), gPending); |
1253 SkAutoTDelete<SkThread> statusThread(start_status_thread()); | 1284 SkAutoTDelete<SkThread> statusThread(start_status_thread()); |
1254 | 1285 |
1255 // Kick off as much parallel work as we can, making note of any serial work
we'll need to do. | 1286 // Kick off as much parallel work as we can, making note of any serial work
we'll need to do. |
1256 SkTaskGroup parallel; | 1287 SkTaskGroup parallel; |
1257 SkTArray<Task> serial; | 1288 SkTArray<Task> serial; |
1258 | 1289 |
1259 for (auto& sink : gSinks) | 1290 for (auto& sink : gSinks) |
1260 for (auto& src : gSrcs) { | 1291 for (auto& src : gSrcs) { |
1261 if (src->veto(sink->flags()) || | 1292 if (src->veto(sink->flags()) || |
1262 is_blacklisted(sink.tag.c_str(), src.tag.c_str(), | 1293 is_blacklisted(sink.tag.c_str(), src.tag.c_str(), |
(...skipping 24 matching lines...) Expand all Loading... |
1287 | 1318 |
1288 // We'd better have run everything. | 1319 // We'd better have run everything. |
1289 SkASSERT(gPending == 0); | 1320 SkASSERT(gPending == 0); |
1290 // Make sure we've flushed all our results to disk. | 1321 // Make sure we've flushed all our results to disk. |
1291 JsonWriter::DumpJson(); | 1322 JsonWriter::DumpJson(); |
1292 | 1323 |
1293 // At this point we're back in single-threaded land. | 1324 // At this point we're back in single-threaded land. |
1294 sk_tool_utils::release_portable_typefaces(); | 1325 sk_tool_utils::release_portable_typefaces(); |
1295 | 1326 |
1296 if (gFailures.count() > 0) { | 1327 if (gFailures.count() > 0) { |
1297 SkDebugf("Failures:\n"); | 1328 info("Failures:\n"); |
1298 for (int i = 0; i < gFailures.count(); i++) { | 1329 for (int i = 0; i < gFailures.count(); i++) { |
1299 SkDebugf("\t%s\n", gFailures[i].c_str()); | 1330 info("\t%s\n", gFailures[i].c_str()); |
1300 } | 1331 } |
1301 SkDebugf("%d failures\n", gFailures.count()); | 1332 info("%d failures\n", gFailures.count()); |
1302 return 1; | 1333 return 1; |
1303 } | 1334 } |
1304 | 1335 |
1305 #ifdef SK_PDF_IMAGE_STATS | 1336 #ifdef SK_PDF_IMAGE_STATS |
1306 SkPDFImageDumpStats(); | 1337 SkPDFImageDumpStats(); |
1307 #endif // SK_PDF_IMAGE_STATS | 1338 #endif // SK_PDF_IMAGE_STATS |
1308 | 1339 |
1309 print_status(); | 1340 print_status(); |
1310 SkDebugf("Finished!\n"); | 1341 info("Finished!\n"); |
1311 return 0; | 1342 return 0; |
1312 } | 1343 } |
1313 | 1344 |
1314 // TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards. | 1345 // TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards. |
1315 // Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0. | 1346 // Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0. |
1316 namespace skiatest { | 1347 namespace skiatest { |
1317 namespace { | 1348 namespace { |
1318 typedef void(*TestWithGrContext)(skiatest::Reporter*, GrContext*); | 1349 typedef void(*TestWithGrContext)(skiatest::Reporter*, GrContext*); |
1319 typedef void(*TestWithGrContextAndGLContext)(skiatest::Reporter*, GrContext*, Sk
GLContext*); | 1350 typedef void(*TestWithGrContextAndGLContext)(skiatest::Reporter*, GrContext*, Sk
GLContext*); |
1320 #if SK_SUPPORT_GPU | 1351 #if SK_SUPPORT_GPU |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 Reporter* reporter, | 1429 Reporter* reporter, |
1399 GrContextFactory* fac
tory); | 1430 GrContextFactory* fac
tory); |
1400 } // namespace skiatest | 1431 } // namespace skiatest |
1401 | 1432 |
1402 #if !defined(SK_BUILD_FOR_IOS) | 1433 #if !defined(SK_BUILD_FOR_IOS) |
1403 int main(int argc, char** argv) { | 1434 int main(int argc, char** argv) { |
1404 SkCommandLineFlags::Parse(argc, argv); | 1435 SkCommandLineFlags::Parse(argc, argv); |
1405 return dm_main(); | 1436 return dm_main(); |
1406 } | 1437 } |
1407 #endif | 1438 #endif |
OLD | NEW |