blob: d5768ed3e39b2d0b39778b1201deb86bd6362612 [file] [log] [blame]
scroggo478652e2015-03-25 07:11:02 -07001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
mtklein748ca3b2015-01-15 10:56:12 -08008#include "DMJsonWriter.h"
9#include "DMSrcSink.h"
mtklein748ca3b2015-01-15 10:56:12 -080010#include "ProcStats.h"
halcanary7d571242016-02-24 17:59:16 -080011#include "Resources.h"
mtklein748ca3b2015-01-15 10:56:12 -080012#include "SkBBHFactory.h"
mtklein62bd1a62015-01-27 14:46:26 -080013#include "SkChecksum.h"
Brian Osman53136aa2017-07-20 15:43:35 -040014#include "SkChromeTracingTracer.h"
scroggocc2feb12015-08-14 08:32:46 -070015#include "SkCodec.h"
mtklein27c3fdd2016-02-26 14:43:21 -080016#include "SkColorPriv.h"
msarett888dc162016-05-23 10:21:17 -070017#include "SkColorSpace.h"
Mike Klein919cc452017-03-18 15:36:52 +000018#include "SkColorSpacePriv.h"
caryclark17f0b6d2014-07-22 10:15:34 -070019#include "SkCommonFlags.h"
kkinnunen3e980c32015-12-23 01:33:00 -080020#include "SkCommonFlagsConfig.h"
Chris Dalton040238b2017-12-18 14:22:34 -070021#include "SkCommonFlagsGpu.h"
brianosman3c579dc2016-04-19 09:18:11 -070022#include "SkData.h"
Brian Salomondcbb9d92017-07-19 10:53:20 -040023#include "SkDebugfTracer.h"
Hal Canaryd7b38452017-12-11 17:46:26 -050024#include "SkDocument.h"
Brian Osman53136aa2017-07-20 15:43:35 -040025#include "SkEventTracingPriv.h"
caryclark83ca6282015-06-10 09:31:09 -070026#include "SkFontMgr.h"
Hal Canaryd7b38452017-12-11 17:46:26 -050027#include "SkFontMgrPriv.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +000028#include "SkGraphics.h"
mtklein27c3fdd2016-02-26 14:43:21 -080029#include "SkHalf.h"
halcanary4dbbd042016-06-07 17:21:10 -070030#include "SkLeanWindows.h"
mtklein748ca3b2015-01-15 10:56:12 -080031#include "SkMD5.h"
mtklein1b249332015-07-07 12:21:21 -070032#include "SkMutex.h"
mtklein1d0f1642014-09-08 08:05:18 -070033#include "SkOSFile.h"
Ben Wagnerbf111d72016-11-07 18:05:29 -050034#include "SkOSPath.h"
mtklein27c3fdd2016-02-26 14:43:21 -080035#include "SkPM4fPriv.h"
Mike Klein13b6afd2017-06-12 12:45:41 -040036#include "SkPngEncoder.h"
Brian Salomondcbb9d92017-07-19 10:53:20 -040037#include "SkScan.h"
mtklein246ba3a2016-02-23 10:39:36 -080038#include "SkSpinlock.h"
Ben Wagner483c7722018-02-20 17:06:07 -050039#include "SkTestFontMgr.h"
mtkleina82f5622015-02-20 12:30:19 -080040#include "SkTHash.h"
mtklein406654b2014-09-03 15:34:37 -070041#include "SkTaskGroup.h"
Mike Klein0c5fdcb2017-11-13 12:40:46 -050042#include "SkTypeface_win.h"
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000043#include "Test.h"
mtklein748ca3b2015-01-15 10:56:12 -080044#include "Timer.h"
Mike Kleinadacaef2017-02-06 09:26:14 -050045#include "ios_utils.h"
brianosman3c579dc2016-04-19 09:18:11 -070046#include "picture_utils.h"
caryclark83ca6282015-06-10 09:31:09 -070047#include "sk_tool_utils.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +000048
scroggo19b91532016-10-24 09:03:26 -070049#include <vector>
50
halcanary7a14b312015-10-01 07:28:13 -070051#ifdef SK_PDF_IMAGE_STATS
52extern void SkPDFImageDumpStats();
53#endif
54
mtkleina5114d72015-08-24 13:27:01 -070055#include "png.h"
56
bungeman60e0fee2015-08-26 05:15:46 -070057#include <stdlib.h>
58
Mike Klein8f11d4d2018-01-24 12:42:55 -050059#ifndef SK_BUILD_FOR_WIN
scroggo27a58342015-10-28 08:56:41 -070060 #include <unistd.h>
61#endif
62
Dongwon Kang0c7861f2018-02-16 10:55:21 -080063#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(SK_HAS_HEIF_LIBRARY)
64#include <binder/IPCThreadState.h>
65#endif
66
Mike Reed7c26ca72017-07-05 15:45:52 -040067extern bool gSkForceRasterPipelineBlitter;
68
Ben Wagner32fa5102017-08-10 21:25:55 -040069DECLARE_bool(undefok);
djsollen54416de2015-04-03 07:24:48 -070070DEFINE_string(src, "tests gm skp image", "Source types to test.");
mtklein748ca3b2015-01-15 10:56:12 -080071DEFINE_bool(nameByHash, false,
72 "If true, write to FLAGS_writePath[0]/<hash>.png instead of "
djsollen54416de2015-04-03 07:24:48 -070073 "to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>.png");
mtklein748ca3b2015-01-15 10:56:12 -080074DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
mtkleind603b222015-02-17 11:13:33 -080075DEFINE_string(matrix, "1 0 0 1",
76 "2x2 scale+skew matrix to apply or upright when using "
77 "'matrix' or 'upright' in config.");
mtklein82d28432015-01-15 12:46:02 -080078DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
mtklein@google.comd36522d2013-10-16 13:02:15 +000079
mtkleina2ef6422015-01-15 13:44:22 -080080DEFINE_string(blacklist, "",
Chris Daltonecf78ac2017-08-15 15:43:08 -060081 "Space-separated config/src/srcOptions/name quadruples to blacklist. "
82 "'_' matches anything. '~' negates the match. E.g. \n"
djsollen54416de2015-04-03 07:24:48 -070083 "'--blacklist gpu skp _ _' will blacklist all SKPs drawn into the gpu config.\n"
Chris Daltonecf78ac2017-08-15 15:43:08 -060084 "'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aarects GM on 8888.\n"
85 "'--blacklist ~8888 svg _ svgparse_' blocks non-8888 SVGs that contain \"svgparse_\" in "
86 "the name.");
mtkleina2ef6422015-01-15 13:44:22 -080087
mtklein62bd1a62015-01-27 14:46:26 -080088DEFINE_string2(readPath, r, "", "If set check for equality with golden results in this directory.");
89
borenet09ed4802015-04-03 14:15:33 -070090DEFINE_string(uninterestingHashesFile, "",
91 "File containing a list of uninteresting hashes. If a result hashes to something in "
92 "this list, no image is written for that result.");
93
mtklein6393c062015-04-27 08:45:01 -070094DEFINE_int32(shards, 1, "We're splitting source data into this many shards.");
95DEFINE_int32(shard, 0, "Which shard do I run?");
96
halcanary45420a92016-06-02 12:41:14 -070097DEFINE_string(mskps, "", "Directory to read mskps from, or a single mskp file.");
Mike Reed7c26ca72017-07-05 15:45:52 -040098DEFINE_bool(forceRasterPipeline, false, "sets gSkForceRasterPipelineBlitter");
halcanary45420a92016-06-02 12:41:14 -070099
Derek Sollenbergeredfe3df2017-07-19 15:25:24 -0400100DEFINE_bool(ignoreSigInt, false, "ignore SIGINT signals during test execution");
101
Mike Klein97d6a7a2017-07-24 10:37:19 -0400102DEFINE_string(dont_write, "", "File extensions to skip writing to --writePath."); // See skia:6821
103
Mike Klein0c5fdcb2017-11-13 12:40:46 -0500104DEFINE_bool(gdi, false, "On Windows, use GDI instead of DirectWrite for font rendering.");
Mike Klein31868212017-11-06 12:02:47 -0500105
mtklein748ca3b2015-01-15 10:56:12 -0800106using namespace DM;
bsalomon3724e572016-03-30 18:56:19 -0700107using sk_gpu_test::GrContextFactory;
bsalomon273c0f52016-03-31 10:59:06 -0700108using sk_gpu_test::GLTestContext;
bsalomonf2f1c172016-04-05 12:59:06 -0700109using sk_gpu_test::ContextInfo;
mtklein@google.comd36522d2013-10-16 13:02:15 +0000110
mtklein748ca3b2015-01-15 10:56:12 -0800111/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
112
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700113static const double kStartMs = SkTime::GetMSecs();
mtkleinc41fd922016-03-08 09:01:39 -0800114
115static FILE* gVLog;
116
117template <typename... Args>
118static void vlog(const char* fmt, Args&&... args) {
119 if (gVLog) {
Jim Van Verth32bbf372017-09-20 12:53:00 -0400120 char s[64];
121 HumanizeMs(s, 64, SkTime::GetMSecs() - kStartMs);
122 fprintf(gVLog, "%s\t", s);
mtkleinc41fd922016-03-08 09:01:39 -0800123 fprintf(gVLog, fmt, args...);
124 fflush(gVLog);
125 }
126}
127
128template <typename... Args>
129static void info(const char* fmt, Args&&... args) {
130 vlog(fmt, args...);
131 if (!FLAGS_quiet) {
132 printf(fmt, args...);
133 }
134}
135static void info(const char* fmt) {
136 if (!FLAGS_quiet) {
137 printf("%s", fmt); // Clang warns printf(fmt) is insecure.
138 }
139}
140
reed086eea92016-05-04 17:12:46 -0700141SK_DECLARE_STATIC_MUTEX(gFailuresMutex);
mtklein748ca3b2015-01-15 10:56:12 -0800142static SkTArray<SkString> gFailures;
143
mtklein3eed7dd2016-02-24 19:07:07 -0800144static void fail(const SkString& err) {
mtklein748ca3b2015-01-15 10:56:12 -0800145 SkAutoMutexAcquire lock(gFailuresMutex);
146 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str());
147 gFailures.push_back(err);
halcanary9e398f72015-01-10 11:18:04 -0800148}
149
mtklein0f7748a2016-07-25 15:27:29 -0700150struct Running {
151 SkString id;
152 SkThreadID thread;
153
154 void dump() const {
155 info("\t%s\n", id.c_str());
156 }
157};
mtkleinb37cb412015-03-18 05:27:14 -0700158
mtklein246ba3a2016-02-23 10:39:36 -0800159// We use a spinlock to make locking this in a signal handler _somewhat_ safe.
Mike Klein03a95ad2017-06-23 12:36:32 -0400160static SkSpinlock gMutex;
161static int gPending;
mtklein0f7748a2016-07-25 15:27:29 -0700162static SkTArray<Running> gRunning;
mtklein748ca3b2015-01-15 10:56:12 -0800163
mtklein3eed7dd2016-02-24 19:07:07 -0800164static void done(const char* config, const char* src, const char* srcOptions, const char* name) {
165 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
mtkleinc41fd922016-03-08 09:01:39 -0800166 vlog("done %s\n", id.c_str());
mtkleinafae30a2016-02-24 12:28:32 -0800167 int pending;
mtkleinb37cb412015-03-18 05:27:14 -0700168 {
mtkleinf10637f2016-06-10 13:56:35 -0700169 SkAutoMutexAcquire lock(gMutex);
mtkleinb37cb412015-03-18 05:27:14 -0700170 for (int i = 0; i < gRunning.count(); i++) {
mtklein0f7748a2016-07-25 15:27:29 -0700171 if (gRunning[i].id == id) {
mtkleinb37cb412015-03-18 05:27:14 -0700172 gRunning.removeShuffle(i);
173 break;
174 }
175 }
mtkleinafae30a2016-02-24 12:28:32 -0800176 pending = --gPending;
reed50bc0512015-05-19 14:13:31 -0700177 }
Mike Klein03a95ad2017-06-23 12:36:32 -0400178
179 // We write out dm.json file and print out a progress update every once in a while.
180 // Notice this also handles the final dm.json and progress update when pending == 0.
mtkleina17241b2015-01-23 05:48:00 -0800181 if (pending % 500 == 0) {
182 JsonWriter::DumpJson();
Mike Klein03a95ad2017-06-23 12:36:32 -0400183
184 int curr = sk_tools::getCurrResidentSetSizeMB(),
185 peak = sk_tools::getMaxResidentSetSizeMB();
186 SkString elapsed = HumanizeMs(SkTime::GetMSecs() - kStartMs);
187
188 SkAutoMutexAcquire lock(gMutex);
189 info("\n%dMB RAM, %dMB peak, %s elapsed, %d queued, %d active:\n",
190 curr, peak, elapsed.c_str(), gPending - gRunning.count(), gRunning.count());
191 for (auto& task : gRunning) {
192 task.dump();
193 }
mtkleina17241b2015-01-23 05:48:00 -0800194 }
mtklein@google.comd36522d2013-10-16 13:02:15 +0000195}
196
mtklein3eed7dd2016-02-24 19:07:07 -0800197static void start(const char* config, const char* src, const char* srcOptions, const char* name) {
198 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
mtkleinc41fd922016-03-08 09:01:39 -0800199 vlog("start %s\n", id.c_str());
mtkleinf10637f2016-06-10 13:56:35 -0700200 SkAutoMutexAcquire lock(gMutex);
mtklein0f7748a2016-07-25 15:27:29 -0700201 gRunning.push_back({id,SkGetThreadID()});
mtkleinb37cb412015-03-18 05:27:14 -0700202}
203
Mike Klein3cc2d202016-10-24 11:39:43 -0400204static void find_culprit() {
205 // Assumes gMutex is locked.
206 SkThreadID thisThread = SkGetThreadID();
207 for (auto& task : gRunning) {
208 if (task.thread == thisThread) {
209 info("Likely culprit:\n");
210 task.dump();
mtklein0f7748a2016-07-25 15:27:29 -0700211 }
212 }
Mike Klein3cc2d202016-10-24 11:39:43 -0400213}
mtklein0f7748a2016-07-25 15:27:29 -0700214
Mike Klein8f11d4d2018-01-24 12:42:55 -0500215#if defined(SK_BUILD_FOR_WIN)
mtklein5b64dab2016-06-09 08:59:48 -0700216 static LONG WINAPI crash_handler(EXCEPTION_POINTERS* e) {
mtkleinf8557292016-02-29 06:35:28 -0800217 static const struct {
218 const char* name;
robertphillips75467862016-03-01 14:10:23 -0800219 DWORD code;
mtkleinf8557292016-02-29 06:35:28 -0800220 } kExceptions[] = {
221 #define _(E) {#E, E}
222 _(EXCEPTION_ACCESS_VIOLATION),
223 _(EXCEPTION_BREAKPOINT),
224 _(EXCEPTION_INT_DIVIDE_BY_ZERO),
225 _(EXCEPTION_STACK_OVERFLOW),
226 // TODO: more?
227 #undef _
228 };
229
mtkleinf10637f2016-06-10 13:56:35 -0700230 SkAutoMutexAcquire lock(gMutex);
mtklein5b64dab2016-06-09 08:59:48 -0700231
232 const DWORD code = e->ExceptionRecord->ExceptionCode;
233 info("\nCaught exception %u", code);
234 for (const auto& exception : kExceptions) {
235 if (exception.code == code) {
236 info(" %s", exception.name);
mtkleinf8557292016-02-29 06:35:28 -0800237 }
mtkleinf8557292016-02-29 06:35:28 -0800238 }
mtklein5b64dab2016-06-09 08:59:48 -0700239 info(", was running:\n");
240 for (auto& task : gRunning) {
mtklein0f7748a2016-07-25 15:27:29 -0700241 task.dump();
mtklein5b64dab2016-06-09 08:59:48 -0700242 }
mtklein0f7748a2016-07-25 15:27:29 -0700243 find_culprit();
mtklein5b64dab2016-06-09 08:59:48 -0700244 fflush(stdout);
245
mtkleinf8557292016-02-29 06:35:28 -0800246 // Execute default exception handler... hopefully, exit.
247 return EXCEPTION_EXECUTE_HANDLER;
mtklein246ba3a2016-02-23 10:39:36 -0800248 }
249
Mike Klein3cc2d202016-10-24 11:39:43 -0400250 static void setup_crash_handler() {
251 SetUnhandledExceptionFilter(crash_handler);
252 }
253#else
mtklein246ba3a2016-02-23 10:39:36 -0800254 #include <signal.h>
Mike Klein3cc2d202016-10-24 11:39:43 -0400255 #if !defined(SK_BUILD_FOR_ANDROID)
256 #include <execinfo.h>
Brian Salomondcbb9d92017-07-19 10:53:20 -0400257
258#endif
Mike Klein3cc2d202016-10-24 11:39:43 -0400259
260 static constexpr int max_of() { return 0; }
261 template <typename... Rest>
262 static constexpr int max_of(int x, Rest... rest) {
263 return x > max_of(rest...) ? x : max_of(rest...);
264 }
265
Mike Kleinc7278ad2018-02-15 09:26:54 -0500266 static void (*previous_handler[max_of(SIGABRT,SIGBUS,SIGFPE,SIGILL,SIGSEGV,SIGTERM)+1])(int);
mtkleinf8557292016-02-29 06:35:28 -0800267
mtklein5b64dab2016-06-09 08:59:48 -0700268 static void crash_handler(int sig) {
mtkleinf10637f2016-06-10 13:56:35 -0700269 SkAutoMutexAcquire lock(gMutex);
mtklein5b64dab2016-06-09 08:59:48 -0700270
271 info("\nCaught signal %d [%s], was running:\n", sig, strsignal(sig));
272 for (auto& task : gRunning) {
mtklein0f7748a2016-07-25 15:27:29 -0700273 task.dump();
mtklein5b64dab2016-06-09 08:59:48 -0700274 }
mtklein0f7748a2016-07-25 15:27:29 -0700275 find_culprit();
mtklein5b64dab2016-06-09 08:59:48 -0700276
Mike Klein3cc2d202016-10-24 11:39:43 -0400277 #if !defined(SK_BUILD_FOR_ANDROID)
mtklein5b64dab2016-06-09 08:59:48 -0700278 void* stack[64];
279 int count = backtrace(stack, SK_ARRAY_COUNT(stack));
280 char** symbols = backtrace_symbols(stack, count);
281 info("\nStack trace:\n");
282 for (int i = 0; i < count; i++) {
283 info(" %s\n", symbols[i]);
284 }
Mike Klein3cc2d202016-10-24 11:39:43 -0400285 #endif
mtklein5b64dab2016-06-09 08:59:48 -0700286 fflush(stdout);
287
Mike Klein3cc2d202016-10-24 11:39:43 -0400288 signal(sig, previous_handler[sig]);
289 raise(sig);
mtklein5b64dab2016-06-09 08:59:48 -0700290 }
291
Mike Kleinc7278ad2018-02-15 09:26:54 -0500292 static void term_handler(int sig) {
293 info("\nWe have been politely asked to die by %s (%d)."
294 "\nCurrently using %dMB RAM, peak %dMB.\n",
295 strsignal(sig), sig,
296 sk_tools::getCurrResidentSetSizeMB(), sk_tools::getMaxResidentSetSizeMB());
297 signal(sig, previous_handler[sig]);
298 raise(sig);
299 }
300
mtklein246ba3a2016-02-23 10:39:36 -0800301 static void setup_crash_handler() {
302 const int kSignals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV };
303 for (int sig : kSignals) {
Mike Klein3cc2d202016-10-24 11:39:43 -0400304 previous_handler[sig] = signal(sig, crash_handler);
mtklein246ba3a2016-02-23 10:39:36 -0800305 }
Mike Kleinc7278ad2018-02-15 09:26:54 -0500306 previous_handler[SIGTERM] = signal(SIGTERM, term_handler);
Derek Sollenbergeredfe3df2017-07-19 15:25:24 -0400307
308 if (FLAGS_ignoreSigInt) {
309 signal(SIGINT, SIG_IGN);
310 }
mtklein246ba3a2016-02-23 10:39:36 -0800311 }
312#endif
313
mtklein748ca3b2015-01-15 10:56:12 -0800314/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
mtklein114c3cd2015-01-15 10:15:02 -0800315
mtklein62bd1a62015-01-27 14:46:26 -0800316struct Gold : public SkString {
mtkleina82f5622015-02-20 12:30:19 -0800317 Gold() : SkString("") {}
mtklein3eed7dd2016-02-24 19:07:07 -0800318 Gold(const SkString& sink, const SkString& src,
319 const SkString& srcOptions, const SkString& name,
320 const SkString& md5)
mtklein62bd1a62015-01-27 14:46:26 -0800321 : SkString("") {
322 this->append(sink);
323 this->append(src);
djsollen54416de2015-04-03 07:24:48 -0700324 this->append(srcOptions);
mtklein62bd1a62015-01-27 14:46:26 -0800325 this->append(name);
326 this->append(md5);
mtklein62bd1a62015-01-27 14:46:26 -0800327 }
mtkleinc8d1dd42015-10-15 12:23:01 -0700328 struct Hash {
329 uint32_t operator()(const Gold& g) const {
330 return SkGoodHash()((const SkString&)g);
331 }
332 };
mtklein62bd1a62015-01-27 14:46:26 -0800333};
mtkleina82f5622015-02-20 12:30:19 -0800334static SkTHashSet<Gold, Gold::Hash> gGold;
mtklein62bd1a62015-01-27 14:46:26 -0800335
336static void add_gold(JsonWriter::BitmapResult r) {
djsollen54416de2015-04-03 07:24:48 -0700337 gGold.add(Gold(r.config, r.sourceType, r.sourceOptions, r.name, r.md5));
mtklein62bd1a62015-01-27 14:46:26 -0800338}
339
340static void gather_gold() {
341 if (!FLAGS_readPath.isEmpty()) {
342 SkString path(FLAGS_readPath[0]);
343 path.append("/dm.json");
344 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) {
345 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_str()));
346 }
347 }
348}
349
350/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
351
Mike Klein8f11d4d2018-01-24 12:42:55 -0500352#if defined(SK_BUILD_FOR_WIN)
mtklein935f1b12016-03-16 08:37:19 -0700353 static const char* kNewline = "\r\n";
354#else
355 static const char* kNewline = "\n";
356#endif
357
borenet09ed4802015-04-03 14:15:33 -0700358static SkTHashSet<SkString> gUninterestingHashes;
359
360static void gather_uninteresting_hashes() {
361 if (!FLAGS_uninterestingHashesFile.isEmpty()) {
bungeman38d909e2016-08-02 14:40:46 -0700362 sk_sp<SkData> data(SkData::MakeFromFileName(FLAGS_uninterestingHashesFile[0]));
mtkleincc334b32015-09-22 11:43:53 -0700363 if (!data) {
mtkleinc41fd922016-03-08 09:01:39 -0800364 info("WARNING: unable to read uninteresting hashes from %s\n",
365 FLAGS_uninterestingHashesFile[0]);
mtkleincc334b32015-09-22 11:43:53 -0700366 return;
367 }
Mike Klein45dcc0c2017-04-05 18:04:31 -0400368
369 // Copy to a string to make sure SkStrSplit has a terminating \0 to find.
370 SkString contents((const char*)data->data(), data->size());
371
borenet09ed4802015-04-03 14:15:33 -0700372 SkTArray<SkString> hashes;
Mike Klein45dcc0c2017-04-05 18:04:31 -0400373 SkStrSplit(contents.c_str(), kNewline, &hashes);
borenet09ed4802015-04-03 14:15:33 -0700374 for (const SkString& hash : hashes) {
375 gUninterestingHashes.add(hash);
376 }
mtkleinc41fd922016-03-08 09:01:39 -0800377 info("FYI: loaded %d distinct uninteresting hashes from %d lines\n",
378 gUninterestingHashes.count(), hashes.count());
borenet09ed4802015-04-03 14:15:33 -0700379 }
380}
381
382/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
383
Ben Wagner145dbcd2016-11-03 14:40:50 -0400384struct TaggedSrc : public std::unique_ptr<Src> {
mtklein3eed7dd2016-02-24 19:07:07 -0800385 SkString tag;
386 SkString options;
mtkleine0effd62015-07-29 06:37:28 -0700387};
388
Ben Wagner145dbcd2016-11-03 14:40:50 -0400389struct TaggedSink : public std::unique_ptr<Sink> {
kkinnunen3e980c32015-12-23 01:33:00 -0800390 SkString tag;
djsollen54416de2015-04-03 07:24:48 -0700391};
mtklein748ca3b2015-01-15 10:56:12 -0800392
393static const bool kMemcpyOK = true;
394
mtkleine0effd62015-07-29 06:37:28 -0700395static SkTArray<TaggedSrc, kMemcpyOK> gSrcs;
396static SkTArray<TaggedSink, kMemcpyOK> gSinks;
mtklein748ca3b2015-01-15 10:56:12 -0800397
mtklein6393c062015-04-27 08:45:01 -0700398static bool in_shard() {
399 static int N = 0;
400 return N++ % FLAGS_shards == FLAGS_shard;
401}
402
mtklein3eed7dd2016-02-24 19:07:07 -0800403static void push_src(const char* tag, ImplicitString options, Src* s) {
Ben Wagner145dbcd2016-11-03 14:40:50 -0400404 std::unique_ptr<Src> src(s);
mtklein6393c062015-04-27 08:45:01 -0700405 if (in_shard() &&
mtklein3eed7dd2016-02-24 19:07:07 -0800406 FLAGS_src.contains(tag) &&
mtklein748ca3b2015-01-15 10:56:12 -0800407 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) {
mtkleine0effd62015-07-29 06:37:28 -0700408 TaggedSrc& s = gSrcs.push_back();
mtklein18300a32016-03-16 13:53:35 -0700409 s.reset(src.release());
mtklein748ca3b2015-01-15 10:56:12 -0800410 s.tag = tag;
djsollen54416de2015-04-03 07:24:48 -0700411 s.options = options;
mtklein114c3cd2015-01-15 10:15:02 -0800412 }
mtklein748ca3b2015-01-15 10:56:12 -0800413}
mtklein114c3cd2015-01-15 10:15:02 -0800414
msarett9e707a02015-09-01 14:57:57 -0700415static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorType dstColorType,
scroggoc5560be2016-02-03 09:42:42 -0800416 SkAlphaType dstAlphaType, float scale) {
scroggoe4499842016-02-25 11:03:47 -0800417 if (FLAGS_simpleCodec) {
scroggo19b91532016-10-24 09:03:26 -0700418 const bool simple = CodecSrc::kCodec_Mode == mode || CodecSrc::kAnimated_Mode == mode;
419 if (!simple || dstColorType != CodecSrc::kGetFromCanvas_DstColorType || scale != 1.0f) {
scroggoe4499842016-02-25 11:03:47 -0800420 // Only decode in the simple case.
421 return;
scroggo19b91532016-10-24 09:03:26 -0700422 }
scroggoe4499842016-02-25 11:03:47 -0800423 }
msarett9e707a02015-09-01 14:57:57 -0700424 SkString folder;
425 switch (mode) {
426 case CodecSrc::kCodec_Mode:
427 folder.append("codec");
428 break;
msarettbb25b532016-01-13 09:31:39 -0800429 case CodecSrc::kCodecZeroInit_Mode:
430 folder.append("codec_zero_init");
431 break;
msarett9e707a02015-09-01 14:57:57 -0700432 case CodecSrc::kScanline_Mode:
433 folder.append("scanline");
434 break;
msarett9e707a02015-09-01 14:57:57 -0700435 case CodecSrc::kStripe_Mode:
436 folder.append("stripe");
437 break;
msarett91c22b22016-02-22 12:27:46 -0800438 case CodecSrc::kCroppedScanline_Mode:
439 folder.append("crop");
440 break;
msarett9e707a02015-09-01 14:57:57 -0700441 case CodecSrc::kSubset_Mode:
msarett36c37962015-09-02 13:20:52 -0700442 folder.append("codec_subset");
msarett9e707a02015-09-01 14:57:57 -0700443 break;
scroggo19b91532016-10-24 09:03:26 -0700444 case CodecSrc::kAnimated_Mode:
445 folder.append("codec_animated");
446 break;
msarett9e707a02015-09-01 14:57:57 -0700447 }
448
449 switch (dstColorType) {
450 case CodecSrc::kGrayscale_Always_DstColorType:
451 folder.append("_kGray8");
452 break;
msarett34e0ec42016-04-22 16:27:24 -0700453 case CodecSrc::kNonNative8888_Always_DstColorType:
454 folder.append("_kNonNative");
455 break;
msarett9e707a02015-09-01 14:57:57 -0700456 default:
457 break;
458 }
459
scroggoc5560be2016-02-03 09:42:42 -0800460 switch (dstAlphaType) {
scroggoc5560be2016-02-03 09:42:42 -0800461 case kPremul_SkAlphaType:
462 folder.append("_premul");
463 break;
464 case kUnpremul_SkAlphaType:
465 folder.append("_unpremul");
466 break;
467 default:
468 break;
469 }
470
msarett9e707a02015-09-01 14:57:57 -0700471 if (1.0f != scale) {
472 folder.appendf("_%.3f", scale);
473 }
474
scroggoc5560be2016-02-03 09:42:42 -0800475 CodecSrc* src = new CodecSrc(path, mode, dstColorType, dstAlphaType, scale);
msarett9e707a02015-09-01 14:57:57 -0700476 push_src("image", folder, src);
477}
478
scroggof8dc9df2016-05-16 09:04:13 -0700479static void push_android_codec_src(Path path, CodecSrc::DstColorType dstColorType,
480 SkAlphaType dstAlphaType, int sampleSize) {
msarett3d9d7a72015-10-21 10:27:10 -0700481 SkString folder;
scroggof8dc9df2016-05-16 09:04:13 -0700482 folder.append("scaled_codec");
msarett3d9d7a72015-10-21 10:27:10 -0700483
484 switch (dstColorType) {
485 case CodecSrc::kGrayscale_Always_DstColorType:
486 folder.append("_kGray8");
487 break;
msarett34e0ec42016-04-22 16:27:24 -0700488 case CodecSrc::kNonNative8888_Always_DstColorType:
489 folder.append("_kNonNative");
490 break;
msarett3d9d7a72015-10-21 10:27:10 -0700491 default:
492 break;
493 }
494
scroggoc5560be2016-02-03 09:42:42 -0800495 switch (dstAlphaType) {
scroggoc5560be2016-02-03 09:42:42 -0800496 case kPremul_SkAlphaType:
497 folder.append("_premul");
498 break;
msarett9e9444c2016-02-03 12:39:10 -0800499 case kUnpremul_SkAlphaType:
500 folder.append("_unpremul");
501 break;
scroggoc5560be2016-02-03 09:42:42 -0800502 default:
503 break;
504 }
505
msarett3d9d7a72015-10-21 10:27:10 -0700506 if (1 != sampleSize) {
msarett4b0778e2015-11-13 09:59:11 -0800507 folder.appendf("_%.3f", 1.0f / (float) sampleSize);
msarett3d9d7a72015-10-21 10:27:10 -0700508 }
509
scroggof8dc9df2016-05-16 09:04:13 -0700510 AndroidCodecSrc* src = new AndroidCodecSrc(path, dstColorType, dstAlphaType, sampleSize);
msarett3d9d7a72015-10-21 10:27:10 -0700511 push_src("image", folder, src);
512}
513
msarett18976312016-03-09 14:20:58 -0800514static void push_image_gen_src(Path path, ImageGenSrc::Mode mode, SkAlphaType alphaType, bool isGpu)
515{
516 SkString folder;
517 switch (mode) {
518 case ImageGenSrc::kCodec_Mode:
519 folder.append("gen_codec");
520 break;
521 case ImageGenSrc::kPlatform_Mode:
522 folder.append("gen_platform");
523 break;
524 }
525
526 if (isGpu) {
527 folder.append("_gpu");
528 } else {
529 switch (alphaType) {
530 case kOpaque_SkAlphaType:
531 folder.append("_opaque");
532 break;
533 case kPremul_SkAlphaType:
534 folder.append("_premul");
535 break;
536 case kUnpremul_SkAlphaType:
537 folder.append("_unpremul");
538 break;
539 default:
540 break;
541 }
542 }
543
544 ImageGenSrc* src = new ImageGenSrc(path, mode, alphaType, isGpu);
545 push_src("image", folder, src);
546}
547
Leon Scroggins III07418182017-08-15 12:24:02 -0400548static void push_brd_src(Path path, CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode,
549 uint32_t sampleSize) {
550 SkString folder("brd_android_codec");
551 switch (mode) {
552 case BRDSrc::kFullImage_Mode:
553 break;
554 case BRDSrc::kDivisor_Mode:
555 folder.append("_divisor");
556 break;
557 default:
558 SkASSERT(false);
559 return;
560 }
561
562 switch (dstColorType) {
563 case CodecSrc::kGetFromCanvas_DstColorType:
564 break;
565 case CodecSrc::kGrayscale_Always_DstColorType:
566 folder.append("_kGray");
567 break;
568 default:
569 SkASSERT(false);
570 return;
571 }
572
573 if (1 != sampleSize) {
574 folder.appendf("_%.3f", 1.0f / (float) sampleSize);
575 }
576
577 BRDSrc* src = new BRDSrc(path, mode, dstColorType, sampleSize);
578 push_src("image", folder, src);
579}
580
581static void push_brd_srcs(Path path, bool gray) {
582 if (gray) {
583 // Only run grayscale to one sampleSize and Mode. Though interesting
584 // to test grayscale, it should not reveal anything across various
585 // sampleSizes and Modes
586 // Arbitrarily choose Mode and sampleSize.
587 push_brd_src(path, CodecSrc::kGrayscale_Always_DstColorType,
588 BRDSrc::kFullImage_Mode, 2);
589 }
590
591 // Test on a variety of sampleSizes, making sure to include:
592 // - 2, 4, and 8, which are natively supported by jpeg
593 // - multiples of 2 which are not divisible by 4 (analogous for 4)
594 // - larger powers of two, since BRD clients generally use powers of 2
595 // We will only produce output for the larger sizes on large images.
596 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64 };
597
598 const BRDSrc::Mode modes[] = { BRDSrc::kFullImage_Mode, BRDSrc::kDivisor_Mode, };
599
600 for (uint32_t sampleSize : sampleSizes) {
601 for (BRDSrc::Mode mode : modes) {
602 push_brd_src(path, CodecSrc::kGetFromCanvas_DstColorType, mode, sampleSize);
603 }
604 }
605}
606
msarett438b2ad2015-04-09 12:43:10 -0700607static void push_codec_srcs(Path path) {
bungeman38d909e2016-08-02 14:40:46 -0700608 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
msarett438b2ad2015-04-09 12:43:10 -0700609 if (!encoded) {
mtkleinc41fd922016-03-08 09:01:39 -0800610 info("Couldn't read %s.", path.c_str());
msarett438b2ad2015-04-09 12:43:10 -0700611 return;
612 }
Mike Reedede7bac2017-07-23 15:30:02 -0400613 std::unique_ptr<SkCodec> codec = SkCodec::MakeFromData(encoded);
halcanary96fcdcc2015-08-27 07:41:13 -0700614 if (nullptr == codec.get()) {
mtkleinc41fd922016-03-08 09:01:39 -0800615 info("Couldn't create codec for %s.", path.c_str());
msarett438b2ad2015-04-09 12:43:10 -0700616 return;
617 }
618
scroggo9366aff2016-05-20 08:38:54 -0700619 // native scaling is only supported by WEBP and JPEG
620 bool supportsNativeScaling = false;
msarett438b2ad2015-04-09 12:43:10 -0700621
msarett91c22b22016-02-22 12:27:46 -0800622 SkTArray<CodecSrc::Mode> nativeModes;
623 nativeModes.push_back(CodecSrc::kCodec_Mode);
624 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode);
msarett91c22b22016-02-22 12:27:46 -0800625 switch (codec->getEncodedFormat()) {
Hal Canarydb683012016-11-23 08:55:18 -0700626 case SkEncodedImageFormat::kJPEG:
msarett91c22b22016-02-22 12:27:46 -0800627 nativeModes.push_back(CodecSrc::kScanline_Mode);
628 nativeModes.push_back(CodecSrc::kStripe_Mode);
629 nativeModes.push_back(CodecSrc::kCroppedScanline_Mode);
scroggo9366aff2016-05-20 08:38:54 -0700630 supportsNativeScaling = true;
msarett91c22b22016-02-22 12:27:46 -0800631 break;
Hal Canarydb683012016-11-23 08:55:18 -0700632 case SkEncodedImageFormat::kWEBP:
msarett91c22b22016-02-22 12:27:46 -0800633 nativeModes.push_back(CodecSrc::kSubset_Mode);
scroggo9366aff2016-05-20 08:38:54 -0700634 supportsNativeScaling = true;
msarett91c22b22016-02-22 12:27:46 -0800635 break;
Hal Canarydb683012016-11-23 08:55:18 -0700636 case SkEncodedImageFormat::kDNG:
msarettb65e6042016-02-23 05:37:25 -0800637 break;
msarett91c22b22016-02-22 12:27:46 -0800638 default:
639 nativeModes.push_back(CodecSrc::kScanline_Mode);
msarett91c22b22016-02-22 12:27:46 -0800640 break;
641 }
msarett9e707a02015-09-01 14:57:57 -0700642
msarett91c22b22016-02-22 12:27:46 -0800643 SkTArray<CodecSrc::DstColorType> colorTypes;
644 colorTypes.push_back(CodecSrc::kGetFromCanvas_DstColorType);
msarett34e0ec42016-04-22 16:27:24 -0700645 colorTypes.push_back(CodecSrc::kNonNative8888_Always_DstColorType);
msarett36c37962015-09-02 13:20:52 -0700646 switch (codec->getInfo().colorType()) {
647 case kGray_8_SkColorType:
msarett91c22b22016-02-22 12:27:46 -0800648 colorTypes.push_back(CodecSrc::kGrayscale_Always_DstColorType);
msarett36c37962015-09-02 13:20:52 -0700649 break;
650 default:
msarett36c37962015-09-02 13:20:52 -0700651 break;
652 }
msarett9e707a02015-09-01 14:57:57 -0700653
scroggoc5560be2016-02-03 09:42:42 -0800654 SkTArray<SkAlphaType> alphaModes;
655 alphaModes.push_back(kPremul_SkAlphaType);
scroggof2c96a22016-05-20 11:08:27 -0700656 if (codec->getInfo().alphaType() != kOpaque_SkAlphaType) {
657 alphaModes.push_back(kUnpremul_SkAlphaType);
scroggoc5560be2016-02-03 09:42:42 -0800658 }
msarettb714fb02016-01-22 14:46:42 -0800659
660 for (CodecSrc::Mode mode : nativeModes) {
scroggo9366aff2016-05-20 08:38:54 -0700661 for (CodecSrc::DstColorType colorType : colorTypes) {
662 for (SkAlphaType alphaType : alphaModes) {
scroggof2c96a22016-05-20 11:08:27 -0700663 // Only test kCroppedScanline_Mode when the alpha type is premul. The test is
scroggo9366aff2016-05-20 08:38:54 -0700664 // slow and won't be interestingly different with different alpha types.
665 if (CodecSrc::kCroppedScanline_Mode == mode &&
scroggof2c96a22016-05-20 11:08:27 -0700666 kPremul_SkAlphaType != alphaType) {
scroggo9366aff2016-05-20 08:38:54 -0700667 continue;
668 }
msarett91c22b22016-02-22 12:27:46 -0800669
scroggo9366aff2016-05-20 08:38:54 -0700670 push_codec_src(path, mode, colorType, alphaType, 1.0f);
msarettf3dc1882016-04-26 13:06:38 -0700671
scroggo9366aff2016-05-20 08:38:54 -0700672 // Skip kNonNative on different native scales. It won't be interestingly
673 // different.
674 if (supportsNativeScaling &&
675 CodecSrc::kNonNative8888_Always_DstColorType == colorType) {
676 // Native Scales
677 // SkJpegCodec natively supports scaling to the following:
678 for (auto scale : { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f }) {
679 push_codec_src(path, mode, colorType, alphaType, scale);
680 }
scroggoc5560be2016-02-03 09:42:42 -0800681 }
msarett9e707a02015-09-01 14:57:57 -0700682 }
683 }
msarett0a242972015-06-11 14:27:27 -0700684 }
msarett36c37962015-09-02 13:20:52 -0700685
scroggo19b91532016-10-24 09:03:26 -0700686 {
687 std::vector<SkCodec::FrameInfo> frameInfos = codec->getFrameInfo();
688 if (frameInfos.size() > 1) {
Leon Scroggins III557fbbe2017-05-23 09:37:21 -0400689 for (auto dstCT : { CodecSrc::kNonNative8888_Always_DstColorType,
690 CodecSrc::kGetFromCanvas_DstColorType }) {
691 for (auto at : { kUnpremul_SkAlphaType, kPremul_SkAlphaType }) {
692 push_codec_src(path, CodecSrc::kAnimated_Mode, dstCT, at, 1.0f);
693 }
694 }
scroggo19b91532016-10-24 09:03:26 -0700695 }
696
697 }
698
scroggoe4499842016-02-25 11:03:47 -0800699 if (FLAGS_simpleCodec) {
700 return;
701 }
702
msarett3d9d7a72015-10-21 10:27:10 -0700703 const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
msarett36c37962015-09-02 13:20:52 -0700704
msarett3d9d7a72015-10-21 10:27:10 -0700705 for (int sampleSize : sampleSizes) {
msarett91c22b22016-02-22 12:27:46 -0800706 for (CodecSrc::DstColorType colorType : colorTypes) {
scroggoc5560be2016-02-03 09:42:42 -0800707 for (SkAlphaType alphaType : alphaModes) {
msarettf3dc1882016-04-26 13:06:38 -0700708 // We can exercise all of the kNonNative support code in the swizzler with just a
709 // few sample sizes. Skip the rest.
710 if (CodecSrc::kNonNative8888_Always_DstColorType == colorType && sampleSize > 3) {
711 continue;
712 }
713
scroggof8dc9df2016-05-16 09:04:13 -0700714 push_android_codec_src(path, colorType, alphaType, sampleSize);
msarett3d9d7a72015-10-21 10:27:10 -0700715 }
msarett36c37962015-09-02 13:20:52 -0700716 }
717 }
msarett18976312016-03-09 14:20:58 -0800718
Leon Scroggins III07418182017-08-15 12:24:02 -0400719 const char* ext = strrchr(path.c_str(), '.');
720 if (ext) {
721 ext++;
msarett18976312016-03-09 14:20:58 -0800722
Leon Scroggins III07418182017-08-15 12:24:02 -0400723 static const char* const rawExts[] = {
724 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
725 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
726 };
727 for (const char* rawExt : rawExts) {
728 if (0 == strcmp(rawExt, ext)) {
729 // RAW is not supported by image generator (skbug.com/5079) or BRD.
730 return;
731 }
732 }
733
734 static const char* const brdExts[] = {
735 "jpg", "jpeg", "png", "webp",
736 "JPG", "JPEG", "PNG", "WEBP",
737 };
738 for (const char* brdExt : brdExts) {
739 if (0 == strcmp(brdExt, ext)) {
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -0500740 bool gray = codec->getInfo().colorType() == kGray_8_SkColorType;
Leon Scroggins III07418182017-08-15 12:24:02 -0400741 push_brd_srcs(path, gray);
742 break;
743 }
msarett18976312016-03-09 14:20:58 -0800744 }
745 }
746
747 // Push image generator GPU test.
brianosmanc9ced392016-03-24 07:27:43 -0700748 push_image_gen_src(path, ImageGenSrc::kCodec_Mode, codec->getInfo().alphaType(), true);
msarett18976312016-03-09 14:20:58 -0800749
750 // Push image generator CPU tests.
751 for (SkAlphaType alphaType : alphaModes) {
752 push_image_gen_src(path, ImageGenSrc::kCodec_Mode, alphaType, false);
753
754#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
Hal Canarydb683012016-11-23 08:55:18 -0700755 if (SkEncodedImageFormat::kWEBP != codec->getEncodedFormat() &&
756 SkEncodedImageFormat::kWBMP != codec->getEncodedFormat() &&
msarett18976312016-03-09 14:20:58 -0800757 kUnpremul_SkAlphaType != alphaType)
758 {
759 push_image_gen_src(path, ImageGenSrc::kPlatform_Mode, alphaType, false);
760 }
msarettfc0b6d12016-03-17 13:50:17 -0700761#elif defined(SK_BUILD_FOR_WIN)
Hal Canarydb683012016-11-23 08:55:18 -0700762 if (SkEncodedImageFormat::kWEBP != codec->getEncodedFormat() &&
763 SkEncodedImageFormat::kWBMP != codec->getEncodedFormat())
msarettfc0b6d12016-03-17 13:50:17 -0700764 {
765 push_image_gen_src(path, ImageGenSrc::kPlatform_Mode, alphaType, false);
766 }
msarett18976312016-03-09 14:20:58 -0800767#endif
768 }
msarett438b2ad2015-04-09 12:43:10 -0700769}
770
fmalitaa2b9fdf2016-08-03 19:53:36 -0700771template <typename T>
772void gather_file_srcs(const SkCommandLineFlags::StringArray& flags, const char* ext) {
773 for (int i = 0; i < flags.count(); i++) {
774 const char* path = flags[i];
775 if (sk_isdir(path)) {
776 SkOSFile::Iter it(path, ext);
777 for (SkString file; it.next(&file); ) {
778 push_src(ext, "", new T(SkOSPath::Join(path, file.c_str())));
779 }
780 } else {
781 push_src(ext, "", new T(path));
782 }
783 }
784}
785
scroggo86737142016-02-03 12:19:11 -0800786static bool gather_srcs() {
mtklein748ca3b2015-01-15 10:56:12 -0800787 for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->next()) {
djsollen54416de2015-04-03 07:24:48 -0700788 push_src("gm", "", new GMSrc(r->factory()));
mtklein748ca3b2015-01-15 10:56:12 -0800789 }
scroggo86737142016-02-03 12:19:11 -0800790
Robert Phillipse47f0a02018-03-27 17:01:16 -0400791 gather_file_srcs<SKPSrc>(FLAGS_skps, "skp");
fmalitaa2b9fdf2016-08-03 19:53:36 -0700792 gather_file_srcs<MSKPSrc>(FLAGS_mskps, "mskp");
Florin Malita87ccf332018-05-04 12:23:24 -0400793#if defined(SK_ENABLE_SKOTTIE)
Florin Malita54f65c42018-01-16 17:04:30 -0500794 gather_file_srcs<SkottieSrc>(FLAGS_jsons, "json");
Florin Malita124d5af2017-12-31 17:02:26 -0500795#endif
fmalitaa2b9fdf2016-08-03 19:53:36 -0700796#if defined(SK_XML)
797 gather_file_srcs<SVGSrc>(FLAGS_svgs, "svg");
798#endif
halcanary45420a92016-06-02 12:41:14 -0700799
scroggo86737142016-02-03 12:19:11 -0800800 SkTArray<SkString> images;
msarett69deca82016-04-29 09:38:40 -0700801 if (!CollectImages(FLAGS_images, &images)) {
scroggo86737142016-02-03 12:19:11 -0800802 return false;
803 }
804
805 for (auto image : images) {
806 push_codec_srcs(image);
mtklein709d2c32015-01-15 08:30:25 -0800807 }
scroggo86737142016-02-03 12:19:11 -0800808
msarett69deca82016-04-29 09:38:40 -0700809 SkTArray<SkString> colorImages;
810 if (!CollectImages(FLAGS_colorImages, &colorImages)) {
811 return false;
812 }
813
814 for (auto colorImage : colorImages) {
msarett9ce3a542016-07-15 13:54:38 -0700815 ColorCodecSrc* src = new ColorCodecSrc(colorImage, ColorCodecSrc::kBaseline_Mode,
816 kN32_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700817 push_src("colorImage", "color_codec_baseline", src);
msarett888dc162016-05-23 10:21:17 -0700818
msarett9ce3a542016-07-15 13:54:38 -0700819 src = new ColorCodecSrc(colorImage, ColorCodecSrc::kDst_HPZR30w_Mode, kN32_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700820 push_src("colorImage", "color_codec_HPZR30w", src);
msarett9ce3a542016-07-15 13:54:38 -0700821 // TODO (msarett):
822 // Should we test this Dst in F16 mode (even though the Dst gamma is 2.2 instead of sRGB)?
msarett9876ac52016-06-01 14:47:18 -0700823
msarett9ce3a542016-07-15 13:54:38 -0700824 src = new ColorCodecSrc(colorImage, ColorCodecSrc::kDst_sRGB_Mode, kN32_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700825 push_src("colorImage", "color_codec_sRGB_kN32", src);
msarett9ce3a542016-07-15 13:54:38 -0700826 src = new ColorCodecSrc(colorImage, ColorCodecSrc::kDst_sRGB_Mode, kRGBA_F16_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700827 push_src("colorImage", "color_codec_sRGB_kF16", src);
msarett69deca82016-04-29 09:38:40 -0700828 }
829
scroggo86737142016-02-03 12:19:11 -0800830 return true;
mtklein709d2c32015-01-15 08:30:25 -0800831}
832
kkinnunen3e980c32015-12-23 01:33:00 -0800833static void push_sink(const SkCommandLineConfig& config, Sink* s) {
Ben Wagner145dbcd2016-11-03 14:40:50 -0400834 std::unique_ptr<Sink> sink(s);
kkinnunen3e980c32015-12-23 01:33:00 -0800835
mtkleine0effd62015-07-29 06:37:28 -0700836 // Try a simple Src as a canary. If it fails, skip this sink.
mtklein748ca3b2015-01-15 10:56:12 -0800837 struct : public Src {
mtkleine0effd62015-07-29 06:37:28 -0700838 Error draw(SkCanvas* c) const override {
839 c->drawRect(SkRect::MakeWH(1,1), SkPaint());
840 return "";
841 }
mtklein36352bf2015-03-25 18:17:31 -0700842 SkISize size() const override { return SkISize::Make(16, 16); }
mtkleine0effd62015-07-29 06:37:28 -0700843 Name name() const override { return "justOneRect"; }
844 } justOneRect;
mtklein114c3cd2015-01-15 10:15:02 -0800845
mtklein748ca3b2015-01-15 10:56:12 -0800846 SkBitmap bitmap;
847 SkDynamicMemoryWStream stream;
mtkleinb9eb4ac2015-02-02 18:26:03 -0800848 SkString log;
mtkleine0effd62015-07-29 06:37:28 -0700849 Error err = sink->draw(justOneRect, &bitmap, &stream, &log);
mtklein4089ef72015-03-05 08:40:28 -0800850 if (err.isFatal()) {
mtkleinc41fd922016-03-08 09:01:39 -0800851 info("Could not run %s: %s\n", config.getTag().c_str(), err.c_str());
mtklein05641a52015-04-21 10:49:13 -0700852 exit(1);
mtklein114c3cd2015-01-15 10:15:02 -0800853 }
854
mtkleine0effd62015-07-29 06:37:28 -0700855 TaggedSink& ts = gSinks.push_back();
mtklein18300a32016-03-16 13:53:35 -0700856 ts.reset(sink.release());
kkinnunen3e980c32015-12-23 01:33:00 -0800857 ts.tag = config.getTag();
mtklein748ca3b2015-01-15 10:56:12 -0800858}
859
860static bool gpu_supported() {
861#if SK_SUPPORT_GPU
862 return FLAGS_gpu;
863#else
864 return false;
865#endif
866}
kkinnunen9ebc3f02015-12-21 23:48:13 -0800867
csmartdalton008b9d82017-02-22 12:00:42 -0700868static Sink* create_sink(const GrContextOptions& grCtxOptions, const SkCommandLineConfig* config) {
kkinnunen3e980c32015-12-23 01:33:00 -0800869#if SK_SUPPORT_GPU
870 if (gpu_supported()) {
871 if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) {
bsalomon85b4b532016-04-05 11:06:27 -0700872 GrContextFactory::ContextType contextType = gpuConfig->getContextType();
csmartdaltone812d492017-02-21 12:36:05 -0700873 GrContextFactory::ContextOverrides contextOverrides = gpuConfig->getContextOverrides();
csmartdalton008b9d82017-02-22 12:00:42 -0700874 GrContextFactory testFactory(grCtxOptions);
csmartdaltone812d492017-02-21 12:36:05 -0700875 if (!testFactory.get(contextType, contextOverrides)) {
mtkleinc41fd922016-03-08 09:01:39 -0800876 info("WARNING: can not create GPU context for config '%s'. "
877 "GM tests will be skipped.\n", gpuConfig->getTag().c_str());
kkinnunen3e980c32015-12-23 01:33:00 -0800878 return nullptr;
879 }
Brian Osmanf9810662017-08-30 10:02:10 -0400880 if (gpuConfig->getTestThreading()) {
Brian Salomonf865b052018-03-09 09:01:53 -0500881 return new GPUThreadTestingSink(
882 contextType, contextOverrides, gpuConfig->getSurfType(),
883 gpuConfig->getSamples(), gpuConfig->getUseDIText(),
884 gpuConfig->getColorType(), gpuConfig->getAlphaType(),
885 sk_ref_sp(gpuConfig->getColorSpace()), FLAGS_gpu_threading, grCtxOptions);
Brian Osmanf9810662017-08-30 10:02:10 -0400886 } else {
Brian Salomonf865b052018-03-09 09:01:53 -0500887 return new GPUSink(contextType, contextOverrides, gpuConfig->getSurfType(),
888 gpuConfig->getSamples(), gpuConfig->getUseDIText(),
889 gpuConfig->getColorType(), gpuConfig->getAlphaType(),
890 sk_ref_sp(gpuConfig->getColorSpace()), FLAGS_gpu_threading,
891 grCtxOptions);
Brian Osmanf9810662017-08-30 10:02:10 -0400892 }
kkinnunen3e980c32015-12-23 01:33:00 -0800893 }
894 }
895#endif
Bryce Thomas95a7b762018-03-02 13:54:21 -0800896 if (const SkCommandLineConfigSvg* svgConfig = config->asConfigSvg()) {
897 int pageIndex = svgConfig->getPageIndex();
898 return new SVGSink(pageIndex);
899 }
kkinnunen3e980c32015-12-23 01:33:00 -0800900
901#define SINK(t, sink, ...) if (config->getBackend().equals(t)) { return new sink(__VA_ARGS__); }
902
mtklein748ca3b2015-01-15 10:56:12 -0800903 if (FLAGS_cpu) {
Matt Sarett77a7a1b2017-02-07 13:56:11 -0500904 auto srgbColorSpace = SkColorSpace::MakeSRGB();
905 auto srgbLinearColorSpace = SkColorSpace::MakeSRGBLinear();
Mike Kleince4cf722018-05-10 11:29:15 -0400906 auto esrgb = SkColorSpace::MakeSRGB()->makeNonlinearBlending();
brianosmanb109b8c2016-06-16 13:03:24 -0700907
Mike Klein515bda62018-01-09 11:21:58 -0500908 SINK("g8", RasterSink, kGray_8_SkColorType);
Matt Sarettd2228302017-03-02 08:53:46 -0500909 SINK("565", RasterSink, kRGB_565_SkColorType);
Mike Klein5340b3f2018-01-24 13:42:05 -0500910 SINK("4444", RasterSink, kARGB_4444_SkColorType);
Matt Sarettd2228302017-03-02 08:53:46 -0500911 SINK("8888", RasterSink, kN32_SkColorType);
912 SINK("srgb", RasterSink, kN32_SkColorType, srgbColorSpace);
Mike Kleinac568a92018-01-25 09:09:32 -0500913 SINK("rgba", RasterSink, kRGBA_8888_SkColorType);
914 SINK("bgra", RasterSink, kBGRA_8888_SkColorType);
915 SINK("rgbx", RasterSink, kRGB_888x_SkColorType);
916 SINK("1010102", RasterSink, kRGBA_1010102_SkColorType);
917 SINK("101010x", RasterSink, kRGB_101010x_SkColorType);
Matt Sarettd2228302017-03-02 08:53:46 -0500918 SINK("f16", RasterSink, kRGBA_F16_SkColorType, srgbLinearColorSpace);
Mike Kleince4cf722018-05-10 11:29:15 -0400919 SINK("esrgb", RasterSink, kRGBA_F16_SkColorType, esrgb);
920 SINK("srgbnl", RasterSink, kRGBA_8888_SkColorType, esrgb);
Yuqian Lib8b62532018-02-23 14:13:36 +0800921 SINK("t8888", ThreadedSink, kN32_SkColorType);
Hal Canaryc7d295e2017-07-20 15:36:00 -0400922 SINK("pdf", PDFSink, false, SK_ScalarDefaultRasterDPI);
Matt Sarettd2228302017-03-02 08:53:46 -0500923 SINK("skp", SKPSink);
924 SINK("pipe", PipeSink);
925 SINK("svg", SVGSink);
926 SINK("null", NullSink);
927 SINK("xps", XPSSink);
Hal Canaryc7d295e2017-07-20 15:36:00 -0400928 SINK("pdfa", PDFSink, true, SK_ScalarDefaultRasterDPI);
929 SINK("pdf300", PDFSink, false, 300);
Hal Canary85c7fe82016-10-25 10:33:27 -0400930 SINK("jsdebug", DebugSink);
mtklein748ca3b2015-01-15 10:56:12 -0800931 }
932#undef SINK
halcanary96fcdcc2015-08-27 07:41:13 -0700933 return nullptr;
mtklein114c3cd2015-01-15 10:15:02 -0800934}
935
Mike Klein841101d2017-03-10 09:55:51 -0500936static sk_sp<SkColorSpace> adobe_rgb() {
937 return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
938 SkColorSpace::kAdobeRGB_Gamut);
939}
940
Mike Kleinb7ea3da2017-10-31 17:42:08 +0000941static sk_sp<SkColorSpace> rgb_to_gbr() {
Brian Osman36703d92017-12-12 14:09:31 -0500942 return SkColorSpace::MakeSRGB()->makeColorSpin();
Mike Klein919cc452017-03-18 15:36:52 +0000943}
944
kkinnunen3e980c32015-12-23 01:33:00 -0800945static Sink* create_via(const SkString& tag, Sink* wrapped) {
946#define VIA(t, via, ...) if (tag.equals(t)) { return new via(__VA_ARGS__); }
Mike Klein919cc452017-03-18 15:36:52 +0000947 VIA("adobe", ViaCSXform, wrapped, adobe_rgb(), false);
Mike Kleinb7ea3da2017-10-31 17:42:08 +0000948 VIA("gbr", ViaCSXform, wrapped, rgb_to_gbr(), true);
mtklein9c5052f2016-08-06 12:51:51 -0700949 VIA("lite", ViaLite, wrapped);
reed54dc4872016-09-13 08:09:45 -0700950 VIA("pipe", ViaPipe, wrapped);
Mike Reedbae888e2017-02-18 16:50:45 -0500951#ifdef TEST_VIA_SVG
Mike Reedf67c4592017-02-17 17:06:11 -0500952 VIA("svg", ViaSVG, wrapped);
Mike Reedbae888e2017-02-18 16:50:45 -0500953#endif
halcanary96fcdcc2015-08-27 07:41:13 -0700954 VIA("serialize", ViaSerialization, wrapped);
mtklein4a34ecb2016-01-08 10:19:35 -0800955 VIA("pic", ViaPicture, wrapped);
halcanary96fcdcc2015-08-27 07:41:13 -0700956 VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped);
mtklein7edca212015-01-21 13:18:51 -0800957 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped);
mtklein748ca3b2015-01-15 10:56:12 -0800958
Robert Phillips33f02ed2018-03-27 08:06:57 -0400959 VIA("ddl", ViaDDL, 3, wrapped);
960
mtkleind603b222015-02-17 11:13:33 -0800961 if (FLAGS_matrix.count() == 4) {
mtklein748ca3b2015-01-15 10:56:12 -0800962 SkMatrix m;
mtkleind603b222015-02-17 11:13:33 -0800963 m.reset();
964 m.setScaleX((SkScalar)atof(FLAGS_matrix[0]));
965 m.setSkewX ((SkScalar)atof(FLAGS_matrix[1]));
966 m.setSkewY ((SkScalar)atof(FLAGS_matrix[2]));
967 m.setScaleY((SkScalar)atof(FLAGS_matrix[3]));
968 VIA("matrix", ViaMatrix, m, wrapped);
969 VIA("upright", ViaUpright, m, wrapped);
mtklein748ca3b2015-01-15 10:56:12 -0800970 }
tomhudson64de1e12015-03-05 08:01:07 -0800971
mtklein748ca3b2015-01-15 10:56:12 -0800972#undef VIA
halcanary96fcdcc2015-08-27 07:41:13 -0700973 return nullptr;
mtklein114c3cd2015-01-15 10:15:02 -0800974}
975
Ben Wagnerf28d4722017-08-11 17:33:22 -0400976static bool gather_sinks(const GrContextOptions& grCtxOptions, bool defaultConfigs) {
kkinnunen3e980c32015-12-23 01:33:00 -0800977 SkCommandLineConfigArray configs;
978 ParseConfigs(FLAGS_config, &configs);
979 for (int i = 0; i < configs.count(); i++) {
980 const SkCommandLineConfig& config = *configs[i];
csmartdalton008b9d82017-02-22 12:00:42 -0700981 Sink* sink = create_sink(grCtxOptions, &config);
kkinnunen3e980c32015-12-23 01:33:00 -0800982 if (sink == nullptr) {
mtkleinc41fd922016-03-08 09:01:39 -0800983 info("Skipping config %s: Don't understand '%s'.\n", config.getTag().c_str(),
984 config.getTag().c_str());
kkinnunen3e980c32015-12-23 01:33:00 -0800985 continue;
986 }
mtklein748ca3b2015-01-15 10:56:12 -0800987
kkinnunen3e980c32015-12-23 01:33:00 -0800988 const SkTArray<SkString>& parts = config.getViaParts();
989 for (int j = parts.count(); j-- > 0;) {
990 const SkString& part = parts[j];
991 Sink* next = create_via(part, sink);
halcanary96fcdcc2015-08-27 07:41:13 -0700992 if (next == nullptr) {
mtkleinc41fd922016-03-08 09:01:39 -0800993 info("Skipping config %s: Don't understand '%s'.\n", config.getTag().c_str(),
994 part.c_str());
mtklein748ca3b2015-01-15 10:56:12 -0800995 delete sink;
halcanary96fcdcc2015-08-27 07:41:13 -0700996 sink = nullptr;
mtklein748ca3b2015-01-15 10:56:12 -0800997 break;
998 }
999 sink = next;
1000 }
1001 if (sink) {
1002 push_sink(config, sink);
mtklein114c3cd2015-01-15 10:15:02 -08001003 }
1004 }
brianosman05c987c2016-05-09 13:42:16 -07001005
1006 // If no configs were requested (just running tests, perhaps?), then we're okay.
Ben Wagnerf28d4722017-08-11 17:33:22 -04001007 if (configs.count() == 0 ||
1008 // If we're using the default configs, we're okay.
1009 defaultConfigs ||
Ben Wagner32fa5102017-08-10 21:25:55 -04001010 // If we've been told to ignore undefined flags, we're okay.
1011 FLAGS_undefok ||
1012 // Otherwise, make sure that all specified configs have become sinks.
1013 configs.count() == gSinks.count()) {
1014 return true;
1015 }
1016 info("Invalid --config. Use --undefok to bypass this warning.\n");
1017 return false;
mtklein114c3cd2015-01-15 10:15:02 -08001018}
mtklein709d2c32015-01-15 08:30:25 -08001019
mtkleina5114d72015-08-24 13:27:01 -07001020static bool dump_png(SkBitmap bitmap, const char* path, const char* md5) {
Mike Klein13b6afd2017-06-12 12:45:41 -04001021 SkPixmap pm;
1022 if (!bitmap.peekPixels(&pm)) {
1023 return false; // Ought to never happen... we're already read-back at this point.
mtkleina5114d72015-08-24 13:27:01 -07001024 }
Mike Klein13b6afd2017-06-12 12:45:41 -04001025 SkFILEWStream dst{path};
mtkleina5114d72015-08-24 13:27:01 -07001026
mtkleind69ece62015-09-10 10:37:44 -07001027 SkString description;
1028 description.append("Key: ");
1029 for (int i = 0; i < FLAGS_key.count(); i++) {
1030 description.appendf("%s ", FLAGS_key[i]);
1031 }
1032 description.append("Properties: ");
1033 for (int i = 0; i < FLAGS_properties.count(); i++) {
1034 description.appendf("%s ", FLAGS_properties[i]);
1035 }
1036 description.appendf("MD5: %s", md5);
1037
Mike Klein13b6afd2017-06-12 12:45:41 -04001038 const char* comments[] = {
1039 "Author", "DM dump_png()",
1040 "Description", description.c_str(),
1041 };
1042 size_t lengths[] = {
1043 strlen(comments[0])+1, strlen(comments[1])+1,
1044 strlen(comments[2])+1, strlen(comments[3])+1,
1045 };
mtkleina5114d72015-08-24 13:27:01 -07001046
Mike Klein13b6afd2017-06-12 12:45:41 -04001047 SkPngEncoder::Options options;
1048 options.fComments = SkDataTable::MakeCopyArrays((const void**)comments, lengths, 4);
1049 options.fFilterFlags = SkPngEncoder::FilterFlag::kNone;
1050 options.fZLibLevel = 1;
1051 options.fUnpremulBehavior = pm.colorSpace() ? SkTransferFunctionBehavior::kRespect
1052 : SkTransferFunctionBehavior::kIgnore;
1053 return SkPngEncoder::Encode(&dst, pm, options);
mtkleina5114d72015-08-24 13:27:01 -07001054}
1055
mtkleina2ef6422015-01-15 13:44:22 -08001056static bool match(const char* needle, const char* haystack) {
Chris Daltonecf78ac2017-08-15 15:43:08 -06001057 if ('~' == needle[0]) {
1058 return !match(needle + 1, haystack);
1059 }
1060 if (0 == strcmp("_", needle)) {
1061 return true;
1062 }
1063 return nullptr != strstr(haystack, needle);
mtkleina2ef6422015-01-15 13:44:22 -08001064}
1065
mtklein3eed7dd2016-02-24 19:07:07 -08001066static bool is_blacklisted(const char* sink, const char* src,
1067 const char* srcOptions, const char* name) {
mtklein0d243ff2015-04-03 07:51:00 -07001068 for (int i = 0; i < FLAGS_blacklist.count() - 3; i += 4) {
mtkleina2ef6422015-01-15 13:44:22 -08001069 if (match(FLAGS_blacklist[i+0], sink) &&
djsollen54416de2015-04-03 07:24:48 -07001070 match(FLAGS_blacklist[i+1], src) &&
1071 match(FLAGS_blacklist[i+2], srcOptions) &&
1072 match(FLAGS_blacklist[i+3], name)) {
mtklein3eed7dd2016-02-24 19:07:07 -08001073 return true;
mtkleina2ef6422015-01-15 13:44:22 -08001074 }
1075 }
mtklein3eed7dd2016-02-24 19:07:07 -08001076 return false;
mtkleina2ef6422015-01-15 13:44:22 -08001077}
1078
mtkleincd50bca2016-01-05 06:20:20 -08001079// Even when a Task Sink reports to be non-threadsafe (e.g. GPU), we know things like
1080// .png encoding are definitely thread safe. This lets us offload that work to CPU threads.
1081static SkTaskGroup gDefinitelyThreadSafeWork;
1082
mtklein748ca3b2015-01-15 10:56:12 -08001083// The finest-grained unit of work we can run: draw a single Src into a single Sink,
1084// report any errors, and perhaps write out the output: a .png of the bitmap, or a raw stream.
1085struct Task {
mtkleine0effd62015-07-29 06:37:28 -07001086 Task(const TaggedSrc& src, const TaggedSink& sink) : src(src), sink(sink) {}
1087 const TaggedSrc& src;
1088 const TaggedSink& sink;
mtklein748ca3b2015-01-15 10:56:12 -08001089
mtklein21eaf3b2016-02-08 12:39:59 -08001090 static void Run(const Task& task) {
1091 SkString name = task.src->name();
mtkleine0effd62015-07-29 06:37:28 -07001092
mtkleinb9eb4ac2015-02-02 18:26:03 -08001093 SkString log;
mtklein3eed7dd2016-02-24 19:07:07 -08001094 if (!FLAGS_dryRun) {
mtklein748ca3b2015-01-15 10:56:12 -08001095 SkBitmap bitmap;
1096 SkDynamicMemoryWStream stream;
mtklein3eed7dd2016-02-24 19:07:07 -08001097 start(task.sink.tag.c_str(), task.src.tag.c_str(),
1098 task.src.options.c_str(), name.c_str());
mtklein21eaf3b2016-02-08 12:39:59 -08001099 Error err = task.sink->draw(*task.src, &bitmap, &stream, &log);
mtkleinb3b13b72016-03-07 13:20:52 -08001100 if (!log.isEmpty()) {
mtkleinc41fd922016-03-08 09:01:39 -08001101 info("%s %s %s %s:\n%s\n", task.sink.tag.c_str()
1102 , task.src.tag.c_str()
1103 , task.src.options.c_str()
1104 , name.c_str()
1105 , log.c_str());
mtkleinb3b13b72016-03-07 13:20:52 -08001106 }
mtklein748ca3b2015-01-15 10:56:12 -08001107 if (!err.isEmpty()) {
mtklein4089ef72015-03-05 08:40:28 -08001108 if (err.isFatal()) {
djsollen54416de2015-04-03 07:24:48 -07001109 fail(SkStringPrintf("%s %s %s %s: %s",
mtklein21eaf3b2016-02-08 12:39:59 -08001110 task.sink.tag.c_str(),
1111 task.src.tag.c_str(),
1112 task.src.options.c_str(),
mtklein4089ef72015-03-05 08:40:28 -08001113 name.c_str(),
1114 err.c_str()));
mtkleinb37cb412015-03-18 05:27:14 -07001115 } else {
mtklein3eed7dd2016-02-24 19:07:07 -08001116 done(task.sink.tag.c_str(), task.src.tag.c_str(),
1117 task.src.options.c_str(), name.c_str());
mtkleinba6ada72016-01-21 09:39:35 -08001118 return;
mtklein4089ef72015-03-05 08:40:28 -08001119 }
mtklein748ca3b2015-01-15 10:56:12 -08001120 }
mtklein62bd1a62015-01-27 14:46:26 -08001121
mtkleincd50bca2016-01-05 06:20:20 -08001122 // We're likely switching threads here, so we must capture by value, [=] or [foo,bar].
Hal Canary0b833192017-03-14 14:35:02 -04001123 SkStreamAsset* data = stream.detachAsStream().release();
mtkleincd50bca2016-01-05 06:20:20 -08001124 gDefinitelyThreadSafeWork.add([task,name,bitmap,data]{
Ben Wagner145dbcd2016-11-03 14:40:50 -04001125 std::unique_ptr<SkStreamAsset> ownedData(data);
mtkleincd50bca2016-01-05 06:20:20 -08001126
mtkleincd50bca2016-01-05 06:20:20 -08001127 SkString md5;
1128 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) {
1129 SkMD5 hash;
1130 if (data->getLength()) {
1131 hash.writeStream(data, data->getLength());
1132 data->rewind();
mtklein38408462015-07-08 07:25:27 -07001133 } else {
mtkleincd50bca2016-01-05 06:20:20 -08001134 // If we're BGRA (Linux, Windows), swizzle over to RGBA (Mac, Android).
1135 // This helps eliminate multiple 0-pixel-diff hashes on gold.skia.org.
1136 // (Android's general slow speed breaks the tie arbitrarily in RGBA's favor.)
1137 // We might consider promoting 565 to RGBA too.
1138 if (bitmap.colorType() == kBGRA_8888_SkColorType) {
1139 SkBitmap swizzle;
Matt Sarett68b8e3d2017-04-28 11:15:22 -04001140 SkAssertResult(sk_tool_utils::copy_to(&swizzle, kRGBA_8888_SkColorType,
1141 bitmap));
Mike Reedf0ffb892017-10-03 14:47:21 -04001142 hash.write(swizzle.getPixels(), swizzle.computeByteSize());
mtkleincd50bca2016-01-05 06:20:20 -08001143 } else {
Mike Reedf0ffb892017-10-03 14:47:21 -04001144 hash.write(bitmap.getPixels(), bitmap.computeByteSize());
mtkleincd50bca2016-01-05 06:20:20 -08001145 }
1146 }
1147 SkMD5::Digest digest;
1148 hash.finish(digest);
1149 for (int i = 0; i < 16; i++) {
1150 md5.appendf("%02x", digest.data[i]);
mtklein38408462015-07-08 07:25:27 -07001151 }
mtklein62bd1a62015-01-27 14:46:26 -08001152 }
mtklein62bd1a62015-01-27 14:46:26 -08001153
mtkleincd50bca2016-01-05 06:20:20 -08001154 if (!FLAGS_readPath.isEmpty() &&
mtklein3eed7dd2016-02-24 19:07:07 -08001155 !gGold.contains(Gold(task.sink.tag, task.src.tag,
1156 task.src.options, name, md5))) {
mtkleincd50bca2016-01-05 06:20:20 -08001157 fail(SkStringPrintf("%s not found for %s %s %s %s in %s",
1158 md5.c_str(),
mtklein21eaf3b2016-02-08 12:39:59 -08001159 task.sink.tag.c_str(),
1160 task.src.tag.c_str(),
1161 task.src.options.c_str(),
mtkleincd50bca2016-01-05 06:20:20 -08001162 name.c_str(),
1163 FLAGS_readPath[0]));
mtklein748ca3b2015-01-15 10:56:12 -08001164 }
mtkleincd50bca2016-01-05 06:20:20 -08001165
1166 if (!FLAGS_writePath.isEmpty()) {
mtklein21eaf3b2016-02-08 12:39:59 -08001167 const char* ext = task.sink->fileExtension();
Brian Osmanf1942de2017-08-30 14:50:22 -04001168 if (ext && !FLAGS_dont_write.contains(ext)) {
Mike Klein97d6a7a2017-07-24 10:37:19 -04001169 if (data->getLength()) {
1170 WriteToDisk(task, md5, ext, data, data->getLength(), nullptr);
1171 SkASSERT(bitmap.drawsNothing());
1172 } else if (!bitmap.drawsNothing()) {
1173 WriteToDisk(task, md5, ext, nullptr, 0, &bitmap);
1174 }
mtkleincd50bca2016-01-05 06:20:20 -08001175 }
1176 }
1177 });
mtklein748ca3b2015-01-15 10:56:12 -08001178 }
mtklein3eed7dd2016-02-24 19:07:07 -08001179 done(task.sink.tag.c_str(), task.src.tag.c_str(), task.src.options.c_str(), name.c_str());
mtklein748ca3b2015-01-15 10:56:12 -08001180 }
1181
1182 static void WriteToDisk(const Task& task,
mtklein62bd1a62015-01-27 14:46:26 -08001183 SkString md5,
1184 const char* ext,
mtklein748ca3b2015-01-15 10:56:12 -08001185 SkStream* data, size_t len,
mtklein62bd1a62015-01-27 14:46:26 -08001186 const SkBitmap* bitmap) {
mtklein409d4702016-02-29 07:38:01 -08001187 bool gammaCorrect = false;
1188 if (bitmap) {
Brian Osman7039f742016-11-01 15:56:16 -04001189 gammaCorrect = SkToBool(bitmap->info().colorSpace());
mtklein409d4702016-02-29 07:38:01 -08001190 }
1191
mtklein748ca3b2015-01-15 10:56:12 -08001192 JsonWriter::BitmapResult result;
djsollen54416de2015-04-03 07:24:48 -07001193 result.name = task.src->name();
mtklein3eed7dd2016-02-24 19:07:07 -08001194 result.config = task.sink.tag;
djsollen54416de2015-04-03 07:24:48 -07001195 result.sourceType = task.src.tag;
1196 result.sourceOptions = task.src.options;
1197 result.ext = ext;
mtklein409d4702016-02-29 07:38:01 -08001198 result.gammaCorrect = gammaCorrect;
djsollen54416de2015-04-03 07:24:48 -07001199 result.md5 = md5;
mtklein748ca3b2015-01-15 10:56:12 -08001200 JsonWriter::AddBitmapResult(result);
1201
mtkleinb0531a72015-04-07 13:38:48 -07001202 // If an MD5 is uninteresting, we want it noted in the JSON file,
1203 // but don't want to dump it out as a .png (or whatever ext is).
1204 if (gUninterestingHashes.contains(md5)) {
1205 return;
1206 }
1207
mtklein748ca3b2015-01-15 10:56:12 -08001208 const char* dir = FLAGS_writePath[0];
1209 if (0 == strcmp(dir, "@")) { // Needed for iOS.
1210 dir = FLAGS_resourcePath[0];
1211 }
1212 sk_mkdir(dir);
1213
1214 SkString path;
1215 if (FLAGS_nameByHash) {
1216 path = SkOSPath::Join(dir, result.md5.c_str());
1217 path.append(".");
1218 path.append(ext);
1219 if (sk_exists(path.c_str())) {
1220 return; // Content-addressed. If it exists already, we're done.
1221 }
1222 } else {
kkinnunen3e980c32015-12-23 01:33:00 -08001223 path = SkOSPath::Join(dir, task.sink.tag.c_str());
mtklein748ca3b2015-01-15 10:56:12 -08001224 sk_mkdir(path.c_str());
msarett9e707a02015-09-01 14:57:57 -07001225 path = SkOSPath::Join(path.c_str(), task.src.tag.c_str());
mtklein748ca3b2015-01-15 10:56:12 -08001226 sk_mkdir(path.c_str());
msarett9e707a02015-09-01 14:57:57 -07001227 if (strcmp(task.src.options.c_str(), "") != 0) {
1228 path = SkOSPath::Join(path.c_str(), task.src.options.c_str());
djsollen54416de2015-04-03 07:24:48 -07001229 sk_mkdir(path.c_str());
1230 }
mtklein748ca3b2015-01-15 10:56:12 -08001231 path = SkOSPath::Join(path.c_str(), task.src->name().c_str());
1232 path.append(".");
1233 path.append(ext);
1234 }
1235
mtklein748ca3b2015-01-15 10:56:12 -08001236 if (bitmap) {
mtkleina5114d72015-08-24 13:27:01 -07001237 if (!dump_png(*bitmap, path.c_str(), result.md5.c_str())) {
mtklein748ca3b2015-01-15 10:56:12 -08001238 fail(SkStringPrintf("Can't encode PNG to %s.\n", path.c_str()));
1239 return;
1240 }
1241 } else {
mtkleina5114d72015-08-24 13:27:01 -07001242 SkFILEWStream file(path.c_str());
1243 if (!file.isValid()) {
1244 fail(SkStringPrintf("Can't open %s for writing.\n", path.c_str()));
1245 return;
1246 }
mtklein748ca3b2015-01-15 10:56:12 -08001247 if (!file.writeStream(data, len)) {
1248 fail(SkStringPrintf("Can't write to %s.\n", path.c_str()));
1249 return;
1250 }
1251 }
1252 }
1253};
1254
mtklein748ca3b2015-01-15 10:56:12 -08001255/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1256
1257// Unit tests don't fit so well into the Src/Sink model, so we give them special treatment.
1258
mtklein21eaf3b2016-02-08 12:39:59 -08001259static SkTDArray<skiatest::Test> gParallelTests, gSerialTests;
mtklein748ca3b2015-01-15 10:56:12 -08001260
1261static void gather_tests() {
mtklein6c5fed22015-01-20 13:47:23 -08001262 if (!FLAGS_src.contains("tests")) {
mtklein748ca3b2015-01-15 10:56:12 -08001263 return;
1264 }
mtklein6393c062015-04-27 08:45:01 -07001265 for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; r = r->next()) {
1266 if (!in_shard()) {
1267 continue;
1268 }
halcanary87f3ba42015-01-20 09:30:20 -08001269 // Despite its name, factory() is returning a reference to
1270 // link-time static const POD data.
1271 const skiatest::Test& test = r->factory();
1272 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test.name)) {
mtklein748ca3b2015-01-15 10:56:12 -08001273 continue;
1274 }
halcanary87f3ba42015-01-20 09:30:20 -08001275 if (test.needsGpu && gpu_supported()) {
mtklein21eaf3b2016-02-08 12:39:59 -08001276 (FLAGS_gpu_threading ? gParallelTests : gSerialTests).push(test);
halcanary87f3ba42015-01-20 09:30:20 -08001277 } else if (!test.needsGpu && FLAGS_cpu) {
mtklein21eaf3b2016-02-08 12:39:59 -08001278 gParallelTests.push(test);
mtklein82d28432015-01-15 12:46:02 -08001279 }
mtklein748ca3b2015-01-15 10:56:12 -08001280 }
1281}
1282
csmartdalton008b9d82017-02-22 12:00:42 -07001283static void run_test(skiatest::Test test, const GrContextOptions& grCtxOptions) {
halcanary87f3ba42015-01-20 09:30:20 -08001284 struct : public skiatest::Reporter {
mtklein36352bf2015-03-25 18:17:31 -07001285 void reportFailed(const skiatest::Failure& failure) override {
halcanary87f3ba42015-01-20 09:30:20 -08001286 fail(failure.toString());
1287 JsonWriter::AddTestFailure(failure);
1288 }
mtklein36352bf2015-03-25 18:17:31 -07001289 bool allowExtendedTest() const override {
halcanary87f3ba42015-01-20 09:30:20 -08001290 return FLAGS_pathOpsExtended;
1291 }
mtklein36352bf2015-03-25 18:17:31 -07001292 bool verbose() const override { return FLAGS_veryVerbose; }
halcanary87f3ba42015-01-20 09:30:20 -08001293 } reporter;
djsollen824996a2015-06-12 12:06:22 -07001294
mtklein3eed7dd2016-02-24 19:07:07 -08001295 if (!FLAGS_dryRun && !is_blacklisted("_", "tests", "_", test.name)) {
Robert Phillipsec325342017-10-30 18:02:48 +00001296 GrContextOptions options = grCtxOptions;
1297 test.modifyGrContextOptions(&options);
1298
mtklein21eaf3b2016-02-08 12:39:59 -08001299 start("unit", "test", "", test.name);
Brian Salomondcfca432017-11-15 15:48:03 -05001300 test.run(&reporter, options);
mtklein748ca3b2015-01-15 10:56:12 -08001301 }
mtklein3eed7dd2016-02-24 19:07:07 -08001302 done("unit", "test", "", test.name);
mtklein748ca3b2015-01-15 10:56:12 -08001303}
1304
1305/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1306
caryclark83ca6282015-06-10 09:31:09 -07001307#define PORTABLE_FONT_PREFIX "Toy Liberation "
1308
mbocee6a9912016-05-31 11:42:36 -07001309static sk_sp<SkTypeface> create_from_name(const char familyName[], SkFontStyle style) {
caryclark83ca6282015-06-10 09:31:09 -07001310 if (familyName && strlen(familyName) > sizeof(PORTABLE_FONT_PREFIX)
1311 && !strncmp(familyName, PORTABLE_FONT_PREFIX, sizeof(PORTABLE_FONT_PREFIX) - 1)) {
caryclark1818acb2015-07-24 12:09:25 -07001312 return sk_tool_utils::create_portable_typeface(familyName, style);
caryclark83ca6282015-06-10 09:31:09 -07001313 }
halcanary96fcdcc2015-08-27 07:41:13 -07001314 return nullptr;
caryclark83ca6282015-06-10 09:31:09 -07001315}
1316
1317#undef PORTABLE_FONT_PREFIX
1318
mbocee6a9912016-05-31 11:42:36 -07001319extern sk_sp<SkTypeface> (*gCreateTypefaceDelegate)(const char [], SkFontStyle );
caryclark83ca6282015-06-10 09:31:09 -07001320
Mike Kleinbe28ee22017-02-06 12:46:20 -05001321int main(int argc, char** argv) {
Dongwon Kang0c7861f2018-02-16 10:55:21 -08001322#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(SK_HAS_HEIF_LIBRARY)
1323 android::ProcessState::self()->startThreadPool();
1324#endif
Mike Kleinbe28ee22017-02-06 12:46:20 -05001325 SkCommandLineFlags::Parse(argc, argv);
Brian Osman53136aa2017-07-20 15:43:35 -04001326
Mike Klein31868212017-11-06 12:02:47 -05001327 if (!FLAGS_nativeFonts) {
Ben Wagner483c7722018-02-20 17:06:07 -05001328 gSkFontMgr_DefaultFactory = &sk_tool_utils::MakePortableFontMgr;
Mike Klein31868212017-11-06 12:02:47 -05001329 }
1330
Mike Klein0c5fdcb2017-11-13 12:40:46 -05001331#if defined(SK_BUILD_FOR_WIN)
1332 if (FLAGS_gdi) {
Hal Canaryccafca02017-11-14 10:34:48 -05001333 gSkFontMgr_DefaultFactory = &SkFontMgr_New_GDI;
Mike Klein0c5fdcb2017-11-13 12:40:46 -05001334 }
1335#endif
1336
Brian Osmanbc8150f2017-07-24 11:38:01 -04001337 initializeEventTracingForTools();
Brian Osman53136aa2017-07-20 15:43:35 -04001338
Mike Klein6613cc52017-12-19 09:09:33 -05001339#if !defined(SK_BUILD_FOR_GOOGLE3) && defined(SK_BUILD_FOR_IOS)
Mike Kleinadacaef2017-02-06 09:26:14 -05001340 cd_Documents();
1341#endif
bsalomon71de3532016-04-26 14:27:21 -07001342 setbuf(stdout, nullptr);
mtklein246ba3a2016-02-23 10:39:36 -08001343 setup_crash_handler();
mtkleinafae30a2016-02-24 12:28:32 -08001344
Yuqian Liba62b4a2016-12-14 13:46:53 -05001345 gSkUseAnalyticAA = FLAGS_analyticAA;
Yuqian Lidf60e362017-07-25 11:26:31 -04001346 gSkUseDeltaAA = FLAGS_deltaAA;
liyuqian38911a72016-10-04 11:23:22 -07001347
Yuqian Li550148b2017-01-13 10:13:13 -05001348 if (FLAGS_forceAnalyticAA) {
1349 gSkForceAnalyticAA = true;
1350 }
Yuqian Lia81b6262017-09-06 17:10:05 -04001351 if (FLAGS_forceDeltaAA) {
1352 gSkForceDeltaAA = true;
1353 }
Mike Reed7c26ca72017-07-05 15:45:52 -04001354 if (FLAGS_forceRasterPipeline) {
1355 gSkForceRasterPipelineBlitter = true;
1356 }
Yuqian Li550148b2017-01-13 10:13:13 -05001357
Mike Kleine9f187b2017-06-26 13:23:12 -04001358 // The bots like having a verbose.log to upload, so always touch the file even if --verbose.
1359 if (!FLAGS_writePath.isEmpty()) {
mtklein51c8cfc2016-03-11 12:59:09 -08001360 sk_mkdir(FLAGS_writePath[0]);
mtkleina1ce2162016-07-22 12:23:46 -07001361 gVLog = fopen(SkOSPath::Join(FLAGS_writePath[0], "verbose.log").c_str(), "w");
mtkleinc41fd922016-03-08 09:01:39 -08001362 }
Mike Kleine9f187b2017-06-26 13:23:12 -04001363 if (FLAGS_verbose) {
1364 gVLog = stderr;
1365 }
mtkleinc41fd922016-03-08 09:01:39 -08001366
csmartdalton008b9d82017-02-22 12:00:42 -07001367 GrContextOptions grCtxOptions;
1368#if SK_SUPPORT_GPU
Chris Dalton040238b2017-12-18 14:22:34 -07001369 SetCtxOptionsFromCommonFlags(&grCtxOptions);
csmartdalton008b9d82017-02-22 12:00:42 -07001370#endif
1371
mtklein5286f022016-01-22 08:18:14 -08001372 JsonWriter::DumpJson(); // It's handy for the bots to assume this is ~never missing.
commit-bot@chromium.org39e8d932014-05-29 20:14:48 +00001373 SkAutoGraphics ag;
mtklein406654b2014-09-03 15:34:37 -07001374 SkTaskGroup::Enabler enabled(FLAGS_threads);
caryclark83ca6282015-06-10 09:31:09 -07001375 gCreateTypefaceDelegate = &create_from_name;
commit-bot@chromium.orga65e2fd2014-05-30 17:23:31 +00001376
Mike Reed0933bc92017-12-09 01:27:41 +00001377 if (nullptr == GetResourceAsData("images/color_wheel.png")) {
1378 info("Some resources are missing. Do you need to set --resourcePath?\n");
halcanary7d571242016-02-24 17:59:16 -08001379 }
mtklein62bd1a62015-01-27 14:46:26 -08001380 gather_gold();
borenet09ed4802015-04-03 14:15:33 -07001381 gather_uninteresting_hashes();
mtklein62bd1a62015-01-27 14:46:26 -08001382
scroggo86737142016-02-03 12:19:11 -08001383 if (!gather_srcs()) {
1384 return 1;
1385 }
Ben Wagnerf28d4722017-08-11 17:33:22 -04001386 // TODO(dogben): This is a bit ugly. Find a cleaner way to do this.
1387 bool defaultConfigs = true;
1388 for (int i = 0; i < argc; i++) {
1389 static const char* kConfigArg = "--config";
1390 if (strcmp(argv[i], kConfigArg) == 0) {
1391 defaultConfigs = false;
1392 break;
1393 }
1394 }
1395 if (!gather_sinks(grCtxOptions, defaultConfigs)) {
brianosman05c987c2016-05-09 13:42:16 -07001396 return 1;
1397 }
mtklein748ca3b2015-01-15 10:56:12 -08001398 gather_tests();
mtklein21eaf3b2016-02-08 12:39:59 -08001399 gPending = gSrcs.count() * gSinks.count() + gParallelTests.count() + gSerialTests.count();
Brian Osmand0677bc2017-08-03 12:13:47 -04001400 info("%d srcs * %d sinks + %d tests == %d tasks\n",
mtkleinc41fd922016-03-08 09:01:39 -08001401 gSrcs.count(), gSinks.count(), gParallelTests.count() + gSerialTests.count(), gPending);
mtklein748ca3b2015-01-15 10:56:12 -08001402
mtklein21eaf3b2016-02-08 12:39:59 -08001403 // Kick off as much parallel work as we can, making note of any serial work we'll need to do.
1404 SkTaskGroup parallel;
1405 SkTArray<Task> serial;
1406
1407 for (auto& sink : gSinks)
1408 for (auto& src : gSrcs) {
mtklein3eed7dd2016-02-24 19:07:07 -08001409 if (src->veto(sink->flags()) ||
1410 is_blacklisted(sink.tag.c_str(), src.tag.c_str(),
1411 src.options.c_str(), src->name().c_str())) {
mtkleinf10637f2016-06-10 13:56:35 -07001412 SkAutoMutexAcquire lock(gMutex);
mtklein3eed7dd2016-02-24 19:07:07 -08001413 gPending--;
1414 continue;
1415 }
1416
mtklein21eaf3b2016-02-08 12:39:59 -08001417 Task task(src, sink);
1418 if (src->serial() || sink->serial()) {
1419 serial.push_back(task);
1420 } else {
1421 parallel.add([task] { Task::Run(task); });
mtklein748ca3b2015-01-15 10:56:12 -08001422 }
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +00001423 }
mtklein21eaf3b2016-02-08 12:39:59 -08001424 for (auto test : gParallelTests) {
csmartdalton008b9d82017-02-22 12:00:42 -07001425 parallel.add([test, grCtxOptions] { run_test(test, grCtxOptions); });
mtklein55e88b22015-01-21 15:50:13 -08001426 }
mtklein21eaf3b2016-02-08 12:39:59 -08001427
1428 // With the parallel work running, run serial tasks and tests here on main thread.
1429 for (auto task : serial) { Task::Run(task); }
csmartdalton008b9d82017-02-22 12:00:42 -07001430 for (auto test : gSerialTests) { run_test(test, grCtxOptions); }
mtklein21eaf3b2016-02-08 12:39:59 -08001431
1432 // Wait for any remaining parallel work to complete (including any spun off of serial tasks).
1433 parallel.wait();
mtkleincd50bca2016-01-05 06:20:20 -08001434 gDefinitelyThreadSafeWork.wait();
1435
mtkleinda884c42016-02-24 18:00:23 -08001436 // We'd better have run everything.
1437 SkASSERT(gPending == 0);
mtkleine027f172016-02-26 15:53:06 -08001438 // Make sure we've flushed all our results to disk.
1439 JsonWriter::DumpJson();
mtkleinda884c42016-02-24 18:00:23 -08001440
mtklein748ca3b2015-01-15 10:56:12 -08001441 // At this point we're back in single-threaded land.
caryclarkf53ce802015-06-15 06:48:30 -07001442 sk_tool_utils::release_portable_typefaces();
mtklein@google.comd36522d2013-10-16 13:02:15 +00001443
mtklein748ca3b2015-01-15 10:56:12 -08001444 if (gFailures.count() > 0) {
mtkleinc41fd922016-03-08 09:01:39 -08001445 info("Failures:\n");
mtklein748ca3b2015-01-15 10:56:12 -08001446 for (int i = 0; i < gFailures.count(); i++) {
mtkleinc41fd922016-03-08 09:01:39 -08001447 info("\t%s\n", gFailures[i].c_str());
mtklein748ca3b2015-01-15 10:56:12 -08001448 }
mtkleinc41fd922016-03-08 09:01:39 -08001449 info("%d failures\n", gFailures.count());
mtklein748ca3b2015-01-15 10:56:12 -08001450 return 1;
mtklein114c3cd2015-01-15 10:15:02 -08001451 }
mtkleinafae30a2016-02-24 12:28:32 -08001452
1453#ifdef SK_PDF_IMAGE_STATS
halcanary7a14b312015-10-01 07:28:13 -07001454 SkPDFImageDumpStats();
mtkleinafae30a2016-02-24 12:28:32 -08001455#endif // SK_PDF_IMAGE_STATS
1456
Herb Derby5a523fe2017-01-26 16:48:28 -05001457 SkGraphics::PurgeAllCaches();
mtkleinc41fd922016-03-08 09:01:39 -08001458 info("Finished!\n");
Brian Osman53136aa2017-07-20 15:43:35 -04001459
mtklein748ca3b2015-01-15 10:56:12 -08001460 return 0;
mtklein@google.comd36522d2013-10-16 13:02:15 +00001461}