blob: 37ff24d8d6f67a8678115702e849bb44194f05d3 [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"
csmartdalton008b9d82017-02-22 12:00:42 -070021#include "SkCommonFlagsPathRenderer.h"
brianosman3c579dc2016-04-19 09:18:11 -070022#include "SkData.h"
Hal Canaryc7d295e2017-07-20 15:36:00 -040023#include "SkDocument.h"
Brian Salomondcbb9d92017-07-19 10:53:20 -040024#include "SkDebugfTracer.h"
Brian Osman53136aa2017-07-20 15:43:35 -040025#include "SkEventTracingPriv.h"
caryclark83ca6282015-06-10 09:31:09 -070026#include "SkFontMgr.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +000027#include "SkGraphics.h"
mtklein27c3fdd2016-02-26 14:43:21 -080028#include "SkHalf.h"
halcanary4dbbd042016-06-07 17:21:10 -070029#include "SkLeanWindows.h"
mtklein748ca3b2015-01-15 10:56:12 -080030#include "SkMD5.h"
mtklein1b249332015-07-07 12:21:21 -070031#include "SkMutex.h"
mtklein1d0f1642014-09-08 08:05:18 -070032#include "SkOSFile.h"
Ben Wagnerbf111d72016-11-07 18:05:29 -050033#include "SkOSPath.h"
mtklein27c3fdd2016-02-26 14:43:21 -080034#include "SkPM4fPriv.h"
Mike Klein13b6afd2017-06-12 12:45:41 -040035#include "SkPngEncoder.h"
Brian Salomondcbb9d92017-07-19 10:53:20 -040036#include "SkScan.h"
mtklein246ba3a2016-02-23 10:39:36 -080037#include "SkSpinlock.h"
mtkleina82f5622015-02-20 12:30:19 -080038#include "SkTHash.h"
mtklein406654b2014-09-03 15:34:37 -070039#include "SkTaskGroup.h"
mtkleinde6fc2b2015-03-12 06:28:54 -070040#include "SkThreadUtils.h"
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000041#include "Test.h"
mtklein748ca3b2015-01-15 10:56:12 -080042#include "Timer.h"
Mike Kleinadacaef2017-02-06 09:26:14 -050043#include "ios_utils.h"
brianosman3c579dc2016-04-19 09:18:11 -070044#include "picture_utils.h"
caryclark83ca6282015-06-10 09:31:09 -070045#include "sk_tool_utils.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +000046
scroggo19b91532016-10-24 09:03:26 -070047#include <vector>
48
halcanary7a14b312015-10-01 07:28:13 -070049#ifdef SK_PDF_IMAGE_STATS
50extern void SkPDFImageDumpStats();
51#endif
52
mtkleina5114d72015-08-24 13:27:01 -070053#include "png.h"
54
bungeman60e0fee2015-08-26 05:15:46 -070055#include <stdlib.h>
56
scroggo27a58342015-10-28 08:56:41 -070057#ifndef SK_BUILD_FOR_WIN32
58 #include <unistd.h>
59#endif
60
Mike Reed7c26ca72017-07-05 15:45:52 -040061extern bool gSkForceRasterPipelineBlitter;
62
Ben Wagner32fa5102017-08-10 21:25:55 -040063DECLARE_bool(undefok);
djsollen54416de2015-04-03 07:24:48 -070064DEFINE_string(src, "tests gm skp image", "Source types to test.");
mtklein748ca3b2015-01-15 10:56:12 -080065DEFINE_bool(nameByHash, false,
66 "If true, write to FLAGS_writePath[0]/<hash>.png instead of "
djsollen54416de2015-04-03 07:24:48 -070067 "to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>.png");
mtklein748ca3b2015-01-15 10:56:12 -080068DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
mtkleind603b222015-02-17 11:13:33 -080069DEFINE_string(matrix, "1 0 0 1",
70 "2x2 scale+skew matrix to apply or upright when using "
71 "'matrix' or 'upright' in config.");
mtklein82d28432015-01-15 12:46:02 -080072DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
mtklein@google.comd36522d2013-10-16 13:02:15 +000073
mtkleina2ef6422015-01-15 13:44:22 -080074DEFINE_string(blacklist, "",
Chris Daltonecf78ac2017-08-15 15:43:08 -060075 "Space-separated config/src/srcOptions/name quadruples to blacklist. "
76 "'_' matches anything. '~' negates the match. E.g. \n"
djsollen54416de2015-04-03 07:24:48 -070077 "'--blacklist gpu skp _ _' will blacklist all SKPs drawn into the gpu config.\n"
Chris Daltonecf78ac2017-08-15 15:43:08 -060078 "'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aarects GM on 8888.\n"
79 "'--blacklist ~8888 svg _ svgparse_' blocks non-8888 SVGs that contain \"svgparse_\" in "
80 "the name.");
mtkleina2ef6422015-01-15 13:44:22 -080081
mtklein62bd1a62015-01-27 14:46:26 -080082DEFINE_string2(readPath, r, "", "If set check for equality with golden results in this directory.");
83
borenet09ed4802015-04-03 14:15:33 -070084DEFINE_string(uninterestingHashesFile, "",
85 "File containing a list of uninteresting hashes. If a result hashes to something in "
86 "this list, no image is written for that result.");
87
mtklein6393c062015-04-27 08:45:01 -070088DEFINE_int32(shards, 1, "We're splitting source data into this many shards.");
89DEFINE_int32(shard, 0, "Which shard do I run?");
90
halcanary45420a92016-06-02 12:41:14 -070091DEFINE_string(mskps, "", "Directory to read mskps from, or a single mskp file.");
Mike Reed7c26ca72017-07-05 15:45:52 -040092DEFINE_bool(forceRasterPipeline, false, "sets gSkForceRasterPipelineBlitter");
halcanary45420a92016-06-02 12:41:14 -070093
csmartdalton008b9d82017-02-22 12:00:42 -070094#if SK_SUPPORT_GPU
95DEFINE_pathrenderer_flag;
96#endif
97
Derek Sollenbergeredfe3df2017-07-19 15:25:24 -040098DEFINE_bool(ignoreSigInt, false, "ignore SIGINT signals during test execution");
99
Mike Klein97d6a7a2017-07-24 10:37:19 -0400100DEFINE_string(dont_write, "", "File extensions to skip writing to --writePath."); // See skia:6821
101
mtklein748ca3b2015-01-15 10:56:12 -0800102using namespace DM;
bsalomon3724e572016-03-30 18:56:19 -0700103using sk_gpu_test::GrContextFactory;
bsalomon273c0f52016-03-31 10:59:06 -0700104using sk_gpu_test::GLTestContext;
bsalomonf2f1c172016-04-05 12:59:06 -0700105using sk_gpu_test::ContextInfo;
mtklein@google.comd36522d2013-10-16 13:02:15 +0000106
mtklein748ca3b2015-01-15 10:56:12 -0800107/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
108
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700109static const double kStartMs = SkTime::GetMSecs();
mtkleinc41fd922016-03-08 09:01:39 -0800110
111static FILE* gVLog;
112
113template <typename... Args>
114static void vlog(const char* fmt, Args&&... args) {
115 if (gVLog) {
116 fprintf(gVLog, "%s\t", HumanizeMs(SkTime::GetMSecs() - kStartMs).c_str());
117 fprintf(gVLog, fmt, args...);
118 fflush(gVLog);
119 }
120}
121
122template <typename... Args>
123static void info(const char* fmt, Args&&... args) {
124 vlog(fmt, args...);
125 if (!FLAGS_quiet) {
126 printf(fmt, args...);
127 }
128}
129static void info(const char* fmt) {
130 if (!FLAGS_quiet) {
131 printf("%s", fmt); // Clang warns printf(fmt) is insecure.
132 }
133}
134
reed086eea92016-05-04 17:12:46 -0700135SK_DECLARE_STATIC_MUTEX(gFailuresMutex);
mtklein748ca3b2015-01-15 10:56:12 -0800136static SkTArray<SkString> gFailures;
137
mtklein3eed7dd2016-02-24 19:07:07 -0800138static void fail(const SkString& err) {
mtklein748ca3b2015-01-15 10:56:12 -0800139 SkAutoMutexAcquire lock(gFailuresMutex);
140 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str());
141 gFailures.push_back(err);
halcanary9e398f72015-01-10 11:18:04 -0800142}
143
mtklein0f7748a2016-07-25 15:27:29 -0700144struct Running {
145 SkString id;
146 SkThreadID thread;
147
148 void dump() const {
149 info("\t%s\n", id.c_str());
150 }
151};
mtkleinb37cb412015-03-18 05:27:14 -0700152
mtklein246ba3a2016-02-23 10:39:36 -0800153// We use a spinlock to make locking this in a signal handler _somewhat_ safe.
Mike Klein03a95ad2017-06-23 12:36:32 -0400154static SkSpinlock gMutex;
155static int gPending;
mtklein0f7748a2016-07-25 15:27:29 -0700156static SkTArray<Running> gRunning;
mtklein748ca3b2015-01-15 10:56:12 -0800157
mtklein3eed7dd2016-02-24 19:07:07 -0800158static void done(const char* config, const char* src, const char* srcOptions, const char* name) {
159 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
mtkleinc41fd922016-03-08 09:01:39 -0800160 vlog("done %s\n", id.c_str());
mtkleinafae30a2016-02-24 12:28:32 -0800161 int pending;
mtkleinb37cb412015-03-18 05:27:14 -0700162 {
mtkleinf10637f2016-06-10 13:56:35 -0700163 SkAutoMutexAcquire lock(gMutex);
mtkleinb37cb412015-03-18 05:27:14 -0700164 for (int i = 0; i < gRunning.count(); i++) {
mtklein0f7748a2016-07-25 15:27:29 -0700165 if (gRunning[i].id == id) {
mtkleinb37cb412015-03-18 05:27:14 -0700166 gRunning.removeShuffle(i);
167 break;
168 }
169 }
mtkleinafae30a2016-02-24 12:28:32 -0800170 pending = --gPending;
reed50bc0512015-05-19 14:13:31 -0700171 }
Mike Klein03a95ad2017-06-23 12:36:32 -0400172
173 // We write out dm.json file and print out a progress update every once in a while.
174 // Notice this also handles the final dm.json and progress update when pending == 0.
mtkleina17241b2015-01-23 05:48:00 -0800175 if (pending % 500 == 0) {
176 JsonWriter::DumpJson();
Mike Klein03a95ad2017-06-23 12:36:32 -0400177
178 int curr = sk_tools::getCurrResidentSetSizeMB(),
179 peak = sk_tools::getMaxResidentSetSizeMB();
180 SkString elapsed = HumanizeMs(SkTime::GetMSecs() - kStartMs);
181
182 SkAutoMutexAcquire lock(gMutex);
183 info("\n%dMB RAM, %dMB peak, %s elapsed, %d queued, %d active:\n",
184 curr, peak, elapsed.c_str(), gPending - gRunning.count(), gRunning.count());
185 for (auto& task : gRunning) {
186 task.dump();
187 }
mtkleina17241b2015-01-23 05:48:00 -0800188 }
mtklein@google.comd36522d2013-10-16 13:02:15 +0000189}
190
mtklein3eed7dd2016-02-24 19:07:07 -0800191static void start(const char* config, const char* src, const char* srcOptions, const char* name) {
192 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
mtkleinc41fd922016-03-08 09:01:39 -0800193 vlog("start %s\n", id.c_str());
mtkleinf10637f2016-06-10 13:56:35 -0700194 SkAutoMutexAcquire lock(gMutex);
mtklein0f7748a2016-07-25 15:27:29 -0700195 gRunning.push_back({id,SkGetThreadID()});
mtkleinb37cb412015-03-18 05:27:14 -0700196}
197
Mike Klein3cc2d202016-10-24 11:39:43 -0400198static void find_culprit() {
199 // Assumes gMutex is locked.
200 SkThreadID thisThread = SkGetThreadID();
201 for (auto& task : gRunning) {
202 if (task.thread == thisThread) {
203 info("Likely culprit:\n");
204 task.dump();
mtklein0f7748a2016-07-25 15:27:29 -0700205 }
206 }
Mike Klein3cc2d202016-10-24 11:39:43 -0400207}
mtklein0f7748a2016-07-25 15:27:29 -0700208
mtklein246ba3a2016-02-23 10:39:36 -0800209#if defined(SK_BUILD_FOR_WIN32)
mtklein5b64dab2016-06-09 08:59:48 -0700210 static LONG WINAPI crash_handler(EXCEPTION_POINTERS* e) {
mtkleinf8557292016-02-29 06:35:28 -0800211 static const struct {
212 const char* name;
robertphillips75467862016-03-01 14:10:23 -0800213 DWORD code;
mtkleinf8557292016-02-29 06:35:28 -0800214 } kExceptions[] = {
215 #define _(E) {#E, E}
216 _(EXCEPTION_ACCESS_VIOLATION),
217 _(EXCEPTION_BREAKPOINT),
218 _(EXCEPTION_INT_DIVIDE_BY_ZERO),
219 _(EXCEPTION_STACK_OVERFLOW),
220 // TODO: more?
221 #undef _
222 };
223
mtkleinf10637f2016-06-10 13:56:35 -0700224 SkAutoMutexAcquire lock(gMutex);
mtklein5b64dab2016-06-09 08:59:48 -0700225
226 const DWORD code = e->ExceptionRecord->ExceptionCode;
227 info("\nCaught exception %u", code);
228 for (const auto& exception : kExceptions) {
229 if (exception.code == code) {
230 info(" %s", exception.name);
mtkleinf8557292016-02-29 06:35:28 -0800231 }
mtkleinf8557292016-02-29 06:35:28 -0800232 }
mtklein5b64dab2016-06-09 08:59:48 -0700233 info(", was running:\n");
234 for (auto& task : gRunning) {
mtklein0f7748a2016-07-25 15:27:29 -0700235 task.dump();
mtklein5b64dab2016-06-09 08:59:48 -0700236 }
mtklein0f7748a2016-07-25 15:27:29 -0700237 find_culprit();
mtklein5b64dab2016-06-09 08:59:48 -0700238 fflush(stdout);
239
mtkleinf8557292016-02-29 06:35:28 -0800240 // Execute default exception handler... hopefully, exit.
241 return EXCEPTION_EXECUTE_HANDLER;
mtklein246ba3a2016-02-23 10:39:36 -0800242 }
243
Mike Klein3cc2d202016-10-24 11:39:43 -0400244 static void setup_crash_handler() {
245 SetUnhandledExceptionFilter(crash_handler);
246 }
247#else
mtklein246ba3a2016-02-23 10:39:36 -0800248 #include <signal.h>
Mike Klein3cc2d202016-10-24 11:39:43 -0400249 #if !defined(SK_BUILD_FOR_ANDROID)
250 #include <execinfo.h>
Brian Salomondcbb9d92017-07-19 10:53:20 -0400251
252#endif
Mike Klein3cc2d202016-10-24 11:39:43 -0400253
254 static constexpr int max_of() { return 0; }
255 template <typename... Rest>
256 static constexpr int max_of(int x, Rest... rest) {
257 return x > max_of(rest...) ? x : max_of(rest...);
258 }
259
260 static void (*previous_handler[max_of(SIGABRT,SIGBUS,SIGFPE,SIGILL,SIGSEGV)+1])(int);
mtkleinf8557292016-02-29 06:35:28 -0800261
mtklein5b64dab2016-06-09 08:59:48 -0700262 static void crash_handler(int sig) {
mtkleinf10637f2016-06-10 13:56:35 -0700263 SkAutoMutexAcquire lock(gMutex);
mtklein5b64dab2016-06-09 08:59:48 -0700264
265 info("\nCaught signal %d [%s], was running:\n", sig, strsignal(sig));
266 for (auto& task : gRunning) {
mtklein0f7748a2016-07-25 15:27:29 -0700267 task.dump();
mtklein5b64dab2016-06-09 08:59:48 -0700268 }
mtklein0f7748a2016-07-25 15:27:29 -0700269 find_culprit();
mtklein5b64dab2016-06-09 08:59:48 -0700270
Mike Klein3cc2d202016-10-24 11:39:43 -0400271 #if !defined(SK_BUILD_FOR_ANDROID)
mtklein5b64dab2016-06-09 08:59:48 -0700272 void* stack[64];
273 int count = backtrace(stack, SK_ARRAY_COUNT(stack));
274 char** symbols = backtrace_symbols(stack, count);
275 info("\nStack trace:\n");
276 for (int i = 0; i < count; i++) {
277 info(" %s\n", symbols[i]);
278 }
Mike Klein3cc2d202016-10-24 11:39:43 -0400279 #endif
mtklein5b64dab2016-06-09 08:59:48 -0700280 fflush(stdout);
281
Mike Klein3cc2d202016-10-24 11:39:43 -0400282 signal(sig, previous_handler[sig]);
283 raise(sig);
mtklein5b64dab2016-06-09 08:59:48 -0700284 }
285
mtklein246ba3a2016-02-23 10:39:36 -0800286 static void setup_crash_handler() {
287 const int kSignals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV };
288 for (int sig : kSignals) {
Mike Klein3cc2d202016-10-24 11:39:43 -0400289 previous_handler[sig] = signal(sig, crash_handler);
mtklein246ba3a2016-02-23 10:39:36 -0800290 }
Derek Sollenbergeredfe3df2017-07-19 15:25:24 -0400291
292 if (FLAGS_ignoreSigInt) {
293 signal(SIGINT, SIG_IGN);
294 }
mtklein246ba3a2016-02-23 10:39:36 -0800295 }
296#endif
297
mtklein748ca3b2015-01-15 10:56:12 -0800298/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
mtklein114c3cd2015-01-15 10:15:02 -0800299
mtklein62bd1a62015-01-27 14:46:26 -0800300struct Gold : public SkString {
mtkleina82f5622015-02-20 12:30:19 -0800301 Gold() : SkString("") {}
mtklein3eed7dd2016-02-24 19:07:07 -0800302 Gold(const SkString& sink, const SkString& src,
303 const SkString& srcOptions, const SkString& name,
304 const SkString& md5)
mtklein62bd1a62015-01-27 14:46:26 -0800305 : SkString("") {
306 this->append(sink);
307 this->append(src);
djsollen54416de2015-04-03 07:24:48 -0700308 this->append(srcOptions);
mtklein62bd1a62015-01-27 14:46:26 -0800309 this->append(name);
310 this->append(md5);
mtklein62bd1a62015-01-27 14:46:26 -0800311 }
mtkleinc8d1dd42015-10-15 12:23:01 -0700312 struct Hash {
313 uint32_t operator()(const Gold& g) const {
314 return SkGoodHash()((const SkString&)g);
315 }
316 };
mtklein62bd1a62015-01-27 14:46:26 -0800317};
mtkleina82f5622015-02-20 12:30:19 -0800318static SkTHashSet<Gold, Gold::Hash> gGold;
mtklein62bd1a62015-01-27 14:46:26 -0800319
320static void add_gold(JsonWriter::BitmapResult r) {
djsollen54416de2015-04-03 07:24:48 -0700321 gGold.add(Gold(r.config, r.sourceType, r.sourceOptions, r.name, r.md5));
mtklein62bd1a62015-01-27 14:46:26 -0800322}
323
324static void gather_gold() {
325 if (!FLAGS_readPath.isEmpty()) {
326 SkString path(FLAGS_readPath[0]);
327 path.append("/dm.json");
328 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) {
329 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_str()));
330 }
331 }
332}
333
334/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
335
mtklein935f1b12016-03-16 08:37:19 -0700336#if defined(SK_BUILD_FOR_WIN32)
337 static const char* kNewline = "\r\n";
338#else
339 static const char* kNewline = "\n";
340#endif
341
borenet09ed4802015-04-03 14:15:33 -0700342static SkTHashSet<SkString> gUninterestingHashes;
343
344static void gather_uninteresting_hashes() {
345 if (!FLAGS_uninterestingHashesFile.isEmpty()) {
bungeman38d909e2016-08-02 14:40:46 -0700346 sk_sp<SkData> data(SkData::MakeFromFileName(FLAGS_uninterestingHashesFile[0]));
mtkleincc334b32015-09-22 11:43:53 -0700347 if (!data) {
mtkleinc41fd922016-03-08 09:01:39 -0800348 info("WARNING: unable to read uninteresting hashes from %s\n",
349 FLAGS_uninterestingHashesFile[0]);
mtkleincc334b32015-09-22 11:43:53 -0700350 return;
351 }
Mike Klein45dcc0c2017-04-05 18:04:31 -0400352
353 // Copy to a string to make sure SkStrSplit has a terminating \0 to find.
354 SkString contents((const char*)data->data(), data->size());
355
borenet09ed4802015-04-03 14:15:33 -0700356 SkTArray<SkString> hashes;
Mike Klein45dcc0c2017-04-05 18:04:31 -0400357 SkStrSplit(contents.c_str(), kNewline, &hashes);
borenet09ed4802015-04-03 14:15:33 -0700358 for (const SkString& hash : hashes) {
359 gUninterestingHashes.add(hash);
360 }
mtkleinc41fd922016-03-08 09:01:39 -0800361 info("FYI: loaded %d distinct uninteresting hashes from %d lines\n",
362 gUninterestingHashes.count(), hashes.count());
borenet09ed4802015-04-03 14:15:33 -0700363 }
364}
365
366/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
367
Ben Wagner145dbcd2016-11-03 14:40:50 -0400368struct TaggedSrc : public std::unique_ptr<Src> {
mtklein3eed7dd2016-02-24 19:07:07 -0800369 SkString tag;
370 SkString options;
mtkleine0effd62015-07-29 06:37:28 -0700371};
372
Ben Wagner145dbcd2016-11-03 14:40:50 -0400373struct TaggedSink : public std::unique_ptr<Sink> {
kkinnunen3e980c32015-12-23 01:33:00 -0800374 SkString tag;
djsollen54416de2015-04-03 07:24:48 -0700375};
mtklein748ca3b2015-01-15 10:56:12 -0800376
377static const bool kMemcpyOK = true;
378
mtkleine0effd62015-07-29 06:37:28 -0700379static SkTArray<TaggedSrc, kMemcpyOK> gSrcs;
380static SkTArray<TaggedSink, kMemcpyOK> gSinks;
mtklein748ca3b2015-01-15 10:56:12 -0800381
mtklein6393c062015-04-27 08:45:01 -0700382static bool in_shard() {
383 static int N = 0;
384 return N++ % FLAGS_shards == FLAGS_shard;
385}
386
mtklein3eed7dd2016-02-24 19:07:07 -0800387static void push_src(const char* tag, ImplicitString options, Src* s) {
Ben Wagner145dbcd2016-11-03 14:40:50 -0400388 std::unique_ptr<Src> src(s);
mtklein6393c062015-04-27 08:45:01 -0700389 if (in_shard() &&
mtklein3eed7dd2016-02-24 19:07:07 -0800390 FLAGS_src.contains(tag) &&
mtklein748ca3b2015-01-15 10:56:12 -0800391 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) {
mtkleine0effd62015-07-29 06:37:28 -0700392 TaggedSrc& s = gSrcs.push_back();
mtklein18300a32016-03-16 13:53:35 -0700393 s.reset(src.release());
mtklein748ca3b2015-01-15 10:56:12 -0800394 s.tag = tag;
djsollen54416de2015-04-03 07:24:48 -0700395 s.options = options;
mtklein114c3cd2015-01-15 10:15:02 -0800396 }
mtklein748ca3b2015-01-15 10:56:12 -0800397}
mtklein114c3cd2015-01-15 10:15:02 -0800398
msarett9e707a02015-09-01 14:57:57 -0700399static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorType dstColorType,
scroggoc5560be2016-02-03 09:42:42 -0800400 SkAlphaType dstAlphaType, float scale) {
scroggoe4499842016-02-25 11:03:47 -0800401 if (FLAGS_simpleCodec) {
scroggo19b91532016-10-24 09:03:26 -0700402 const bool simple = CodecSrc::kCodec_Mode == mode || CodecSrc::kAnimated_Mode == mode;
403 if (!simple || dstColorType != CodecSrc::kGetFromCanvas_DstColorType || scale != 1.0f) {
scroggoe4499842016-02-25 11:03:47 -0800404 // Only decode in the simple case.
405 return;
scroggo19b91532016-10-24 09:03:26 -0700406 }
scroggoe4499842016-02-25 11:03:47 -0800407 }
msarett9e707a02015-09-01 14:57:57 -0700408 SkString folder;
409 switch (mode) {
410 case CodecSrc::kCodec_Mode:
411 folder.append("codec");
412 break;
msarettbb25b532016-01-13 09:31:39 -0800413 case CodecSrc::kCodecZeroInit_Mode:
414 folder.append("codec_zero_init");
415 break;
msarett9e707a02015-09-01 14:57:57 -0700416 case CodecSrc::kScanline_Mode:
417 folder.append("scanline");
418 break;
msarett9e707a02015-09-01 14:57:57 -0700419 case CodecSrc::kStripe_Mode:
420 folder.append("stripe");
421 break;
msarett91c22b22016-02-22 12:27:46 -0800422 case CodecSrc::kCroppedScanline_Mode:
423 folder.append("crop");
424 break;
msarett9e707a02015-09-01 14:57:57 -0700425 case CodecSrc::kSubset_Mode:
msarett36c37962015-09-02 13:20:52 -0700426 folder.append("codec_subset");
msarett9e707a02015-09-01 14:57:57 -0700427 break;
scroggo19b91532016-10-24 09:03:26 -0700428 case CodecSrc::kAnimated_Mode:
429 folder.append("codec_animated");
430 break;
msarett9e707a02015-09-01 14:57:57 -0700431 }
432
433 switch (dstColorType) {
434 case CodecSrc::kGrayscale_Always_DstColorType:
435 folder.append("_kGray8");
436 break;
msarett34e0ec42016-04-22 16:27:24 -0700437 case CodecSrc::kNonNative8888_Always_DstColorType:
438 folder.append("_kNonNative");
439 break;
msarett9e707a02015-09-01 14:57:57 -0700440 default:
441 break;
442 }
443
scroggoc5560be2016-02-03 09:42:42 -0800444 switch (dstAlphaType) {
scroggoc5560be2016-02-03 09:42:42 -0800445 case kPremul_SkAlphaType:
446 folder.append("_premul");
447 break;
448 case kUnpremul_SkAlphaType:
449 folder.append("_unpremul");
450 break;
451 default:
452 break;
453 }
454
msarett9e707a02015-09-01 14:57:57 -0700455 if (1.0f != scale) {
456 folder.appendf("_%.3f", scale);
457 }
458
scroggoc5560be2016-02-03 09:42:42 -0800459 CodecSrc* src = new CodecSrc(path, mode, dstColorType, dstAlphaType, scale);
msarett9e707a02015-09-01 14:57:57 -0700460 push_src("image", folder, src);
461}
462
scroggof8dc9df2016-05-16 09:04:13 -0700463static void push_android_codec_src(Path path, CodecSrc::DstColorType dstColorType,
464 SkAlphaType dstAlphaType, int sampleSize) {
msarett3d9d7a72015-10-21 10:27:10 -0700465 SkString folder;
scroggof8dc9df2016-05-16 09:04:13 -0700466 folder.append("scaled_codec");
msarett3d9d7a72015-10-21 10:27:10 -0700467
468 switch (dstColorType) {
469 case CodecSrc::kGrayscale_Always_DstColorType:
470 folder.append("_kGray8");
471 break;
msarett34e0ec42016-04-22 16:27:24 -0700472 case CodecSrc::kNonNative8888_Always_DstColorType:
473 folder.append("_kNonNative");
474 break;
msarett3d9d7a72015-10-21 10:27:10 -0700475 default:
476 break;
477 }
478
scroggoc5560be2016-02-03 09:42:42 -0800479 switch (dstAlphaType) {
scroggoc5560be2016-02-03 09:42:42 -0800480 case kPremul_SkAlphaType:
481 folder.append("_premul");
482 break;
msarett9e9444c2016-02-03 12:39:10 -0800483 case kUnpremul_SkAlphaType:
484 folder.append("_unpremul");
485 break;
scroggoc5560be2016-02-03 09:42:42 -0800486 default:
487 break;
488 }
489
msarett3d9d7a72015-10-21 10:27:10 -0700490 if (1 != sampleSize) {
msarett4b0778e2015-11-13 09:59:11 -0800491 folder.appendf("_%.3f", 1.0f / (float) sampleSize);
msarett3d9d7a72015-10-21 10:27:10 -0700492 }
493
scroggof8dc9df2016-05-16 09:04:13 -0700494 AndroidCodecSrc* src = new AndroidCodecSrc(path, dstColorType, dstAlphaType, sampleSize);
msarett3d9d7a72015-10-21 10:27:10 -0700495 push_src("image", folder, src);
496}
497
msarett18976312016-03-09 14:20:58 -0800498static void push_image_gen_src(Path path, ImageGenSrc::Mode mode, SkAlphaType alphaType, bool isGpu)
499{
500 SkString folder;
501 switch (mode) {
502 case ImageGenSrc::kCodec_Mode:
503 folder.append("gen_codec");
504 break;
505 case ImageGenSrc::kPlatform_Mode:
506 folder.append("gen_platform");
507 break;
508 }
509
510 if (isGpu) {
511 folder.append("_gpu");
512 } else {
513 switch (alphaType) {
514 case kOpaque_SkAlphaType:
515 folder.append("_opaque");
516 break;
517 case kPremul_SkAlphaType:
518 folder.append("_premul");
519 break;
520 case kUnpremul_SkAlphaType:
521 folder.append("_unpremul");
522 break;
523 default:
524 break;
525 }
526 }
527
528 ImageGenSrc* src = new ImageGenSrc(path, mode, alphaType, isGpu);
529 push_src("image", folder, src);
530}
531
Leon Scroggins III07418182017-08-15 12:24:02 -0400532static void push_brd_src(Path path, CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode,
533 uint32_t sampleSize) {
534 SkString folder("brd_android_codec");
535 switch (mode) {
536 case BRDSrc::kFullImage_Mode:
537 break;
538 case BRDSrc::kDivisor_Mode:
539 folder.append("_divisor");
540 break;
541 default:
542 SkASSERT(false);
543 return;
544 }
545
546 switch (dstColorType) {
547 case CodecSrc::kGetFromCanvas_DstColorType:
548 break;
549 case CodecSrc::kGrayscale_Always_DstColorType:
550 folder.append("_kGray");
551 break;
552 default:
553 SkASSERT(false);
554 return;
555 }
556
557 if (1 != sampleSize) {
558 folder.appendf("_%.3f", 1.0f / (float) sampleSize);
559 }
560
561 BRDSrc* src = new BRDSrc(path, mode, dstColorType, sampleSize);
562 push_src("image", folder, src);
563}
564
565static void push_brd_srcs(Path path, bool gray) {
566 if (gray) {
567 // Only run grayscale to one sampleSize and Mode. Though interesting
568 // to test grayscale, it should not reveal anything across various
569 // sampleSizes and Modes
570 // Arbitrarily choose Mode and sampleSize.
571 push_brd_src(path, CodecSrc::kGrayscale_Always_DstColorType,
572 BRDSrc::kFullImage_Mode, 2);
573 }
574
575 // Test on a variety of sampleSizes, making sure to include:
576 // - 2, 4, and 8, which are natively supported by jpeg
577 // - multiples of 2 which are not divisible by 4 (analogous for 4)
578 // - larger powers of two, since BRD clients generally use powers of 2
579 // We will only produce output for the larger sizes on large images.
580 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64 };
581
582 const BRDSrc::Mode modes[] = { BRDSrc::kFullImage_Mode, BRDSrc::kDivisor_Mode, };
583
584 for (uint32_t sampleSize : sampleSizes) {
585 for (BRDSrc::Mode mode : modes) {
586 push_brd_src(path, CodecSrc::kGetFromCanvas_DstColorType, mode, sampleSize);
587 }
588 }
589}
590
msarett438b2ad2015-04-09 12:43:10 -0700591static void push_codec_srcs(Path path) {
bungeman38d909e2016-08-02 14:40:46 -0700592 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
msarett438b2ad2015-04-09 12:43:10 -0700593 if (!encoded) {
mtkleinc41fd922016-03-08 09:01:39 -0800594 info("Couldn't read %s.", path.c_str());
msarett438b2ad2015-04-09 12:43:10 -0700595 return;
596 }
Mike Reedede7bac2017-07-23 15:30:02 -0400597 std::unique_ptr<SkCodec> codec = SkCodec::MakeFromData(encoded);
halcanary96fcdcc2015-08-27 07:41:13 -0700598 if (nullptr == codec.get()) {
mtkleinc41fd922016-03-08 09:01:39 -0800599 info("Couldn't create codec for %s.", path.c_str());
msarett438b2ad2015-04-09 12:43:10 -0700600 return;
601 }
602
scroggo9366aff2016-05-20 08:38:54 -0700603 // native scaling is only supported by WEBP and JPEG
604 bool supportsNativeScaling = false;
msarett438b2ad2015-04-09 12:43:10 -0700605
msarett91c22b22016-02-22 12:27:46 -0800606 SkTArray<CodecSrc::Mode> nativeModes;
607 nativeModes.push_back(CodecSrc::kCodec_Mode);
608 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode);
msarett91c22b22016-02-22 12:27:46 -0800609 switch (codec->getEncodedFormat()) {
Hal Canarydb683012016-11-23 08:55:18 -0700610 case SkEncodedImageFormat::kJPEG:
msarett91c22b22016-02-22 12:27:46 -0800611 nativeModes.push_back(CodecSrc::kScanline_Mode);
612 nativeModes.push_back(CodecSrc::kStripe_Mode);
613 nativeModes.push_back(CodecSrc::kCroppedScanline_Mode);
scroggo9366aff2016-05-20 08:38:54 -0700614 supportsNativeScaling = true;
msarett91c22b22016-02-22 12:27:46 -0800615 break;
Hal Canarydb683012016-11-23 08:55:18 -0700616 case SkEncodedImageFormat::kWEBP:
msarett91c22b22016-02-22 12:27:46 -0800617 nativeModes.push_back(CodecSrc::kSubset_Mode);
scroggo9366aff2016-05-20 08:38:54 -0700618 supportsNativeScaling = true;
msarett91c22b22016-02-22 12:27:46 -0800619 break;
Hal Canarydb683012016-11-23 08:55:18 -0700620 case SkEncodedImageFormat::kDNG:
msarettb65e6042016-02-23 05:37:25 -0800621 break;
msarett91c22b22016-02-22 12:27:46 -0800622 default:
623 nativeModes.push_back(CodecSrc::kScanline_Mode);
msarett91c22b22016-02-22 12:27:46 -0800624 break;
625 }
msarett9e707a02015-09-01 14:57:57 -0700626
msarett91c22b22016-02-22 12:27:46 -0800627 SkTArray<CodecSrc::DstColorType> colorTypes;
628 colorTypes.push_back(CodecSrc::kGetFromCanvas_DstColorType);
msarett34e0ec42016-04-22 16:27:24 -0700629 colorTypes.push_back(CodecSrc::kNonNative8888_Always_DstColorType);
msarett36c37962015-09-02 13:20:52 -0700630 switch (codec->getInfo().colorType()) {
631 case kGray_8_SkColorType:
msarett91c22b22016-02-22 12:27:46 -0800632 colorTypes.push_back(CodecSrc::kGrayscale_Always_DstColorType);
msarett36c37962015-09-02 13:20:52 -0700633 break;
634 default:
msarett36c37962015-09-02 13:20:52 -0700635 break;
636 }
msarett9e707a02015-09-01 14:57:57 -0700637
scroggoc5560be2016-02-03 09:42:42 -0800638 SkTArray<SkAlphaType> alphaModes;
639 alphaModes.push_back(kPremul_SkAlphaType);
scroggof2c96a22016-05-20 11:08:27 -0700640 if (codec->getInfo().alphaType() != kOpaque_SkAlphaType) {
641 alphaModes.push_back(kUnpremul_SkAlphaType);
scroggoc5560be2016-02-03 09:42:42 -0800642 }
msarettb714fb02016-01-22 14:46:42 -0800643
644 for (CodecSrc::Mode mode : nativeModes) {
scroggo9366aff2016-05-20 08:38:54 -0700645 for (CodecSrc::DstColorType colorType : colorTypes) {
646 for (SkAlphaType alphaType : alphaModes) {
scroggof2c96a22016-05-20 11:08:27 -0700647 // Only test kCroppedScanline_Mode when the alpha type is premul. The test is
scroggo9366aff2016-05-20 08:38:54 -0700648 // slow and won't be interestingly different with different alpha types.
649 if (CodecSrc::kCroppedScanline_Mode == mode &&
scroggof2c96a22016-05-20 11:08:27 -0700650 kPremul_SkAlphaType != alphaType) {
scroggo9366aff2016-05-20 08:38:54 -0700651 continue;
652 }
msarett91c22b22016-02-22 12:27:46 -0800653
scroggo9366aff2016-05-20 08:38:54 -0700654 push_codec_src(path, mode, colorType, alphaType, 1.0f);
msarettf3dc1882016-04-26 13:06:38 -0700655
scroggo9366aff2016-05-20 08:38:54 -0700656 // Skip kNonNative on different native scales. It won't be interestingly
657 // different.
658 if (supportsNativeScaling &&
659 CodecSrc::kNonNative8888_Always_DstColorType == colorType) {
660 // Native Scales
661 // SkJpegCodec natively supports scaling to the following:
662 for (auto scale : { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f }) {
663 push_codec_src(path, mode, colorType, alphaType, scale);
664 }
scroggoc5560be2016-02-03 09:42:42 -0800665 }
msarett9e707a02015-09-01 14:57:57 -0700666 }
667 }
msarett0a242972015-06-11 14:27:27 -0700668 }
msarett36c37962015-09-02 13:20:52 -0700669
scroggo19b91532016-10-24 09:03:26 -0700670 {
671 std::vector<SkCodec::FrameInfo> frameInfos = codec->getFrameInfo();
672 if (frameInfos.size() > 1) {
Leon Scroggins III557fbbe2017-05-23 09:37:21 -0400673 for (auto dstCT : { CodecSrc::kNonNative8888_Always_DstColorType,
674 CodecSrc::kGetFromCanvas_DstColorType }) {
675 for (auto at : { kUnpremul_SkAlphaType, kPremul_SkAlphaType }) {
676 push_codec_src(path, CodecSrc::kAnimated_Mode, dstCT, at, 1.0f);
677 }
678 }
scroggo19b91532016-10-24 09:03:26 -0700679 }
680
681 }
682
scroggoe4499842016-02-25 11:03:47 -0800683 if (FLAGS_simpleCodec) {
684 return;
685 }
686
msarett3d9d7a72015-10-21 10:27:10 -0700687 const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
msarett36c37962015-09-02 13:20:52 -0700688
msarett3d9d7a72015-10-21 10:27:10 -0700689 for (int sampleSize : sampleSizes) {
msarett91c22b22016-02-22 12:27:46 -0800690 for (CodecSrc::DstColorType colorType : colorTypes) {
scroggoc5560be2016-02-03 09:42:42 -0800691 for (SkAlphaType alphaType : alphaModes) {
msarettf3dc1882016-04-26 13:06:38 -0700692 // We can exercise all of the kNonNative support code in the swizzler with just a
693 // few sample sizes. Skip the rest.
694 if (CodecSrc::kNonNative8888_Always_DstColorType == colorType && sampleSize > 3) {
695 continue;
696 }
697
scroggof8dc9df2016-05-16 09:04:13 -0700698 push_android_codec_src(path, colorType, alphaType, sampleSize);
msarett3d9d7a72015-10-21 10:27:10 -0700699 }
msarett36c37962015-09-02 13:20:52 -0700700 }
701 }
msarett18976312016-03-09 14:20:58 -0800702
Leon Scroggins III07418182017-08-15 12:24:02 -0400703 const char* ext = strrchr(path.c_str(), '.');
704 if (ext) {
705 ext++;
msarett18976312016-03-09 14:20:58 -0800706
Leon Scroggins III07418182017-08-15 12:24:02 -0400707 static const char* const rawExts[] = {
708 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
709 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
710 };
711 for (const char* rawExt : rawExts) {
712 if (0 == strcmp(rawExt, ext)) {
713 // RAW is not supported by image generator (skbug.com/5079) or BRD.
714 return;
715 }
716 }
717
718 static const char* const brdExts[] = {
719 "jpg", "jpeg", "png", "webp",
720 "JPG", "JPEG", "PNG", "WEBP",
721 };
722 for (const char* brdExt : brdExts) {
723 if (0 == strcmp(brdExt, ext)) {
724 bool gray = codec->getEncodedInfo().color() == SkEncodedInfo::kGray_Color;
725 push_brd_srcs(path, gray);
726 break;
727 }
msarett18976312016-03-09 14:20:58 -0800728 }
729 }
730
731 // Push image generator GPU test.
brianosmanc9ced392016-03-24 07:27:43 -0700732 push_image_gen_src(path, ImageGenSrc::kCodec_Mode, codec->getInfo().alphaType(), true);
msarett18976312016-03-09 14:20:58 -0800733
734 // Push image generator CPU tests.
735 for (SkAlphaType alphaType : alphaModes) {
736 push_image_gen_src(path, ImageGenSrc::kCodec_Mode, alphaType, false);
737
738#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
Hal Canarydb683012016-11-23 08:55:18 -0700739 if (SkEncodedImageFormat::kWEBP != codec->getEncodedFormat() &&
740 SkEncodedImageFormat::kWBMP != codec->getEncodedFormat() &&
msarett18976312016-03-09 14:20:58 -0800741 kUnpremul_SkAlphaType != alphaType)
742 {
743 push_image_gen_src(path, ImageGenSrc::kPlatform_Mode, alphaType, false);
744 }
msarettfc0b6d12016-03-17 13:50:17 -0700745#elif defined(SK_BUILD_FOR_WIN)
Hal Canarydb683012016-11-23 08:55:18 -0700746 if (SkEncodedImageFormat::kWEBP != codec->getEncodedFormat() &&
747 SkEncodedImageFormat::kWBMP != codec->getEncodedFormat())
msarettfc0b6d12016-03-17 13:50:17 -0700748 {
749 push_image_gen_src(path, ImageGenSrc::kPlatform_Mode, alphaType, false);
750 }
msarett18976312016-03-09 14:20:58 -0800751#endif
752 }
msarett438b2ad2015-04-09 12:43:10 -0700753}
754
fmalitaa2b9fdf2016-08-03 19:53:36 -0700755template <typename T>
756void gather_file_srcs(const SkCommandLineFlags::StringArray& flags, const char* ext) {
757 for (int i = 0; i < flags.count(); i++) {
758 const char* path = flags[i];
759 if (sk_isdir(path)) {
760 SkOSFile::Iter it(path, ext);
761 for (SkString file; it.next(&file); ) {
762 push_src(ext, "", new T(SkOSPath::Join(path, file.c_str())));
763 }
764 } else {
765 push_src(ext, "", new T(path));
766 }
767 }
768}
769
scroggo86737142016-02-03 12:19:11 -0800770static bool gather_srcs() {
mtklein748ca3b2015-01-15 10:56:12 -0800771 for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->next()) {
djsollen54416de2015-04-03 07:24:48 -0700772 push_src("gm", "", new GMSrc(r->factory()));
mtklein748ca3b2015-01-15 10:56:12 -0800773 }
scroggo86737142016-02-03 12:19:11 -0800774
fmalitaa2b9fdf2016-08-03 19:53:36 -0700775 gather_file_srcs<SKPSrc>(FLAGS_skps, "skp");
776 gather_file_srcs<MSKPSrc>(FLAGS_mskps, "mskp");
777#if defined(SK_XML)
778 gather_file_srcs<SVGSrc>(FLAGS_svgs, "svg");
779#endif
halcanary45420a92016-06-02 12:41:14 -0700780
scroggo86737142016-02-03 12:19:11 -0800781 SkTArray<SkString> images;
msarett69deca82016-04-29 09:38:40 -0700782 if (!CollectImages(FLAGS_images, &images)) {
scroggo86737142016-02-03 12:19:11 -0800783 return false;
784 }
785
786 for (auto image : images) {
787 push_codec_srcs(image);
mtklein709d2c32015-01-15 08:30:25 -0800788 }
scroggo86737142016-02-03 12:19:11 -0800789
msarett69deca82016-04-29 09:38:40 -0700790 SkTArray<SkString> colorImages;
791 if (!CollectImages(FLAGS_colorImages, &colorImages)) {
792 return false;
793 }
794
795 for (auto colorImage : colorImages) {
msarett9ce3a542016-07-15 13:54:38 -0700796 ColorCodecSrc* src = new ColorCodecSrc(colorImage, ColorCodecSrc::kBaseline_Mode,
797 kN32_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700798 push_src("colorImage", "color_codec_baseline", src);
msarett888dc162016-05-23 10:21:17 -0700799
msarett9ce3a542016-07-15 13:54:38 -0700800 src = new ColorCodecSrc(colorImage, ColorCodecSrc::kDst_HPZR30w_Mode, kN32_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700801 push_src("colorImage", "color_codec_HPZR30w", src);
msarett9ce3a542016-07-15 13:54:38 -0700802 // TODO (msarett):
803 // 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 -0700804
msarett9ce3a542016-07-15 13:54:38 -0700805 src = new ColorCodecSrc(colorImage, ColorCodecSrc::kDst_sRGB_Mode, kN32_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700806 push_src("colorImage", "color_codec_sRGB_kN32", src);
msarett9ce3a542016-07-15 13:54:38 -0700807 src = new ColorCodecSrc(colorImage, ColorCodecSrc::kDst_sRGB_Mode, kRGBA_F16_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700808 push_src("colorImage", "color_codec_sRGB_kF16", src);
msarett69deca82016-04-29 09:38:40 -0700809 }
810
scroggo86737142016-02-03 12:19:11 -0800811 return true;
mtklein709d2c32015-01-15 08:30:25 -0800812}
813
kkinnunen3e980c32015-12-23 01:33:00 -0800814static void push_sink(const SkCommandLineConfig& config, Sink* s) {
Ben Wagner145dbcd2016-11-03 14:40:50 -0400815 std::unique_ptr<Sink> sink(s);
kkinnunen3e980c32015-12-23 01:33:00 -0800816
mtkleine0effd62015-07-29 06:37:28 -0700817 // Try a simple Src as a canary. If it fails, skip this sink.
mtklein748ca3b2015-01-15 10:56:12 -0800818 struct : public Src {
mtkleine0effd62015-07-29 06:37:28 -0700819 Error draw(SkCanvas* c) const override {
820 c->drawRect(SkRect::MakeWH(1,1), SkPaint());
821 return "";
822 }
mtklein36352bf2015-03-25 18:17:31 -0700823 SkISize size() const override { return SkISize::Make(16, 16); }
mtkleine0effd62015-07-29 06:37:28 -0700824 Name name() const override { return "justOneRect"; }
825 } justOneRect;
mtklein114c3cd2015-01-15 10:15:02 -0800826
mtklein748ca3b2015-01-15 10:56:12 -0800827 SkBitmap bitmap;
828 SkDynamicMemoryWStream stream;
mtkleinb9eb4ac2015-02-02 18:26:03 -0800829 SkString log;
mtkleine0effd62015-07-29 06:37:28 -0700830 Error err = sink->draw(justOneRect, &bitmap, &stream, &log);
mtklein4089ef72015-03-05 08:40:28 -0800831 if (err.isFatal()) {
mtkleinc41fd922016-03-08 09:01:39 -0800832 info("Could not run %s: %s\n", config.getTag().c_str(), err.c_str());
mtklein05641a52015-04-21 10:49:13 -0700833 exit(1);
mtklein114c3cd2015-01-15 10:15:02 -0800834 }
835
mtkleine0effd62015-07-29 06:37:28 -0700836 TaggedSink& ts = gSinks.push_back();
mtklein18300a32016-03-16 13:53:35 -0700837 ts.reset(sink.release());
kkinnunen3e980c32015-12-23 01:33:00 -0800838 ts.tag = config.getTag();
mtklein748ca3b2015-01-15 10:56:12 -0800839}
840
841static bool gpu_supported() {
842#if SK_SUPPORT_GPU
843 return FLAGS_gpu;
844#else
845 return false;
846#endif
847}
kkinnunen9ebc3f02015-12-21 23:48:13 -0800848
csmartdalton008b9d82017-02-22 12:00:42 -0700849static Sink* create_sink(const GrContextOptions& grCtxOptions, const SkCommandLineConfig* config) {
kkinnunen3e980c32015-12-23 01:33:00 -0800850#if SK_SUPPORT_GPU
851 if (gpu_supported()) {
852 if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) {
bsalomon85b4b532016-04-05 11:06:27 -0700853 GrContextFactory::ContextType contextType = gpuConfig->getContextType();
csmartdaltone812d492017-02-21 12:36:05 -0700854 GrContextFactory::ContextOverrides contextOverrides = gpuConfig->getContextOverrides();
csmartdalton008b9d82017-02-22 12:00:42 -0700855 GrContextFactory testFactory(grCtxOptions);
csmartdaltone812d492017-02-21 12:36:05 -0700856 if (!testFactory.get(contextType, contextOverrides)) {
mtkleinc41fd922016-03-08 09:01:39 -0800857 info("WARNING: can not create GPU context for config '%s'. "
858 "GM tests will be skipped.\n", gpuConfig->getTag().c_str());
kkinnunen3e980c32015-12-23 01:33:00 -0800859 return nullptr;
860 }
csmartdaltone812d492017-02-21 12:36:05 -0700861 return new GPUSink(contextType, contextOverrides, gpuConfig->getSamples(),
brianosmand93c1202016-03-10 07:49:08 -0800862 gpuConfig->getUseDIText(), gpuConfig->getColorType(),
Brian Salomonce5ee602017-07-17 11:31:31 -0400863 gpuConfig->getAlphaType(), sk_ref_sp(gpuConfig->getColorSpace()),
864 FLAGS_gpu_threading);
kkinnunen3e980c32015-12-23 01:33:00 -0800865 }
866 }
867#endif
868
869#define SINK(t, sink, ...) if (config->getBackend().equals(t)) { return new sink(__VA_ARGS__); }
870
mtklein748ca3b2015-01-15 10:56:12 -0800871 if (FLAGS_cpu) {
Matt Sarett77a7a1b2017-02-07 13:56:11 -0500872 auto srgbColorSpace = SkColorSpace::MakeSRGB();
873 auto srgbLinearColorSpace = SkColorSpace::MakeSRGBLinear();
brianosmanb109b8c2016-06-16 13:03:24 -0700874
Matt Sarettd2228302017-03-02 08:53:46 -0500875 SINK("565", RasterSink, kRGB_565_SkColorType);
876 SINK("8888", RasterSink, kN32_SkColorType);
877 SINK("srgb", RasterSink, kN32_SkColorType, srgbColorSpace);
Matt Sarettd2228302017-03-02 08:53:46 -0500878 SINK("f16", RasterSink, kRGBA_F16_SkColorType, srgbLinearColorSpace);
Hal Canaryc7d295e2017-07-20 15:36:00 -0400879 SINK("pdf", PDFSink, false, SK_ScalarDefaultRasterDPI);
Matt Sarettd2228302017-03-02 08:53:46 -0500880 SINK("skp", SKPSink);
881 SINK("pipe", PipeSink);
882 SINK("svg", SVGSink);
883 SINK("null", NullSink);
884 SINK("xps", XPSSink);
Hal Canaryc7d295e2017-07-20 15:36:00 -0400885 SINK("pdfa", PDFSink, true, SK_ScalarDefaultRasterDPI);
886 SINK("pdf300", PDFSink, false, 300);
Hal Canary85c7fe82016-10-25 10:33:27 -0400887 SINK("jsdebug", DebugSink);
mtklein748ca3b2015-01-15 10:56:12 -0800888 }
889#undef SINK
halcanary96fcdcc2015-08-27 07:41:13 -0700890 return nullptr;
mtklein114c3cd2015-01-15 10:15:02 -0800891}
892
Mike Klein841101d2017-03-10 09:55:51 -0500893static sk_sp<SkColorSpace> adobe_rgb() {
894 return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
895 SkColorSpace::kAdobeRGB_Gamut);
896}
897
Mike Klein919cc452017-03-18 15:36:52 +0000898static sk_sp<SkColorSpace> rgb_to_gbr() {
899 float gbr[9];
900 gbr[0] = gSRGB_toXYZD50[1];
901 gbr[1] = gSRGB_toXYZD50[2];
902 gbr[2] = gSRGB_toXYZD50[0];
903 gbr[3] = gSRGB_toXYZD50[4];
904 gbr[4] = gSRGB_toXYZD50[5];
905 gbr[5] = gSRGB_toXYZD50[3];
906 gbr[6] = gSRGB_toXYZD50[7];
907 gbr[7] = gSRGB_toXYZD50[8];
908 gbr[8] = gSRGB_toXYZD50[6];
909 SkMatrix44 toXYZD50(SkMatrix44::kUninitialized_Constructor);
910 toXYZD50.set3x3RowMajorf(gbr);
911 return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, toXYZD50);
912}
913
kkinnunen3e980c32015-12-23 01:33:00 -0800914static Sink* create_via(const SkString& tag, Sink* wrapped) {
915#define VIA(t, via, ...) if (tag.equals(t)) { return new via(__VA_ARGS__); }
Mike Klein919cc452017-03-18 15:36:52 +0000916 VIA("adobe", ViaCSXform, wrapped, adobe_rgb(), false);
917 VIA("gbr", ViaCSXform, wrapped, rgb_to_gbr(), true);
mtklein9c5052f2016-08-06 12:51:51 -0700918 VIA("lite", ViaLite, wrapped);
reed54dc4872016-09-13 08:09:45 -0700919 VIA("pipe", ViaPipe, wrapped);
halcanary96fcdcc2015-08-27 07:41:13 -0700920 VIA("twice", ViaTwice, wrapped);
Mike Reedbae888e2017-02-18 16:50:45 -0500921#ifdef TEST_VIA_SVG
Mike Reedf67c4592017-02-17 17:06:11 -0500922 VIA("svg", ViaSVG, wrapped);
Mike Reedbae888e2017-02-18 16:50:45 -0500923#endif
halcanary96fcdcc2015-08-27 07:41:13 -0700924 VIA("serialize", ViaSerialization, wrapped);
mtklein4a34ecb2016-01-08 10:19:35 -0800925 VIA("pic", ViaPicture, wrapped);
halcanary96fcdcc2015-08-27 07:41:13 -0700926 VIA("2ndpic", ViaSecondPicture, wrapped);
mtkleind31c13d2015-05-05 12:59:56 -0700927 VIA("sp", ViaSingletonPictures, wrapped);
reedbabc3de2016-07-08 08:43:27 -0700928 VIA("defer", ViaDefer, wrapped);
halcanary96fcdcc2015-08-27 07:41:13 -0700929 VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped);
mtklein7edca212015-01-21 13:18:51 -0800930 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped);
mtklein748ca3b2015-01-15 10:56:12 -0800931
mtkleind603b222015-02-17 11:13:33 -0800932 if (FLAGS_matrix.count() == 4) {
mtklein748ca3b2015-01-15 10:56:12 -0800933 SkMatrix m;
mtkleind603b222015-02-17 11:13:33 -0800934 m.reset();
935 m.setScaleX((SkScalar)atof(FLAGS_matrix[0]));
936 m.setSkewX ((SkScalar)atof(FLAGS_matrix[1]));
937 m.setSkewY ((SkScalar)atof(FLAGS_matrix[2]));
938 m.setScaleY((SkScalar)atof(FLAGS_matrix[3]));
939 VIA("matrix", ViaMatrix, m, wrapped);
940 VIA("upright", ViaUpright, m, wrapped);
mtklein748ca3b2015-01-15 10:56:12 -0800941 }
tomhudson64de1e12015-03-05 08:01:07 -0800942
mtklein748ca3b2015-01-15 10:56:12 -0800943#undef VIA
halcanary96fcdcc2015-08-27 07:41:13 -0700944 return nullptr;
mtklein114c3cd2015-01-15 10:15:02 -0800945}
946
Ben Wagnerf28d4722017-08-11 17:33:22 -0400947static bool gather_sinks(const GrContextOptions& grCtxOptions, bool defaultConfigs) {
kkinnunen3e980c32015-12-23 01:33:00 -0800948 SkCommandLineConfigArray configs;
949 ParseConfigs(FLAGS_config, &configs);
950 for (int i = 0; i < configs.count(); i++) {
951 const SkCommandLineConfig& config = *configs[i];
csmartdalton008b9d82017-02-22 12:00:42 -0700952 Sink* sink = create_sink(grCtxOptions, &config);
kkinnunen3e980c32015-12-23 01:33:00 -0800953 if (sink == nullptr) {
mtkleinc41fd922016-03-08 09:01:39 -0800954 info("Skipping config %s: Don't understand '%s'.\n", config.getTag().c_str(),
955 config.getTag().c_str());
kkinnunen3e980c32015-12-23 01:33:00 -0800956 continue;
957 }
mtklein748ca3b2015-01-15 10:56:12 -0800958
kkinnunen3e980c32015-12-23 01:33:00 -0800959 const SkTArray<SkString>& parts = config.getViaParts();
960 for (int j = parts.count(); j-- > 0;) {
961 const SkString& part = parts[j];
962 Sink* next = create_via(part, sink);
halcanary96fcdcc2015-08-27 07:41:13 -0700963 if (next == nullptr) {
mtkleinc41fd922016-03-08 09:01:39 -0800964 info("Skipping config %s: Don't understand '%s'.\n", config.getTag().c_str(),
965 part.c_str());
mtklein748ca3b2015-01-15 10:56:12 -0800966 delete sink;
halcanary96fcdcc2015-08-27 07:41:13 -0700967 sink = nullptr;
mtklein748ca3b2015-01-15 10:56:12 -0800968 break;
969 }
970 sink = next;
971 }
972 if (sink) {
973 push_sink(config, sink);
mtklein114c3cd2015-01-15 10:15:02 -0800974 }
975 }
brianosman05c987c2016-05-09 13:42:16 -0700976
977 // If no configs were requested (just running tests, perhaps?), then we're okay.
Ben Wagnerf28d4722017-08-11 17:33:22 -0400978 if (configs.count() == 0 ||
979 // If we're using the default configs, we're okay.
980 defaultConfigs ||
Ben Wagner32fa5102017-08-10 21:25:55 -0400981 // If we've been told to ignore undefined flags, we're okay.
982 FLAGS_undefok ||
983 // Otherwise, make sure that all specified configs have become sinks.
984 configs.count() == gSinks.count()) {
985 return true;
986 }
987 info("Invalid --config. Use --undefok to bypass this warning.\n");
988 return false;
mtklein114c3cd2015-01-15 10:15:02 -0800989}
mtklein709d2c32015-01-15 08:30:25 -0800990
mtkleina5114d72015-08-24 13:27:01 -0700991static bool dump_png(SkBitmap bitmap, const char* path, const char* md5) {
Mike Klein13b6afd2017-06-12 12:45:41 -0400992 SkPixmap pm;
993 if (!bitmap.peekPixels(&pm)) {
994 return false; // Ought to never happen... we're already read-back at this point.
mtkleina5114d72015-08-24 13:27:01 -0700995 }
Mike Klein13b6afd2017-06-12 12:45:41 -0400996 SkFILEWStream dst{path};
mtkleina5114d72015-08-24 13:27:01 -0700997
mtkleind69ece62015-09-10 10:37:44 -0700998 SkString description;
999 description.append("Key: ");
1000 for (int i = 0; i < FLAGS_key.count(); i++) {
1001 description.appendf("%s ", FLAGS_key[i]);
1002 }
1003 description.append("Properties: ");
1004 for (int i = 0; i < FLAGS_properties.count(); i++) {
1005 description.appendf("%s ", FLAGS_properties[i]);
1006 }
1007 description.appendf("MD5: %s", md5);
1008
Mike Klein13b6afd2017-06-12 12:45:41 -04001009 const char* comments[] = {
1010 "Author", "DM dump_png()",
1011 "Description", description.c_str(),
1012 };
1013 size_t lengths[] = {
1014 strlen(comments[0])+1, strlen(comments[1])+1,
1015 strlen(comments[2])+1, strlen(comments[3])+1,
1016 };
mtkleina5114d72015-08-24 13:27:01 -07001017
Mike Klein13b6afd2017-06-12 12:45:41 -04001018 SkPngEncoder::Options options;
1019 options.fComments = SkDataTable::MakeCopyArrays((const void**)comments, lengths, 4);
1020 options.fFilterFlags = SkPngEncoder::FilterFlag::kNone;
1021 options.fZLibLevel = 1;
1022 options.fUnpremulBehavior = pm.colorSpace() ? SkTransferFunctionBehavior::kRespect
1023 : SkTransferFunctionBehavior::kIgnore;
1024 return SkPngEncoder::Encode(&dst, pm, options);
mtkleina5114d72015-08-24 13:27:01 -07001025}
1026
mtkleina2ef6422015-01-15 13:44:22 -08001027static bool match(const char* needle, const char* haystack) {
Chris Daltonecf78ac2017-08-15 15:43:08 -06001028 if ('~' == needle[0]) {
1029 return !match(needle + 1, haystack);
1030 }
1031 if (0 == strcmp("_", needle)) {
1032 return true;
1033 }
1034 return nullptr != strstr(haystack, needle);
mtkleina2ef6422015-01-15 13:44:22 -08001035}
1036
mtklein3eed7dd2016-02-24 19:07:07 -08001037static bool is_blacklisted(const char* sink, const char* src,
1038 const char* srcOptions, const char* name) {
mtklein0d243ff2015-04-03 07:51:00 -07001039 for (int i = 0; i < FLAGS_blacklist.count() - 3; i += 4) {
mtkleina2ef6422015-01-15 13:44:22 -08001040 if (match(FLAGS_blacklist[i+0], sink) &&
djsollen54416de2015-04-03 07:24:48 -07001041 match(FLAGS_blacklist[i+1], src) &&
1042 match(FLAGS_blacklist[i+2], srcOptions) &&
1043 match(FLAGS_blacklist[i+3], name)) {
mtklein3eed7dd2016-02-24 19:07:07 -08001044 return true;
mtkleina2ef6422015-01-15 13:44:22 -08001045 }
1046 }
mtklein3eed7dd2016-02-24 19:07:07 -08001047 return false;
mtkleina2ef6422015-01-15 13:44:22 -08001048}
1049
mtkleincd50bca2016-01-05 06:20:20 -08001050// Even when a Task Sink reports to be non-threadsafe (e.g. GPU), we know things like
1051// .png encoding are definitely thread safe. This lets us offload that work to CPU threads.
1052static SkTaskGroup gDefinitelyThreadSafeWork;
1053
mtklein748ca3b2015-01-15 10:56:12 -08001054// The finest-grained unit of work we can run: draw a single Src into a single Sink,
1055// report any errors, and perhaps write out the output: a .png of the bitmap, or a raw stream.
1056struct Task {
mtkleine0effd62015-07-29 06:37:28 -07001057 Task(const TaggedSrc& src, const TaggedSink& sink) : src(src), sink(sink) {}
1058 const TaggedSrc& src;
1059 const TaggedSink& sink;
mtklein748ca3b2015-01-15 10:56:12 -08001060
mtklein21eaf3b2016-02-08 12:39:59 -08001061 static void Run(const Task& task) {
1062 SkString name = task.src->name();
mtkleine0effd62015-07-29 06:37:28 -07001063
mtkleinb9eb4ac2015-02-02 18:26:03 -08001064 SkString log;
mtklein3eed7dd2016-02-24 19:07:07 -08001065 if (!FLAGS_dryRun) {
mtklein748ca3b2015-01-15 10:56:12 -08001066 SkBitmap bitmap;
1067 SkDynamicMemoryWStream stream;
mtklein3eed7dd2016-02-24 19:07:07 -08001068 start(task.sink.tag.c_str(), task.src.tag.c_str(),
1069 task.src.options.c_str(), name.c_str());
mtklein21eaf3b2016-02-08 12:39:59 -08001070 Error err = task.sink->draw(*task.src, &bitmap, &stream, &log);
mtkleinb3b13b72016-03-07 13:20:52 -08001071 if (!log.isEmpty()) {
mtkleinc41fd922016-03-08 09:01:39 -08001072 info("%s %s %s %s:\n%s\n", task.sink.tag.c_str()
1073 , task.src.tag.c_str()
1074 , task.src.options.c_str()
1075 , name.c_str()
1076 , log.c_str());
mtkleinb3b13b72016-03-07 13:20:52 -08001077 }
mtklein748ca3b2015-01-15 10:56:12 -08001078 if (!err.isEmpty()) {
mtklein4089ef72015-03-05 08:40:28 -08001079 if (err.isFatal()) {
djsollen54416de2015-04-03 07:24:48 -07001080 fail(SkStringPrintf("%s %s %s %s: %s",
mtklein21eaf3b2016-02-08 12:39:59 -08001081 task.sink.tag.c_str(),
1082 task.src.tag.c_str(),
1083 task.src.options.c_str(),
mtklein4089ef72015-03-05 08:40:28 -08001084 name.c_str(),
1085 err.c_str()));
mtkleinb37cb412015-03-18 05:27:14 -07001086 } else {
mtklein3eed7dd2016-02-24 19:07:07 -08001087 done(task.sink.tag.c_str(), task.src.tag.c_str(),
1088 task.src.options.c_str(), name.c_str());
mtkleinba6ada72016-01-21 09:39:35 -08001089 return;
mtklein4089ef72015-03-05 08:40:28 -08001090 }
mtklein748ca3b2015-01-15 10:56:12 -08001091 }
mtklein62bd1a62015-01-27 14:46:26 -08001092
mtkleincd50bca2016-01-05 06:20:20 -08001093 // We're likely switching threads here, so we must capture by value, [=] or [foo,bar].
Hal Canary0b833192017-03-14 14:35:02 -04001094 SkStreamAsset* data = stream.detachAsStream().release();
mtkleincd50bca2016-01-05 06:20:20 -08001095 gDefinitelyThreadSafeWork.add([task,name,bitmap,data]{
Ben Wagner145dbcd2016-11-03 14:40:50 -04001096 std::unique_ptr<SkStreamAsset> ownedData(data);
mtkleincd50bca2016-01-05 06:20:20 -08001097
mtkleincd50bca2016-01-05 06:20:20 -08001098 SkString md5;
1099 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) {
1100 SkMD5 hash;
1101 if (data->getLength()) {
1102 hash.writeStream(data, data->getLength());
1103 data->rewind();
mtklein38408462015-07-08 07:25:27 -07001104 } else {
mtkleincd50bca2016-01-05 06:20:20 -08001105 // If we're BGRA (Linux, Windows), swizzle over to RGBA (Mac, Android).
1106 // This helps eliminate multiple 0-pixel-diff hashes on gold.skia.org.
1107 // (Android's general slow speed breaks the tie arbitrarily in RGBA's favor.)
1108 // We might consider promoting 565 to RGBA too.
1109 if (bitmap.colorType() == kBGRA_8888_SkColorType) {
1110 SkBitmap swizzle;
Matt Sarett68b8e3d2017-04-28 11:15:22 -04001111 SkAssertResult(sk_tool_utils::copy_to(&swizzle, kRGBA_8888_SkColorType,
1112 bitmap));
mtkleincd50bca2016-01-05 06:20:20 -08001113 hash.write(swizzle.getPixels(), swizzle.getSize());
1114 } else {
1115 hash.write(bitmap.getPixels(), bitmap.getSize());
1116 }
1117 }
1118 SkMD5::Digest digest;
1119 hash.finish(digest);
1120 for (int i = 0; i < 16; i++) {
1121 md5.appendf("%02x", digest.data[i]);
mtklein38408462015-07-08 07:25:27 -07001122 }
mtklein62bd1a62015-01-27 14:46:26 -08001123 }
mtklein62bd1a62015-01-27 14:46:26 -08001124
mtkleincd50bca2016-01-05 06:20:20 -08001125 if (!FLAGS_readPath.isEmpty() &&
mtklein3eed7dd2016-02-24 19:07:07 -08001126 !gGold.contains(Gold(task.sink.tag, task.src.tag,
1127 task.src.options, name, md5))) {
mtkleincd50bca2016-01-05 06:20:20 -08001128 fail(SkStringPrintf("%s not found for %s %s %s %s in %s",
1129 md5.c_str(),
mtklein21eaf3b2016-02-08 12:39:59 -08001130 task.sink.tag.c_str(),
1131 task.src.tag.c_str(),
1132 task.src.options.c_str(),
mtkleincd50bca2016-01-05 06:20:20 -08001133 name.c_str(),
1134 FLAGS_readPath[0]));
mtklein748ca3b2015-01-15 10:56:12 -08001135 }
mtkleincd50bca2016-01-05 06:20:20 -08001136
1137 if (!FLAGS_writePath.isEmpty()) {
mtklein21eaf3b2016-02-08 12:39:59 -08001138 const char* ext = task.sink->fileExtension();
Mike Klein97d6a7a2017-07-24 10:37:19 -04001139 if (!FLAGS_dont_write.contains(ext)) {
1140 if (data->getLength()) {
1141 WriteToDisk(task, md5, ext, data, data->getLength(), nullptr);
1142 SkASSERT(bitmap.drawsNothing());
1143 } else if (!bitmap.drawsNothing()) {
1144 WriteToDisk(task, md5, ext, nullptr, 0, &bitmap);
1145 }
mtkleincd50bca2016-01-05 06:20:20 -08001146 }
1147 }
1148 });
mtklein748ca3b2015-01-15 10:56:12 -08001149 }
mtklein3eed7dd2016-02-24 19:07:07 -08001150 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 -08001151 }
1152
1153 static void WriteToDisk(const Task& task,
mtklein62bd1a62015-01-27 14:46:26 -08001154 SkString md5,
1155 const char* ext,
mtklein748ca3b2015-01-15 10:56:12 -08001156 SkStream* data, size_t len,
mtklein62bd1a62015-01-27 14:46:26 -08001157 const SkBitmap* bitmap) {
mtklein409d4702016-02-29 07:38:01 -08001158 bool gammaCorrect = false;
1159 if (bitmap) {
Brian Osman7039f742016-11-01 15:56:16 -04001160 gammaCorrect = SkToBool(bitmap->info().colorSpace());
mtklein409d4702016-02-29 07:38:01 -08001161 }
1162
mtklein748ca3b2015-01-15 10:56:12 -08001163 JsonWriter::BitmapResult result;
djsollen54416de2015-04-03 07:24:48 -07001164 result.name = task.src->name();
mtklein3eed7dd2016-02-24 19:07:07 -08001165 result.config = task.sink.tag;
djsollen54416de2015-04-03 07:24:48 -07001166 result.sourceType = task.src.tag;
1167 result.sourceOptions = task.src.options;
1168 result.ext = ext;
mtklein409d4702016-02-29 07:38:01 -08001169 result.gammaCorrect = gammaCorrect;
djsollen54416de2015-04-03 07:24:48 -07001170 result.md5 = md5;
mtklein748ca3b2015-01-15 10:56:12 -08001171 JsonWriter::AddBitmapResult(result);
1172
mtkleinb0531a72015-04-07 13:38:48 -07001173 // If an MD5 is uninteresting, we want it noted in the JSON file,
1174 // but don't want to dump it out as a .png (or whatever ext is).
1175 if (gUninterestingHashes.contains(md5)) {
1176 return;
1177 }
1178
mtklein748ca3b2015-01-15 10:56:12 -08001179 const char* dir = FLAGS_writePath[0];
1180 if (0 == strcmp(dir, "@")) { // Needed for iOS.
1181 dir = FLAGS_resourcePath[0];
1182 }
1183 sk_mkdir(dir);
1184
1185 SkString path;
1186 if (FLAGS_nameByHash) {
1187 path = SkOSPath::Join(dir, result.md5.c_str());
1188 path.append(".");
1189 path.append(ext);
1190 if (sk_exists(path.c_str())) {
1191 return; // Content-addressed. If it exists already, we're done.
1192 }
1193 } else {
kkinnunen3e980c32015-12-23 01:33:00 -08001194 path = SkOSPath::Join(dir, task.sink.tag.c_str());
mtklein748ca3b2015-01-15 10:56:12 -08001195 sk_mkdir(path.c_str());
msarett9e707a02015-09-01 14:57:57 -07001196 path = SkOSPath::Join(path.c_str(), task.src.tag.c_str());
mtklein748ca3b2015-01-15 10:56:12 -08001197 sk_mkdir(path.c_str());
msarett9e707a02015-09-01 14:57:57 -07001198 if (strcmp(task.src.options.c_str(), "") != 0) {
1199 path = SkOSPath::Join(path.c_str(), task.src.options.c_str());
djsollen54416de2015-04-03 07:24:48 -07001200 sk_mkdir(path.c_str());
1201 }
mtklein748ca3b2015-01-15 10:56:12 -08001202 path = SkOSPath::Join(path.c_str(), task.src->name().c_str());
1203 path.append(".");
1204 path.append(ext);
1205 }
1206
mtklein748ca3b2015-01-15 10:56:12 -08001207 if (bitmap) {
mtkleina5114d72015-08-24 13:27:01 -07001208 if (!dump_png(*bitmap, path.c_str(), result.md5.c_str())) {
mtklein748ca3b2015-01-15 10:56:12 -08001209 fail(SkStringPrintf("Can't encode PNG to %s.\n", path.c_str()));
1210 return;
1211 }
1212 } else {
mtkleina5114d72015-08-24 13:27:01 -07001213 SkFILEWStream file(path.c_str());
1214 if (!file.isValid()) {
1215 fail(SkStringPrintf("Can't open %s for writing.\n", path.c_str()));
1216 return;
1217 }
mtklein748ca3b2015-01-15 10:56:12 -08001218 if (!file.writeStream(data, len)) {
1219 fail(SkStringPrintf("Can't write to %s.\n", path.c_str()));
1220 return;
1221 }
1222 }
1223 }
1224};
1225
mtklein748ca3b2015-01-15 10:56:12 -08001226/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1227
1228// Unit tests don't fit so well into the Src/Sink model, so we give them special treatment.
1229
mtklein21eaf3b2016-02-08 12:39:59 -08001230static SkTDArray<skiatest::Test> gParallelTests, gSerialTests;
mtklein748ca3b2015-01-15 10:56:12 -08001231
1232static void gather_tests() {
mtklein6c5fed22015-01-20 13:47:23 -08001233 if (!FLAGS_src.contains("tests")) {
mtklein748ca3b2015-01-15 10:56:12 -08001234 return;
1235 }
mtklein6393c062015-04-27 08:45:01 -07001236 for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; r = r->next()) {
1237 if (!in_shard()) {
1238 continue;
1239 }
halcanary87f3ba42015-01-20 09:30:20 -08001240 // Despite its name, factory() is returning a reference to
1241 // link-time static const POD data.
1242 const skiatest::Test& test = r->factory();
1243 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test.name)) {
mtklein748ca3b2015-01-15 10:56:12 -08001244 continue;
1245 }
halcanary87f3ba42015-01-20 09:30:20 -08001246 if (test.needsGpu && gpu_supported()) {
mtklein21eaf3b2016-02-08 12:39:59 -08001247 (FLAGS_gpu_threading ? gParallelTests : gSerialTests).push(test);
halcanary87f3ba42015-01-20 09:30:20 -08001248 } else if (!test.needsGpu && FLAGS_cpu) {
mtklein21eaf3b2016-02-08 12:39:59 -08001249 gParallelTests.push(test);
mtklein82d28432015-01-15 12:46:02 -08001250 }
mtklein748ca3b2015-01-15 10:56:12 -08001251 }
1252}
1253
csmartdalton008b9d82017-02-22 12:00:42 -07001254static void run_test(skiatest::Test test, const GrContextOptions& grCtxOptions) {
halcanary87f3ba42015-01-20 09:30:20 -08001255 struct : public skiatest::Reporter {
mtklein36352bf2015-03-25 18:17:31 -07001256 void reportFailed(const skiatest::Failure& failure) override {
halcanary87f3ba42015-01-20 09:30:20 -08001257 fail(failure.toString());
1258 JsonWriter::AddTestFailure(failure);
1259 }
mtklein36352bf2015-03-25 18:17:31 -07001260 bool allowExtendedTest() const override {
halcanary87f3ba42015-01-20 09:30:20 -08001261 return FLAGS_pathOpsExtended;
1262 }
mtklein36352bf2015-03-25 18:17:31 -07001263 bool verbose() const override { return FLAGS_veryVerbose; }
halcanary87f3ba42015-01-20 09:30:20 -08001264 } reporter;
djsollen824996a2015-06-12 12:06:22 -07001265
mtklein3eed7dd2016-02-24 19:07:07 -08001266 if (!FLAGS_dryRun && !is_blacklisted("_", "tests", "_", test.name)) {
mtklein21eaf3b2016-02-08 12:39:59 -08001267 start("unit", "test", "", test.name);
csmartdalton008b9d82017-02-22 12:00:42 -07001268 GrContextFactory factory(grCtxOptions);
Mike Kleinb323a5e2017-07-24 15:21:31 -04001269 test.run(&reporter, &factory);
mtklein748ca3b2015-01-15 10:56:12 -08001270 }
mtklein3eed7dd2016-02-24 19:07:07 -08001271 done("unit", "test", "", test.name);
mtklein748ca3b2015-01-15 10:56:12 -08001272}
1273
1274/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1275
caryclark83ca6282015-06-10 09:31:09 -07001276#define PORTABLE_FONT_PREFIX "Toy Liberation "
1277
mbocee6a9912016-05-31 11:42:36 -07001278static sk_sp<SkTypeface> create_from_name(const char familyName[], SkFontStyle style) {
caryclark83ca6282015-06-10 09:31:09 -07001279 if (familyName && strlen(familyName) > sizeof(PORTABLE_FONT_PREFIX)
1280 && !strncmp(familyName, PORTABLE_FONT_PREFIX, sizeof(PORTABLE_FONT_PREFIX) - 1)) {
caryclark1818acb2015-07-24 12:09:25 -07001281 return sk_tool_utils::create_portable_typeface(familyName, style);
caryclark83ca6282015-06-10 09:31:09 -07001282 }
halcanary96fcdcc2015-08-27 07:41:13 -07001283 return nullptr;
caryclark83ca6282015-06-10 09:31:09 -07001284}
1285
1286#undef PORTABLE_FONT_PREFIX
1287
mbocee6a9912016-05-31 11:42:36 -07001288extern sk_sp<SkTypeface> (*gCreateTypefaceDelegate)(const char [], SkFontStyle );
caryclark83ca6282015-06-10 09:31:09 -07001289
Mike Kleinbe28ee22017-02-06 12:46:20 -05001290int main(int argc, char** argv) {
1291 SkCommandLineFlags::Parse(argc, argv);
Brian Osman53136aa2017-07-20 15:43:35 -04001292
Brian Osmanbc8150f2017-07-24 11:38:01 -04001293 initializeEventTracingForTools();
Brian Osman53136aa2017-07-20 15:43:35 -04001294
Mike Klein135a1b12017-08-15 13:13:59 -04001295#if !defined(GOOGLE3) && defined(SK_BUILD_FOR_IOS)
Mike Kleinadacaef2017-02-06 09:26:14 -05001296 cd_Documents();
1297#endif
bsalomon71de3532016-04-26 14:27:21 -07001298 setbuf(stdout, nullptr);
mtklein246ba3a2016-02-23 10:39:36 -08001299 setup_crash_handler();
mtkleinafae30a2016-02-24 12:28:32 -08001300
Yuqian Liba62b4a2016-12-14 13:46:53 -05001301 gSkUseAnalyticAA = FLAGS_analyticAA;
Yuqian Lidf60e362017-07-25 11:26:31 -04001302 gSkUseDeltaAA = FLAGS_deltaAA;
liyuqian38911a72016-10-04 11:23:22 -07001303
Yuqian Li550148b2017-01-13 10:13:13 -05001304 if (FLAGS_forceAnalyticAA) {
1305 gSkForceAnalyticAA = true;
1306 }
Mike Reed7c26ca72017-07-05 15:45:52 -04001307 if (FLAGS_forceRasterPipeline) {
1308 gSkForceRasterPipelineBlitter = true;
1309 }
Yuqian Li550148b2017-01-13 10:13:13 -05001310
Mike Kleine9f187b2017-06-26 13:23:12 -04001311 // The bots like having a verbose.log to upload, so always touch the file even if --verbose.
1312 if (!FLAGS_writePath.isEmpty()) {
mtklein51c8cfc2016-03-11 12:59:09 -08001313 sk_mkdir(FLAGS_writePath[0]);
mtkleina1ce2162016-07-22 12:23:46 -07001314 gVLog = fopen(SkOSPath::Join(FLAGS_writePath[0], "verbose.log").c_str(), "w");
mtkleinc41fd922016-03-08 09:01:39 -08001315 }
Mike Kleine9f187b2017-06-26 13:23:12 -04001316 if (FLAGS_verbose) {
1317 gVLog = stderr;
1318 }
mtkleinc41fd922016-03-08 09:01:39 -08001319
csmartdalton008b9d82017-02-22 12:00:42 -07001320 GrContextOptions grCtxOptions;
1321#if SK_SUPPORT_GPU
1322 grCtxOptions.fGpuPathRenderers = CollectGpuPathRenderersFromFlags();
1323#endif
1324
mtklein5286f022016-01-22 08:18:14 -08001325 JsonWriter::DumpJson(); // It's handy for the bots to assume this is ~never missing.
commit-bot@chromium.org39e8d932014-05-29 20:14:48 +00001326 SkAutoGraphics ag;
mtklein406654b2014-09-03 15:34:37 -07001327 SkTaskGroup::Enabler enabled(FLAGS_threads);
caryclark83ca6282015-06-10 09:31:09 -07001328 gCreateTypefaceDelegate = &create_from_name;
commit-bot@chromium.orga65e2fd2014-05-30 17:23:31 +00001329
halcanary7d571242016-02-24 17:59:16 -08001330 {
1331 SkString testResourcePath = GetResourcePath("color_wheel.png");
1332 SkFILEStream testResource(testResourcePath.c_str());
1333 if (!testResource.isValid()) {
mtkleinc41fd922016-03-08 09:01:39 -08001334 info("Some resources are missing. Do you need to set --resourcePath?\n");
halcanary7d571242016-02-24 17:59:16 -08001335 }
1336 }
mtklein62bd1a62015-01-27 14:46:26 -08001337 gather_gold();
borenet09ed4802015-04-03 14:15:33 -07001338 gather_uninteresting_hashes();
mtklein62bd1a62015-01-27 14:46:26 -08001339
scroggo86737142016-02-03 12:19:11 -08001340 if (!gather_srcs()) {
1341 return 1;
1342 }
Ben Wagnerf28d4722017-08-11 17:33:22 -04001343 // TODO(dogben): This is a bit ugly. Find a cleaner way to do this.
1344 bool defaultConfigs = true;
1345 for (int i = 0; i < argc; i++) {
1346 static const char* kConfigArg = "--config";
1347 if (strcmp(argv[i], kConfigArg) == 0) {
1348 defaultConfigs = false;
1349 break;
1350 }
1351 }
1352 if (!gather_sinks(grCtxOptions, defaultConfigs)) {
brianosman05c987c2016-05-09 13:42:16 -07001353 return 1;
1354 }
mtklein748ca3b2015-01-15 10:56:12 -08001355 gather_tests();
mtklein21eaf3b2016-02-08 12:39:59 -08001356 gPending = gSrcs.count() * gSinks.count() + gParallelTests.count() + gSerialTests.count();
Brian Osmand0677bc2017-08-03 12:13:47 -04001357 info("%d srcs * %d sinks + %d tests == %d tasks\n",
mtkleinc41fd922016-03-08 09:01:39 -08001358 gSrcs.count(), gSinks.count(), gParallelTests.count() + gSerialTests.count(), gPending);
mtklein748ca3b2015-01-15 10:56:12 -08001359
mtklein21eaf3b2016-02-08 12:39:59 -08001360 // Kick off as much parallel work as we can, making note of any serial work we'll need to do.
1361 SkTaskGroup parallel;
1362 SkTArray<Task> serial;
1363
1364 for (auto& sink : gSinks)
1365 for (auto& src : gSrcs) {
mtklein3eed7dd2016-02-24 19:07:07 -08001366 if (src->veto(sink->flags()) ||
1367 is_blacklisted(sink.tag.c_str(), src.tag.c_str(),
1368 src.options.c_str(), src->name().c_str())) {
mtkleinf10637f2016-06-10 13:56:35 -07001369 SkAutoMutexAcquire lock(gMutex);
mtklein3eed7dd2016-02-24 19:07:07 -08001370 gPending--;
1371 continue;
1372 }
1373
mtklein21eaf3b2016-02-08 12:39:59 -08001374 Task task(src, sink);
1375 if (src->serial() || sink->serial()) {
1376 serial.push_back(task);
1377 } else {
1378 parallel.add([task] { Task::Run(task); });
mtklein748ca3b2015-01-15 10:56:12 -08001379 }
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +00001380 }
mtklein21eaf3b2016-02-08 12:39:59 -08001381 for (auto test : gParallelTests) {
csmartdalton008b9d82017-02-22 12:00:42 -07001382 parallel.add([test, grCtxOptions] { run_test(test, grCtxOptions); });
mtklein55e88b22015-01-21 15:50:13 -08001383 }
mtklein21eaf3b2016-02-08 12:39:59 -08001384
1385 // With the parallel work running, run serial tasks and tests here on main thread.
1386 for (auto task : serial) { Task::Run(task); }
csmartdalton008b9d82017-02-22 12:00:42 -07001387 for (auto test : gSerialTests) { run_test(test, grCtxOptions); }
mtklein21eaf3b2016-02-08 12:39:59 -08001388
1389 // Wait for any remaining parallel work to complete (including any spun off of serial tasks).
1390 parallel.wait();
mtkleincd50bca2016-01-05 06:20:20 -08001391 gDefinitelyThreadSafeWork.wait();
1392
mtkleinda884c42016-02-24 18:00:23 -08001393 // We'd better have run everything.
1394 SkASSERT(gPending == 0);
mtkleine027f172016-02-26 15:53:06 -08001395 // Make sure we've flushed all our results to disk.
1396 JsonWriter::DumpJson();
mtkleinda884c42016-02-24 18:00:23 -08001397
mtklein748ca3b2015-01-15 10:56:12 -08001398 // At this point we're back in single-threaded land.
caryclarkf53ce802015-06-15 06:48:30 -07001399 sk_tool_utils::release_portable_typefaces();
mtklein@google.comd36522d2013-10-16 13:02:15 +00001400
mtklein748ca3b2015-01-15 10:56:12 -08001401 if (gFailures.count() > 0) {
mtkleinc41fd922016-03-08 09:01:39 -08001402 info("Failures:\n");
mtklein748ca3b2015-01-15 10:56:12 -08001403 for (int i = 0; i < gFailures.count(); i++) {
mtkleinc41fd922016-03-08 09:01:39 -08001404 info("\t%s\n", gFailures[i].c_str());
mtklein748ca3b2015-01-15 10:56:12 -08001405 }
mtkleinc41fd922016-03-08 09:01:39 -08001406 info("%d failures\n", gFailures.count());
mtklein748ca3b2015-01-15 10:56:12 -08001407 return 1;
mtklein114c3cd2015-01-15 10:15:02 -08001408 }
mtkleinafae30a2016-02-24 12:28:32 -08001409
1410#ifdef SK_PDF_IMAGE_STATS
halcanary7a14b312015-10-01 07:28:13 -07001411 SkPDFImageDumpStats();
mtkleinafae30a2016-02-24 12:28:32 -08001412#endif // SK_PDF_IMAGE_STATS
1413
Herb Derby5a523fe2017-01-26 16:48:28 -05001414 SkGraphics::PurgeAllCaches();
mtkleinc41fd922016-03-08 09:01:39 -08001415 info("Finished!\n");
Brian Osman53136aa2017-07-20 15:43:35 -04001416
mtklein748ca3b2015-01-15 10:56:12 -08001417 return 0;
mtklein@google.comd36522d2013-10-16 13:02:15 +00001418}
jcgregorio3b27ade2014-11-13 08:06:40 -08001419
kkinnunen179a8f52015-11-20 13:32:24 -08001420// TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards.
1421// Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0.
1422namespace skiatest {
bsalomon758586c2016-04-06 14:02:39 -07001423
1424#if SK_SUPPORT_GPU
1425bool IsGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
1426 return kOpenGL_GrBackend == GrContextFactory::ContextTypeBackend(type);
1427}
bsalomondc0fcd42016-04-11 14:21:33 -07001428bool IsVulkanContextType(sk_gpu_test::GrContextFactory::ContextType type) {
1429 return kVulkan_GrBackend == GrContextFactory::ContextTypeBackend(type);
1430}
bsalomon758586c2016-04-06 14:02:39 -07001431bool IsRenderingGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
1432 return IsGLContextType(type) && GrContextFactory::IsRenderingContext(type);
1433}
1434bool IsNullGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
1435 return type == GrContextFactory::kNullGL_ContextType;
1436}
1437#else
1438bool IsGLContextType(int) { return false; }
bsalomondc0fcd42016-04-11 14:21:33 -07001439bool IsVulkanContextType(int) { return false; }
bsalomon758586c2016-04-06 14:02:39 -07001440bool IsRenderingGLContextType(int) { return false; }
1441bool IsNullGLContextType(int) { return false; }
1442#endif
1443
1444void RunWithGPUTestContexts(GrContextTestFn* test, GrContextTypeFilterFn* contextTypeFilter,
bsalomonf2f1c172016-04-05 12:59:06 -07001445 Reporter* reporter, GrContextFactory* factory) {
kkinnunen179a8f52015-11-20 13:32:24 -08001446#if SK_SUPPORT_GPU
kkinnunen3e980c32015-12-23 01:33:00 -08001447
Brian Salomon6405e712017-03-20 08:54:16 -04001448#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC)
1449 static constexpr auto kNativeGLType = GrContextFactory::kGL_ContextType;
1450#else
1451 static constexpr auto kNativeGLType = GrContextFactory::kGLES_ContextType;
1452#endif
1453
bsalomon758586c2016-04-06 14:02:39 -07001454 for (int typeInt = 0; typeInt < GrContextFactory::kContextTypeCnt; ++typeInt) {
1455 GrContextFactory::ContextType contextType = (GrContextFactory::ContextType) typeInt;
Brian Osmanaa2219c2016-12-05 10:12:17 -05001456 // Use "native" instead of explicitly trying OpenGL and OpenGL ES. Do not use GLES on
bsalomon758586c2016-04-06 14:02:39 -07001457 // desktop since tests do not account for not fixing http://skbug.com/2809
1458 if (contextType == GrContextFactory::kGL_ContextType ||
1459 contextType == GrContextFactory::kGLES_ContextType) {
Brian Salomon6405e712017-03-20 08:54:16 -04001460 if (contextType != kNativeGLType) {
bsalomon758586c2016-04-06 14:02:39 -07001461 continue;
1462 }
1463 }
csmartdaltone812d492017-02-21 12:36:05 -07001464 ContextInfo ctxInfo = factory->getContextInfo(contextType,
1465 GrContextFactory::ContextOverrides::kDisableNVPR);
Brian Osmanaa2219c2016-12-05 10:12:17 -05001466 if (contextTypeFilter && !(*contextTypeFilter)(contextType)) {
1467 continue;
1468 }
Greg Daniela5cb7812017-06-16 09:45:32 -04001469 ReporterContext ctx(reporter, SkString(GrContextFactory::ContextTypeName(contextType)));
bsalomon8b7451a2016-05-11 06:33:06 -07001470 if (ctxInfo.grContext()) {
bsalomonf2f1c172016-04-05 12:59:06 -07001471 (*test)(reporter, ctxInfo);
Robert Phillipseaa90b22017-08-01 10:36:36 -04001472 ctxInfo.grContext()->flush();
kkinnunen5219fd92015-12-10 06:28:13 -08001473 }
bsalomonf2f1c172016-04-05 12:59:06 -07001474 ctxInfo = factory->getContextInfo(contextType,
csmartdaltone812d492017-02-21 12:36:05 -07001475 GrContextFactory::ContextOverrides::kRequireNVPRSupport);
bsalomon8b7451a2016-05-11 06:33:06 -07001476 if (ctxInfo.grContext()) {
bsalomonf2f1c172016-04-05 12:59:06 -07001477 (*test)(reporter, ctxInfo);
Robert Phillipseaa90b22017-08-01 10:36:36 -04001478 ctxInfo.grContext()->flush();
kkinnunen179a8f52015-11-20 13:32:24 -08001479 }
1480 }
1481#endif
1482}
kkinnunen179a8f52015-11-20 13:32:24 -08001483} // namespace skiatest