blob: 11527bfdaf68d1865f001e4f208b43f9e8183f86 [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
djsollen54416de2015-04-03 07:24:48 -070063DEFINE_string(src, "tests gm skp image", "Source types to test.");
mtklein748ca3b2015-01-15 10:56:12 -080064DEFINE_bool(nameByHash, false,
65 "If true, write to FLAGS_writePath[0]/<hash>.png instead of "
djsollen54416de2015-04-03 07:24:48 -070066 "to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>.png");
mtklein748ca3b2015-01-15 10:56:12 -080067DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
mtkleind603b222015-02-17 11:13:33 -080068DEFINE_string(matrix, "1 0 0 1",
69 "2x2 scale+skew matrix to apply or upright when using "
70 "'matrix' or 'upright' in config.");
mtklein82d28432015-01-15 12:46:02 -080071DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
mtklein@google.comd36522d2013-10-16 13:02:15 +000072
mtkleina2ef6422015-01-15 13:44:22 -080073DEFINE_string(blacklist, "",
djsollen54416de2015-04-03 07:24:48 -070074 "Space-separated config/src/srcOptions/name quadruples to blacklist. '_' matches anything. E.g. \n"
75 "'--blacklist gpu skp _ _' will blacklist all SKPs drawn into the gpu config.\n"
76 "'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aarects GM on 8888.");
mtkleina2ef6422015-01-15 13:44:22 -080077
mtklein62bd1a62015-01-27 14:46:26 -080078DEFINE_string2(readPath, r, "", "If set check for equality with golden results in this directory.");
79
borenet09ed4802015-04-03 14:15:33 -070080DEFINE_string(uninterestingHashesFile, "",
81 "File containing a list of uninteresting hashes. If a result hashes to something in "
82 "this list, no image is written for that result.");
83
mtklein6393c062015-04-27 08:45:01 -070084DEFINE_int32(shards, 1, "We're splitting source data into this many shards.");
85DEFINE_int32(shard, 0, "Which shard do I run?");
86
halcanary45420a92016-06-02 12:41:14 -070087DEFINE_string(mskps, "", "Directory to read mskps from, or a single mskp file.");
Mike Reed7c26ca72017-07-05 15:45:52 -040088DEFINE_bool(forceRasterPipeline, false, "sets gSkForceRasterPipelineBlitter");
halcanary45420a92016-06-02 12:41:14 -070089
csmartdalton008b9d82017-02-22 12:00:42 -070090#if SK_SUPPORT_GPU
91DEFINE_pathrenderer_flag;
92#endif
93
Derek Sollenbergeredfe3df2017-07-19 15:25:24 -040094DEFINE_bool(ignoreSigInt, false, "ignore SIGINT signals during test execution");
95
Mike Klein97d6a7a2017-07-24 10:37:19 -040096DEFINE_string(dont_write, "", "File extensions to skip writing to --writePath."); // See skia:6821
97
mtklein748ca3b2015-01-15 10:56:12 -080098using namespace DM;
bsalomon3724e572016-03-30 18:56:19 -070099using sk_gpu_test::GrContextFactory;
bsalomon273c0f52016-03-31 10:59:06 -0700100using sk_gpu_test::GLTestContext;
bsalomonf2f1c172016-04-05 12:59:06 -0700101using sk_gpu_test::ContextInfo;
mtklein@google.comd36522d2013-10-16 13:02:15 +0000102
mtklein748ca3b2015-01-15 10:56:12 -0800103/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
104
benjaminwagnerec4d4d72016-03-25 12:59:53 -0700105static const double kStartMs = SkTime::GetMSecs();
mtkleinc41fd922016-03-08 09:01:39 -0800106
107static FILE* gVLog;
108
109template <typename... Args>
110static void vlog(const char* fmt, Args&&... args) {
111 if (gVLog) {
112 fprintf(gVLog, "%s\t", HumanizeMs(SkTime::GetMSecs() - kStartMs).c_str());
113 fprintf(gVLog, fmt, args...);
114 fflush(gVLog);
115 }
116}
117
118template <typename... Args>
119static void info(const char* fmt, Args&&... args) {
120 vlog(fmt, args...);
121 if (!FLAGS_quiet) {
122 printf(fmt, args...);
123 }
124}
125static void info(const char* fmt) {
126 if (!FLAGS_quiet) {
127 printf("%s", fmt); // Clang warns printf(fmt) is insecure.
128 }
129}
130
reed086eea92016-05-04 17:12:46 -0700131SK_DECLARE_STATIC_MUTEX(gFailuresMutex);
mtklein748ca3b2015-01-15 10:56:12 -0800132static SkTArray<SkString> gFailures;
133
mtklein3eed7dd2016-02-24 19:07:07 -0800134static void fail(const SkString& err) {
mtklein748ca3b2015-01-15 10:56:12 -0800135 SkAutoMutexAcquire lock(gFailuresMutex);
136 SkDebugf("\n\nFAILURE: %s\n\n", err.c_str());
137 gFailures.push_back(err);
halcanary9e398f72015-01-10 11:18:04 -0800138}
139
mtklein0f7748a2016-07-25 15:27:29 -0700140struct Running {
141 SkString id;
142 SkThreadID thread;
143
144 void dump() const {
145 info("\t%s\n", id.c_str());
146 }
147};
mtkleinb37cb412015-03-18 05:27:14 -0700148
mtklein246ba3a2016-02-23 10:39:36 -0800149// We use a spinlock to make locking this in a signal handler _somewhat_ safe.
Mike Klein03a95ad2017-06-23 12:36:32 -0400150static SkSpinlock gMutex;
151static int gPending;
mtklein0f7748a2016-07-25 15:27:29 -0700152static SkTArray<Running> gRunning;
mtklein748ca3b2015-01-15 10:56:12 -0800153
mtklein3eed7dd2016-02-24 19:07:07 -0800154static void done(const char* config, const char* src, const char* srcOptions, const char* name) {
155 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
mtkleinc41fd922016-03-08 09:01:39 -0800156 vlog("done %s\n", id.c_str());
mtkleinafae30a2016-02-24 12:28:32 -0800157 int pending;
mtkleinb37cb412015-03-18 05:27:14 -0700158 {
mtkleinf10637f2016-06-10 13:56:35 -0700159 SkAutoMutexAcquire lock(gMutex);
mtkleinb37cb412015-03-18 05:27:14 -0700160 for (int i = 0; i < gRunning.count(); i++) {
mtklein0f7748a2016-07-25 15:27:29 -0700161 if (gRunning[i].id == id) {
mtkleinb37cb412015-03-18 05:27:14 -0700162 gRunning.removeShuffle(i);
163 break;
164 }
165 }
mtkleinafae30a2016-02-24 12:28:32 -0800166 pending = --gPending;
reed50bc0512015-05-19 14:13:31 -0700167 }
Mike Klein03a95ad2017-06-23 12:36:32 -0400168
169 // We write out dm.json file and print out a progress update every once in a while.
170 // Notice this also handles the final dm.json and progress update when pending == 0.
mtkleina17241b2015-01-23 05:48:00 -0800171 if (pending % 500 == 0) {
172 JsonWriter::DumpJson();
Mike Klein03a95ad2017-06-23 12:36:32 -0400173
174 int curr = sk_tools::getCurrResidentSetSizeMB(),
175 peak = sk_tools::getMaxResidentSetSizeMB();
176 SkString elapsed = HumanizeMs(SkTime::GetMSecs() - kStartMs);
177
178 SkAutoMutexAcquire lock(gMutex);
179 info("\n%dMB RAM, %dMB peak, %s elapsed, %d queued, %d active:\n",
180 curr, peak, elapsed.c_str(), gPending - gRunning.count(), gRunning.count());
181 for (auto& task : gRunning) {
182 task.dump();
183 }
mtkleina17241b2015-01-23 05:48:00 -0800184 }
mtklein@google.comd36522d2013-10-16 13:02:15 +0000185}
186
mtklein3eed7dd2016-02-24 19:07:07 -0800187static void start(const char* config, const char* src, const char* srcOptions, const char* name) {
188 SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name);
mtkleinc41fd922016-03-08 09:01:39 -0800189 vlog("start %s\n", id.c_str());
mtkleinf10637f2016-06-10 13:56:35 -0700190 SkAutoMutexAcquire lock(gMutex);
mtklein0f7748a2016-07-25 15:27:29 -0700191 gRunning.push_back({id,SkGetThreadID()});
mtkleinb37cb412015-03-18 05:27:14 -0700192}
193
Mike Klein3cc2d202016-10-24 11:39:43 -0400194static void find_culprit() {
195 // Assumes gMutex is locked.
196 SkThreadID thisThread = SkGetThreadID();
197 for (auto& task : gRunning) {
198 if (task.thread == thisThread) {
199 info("Likely culprit:\n");
200 task.dump();
mtklein0f7748a2016-07-25 15:27:29 -0700201 }
202 }
Mike Klein3cc2d202016-10-24 11:39:43 -0400203}
mtklein0f7748a2016-07-25 15:27:29 -0700204
mtklein246ba3a2016-02-23 10:39:36 -0800205#if defined(SK_BUILD_FOR_WIN32)
mtklein5b64dab2016-06-09 08:59:48 -0700206 static LONG WINAPI crash_handler(EXCEPTION_POINTERS* e) {
mtkleinf8557292016-02-29 06:35:28 -0800207 static const struct {
208 const char* name;
robertphillips75467862016-03-01 14:10:23 -0800209 DWORD code;
mtkleinf8557292016-02-29 06:35:28 -0800210 } kExceptions[] = {
211 #define _(E) {#E, E}
212 _(EXCEPTION_ACCESS_VIOLATION),
213 _(EXCEPTION_BREAKPOINT),
214 _(EXCEPTION_INT_DIVIDE_BY_ZERO),
215 _(EXCEPTION_STACK_OVERFLOW),
216 // TODO: more?
217 #undef _
218 };
219
mtkleinf10637f2016-06-10 13:56:35 -0700220 SkAutoMutexAcquire lock(gMutex);
mtklein5b64dab2016-06-09 08:59:48 -0700221
222 const DWORD code = e->ExceptionRecord->ExceptionCode;
223 info("\nCaught exception %u", code);
224 for (const auto& exception : kExceptions) {
225 if (exception.code == code) {
226 info(" %s", exception.name);
mtkleinf8557292016-02-29 06:35:28 -0800227 }
mtkleinf8557292016-02-29 06:35:28 -0800228 }
mtklein5b64dab2016-06-09 08:59:48 -0700229 info(", was running:\n");
230 for (auto& task : gRunning) {
mtklein0f7748a2016-07-25 15:27:29 -0700231 task.dump();
mtklein5b64dab2016-06-09 08:59:48 -0700232 }
mtklein0f7748a2016-07-25 15:27:29 -0700233 find_culprit();
mtklein5b64dab2016-06-09 08:59:48 -0700234 fflush(stdout);
235
mtkleinf8557292016-02-29 06:35:28 -0800236 // Execute default exception handler... hopefully, exit.
237 return EXCEPTION_EXECUTE_HANDLER;
mtklein246ba3a2016-02-23 10:39:36 -0800238 }
239
Mike Klein3cc2d202016-10-24 11:39:43 -0400240 static void setup_crash_handler() {
241 SetUnhandledExceptionFilter(crash_handler);
242 }
243#else
mtklein246ba3a2016-02-23 10:39:36 -0800244 #include <signal.h>
Mike Klein3cc2d202016-10-24 11:39:43 -0400245 #if !defined(SK_BUILD_FOR_ANDROID)
246 #include <execinfo.h>
Brian Salomondcbb9d92017-07-19 10:53:20 -0400247
248#endif
Mike Klein3cc2d202016-10-24 11:39:43 -0400249
250 static constexpr int max_of() { return 0; }
251 template <typename... Rest>
252 static constexpr int max_of(int x, Rest... rest) {
253 return x > max_of(rest...) ? x : max_of(rest...);
254 }
255
256 static void (*previous_handler[max_of(SIGABRT,SIGBUS,SIGFPE,SIGILL,SIGSEGV)+1])(int);
mtkleinf8557292016-02-29 06:35:28 -0800257
mtklein5b64dab2016-06-09 08:59:48 -0700258 static void crash_handler(int sig) {
mtkleinf10637f2016-06-10 13:56:35 -0700259 SkAutoMutexAcquire lock(gMutex);
mtklein5b64dab2016-06-09 08:59:48 -0700260
261 info("\nCaught signal %d [%s], was running:\n", sig, strsignal(sig));
262 for (auto& task : gRunning) {
mtklein0f7748a2016-07-25 15:27:29 -0700263 task.dump();
mtklein5b64dab2016-06-09 08:59:48 -0700264 }
mtklein0f7748a2016-07-25 15:27:29 -0700265 find_culprit();
mtklein5b64dab2016-06-09 08:59:48 -0700266
Mike Klein3cc2d202016-10-24 11:39:43 -0400267 #if !defined(SK_BUILD_FOR_ANDROID)
mtklein5b64dab2016-06-09 08:59:48 -0700268 void* stack[64];
269 int count = backtrace(stack, SK_ARRAY_COUNT(stack));
270 char** symbols = backtrace_symbols(stack, count);
271 info("\nStack trace:\n");
272 for (int i = 0; i < count; i++) {
273 info(" %s\n", symbols[i]);
274 }
Mike Klein3cc2d202016-10-24 11:39:43 -0400275 #endif
mtklein5b64dab2016-06-09 08:59:48 -0700276 fflush(stdout);
277
Mike Klein3cc2d202016-10-24 11:39:43 -0400278 signal(sig, previous_handler[sig]);
279 raise(sig);
mtklein5b64dab2016-06-09 08:59:48 -0700280 }
281
mtklein246ba3a2016-02-23 10:39:36 -0800282 static void setup_crash_handler() {
283 const int kSignals[] = { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGSEGV };
284 for (int sig : kSignals) {
Mike Klein3cc2d202016-10-24 11:39:43 -0400285 previous_handler[sig] = signal(sig, crash_handler);
mtklein246ba3a2016-02-23 10:39:36 -0800286 }
Derek Sollenbergeredfe3df2017-07-19 15:25:24 -0400287
288 if (FLAGS_ignoreSigInt) {
289 signal(SIGINT, SIG_IGN);
290 }
mtklein246ba3a2016-02-23 10:39:36 -0800291 }
292#endif
293
mtklein748ca3b2015-01-15 10:56:12 -0800294/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
mtklein114c3cd2015-01-15 10:15:02 -0800295
mtklein62bd1a62015-01-27 14:46:26 -0800296struct Gold : public SkString {
mtkleina82f5622015-02-20 12:30:19 -0800297 Gold() : SkString("") {}
mtklein3eed7dd2016-02-24 19:07:07 -0800298 Gold(const SkString& sink, const SkString& src,
299 const SkString& srcOptions, const SkString& name,
300 const SkString& md5)
mtklein62bd1a62015-01-27 14:46:26 -0800301 : SkString("") {
302 this->append(sink);
303 this->append(src);
djsollen54416de2015-04-03 07:24:48 -0700304 this->append(srcOptions);
mtklein62bd1a62015-01-27 14:46:26 -0800305 this->append(name);
306 this->append(md5);
mtklein62bd1a62015-01-27 14:46:26 -0800307 }
mtkleinc8d1dd42015-10-15 12:23:01 -0700308 struct Hash {
309 uint32_t operator()(const Gold& g) const {
310 return SkGoodHash()((const SkString&)g);
311 }
312 };
mtklein62bd1a62015-01-27 14:46:26 -0800313};
mtkleina82f5622015-02-20 12:30:19 -0800314static SkTHashSet<Gold, Gold::Hash> gGold;
mtklein62bd1a62015-01-27 14:46:26 -0800315
316static void add_gold(JsonWriter::BitmapResult r) {
djsollen54416de2015-04-03 07:24:48 -0700317 gGold.add(Gold(r.config, r.sourceType, r.sourceOptions, r.name, r.md5));
mtklein62bd1a62015-01-27 14:46:26 -0800318}
319
320static void gather_gold() {
321 if (!FLAGS_readPath.isEmpty()) {
322 SkString path(FLAGS_readPath[0]);
323 path.append("/dm.json");
324 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) {
325 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_str()));
326 }
327 }
328}
329
330/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
331
mtklein935f1b12016-03-16 08:37:19 -0700332#if defined(SK_BUILD_FOR_WIN32)
333 static const char* kNewline = "\r\n";
334#else
335 static const char* kNewline = "\n";
336#endif
337
borenet09ed4802015-04-03 14:15:33 -0700338static SkTHashSet<SkString> gUninterestingHashes;
339
340static void gather_uninteresting_hashes() {
341 if (!FLAGS_uninterestingHashesFile.isEmpty()) {
bungeman38d909e2016-08-02 14:40:46 -0700342 sk_sp<SkData> data(SkData::MakeFromFileName(FLAGS_uninterestingHashesFile[0]));
mtkleincc334b32015-09-22 11:43:53 -0700343 if (!data) {
mtkleinc41fd922016-03-08 09:01:39 -0800344 info("WARNING: unable to read uninteresting hashes from %s\n",
345 FLAGS_uninterestingHashesFile[0]);
mtkleincc334b32015-09-22 11:43:53 -0700346 return;
347 }
Mike Klein45dcc0c2017-04-05 18:04:31 -0400348
349 // Copy to a string to make sure SkStrSplit has a terminating \0 to find.
350 SkString contents((const char*)data->data(), data->size());
351
borenet09ed4802015-04-03 14:15:33 -0700352 SkTArray<SkString> hashes;
Mike Klein45dcc0c2017-04-05 18:04:31 -0400353 SkStrSplit(contents.c_str(), kNewline, &hashes);
borenet09ed4802015-04-03 14:15:33 -0700354 for (const SkString& hash : hashes) {
355 gUninterestingHashes.add(hash);
356 }
mtkleinc41fd922016-03-08 09:01:39 -0800357 info("FYI: loaded %d distinct uninteresting hashes from %d lines\n",
358 gUninterestingHashes.count(), hashes.count());
borenet09ed4802015-04-03 14:15:33 -0700359 }
360}
361
362/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
363
Ben Wagner145dbcd2016-11-03 14:40:50 -0400364struct TaggedSrc : public std::unique_ptr<Src> {
mtklein3eed7dd2016-02-24 19:07:07 -0800365 SkString tag;
366 SkString options;
mtkleine0effd62015-07-29 06:37:28 -0700367};
368
Ben Wagner145dbcd2016-11-03 14:40:50 -0400369struct TaggedSink : public std::unique_ptr<Sink> {
kkinnunen3e980c32015-12-23 01:33:00 -0800370 SkString tag;
djsollen54416de2015-04-03 07:24:48 -0700371};
mtklein748ca3b2015-01-15 10:56:12 -0800372
373static const bool kMemcpyOK = true;
374
mtkleine0effd62015-07-29 06:37:28 -0700375static SkTArray<TaggedSrc, kMemcpyOK> gSrcs;
376static SkTArray<TaggedSink, kMemcpyOK> gSinks;
mtklein748ca3b2015-01-15 10:56:12 -0800377
mtklein6393c062015-04-27 08:45:01 -0700378static bool in_shard() {
379 static int N = 0;
380 return N++ % FLAGS_shards == FLAGS_shard;
381}
382
mtklein3eed7dd2016-02-24 19:07:07 -0800383static void push_src(const char* tag, ImplicitString options, Src* s) {
Ben Wagner145dbcd2016-11-03 14:40:50 -0400384 std::unique_ptr<Src> src(s);
mtklein6393c062015-04-27 08:45:01 -0700385 if (in_shard() &&
mtklein3eed7dd2016-02-24 19:07:07 -0800386 FLAGS_src.contains(tag) &&
mtklein748ca3b2015-01-15 10:56:12 -0800387 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) {
mtkleine0effd62015-07-29 06:37:28 -0700388 TaggedSrc& s = gSrcs.push_back();
mtklein18300a32016-03-16 13:53:35 -0700389 s.reset(src.release());
mtklein748ca3b2015-01-15 10:56:12 -0800390 s.tag = tag;
djsollen54416de2015-04-03 07:24:48 -0700391 s.options = options;
mtklein114c3cd2015-01-15 10:15:02 -0800392 }
mtklein748ca3b2015-01-15 10:56:12 -0800393}
mtklein114c3cd2015-01-15 10:15:02 -0800394
msarett9e707a02015-09-01 14:57:57 -0700395static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorType dstColorType,
scroggoc5560be2016-02-03 09:42:42 -0800396 SkAlphaType dstAlphaType, float scale) {
scroggoe4499842016-02-25 11:03:47 -0800397 if (FLAGS_simpleCodec) {
scroggo19b91532016-10-24 09:03:26 -0700398 const bool simple = CodecSrc::kCodec_Mode == mode || CodecSrc::kAnimated_Mode == mode;
399 if (!simple || dstColorType != CodecSrc::kGetFromCanvas_DstColorType || scale != 1.0f) {
scroggoe4499842016-02-25 11:03:47 -0800400 // Only decode in the simple case.
401 return;
scroggo19b91532016-10-24 09:03:26 -0700402 }
scroggoe4499842016-02-25 11:03:47 -0800403 }
msarett9e707a02015-09-01 14:57:57 -0700404 SkString folder;
405 switch (mode) {
406 case CodecSrc::kCodec_Mode:
407 folder.append("codec");
408 break;
msarettbb25b532016-01-13 09:31:39 -0800409 case CodecSrc::kCodecZeroInit_Mode:
410 folder.append("codec_zero_init");
411 break;
msarett9e707a02015-09-01 14:57:57 -0700412 case CodecSrc::kScanline_Mode:
413 folder.append("scanline");
414 break;
msarett9e707a02015-09-01 14:57:57 -0700415 case CodecSrc::kStripe_Mode:
416 folder.append("stripe");
417 break;
msarett91c22b22016-02-22 12:27:46 -0800418 case CodecSrc::kCroppedScanline_Mode:
419 folder.append("crop");
420 break;
msarett9e707a02015-09-01 14:57:57 -0700421 case CodecSrc::kSubset_Mode:
msarett36c37962015-09-02 13:20:52 -0700422 folder.append("codec_subset");
msarett9e707a02015-09-01 14:57:57 -0700423 break;
scroggo19b91532016-10-24 09:03:26 -0700424 case CodecSrc::kAnimated_Mode:
425 folder.append("codec_animated");
426 break;
msarett9e707a02015-09-01 14:57:57 -0700427 }
428
429 switch (dstColorType) {
430 case CodecSrc::kGrayscale_Always_DstColorType:
431 folder.append("_kGray8");
432 break;
msarett34e0ec42016-04-22 16:27:24 -0700433 case CodecSrc::kNonNative8888_Always_DstColorType:
434 folder.append("_kNonNative");
435 break;
msarett9e707a02015-09-01 14:57:57 -0700436 default:
437 break;
438 }
439
scroggoc5560be2016-02-03 09:42:42 -0800440 switch (dstAlphaType) {
scroggoc5560be2016-02-03 09:42:42 -0800441 case kPremul_SkAlphaType:
442 folder.append("_premul");
443 break;
444 case kUnpremul_SkAlphaType:
445 folder.append("_unpremul");
446 break;
447 default:
448 break;
449 }
450
msarett9e707a02015-09-01 14:57:57 -0700451 if (1.0f != scale) {
452 folder.appendf("_%.3f", scale);
453 }
454
scroggoc5560be2016-02-03 09:42:42 -0800455 CodecSrc* src = new CodecSrc(path, mode, dstColorType, dstAlphaType, scale);
msarett9e707a02015-09-01 14:57:57 -0700456 push_src("image", folder, src);
457}
458
scroggof8dc9df2016-05-16 09:04:13 -0700459static void push_android_codec_src(Path path, CodecSrc::DstColorType dstColorType,
460 SkAlphaType dstAlphaType, int sampleSize) {
msarett3d9d7a72015-10-21 10:27:10 -0700461 SkString folder;
scroggof8dc9df2016-05-16 09:04:13 -0700462 folder.append("scaled_codec");
msarett3d9d7a72015-10-21 10:27:10 -0700463
464 switch (dstColorType) {
465 case CodecSrc::kGrayscale_Always_DstColorType:
466 folder.append("_kGray8");
467 break;
msarett34e0ec42016-04-22 16:27:24 -0700468 case CodecSrc::kNonNative8888_Always_DstColorType:
469 folder.append("_kNonNative");
470 break;
msarett3d9d7a72015-10-21 10:27:10 -0700471 default:
472 break;
473 }
474
scroggoc5560be2016-02-03 09:42:42 -0800475 switch (dstAlphaType) {
scroggoc5560be2016-02-03 09:42:42 -0800476 case kPremul_SkAlphaType:
477 folder.append("_premul");
478 break;
msarett9e9444c2016-02-03 12:39:10 -0800479 case kUnpremul_SkAlphaType:
480 folder.append("_unpremul");
481 break;
scroggoc5560be2016-02-03 09:42:42 -0800482 default:
483 break;
484 }
485
msarett3d9d7a72015-10-21 10:27:10 -0700486 if (1 != sampleSize) {
msarett4b0778e2015-11-13 09:59:11 -0800487 folder.appendf("_%.3f", 1.0f / (float) sampleSize);
msarett3d9d7a72015-10-21 10:27:10 -0700488 }
489
scroggof8dc9df2016-05-16 09:04:13 -0700490 AndroidCodecSrc* src = new AndroidCodecSrc(path, dstColorType, dstAlphaType, sampleSize);
msarett3d9d7a72015-10-21 10:27:10 -0700491 push_src("image", folder, src);
492}
493
msarett18976312016-03-09 14:20:58 -0800494static void push_image_gen_src(Path path, ImageGenSrc::Mode mode, SkAlphaType alphaType, bool isGpu)
495{
496 SkString folder;
497 switch (mode) {
498 case ImageGenSrc::kCodec_Mode:
499 folder.append("gen_codec");
500 break;
501 case ImageGenSrc::kPlatform_Mode:
502 folder.append("gen_platform");
503 break;
504 }
505
506 if (isGpu) {
507 folder.append("_gpu");
508 } else {
509 switch (alphaType) {
510 case kOpaque_SkAlphaType:
511 folder.append("_opaque");
512 break;
513 case kPremul_SkAlphaType:
514 folder.append("_premul");
515 break;
516 case kUnpremul_SkAlphaType:
517 folder.append("_unpremul");
518 break;
519 default:
520 break;
521 }
522 }
523
524 ImageGenSrc* src = new ImageGenSrc(path, mode, alphaType, isGpu);
525 push_src("image", folder, src);
526}
527
msarett438b2ad2015-04-09 12:43:10 -0700528static void push_codec_srcs(Path path) {
bungeman38d909e2016-08-02 14:40:46 -0700529 sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
msarett438b2ad2015-04-09 12:43:10 -0700530 if (!encoded) {
mtkleinc41fd922016-03-08 09:01:39 -0800531 info("Couldn't read %s.", path.c_str());
msarett438b2ad2015-04-09 12:43:10 -0700532 return;
533 }
Mike Reedede7bac2017-07-23 15:30:02 -0400534 std::unique_ptr<SkCodec> codec = SkCodec::MakeFromData(encoded);
halcanary96fcdcc2015-08-27 07:41:13 -0700535 if (nullptr == codec.get()) {
mtkleinc41fd922016-03-08 09:01:39 -0800536 info("Couldn't create codec for %s.", path.c_str());
msarett438b2ad2015-04-09 12:43:10 -0700537 return;
538 }
539
scroggo9366aff2016-05-20 08:38:54 -0700540 // native scaling is only supported by WEBP and JPEG
541 bool supportsNativeScaling = false;
msarett438b2ad2015-04-09 12:43:10 -0700542
msarett91c22b22016-02-22 12:27:46 -0800543 SkTArray<CodecSrc::Mode> nativeModes;
544 nativeModes.push_back(CodecSrc::kCodec_Mode);
545 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode);
msarett91c22b22016-02-22 12:27:46 -0800546 switch (codec->getEncodedFormat()) {
Hal Canarydb683012016-11-23 08:55:18 -0700547 case SkEncodedImageFormat::kJPEG:
msarett91c22b22016-02-22 12:27:46 -0800548 nativeModes.push_back(CodecSrc::kScanline_Mode);
549 nativeModes.push_back(CodecSrc::kStripe_Mode);
550 nativeModes.push_back(CodecSrc::kCroppedScanline_Mode);
scroggo9366aff2016-05-20 08:38:54 -0700551 supportsNativeScaling = true;
msarett91c22b22016-02-22 12:27:46 -0800552 break;
Hal Canarydb683012016-11-23 08:55:18 -0700553 case SkEncodedImageFormat::kWEBP:
msarett91c22b22016-02-22 12:27:46 -0800554 nativeModes.push_back(CodecSrc::kSubset_Mode);
scroggo9366aff2016-05-20 08:38:54 -0700555 supportsNativeScaling = true;
msarett91c22b22016-02-22 12:27:46 -0800556 break;
Hal Canarydb683012016-11-23 08:55:18 -0700557 case SkEncodedImageFormat::kDNG:
msarettb65e6042016-02-23 05:37:25 -0800558 break;
msarett91c22b22016-02-22 12:27:46 -0800559 default:
560 nativeModes.push_back(CodecSrc::kScanline_Mode);
msarett91c22b22016-02-22 12:27:46 -0800561 break;
562 }
msarett9e707a02015-09-01 14:57:57 -0700563
msarett91c22b22016-02-22 12:27:46 -0800564 SkTArray<CodecSrc::DstColorType> colorTypes;
565 colorTypes.push_back(CodecSrc::kGetFromCanvas_DstColorType);
msarett34e0ec42016-04-22 16:27:24 -0700566 colorTypes.push_back(CodecSrc::kNonNative8888_Always_DstColorType);
msarett36c37962015-09-02 13:20:52 -0700567 switch (codec->getInfo().colorType()) {
568 case kGray_8_SkColorType:
msarett91c22b22016-02-22 12:27:46 -0800569 colorTypes.push_back(CodecSrc::kGrayscale_Always_DstColorType);
msarett36c37962015-09-02 13:20:52 -0700570 break;
571 default:
msarett36c37962015-09-02 13:20:52 -0700572 break;
573 }
msarett9e707a02015-09-01 14:57:57 -0700574
scroggoc5560be2016-02-03 09:42:42 -0800575 SkTArray<SkAlphaType> alphaModes;
576 alphaModes.push_back(kPremul_SkAlphaType);
scroggof2c96a22016-05-20 11:08:27 -0700577 if (codec->getInfo().alphaType() != kOpaque_SkAlphaType) {
578 alphaModes.push_back(kUnpremul_SkAlphaType);
scroggoc5560be2016-02-03 09:42:42 -0800579 }
msarettb714fb02016-01-22 14:46:42 -0800580
581 for (CodecSrc::Mode mode : nativeModes) {
scroggo9366aff2016-05-20 08:38:54 -0700582 for (CodecSrc::DstColorType colorType : colorTypes) {
583 for (SkAlphaType alphaType : alphaModes) {
scroggof2c96a22016-05-20 11:08:27 -0700584 // Only test kCroppedScanline_Mode when the alpha type is premul. The test is
scroggo9366aff2016-05-20 08:38:54 -0700585 // slow and won't be interestingly different with different alpha types.
586 if (CodecSrc::kCroppedScanline_Mode == mode &&
scroggof2c96a22016-05-20 11:08:27 -0700587 kPremul_SkAlphaType != alphaType) {
scroggo9366aff2016-05-20 08:38:54 -0700588 continue;
589 }
msarett91c22b22016-02-22 12:27:46 -0800590
scroggo9366aff2016-05-20 08:38:54 -0700591 push_codec_src(path, mode, colorType, alphaType, 1.0f);
msarettf3dc1882016-04-26 13:06:38 -0700592
scroggo9366aff2016-05-20 08:38:54 -0700593 // Skip kNonNative on different native scales. It won't be interestingly
594 // different.
595 if (supportsNativeScaling &&
596 CodecSrc::kNonNative8888_Always_DstColorType == colorType) {
597 // Native Scales
598 // SkJpegCodec natively supports scaling to the following:
599 for (auto scale : { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f }) {
600 push_codec_src(path, mode, colorType, alphaType, scale);
601 }
scroggoc5560be2016-02-03 09:42:42 -0800602 }
msarett9e707a02015-09-01 14:57:57 -0700603 }
604 }
msarett0a242972015-06-11 14:27:27 -0700605 }
msarett36c37962015-09-02 13:20:52 -0700606
scroggo19b91532016-10-24 09:03:26 -0700607 {
608 std::vector<SkCodec::FrameInfo> frameInfos = codec->getFrameInfo();
609 if (frameInfos.size() > 1) {
Leon Scroggins III557fbbe2017-05-23 09:37:21 -0400610 for (auto dstCT : { CodecSrc::kNonNative8888_Always_DstColorType,
611 CodecSrc::kGetFromCanvas_DstColorType }) {
612 for (auto at : { kUnpremul_SkAlphaType, kPremul_SkAlphaType }) {
613 push_codec_src(path, CodecSrc::kAnimated_Mode, dstCT, at, 1.0f);
614 }
615 }
scroggo19b91532016-10-24 09:03:26 -0700616 }
617
618 }
619
scroggoe4499842016-02-25 11:03:47 -0800620 if (FLAGS_simpleCodec) {
621 return;
622 }
623
msarett3d9d7a72015-10-21 10:27:10 -0700624 const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
msarett36c37962015-09-02 13:20:52 -0700625
msarett3d9d7a72015-10-21 10:27:10 -0700626 for (int sampleSize : sampleSizes) {
msarett91c22b22016-02-22 12:27:46 -0800627 for (CodecSrc::DstColorType colorType : colorTypes) {
scroggoc5560be2016-02-03 09:42:42 -0800628 for (SkAlphaType alphaType : alphaModes) {
msarettf3dc1882016-04-26 13:06:38 -0700629 // We can exercise all of the kNonNative support code in the swizzler with just a
630 // few sample sizes. Skip the rest.
631 if (CodecSrc::kNonNative8888_Always_DstColorType == colorType && sampleSize > 3) {
632 continue;
633 }
634
scroggof8dc9df2016-05-16 09:04:13 -0700635 push_android_codec_src(path, colorType, alphaType, sampleSize);
msarett3d9d7a72015-10-21 10:27:10 -0700636 }
msarett36c37962015-09-02 13:20:52 -0700637 }
638 }
msarett18976312016-03-09 14:20:58 -0800639
640 static const char* const rawExts[] = {
641 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw",
642 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW",
643 };
644
645 // There is not currently a reason to test RAW images on image generator.
646 // If we want to enable these tests, we will need to fix skbug.com/5079.
647 for (const char* ext : rawExts) {
648 if (path.endsWith(ext)) {
649 return;
650 }
651 }
652
653 // Push image generator GPU test.
brianosmanc9ced392016-03-24 07:27:43 -0700654 push_image_gen_src(path, ImageGenSrc::kCodec_Mode, codec->getInfo().alphaType(), true);
msarett18976312016-03-09 14:20:58 -0800655
656 // Push image generator CPU tests.
657 for (SkAlphaType alphaType : alphaModes) {
658 push_image_gen_src(path, ImageGenSrc::kCodec_Mode, alphaType, false);
659
660#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
Hal Canarydb683012016-11-23 08:55:18 -0700661 if (SkEncodedImageFormat::kWEBP != codec->getEncodedFormat() &&
662 SkEncodedImageFormat::kWBMP != codec->getEncodedFormat() &&
msarett18976312016-03-09 14:20:58 -0800663 kUnpremul_SkAlphaType != alphaType)
664 {
665 push_image_gen_src(path, ImageGenSrc::kPlatform_Mode, alphaType, false);
666 }
msarettfc0b6d12016-03-17 13:50:17 -0700667#elif defined(SK_BUILD_FOR_WIN)
Hal Canarydb683012016-11-23 08:55:18 -0700668 if (SkEncodedImageFormat::kWEBP != codec->getEncodedFormat() &&
669 SkEncodedImageFormat::kWBMP != codec->getEncodedFormat())
msarettfc0b6d12016-03-17 13:50:17 -0700670 {
671 push_image_gen_src(path, ImageGenSrc::kPlatform_Mode, alphaType, false);
672 }
msarett18976312016-03-09 14:20:58 -0800673#endif
674 }
msarett438b2ad2015-04-09 12:43:10 -0700675}
676
msarettd1227a72016-05-18 06:23:57 -0700677static void push_brd_src(Path path, CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode,
678 uint32_t sampleSize) {
679 SkString folder("brd_android_codec");
msaretta5783ae2015-09-08 15:35:32 -0700680 switch (mode) {
681 case BRDSrc::kFullImage_Mode:
682 break;
683 case BRDSrc::kDivisor_Mode:
684 folder.append("_divisor");
685 break;
686 default:
687 SkASSERT(false);
688 return;
689 }
690
691 switch (dstColorType) {
692 case CodecSrc::kGetFromCanvas_DstColorType:
693 break;
msaretta5783ae2015-09-08 15:35:32 -0700694 case CodecSrc::kGrayscale_Always_DstColorType:
695 folder.append("_kGray");
696 break;
697 default:
698 SkASSERT(false);
699 return;
700 }
701
702 if (1 != sampleSize) {
msarett4b0778e2015-11-13 09:59:11 -0800703 folder.appendf("_%.3f", 1.0f / (float) sampleSize);
msaretta5783ae2015-09-08 15:35:32 -0700704 }
705
msarettd1227a72016-05-18 06:23:57 -0700706 BRDSrc* src = new BRDSrc(path, mode, dstColorType, sampleSize);
msaretta5783ae2015-09-08 15:35:32 -0700707 push_src("image", folder, src);
708}
709
710static void push_brd_srcs(Path path) {
Leon Scroggins IIIbace7a92017-07-05 11:39:27 -0400711 // Only run grayscale to one sampleSize and Mode. Though interesting
712 // to test grayscale, it should not reveal anything across various
scroggo24a9bd72016-05-20 06:02:42 -0700713 // sampleSizes and Modes
Leon Scroggins IIIbace7a92017-07-05 11:39:27 -0400714 // Arbitrarily choose Mode and sampleSize.
715 push_brd_src(path, CodecSrc::kGrayscale_Always_DstColorType, BRDSrc::kFullImage_Mode, 2);
scroggo24a9bd72016-05-20 06:02:42 -0700716
717
scroggo501b7342015-11-03 07:55:11 -0800718 // Test on a variety of sampleSizes, making sure to include:
719 // - 2, 4, and 8, which are natively supported by jpeg
720 // - multiples of 2 which are not divisible by 4 (analogous for 4)
721 // - larger powers of two, since BRD clients generally use powers of 2
722 // We will only produce output for the larger sizes on large images.
723 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 64 };
msarett6efbe052015-09-11 09:01:16 -0700724
msaretta5783ae2015-09-08 15:35:32 -0700725 const BRDSrc::Mode modes[] = {
msarett26ad17b2015-10-22 07:29:19 -0700726 BRDSrc::kFullImage_Mode,
727 BRDSrc::kDivisor_Mode,
msaretta5783ae2015-09-08 15:35:32 -0700728 };
729
msarettd1227a72016-05-18 06:23:57 -0700730 for (uint32_t sampleSize : sampleSizes) {
scroggo24a9bd72016-05-20 06:02:42 -0700731 for (BRDSrc::Mode mode : modes) {
732 push_brd_src(path, CodecSrc::kGetFromCanvas_DstColorType, mode, sampleSize);
msaretta5783ae2015-09-08 15:35:32 -0700733 }
734 }
735}
736
737static bool brd_supported(const char* ext) {
msarett8c8f22a2015-04-01 06:58:48 -0700738 static const char* const exts[] = {
msaretta5783ae2015-09-08 15:35:32 -0700739 "jpg", "jpeg", "png", "webp",
740 "JPG", "JPEG", "PNG", "WEBP",
msarett8c8f22a2015-04-01 06:58:48 -0700741 };
742
743 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) {
744 if (0 == strcmp(exts[i], ext)) {
745 return true;
746 }
747 }
748 return false;
scroggo9b77ddd2015-03-19 06:03:39 -0700749}
750
fmalitaa2b9fdf2016-08-03 19:53:36 -0700751template <typename T>
752void gather_file_srcs(const SkCommandLineFlags::StringArray& flags, const char* ext) {
753 for (int i = 0; i < flags.count(); i++) {
754 const char* path = flags[i];
755 if (sk_isdir(path)) {
756 SkOSFile::Iter it(path, ext);
757 for (SkString file; it.next(&file); ) {
758 push_src(ext, "", new T(SkOSPath::Join(path, file.c_str())));
759 }
760 } else {
761 push_src(ext, "", new T(path));
762 }
763 }
764}
765
scroggo86737142016-02-03 12:19:11 -0800766static bool gather_srcs() {
mtklein748ca3b2015-01-15 10:56:12 -0800767 for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->next()) {
djsollen54416de2015-04-03 07:24:48 -0700768 push_src("gm", "", new GMSrc(r->factory()));
mtklein748ca3b2015-01-15 10:56:12 -0800769 }
scroggo86737142016-02-03 12:19:11 -0800770
fmalitaa2b9fdf2016-08-03 19:53:36 -0700771 gather_file_srcs<SKPSrc>(FLAGS_skps, "skp");
772 gather_file_srcs<MSKPSrc>(FLAGS_mskps, "mskp");
773#if defined(SK_XML)
774 gather_file_srcs<SVGSrc>(FLAGS_svgs, "svg");
775#endif
halcanary45420a92016-06-02 12:41:14 -0700776
scroggo86737142016-02-03 12:19:11 -0800777 SkTArray<SkString> images;
msarett69deca82016-04-29 09:38:40 -0700778 if (!CollectImages(FLAGS_images, &images)) {
scroggo86737142016-02-03 12:19:11 -0800779 return false;
780 }
781
782 for (auto image : images) {
783 push_codec_srcs(image);
scroggoe4499842016-02-25 11:03:47 -0800784 if (FLAGS_simpleCodec) {
785 continue;
786 }
787
mtklein21eaf3b2016-02-08 12:39:59 -0800788 const char* ext = strrchr(image.c_str(), '.');
789 if (ext && brd_supported(ext+1)) {
scroggo86737142016-02-03 12:19:11 -0800790 push_brd_srcs(image);
mtklein709d2c32015-01-15 08:30:25 -0800791 }
mtklein709d2c32015-01-15 08:30:25 -0800792 }
scroggo86737142016-02-03 12:19:11 -0800793
msarett69deca82016-04-29 09:38:40 -0700794 SkTArray<SkString> colorImages;
795 if (!CollectImages(FLAGS_colorImages, &colorImages)) {
796 return false;
797 }
798
799 for (auto colorImage : colorImages) {
msarett9ce3a542016-07-15 13:54:38 -0700800 ColorCodecSrc* src = new ColorCodecSrc(colorImage, ColorCodecSrc::kBaseline_Mode,
801 kN32_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700802 push_src("colorImage", "color_codec_baseline", src);
msarett888dc162016-05-23 10:21:17 -0700803
msarett9ce3a542016-07-15 13:54:38 -0700804 src = new ColorCodecSrc(colorImage, ColorCodecSrc::kDst_HPZR30w_Mode, kN32_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700805 push_src("colorImage", "color_codec_HPZR30w", src);
msarett9ce3a542016-07-15 13:54:38 -0700806 // TODO (msarett):
807 // 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 -0700808
msarett9ce3a542016-07-15 13:54:38 -0700809 src = new ColorCodecSrc(colorImage, ColorCodecSrc::kDst_sRGB_Mode, kN32_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700810 push_src("colorImage", "color_codec_sRGB_kN32", src);
msarett9ce3a542016-07-15 13:54:38 -0700811 src = new ColorCodecSrc(colorImage, ColorCodecSrc::kDst_sRGB_Mode, kRGBA_F16_SkColorType);
msarettb8d1aac2016-08-04 12:22:06 -0700812 push_src("colorImage", "color_codec_sRGB_kF16", src);
msarett69deca82016-04-29 09:38:40 -0700813 }
814
scroggo86737142016-02-03 12:19:11 -0800815 return true;
mtklein709d2c32015-01-15 08:30:25 -0800816}
817
kkinnunen3e980c32015-12-23 01:33:00 -0800818static void push_sink(const SkCommandLineConfig& config, Sink* s) {
Ben Wagner145dbcd2016-11-03 14:40:50 -0400819 std::unique_ptr<Sink> sink(s);
kkinnunen3e980c32015-12-23 01:33:00 -0800820
mtkleine0effd62015-07-29 06:37:28 -0700821 // Try a simple Src as a canary. If it fails, skip this sink.
mtklein748ca3b2015-01-15 10:56:12 -0800822 struct : public Src {
mtkleine0effd62015-07-29 06:37:28 -0700823 Error draw(SkCanvas* c) const override {
824 c->drawRect(SkRect::MakeWH(1,1), SkPaint());
825 return "";
826 }
mtklein36352bf2015-03-25 18:17:31 -0700827 SkISize size() const override { return SkISize::Make(16, 16); }
mtkleine0effd62015-07-29 06:37:28 -0700828 Name name() const override { return "justOneRect"; }
829 } justOneRect;
mtklein114c3cd2015-01-15 10:15:02 -0800830
mtklein748ca3b2015-01-15 10:56:12 -0800831 SkBitmap bitmap;
832 SkDynamicMemoryWStream stream;
mtkleinb9eb4ac2015-02-02 18:26:03 -0800833 SkString log;
mtkleine0effd62015-07-29 06:37:28 -0700834 Error err = sink->draw(justOneRect, &bitmap, &stream, &log);
mtklein4089ef72015-03-05 08:40:28 -0800835 if (err.isFatal()) {
mtkleinc41fd922016-03-08 09:01:39 -0800836 info("Could not run %s: %s\n", config.getTag().c_str(), err.c_str());
mtklein05641a52015-04-21 10:49:13 -0700837 exit(1);
mtklein114c3cd2015-01-15 10:15:02 -0800838 }
839
mtkleine0effd62015-07-29 06:37:28 -0700840 TaggedSink& ts = gSinks.push_back();
mtklein18300a32016-03-16 13:53:35 -0700841 ts.reset(sink.release());
kkinnunen3e980c32015-12-23 01:33:00 -0800842 ts.tag = config.getTag();
mtklein748ca3b2015-01-15 10:56:12 -0800843}
844
845static bool gpu_supported() {
846#if SK_SUPPORT_GPU
847 return FLAGS_gpu;
848#else
849 return false;
850#endif
851}
kkinnunen9ebc3f02015-12-21 23:48:13 -0800852
csmartdalton008b9d82017-02-22 12:00:42 -0700853static Sink* create_sink(const GrContextOptions& grCtxOptions, const SkCommandLineConfig* config) {
kkinnunen3e980c32015-12-23 01:33:00 -0800854#if SK_SUPPORT_GPU
855 if (gpu_supported()) {
856 if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) {
bsalomon85b4b532016-04-05 11:06:27 -0700857 GrContextFactory::ContextType contextType = gpuConfig->getContextType();
csmartdaltone812d492017-02-21 12:36:05 -0700858 GrContextFactory::ContextOverrides contextOverrides = gpuConfig->getContextOverrides();
csmartdalton008b9d82017-02-22 12:00:42 -0700859 GrContextFactory testFactory(grCtxOptions);
csmartdaltone812d492017-02-21 12:36:05 -0700860 if (!testFactory.get(contextType, contextOverrides)) {
mtkleinc41fd922016-03-08 09:01:39 -0800861 info("WARNING: can not create GPU context for config '%s'. "
862 "GM tests will be skipped.\n", gpuConfig->getTag().c_str());
kkinnunen3e980c32015-12-23 01:33:00 -0800863 return nullptr;
864 }
csmartdaltone812d492017-02-21 12:36:05 -0700865 return new GPUSink(contextType, contextOverrides, gpuConfig->getSamples(),
brianosmand93c1202016-03-10 07:49:08 -0800866 gpuConfig->getUseDIText(), gpuConfig->getColorType(),
Brian Salomonce5ee602017-07-17 11:31:31 -0400867 gpuConfig->getAlphaType(), sk_ref_sp(gpuConfig->getColorSpace()),
868 FLAGS_gpu_threading);
kkinnunen3e980c32015-12-23 01:33:00 -0800869 }
870 }
871#endif
872
873#define SINK(t, sink, ...) if (config->getBackend().equals(t)) { return new sink(__VA_ARGS__); }
874
mtklein748ca3b2015-01-15 10:56:12 -0800875 if (FLAGS_cpu) {
Matt Sarett77a7a1b2017-02-07 13:56:11 -0500876 auto srgbColorSpace = SkColorSpace::MakeSRGB();
877 auto srgbLinearColorSpace = SkColorSpace::MakeSRGBLinear();
brianosmanb109b8c2016-06-16 13:03:24 -0700878
Matt Sarettd2228302017-03-02 08:53:46 -0500879 SINK("565", RasterSink, kRGB_565_SkColorType);
880 SINK("8888", RasterSink, kN32_SkColorType);
881 SINK("srgb", RasterSink, kN32_SkColorType, srgbColorSpace);
Matt Sarettd2228302017-03-02 08:53:46 -0500882 SINK("f16", RasterSink, kRGBA_F16_SkColorType, srgbLinearColorSpace);
Hal Canaryc7d295e2017-07-20 15:36:00 -0400883 SINK("pdf", PDFSink, false, SK_ScalarDefaultRasterDPI);
Matt Sarettd2228302017-03-02 08:53:46 -0500884 SINK("skp", SKPSink);
885 SINK("pipe", PipeSink);
886 SINK("svg", SVGSink);
887 SINK("null", NullSink);
888 SINK("xps", XPSSink);
Hal Canaryc7d295e2017-07-20 15:36:00 -0400889 SINK("pdfa", PDFSink, true, SK_ScalarDefaultRasterDPI);
890 SINK("pdf300", PDFSink, false, 300);
Hal Canary85c7fe82016-10-25 10:33:27 -0400891 SINK("jsdebug", DebugSink);
mtklein748ca3b2015-01-15 10:56:12 -0800892 }
893#undef SINK
halcanary96fcdcc2015-08-27 07:41:13 -0700894 return nullptr;
mtklein114c3cd2015-01-15 10:15:02 -0800895}
896
Mike Klein841101d2017-03-10 09:55:51 -0500897static sk_sp<SkColorSpace> adobe_rgb() {
898 return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
899 SkColorSpace::kAdobeRGB_Gamut);
900}
901
Mike Klein919cc452017-03-18 15:36:52 +0000902static sk_sp<SkColorSpace> rgb_to_gbr() {
903 float gbr[9];
904 gbr[0] = gSRGB_toXYZD50[1];
905 gbr[1] = gSRGB_toXYZD50[2];
906 gbr[2] = gSRGB_toXYZD50[0];
907 gbr[3] = gSRGB_toXYZD50[4];
908 gbr[4] = gSRGB_toXYZD50[5];
909 gbr[5] = gSRGB_toXYZD50[3];
910 gbr[6] = gSRGB_toXYZD50[7];
911 gbr[7] = gSRGB_toXYZD50[8];
912 gbr[8] = gSRGB_toXYZD50[6];
913 SkMatrix44 toXYZD50(SkMatrix44::kUninitialized_Constructor);
914 toXYZD50.set3x3RowMajorf(gbr);
915 return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, toXYZD50);
916}
917
kkinnunen3e980c32015-12-23 01:33:00 -0800918static Sink* create_via(const SkString& tag, Sink* wrapped) {
919#define VIA(t, via, ...) if (tag.equals(t)) { return new via(__VA_ARGS__); }
Mike Klein919cc452017-03-18 15:36:52 +0000920 VIA("adobe", ViaCSXform, wrapped, adobe_rgb(), false);
921 VIA("gbr", ViaCSXform, wrapped, rgb_to_gbr(), true);
mtklein9c5052f2016-08-06 12:51:51 -0700922 VIA("lite", ViaLite, wrapped);
reed54dc4872016-09-13 08:09:45 -0700923 VIA("pipe", ViaPipe, wrapped);
halcanary96fcdcc2015-08-27 07:41:13 -0700924 VIA("twice", ViaTwice, wrapped);
Mike Reedbae888e2017-02-18 16:50:45 -0500925#ifdef TEST_VIA_SVG
Mike Reedf67c4592017-02-17 17:06:11 -0500926 VIA("svg", ViaSVG, wrapped);
Mike Reedbae888e2017-02-18 16:50:45 -0500927#endif
halcanary96fcdcc2015-08-27 07:41:13 -0700928 VIA("serialize", ViaSerialization, wrapped);
mtklein4a34ecb2016-01-08 10:19:35 -0800929 VIA("pic", ViaPicture, wrapped);
halcanary96fcdcc2015-08-27 07:41:13 -0700930 VIA("2ndpic", ViaSecondPicture, wrapped);
mtkleind31c13d2015-05-05 12:59:56 -0700931 VIA("sp", ViaSingletonPictures, wrapped);
reedbabc3de2016-07-08 08:43:27 -0700932 VIA("defer", ViaDefer, wrapped);
halcanary96fcdcc2015-08-27 07:41:13 -0700933 VIA("tiles", ViaTiles, 256, 256, nullptr, wrapped);
mtklein7edca212015-01-21 13:18:51 -0800934 VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped);
mtklein748ca3b2015-01-15 10:56:12 -0800935
mtkleind603b222015-02-17 11:13:33 -0800936 if (FLAGS_matrix.count() == 4) {
mtklein748ca3b2015-01-15 10:56:12 -0800937 SkMatrix m;
mtkleind603b222015-02-17 11:13:33 -0800938 m.reset();
939 m.setScaleX((SkScalar)atof(FLAGS_matrix[0]));
940 m.setSkewX ((SkScalar)atof(FLAGS_matrix[1]));
941 m.setSkewY ((SkScalar)atof(FLAGS_matrix[2]));
942 m.setScaleY((SkScalar)atof(FLAGS_matrix[3]));
943 VIA("matrix", ViaMatrix, m, wrapped);
944 VIA("upright", ViaUpright, m, wrapped);
mtklein748ca3b2015-01-15 10:56:12 -0800945 }
tomhudson64de1e12015-03-05 08:01:07 -0800946
mtklein748ca3b2015-01-15 10:56:12 -0800947#undef VIA
halcanary96fcdcc2015-08-27 07:41:13 -0700948 return nullptr;
mtklein114c3cd2015-01-15 10:15:02 -0800949}
950
csmartdalton008b9d82017-02-22 12:00:42 -0700951static bool gather_sinks(const GrContextOptions& grCtxOptions) {
kkinnunen3e980c32015-12-23 01:33:00 -0800952 SkCommandLineConfigArray configs;
953 ParseConfigs(FLAGS_config, &configs);
954 for (int i = 0; i < configs.count(); i++) {
955 const SkCommandLineConfig& config = *configs[i];
csmartdalton008b9d82017-02-22 12:00:42 -0700956 Sink* sink = create_sink(grCtxOptions, &config);
kkinnunen3e980c32015-12-23 01:33:00 -0800957 if (sink == nullptr) {
mtkleinc41fd922016-03-08 09:01:39 -0800958 info("Skipping config %s: Don't understand '%s'.\n", config.getTag().c_str(),
959 config.getTag().c_str());
kkinnunen3e980c32015-12-23 01:33:00 -0800960 continue;
961 }
mtklein748ca3b2015-01-15 10:56:12 -0800962
kkinnunen3e980c32015-12-23 01:33:00 -0800963 const SkTArray<SkString>& parts = config.getViaParts();
964 for (int j = parts.count(); j-- > 0;) {
965 const SkString& part = parts[j];
966 Sink* next = create_via(part, sink);
halcanary96fcdcc2015-08-27 07:41:13 -0700967 if (next == nullptr) {
mtkleinc41fd922016-03-08 09:01:39 -0800968 info("Skipping config %s: Don't understand '%s'.\n", config.getTag().c_str(),
969 part.c_str());
mtklein748ca3b2015-01-15 10:56:12 -0800970 delete sink;
halcanary96fcdcc2015-08-27 07:41:13 -0700971 sink = nullptr;
mtklein748ca3b2015-01-15 10:56:12 -0800972 break;
973 }
974 sink = next;
975 }
976 if (sink) {
977 push_sink(config, sink);
mtklein114c3cd2015-01-15 10:15:02 -0800978 }
979 }
brianosman05c987c2016-05-09 13:42:16 -0700980
981 // If no configs were requested (just running tests, perhaps?), then we're okay.
982 // Otherwise, make sure that at least one sink was constructed correctly. This catches
983 // the case of bots without a GPU being assigned GPU configs.
984 return (configs.count() == 0) || (gSinks.count() > 0);
mtklein114c3cd2015-01-15 10:15:02 -0800985}
mtklein709d2c32015-01-15 08:30:25 -0800986
mtkleina5114d72015-08-24 13:27:01 -0700987static bool dump_png(SkBitmap bitmap, const char* path, const char* md5) {
Mike Klein13b6afd2017-06-12 12:45:41 -0400988 SkPixmap pm;
989 if (!bitmap.peekPixels(&pm)) {
990 return false; // Ought to never happen... we're already read-back at this point.
mtkleina5114d72015-08-24 13:27:01 -0700991 }
Mike Klein13b6afd2017-06-12 12:45:41 -0400992 SkFILEWStream dst{path};
mtkleina5114d72015-08-24 13:27:01 -0700993
mtkleind69ece62015-09-10 10:37:44 -0700994 SkString description;
995 description.append("Key: ");
996 for (int i = 0; i < FLAGS_key.count(); i++) {
997 description.appendf("%s ", FLAGS_key[i]);
998 }
999 description.append("Properties: ");
1000 for (int i = 0; i < FLAGS_properties.count(); i++) {
1001 description.appendf("%s ", FLAGS_properties[i]);
1002 }
1003 description.appendf("MD5: %s", md5);
1004
Mike Klein13b6afd2017-06-12 12:45:41 -04001005 const char* comments[] = {
1006 "Author", "DM dump_png()",
1007 "Description", description.c_str(),
1008 };
1009 size_t lengths[] = {
1010 strlen(comments[0])+1, strlen(comments[1])+1,
1011 strlen(comments[2])+1, strlen(comments[3])+1,
1012 };
mtkleina5114d72015-08-24 13:27:01 -07001013
Mike Klein13b6afd2017-06-12 12:45:41 -04001014 SkPngEncoder::Options options;
1015 options.fComments = SkDataTable::MakeCopyArrays((const void**)comments, lengths, 4);
1016 options.fFilterFlags = SkPngEncoder::FilterFlag::kNone;
1017 options.fZLibLevel = 1;
1018 options.fUnpremulBehavior = pm.colorSpace() ? SkTransferFunctionBehavior::kRespect
1019 : SkTransferFunctionBehavior::kIgnore;
1020 return SkPngEncoder::Encode(&dst, pm, options);
mtkleina5114d72015-08-24 13:27:01 -07001021}
1022
mtkleina2ef6422015-01-15 13:44:22 -08001023static bool match(const char* needle, const char* haystack) {
halcanary96fcdcc2015-08-27 07:41:13 -07001024 return 0 == strcmp("_", needle) || nullptr != strstr(haystack, needle);
mtkleina2ef6422015-01-15 13:44:22 -08001025}
1026
mtklein3eed7dd2016-02-24 19:07:07 -08001027static bool is_blacklisted(const char* sink, const char* src,
1028 const char* srcOptions, const char* name) {
mtklein0d243ff2015-04-03 07:51:00 -07001029 for (int i = 0; i < FLAGS_blacklist.count() - 3; i += 4) {
mtkleina2ef6422015-01-15 13:44:22 -08001030 if (match(FLAGS_blacklist[i+0], sink) &&
djsollen54416de2015-04-03 07:24:48 -07001031 match(FLAGS_blacklist[i+1], src) &&
1032 match(FLAGS_blacklist[i+2], srcOptions) &&
1033 match(FLAGS_blacklist[i+3], name)) {
mtklein3eed7dd2016-02-24 19:07:07 -08001034 return true;
mtkleina2ef6422015-01-15 13:44:22 -08001035 }
1036 }
mtklein3eed7dd2016-02-24 19:07:07 -08001037 return false;
mtkleina2ef6422015-01-15 13:44:22 -08001038}
1039
mtkleincd50bca2016-01-05 06:20:20 -08001040// Even when a Task Sink reports to be non-threadsafe (e.g. GPU), we know things like
1041// .png encoding are definitely thread safe. This lets us offload that work to CPU threads.
1042static SkTaskGroup gDefinitelyThreadSafeWork;
1043
mtklein748ca3b2015-01-15 10:56:12 -08001044// The finest-grained unit of work we can run: draw a single Src into a single Sink,
1045// report any errors, and perhaps write out the output: a .png of the bitmap, or a raw stream.
1046struct Task {
mtkleine0effd62015-07-29 06:37:28 -07001047 Task(const TaggedSrc& src, const TaggedSink& sink) : src(src), sink(sink) {}
1048 const TaggedSrc& src;
1049 const TaggedSink& sink;
mtklein748ca3b2015-01-15 10:56:12 -08001050
mtklein21eaf3b2016-02-08 12:39:59 -08001051 static void Run(const Task& task) {
1052 SkString name = task.src->name();
mtkleine0effd62015-07-29 06:37:28 -07001053
mtkleinb9eb4ac2015-02-02 18:26:03 -08001054 SkString log;
mtklein3eed7dd2016-02-24 19:07:07 -08001055 if (!FLAGS_dryRun) {
mtklein748ca3b2015-01-15 10:56:12 -08001056 SkBitmap bitmap;
1057 SkDynamicMemoryWStream stream;
mtklein3eed7dd2016-02-24 19:07:07 -08001058 start(task.sink.tag.c_str(), task.src.tag.c_str(),
1059 task.src.options.c_str(), name.c_str());
mtklein21eaf3b2016-02-08 12:39:59 -08001060 Error err = task.sink->draw(*task.src, &bitmap, &stream, &log);
mtkleinb3b13b72016-03-07 13:20:52 -08001061 if (!log.isEmpty()) {
mtkleinc41fd922016-03-08 09:01:39 -08001062 info("%s %s %s %s:\n%s\n", task.sink.tag.c_str()
1063 , task.src.tag.c_str()
1064 , task.src.options.c_str()
1065 , name.c_str()
1066 , log.c_str());
mtkleinb3b13b72016-03-07 13:20:52 -08001067 }
mtklein748ca3b2015-01-15 10:56:12 -08001068 if (!err.isEmpty()) {
mtklein4089ef72015-03-05 08:40:28 -08001069 if (err.isFatal()) {
djsollen54416de2015-04-03 07:24:48 -07001070 fail(SkStringPrintf("%s %s %s %s: %s",
mtklein21eaf3b2016-02-08 12:39:59 -08001071 task.sink.tag.c_str(),
1072 task.src.tag.c_str(),
1073 task.src.options.c_str(),
mtklein4089ef72015-03-05 08:40:28 -08001074 name.c_str(),
1075 err.c_str()));
mtkleinb37cb412015-03-18 05:27:14 -07001076 } else {
mtklein3eed7dd2016-02-24 19:07:07 -08001077 done(task.sink.tag.c_str(), task.src.tag.c_str(),
1078 task.src.options.c_str(), name.c_str());
mtkleinba6ada72016-01-21 09:39:35 -08001079 return;
mtklein4089ef72015-03-05 08:40:28 -08001080 }
mtklein748ca3b2015-01-15 10:56:12 -08001081 }
mtklein62bd1a62015-01-27 14:46:26 -08001082
mtkleincd50bca2016-01-05 06:20:20 -08001083 // We're likely switching threads here, so we must capture by value, [=] or [foo,bar].
Hal Canary0b833192017-03-14 14:35:02 -04001084 SkStreamAsset* data = stream.detachAsStream().release();
mtkleincd50bca2016-01-05 06:20:20 -08001085 gDefinitelyThreadSafeWork.add([task,name,bitmap,data]{
Ben Wagner145dbcd2016-11-03 14:40:50 -04001086 std::unique_ptr<SkStreamAsset> ownedData(data);
mtkleincd50bca2016-01-05 06:20:20 -08001087
mtkleincd50bca2016-01-05 06:20:20 -08001088 SkString md5;
1089 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) {
1090 SkMD5 hash;
1091 if (data->getLength()) {
1092 hash.writeStream(data, data->getLength());
1093 data->rewind();
mtklein38408462015-07-08 07:25:27 -07001094 } else {
mtkleincd50bca2016-01-05 06:20:20 -08001095 // If we're BGRA (Linux, Windows), swizzle over to RGBA (Mac, Android).
1096 // This helps eliminate multiple 0-pixel-diff hashes on gold.skia.org.
1097 // (Android's general slow speed breaks the tie arbitrarily in RGBA's favor.)
1098 // We might consider promoting 565 to RGBA too.
1099 if (bitmap.colorType() == kBGRA_8888_SkColorType) {
1100 SkBitmap swizzle;
Matt Sarett68b8e3d2017-04-28 11:15:22 -04001101 SkAssertResult(sk_tool_utils::copy_to(&swizzle, kRGBA_8888_SkColorType,
1102 bitmap));
mtkleincd50bca2016-01-05 06:20:20 -08001103 hash.write(swizzle.getPixels(), swizzle.getSize());
1104 } else {
1105 hash.write(bitmap.getPixels(), bitmap.getSize());
1106 }
1107 }
1108 SkMD5::Digest digest;
1109 hash.finish(digest);
1110 for (int i = 0; i < 16; i++) {
1111 md5.appendf("%02x", digest.data[i]);
mtklein38408462015-07-08 07:25:27 -07001112 }
mtklein62bd1a62015-01-27 14:46:26 -08001113 }
mtklein62bd1a62015-01-27 14:46:26 -08001114
mtkleincd50bca2016-01-05 06:20:20 -08001115 if (!FLAGS_readPath.isEmpty() &&
mtklein3eed7dd2016-02-24 19:07:07 -08001116 !gGold.contains(Gold(task.sink.tag, task.src.tag,
1117 task.src.options, name, md5))) {
mtkleincd50bca2016-01-05 06:20:20 -08001118 fail(SkStringPrintf("%s not found for %s %s %s %s in %s",
1119 md5.c_str(),
mtklein21eaf3b2016-02-08 12:39:59 -08001120 task.sink.tag.c_str(),
1121 task.src.tag.c_str(),
1122 task.src.options.c_str(),
mtkleincd50bca2016-01-05 06:20:20 -08001123 name.c_str(),
1124 FLAGS_readPath[0]));
mtklein748ca3b2015-01-15 10:56:12 -08001125 }
mtkleincd50bca2016-01-05 06:20:20 -08001126
1127 if (!FLAGS_writePath.isEmpty()) {
mtklein21eaf3b2016-02-08 12:39:59 -08001128 const char* ext = task.sink->fileExtension();
Mike Klein97d6a7a2017-07-24 10:37:19 -04001129 if (!FLAGS_dont_write.contains(ext)) {
1130 if (data->getLength()) {
1131 WriteToDisk(task, md5, ext, data, data->getLength(), nullptr);
1132 SkASSERT(bitmap.drawsNothing());
1133 } else if (!bitmap.drawsNothing()) {
1134 WriteToDisk(task, md5, ext, nullptr, 0, &bitmap);
1135 }
mtkleincd50bca2016-01-05 06:20:20 -08001136 }
1137 }
1138 });
mtklein748ca3b2015-01-15 10:56:12 -08001139 }
mtklein3eed7dd2016-02-24 19:07:07 -08001140 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 -08001141 }
1142
1143 static void WriteToDisk(const Task& task,
mtklein62bd1a62015-01-27 14:46:26 -08001144 SkString md5,
1145 const char* ext,
mtklein748ca3b2015-01-15 10:56:12 -08001146 SkStream* data, size_t len,
mtklein62bd1a62015-01-27 14:46:26 -08001147 const SkBitmap* bitmap) {
mtklein409d4702016-02-29 07:38:01 -08001148 bool gammaCorrect = false;
1149 if (bitmap) {
Brian Osman7039f742016-11-01 15:56:16 -04001150 gammaCorrect = SkToBool(bitmap->info().colorSpace());
mtklein409d4702016-02-29 07:38:01 -08001151 }
1152
mtklein748ca3b2015-01-15 10:56:12 -08001153 JsonWriter::BitmapResult result;
djsollen54416de2015-04-03 07:24:48 -07001154 result.name = task.src->name();
mtklein3eed7dd2016-02-24 19:07:07 -08001155 result.config = task.sink.tag;
djsollen54416de2015-04-03 07:24:48 -07001156 result.sourceType = task.src.tag;
1157 result.sourceOptions = task.src.options;
1158 result.ext = ext;
mtklein409d4702016-02-29 07:38:01 -08001159 result.gammaCorrect = gammaCorrect;
djsollen54416de2015-04-03 07:24:48 -07001160 result.md5 = md5;
mtklein748ca3b2015-01-15 10:56:12 -08001161 JsonWriter::AddBitmapResult(result);
1162
mtkleinb0531a72015-04-07 13:38:48 -07001163 // If an MD5 is uninteresting, we want it noted in the JSON file,
1164 // but don't want to dump it out as a .png (or whatever ext is).
1165 if (gUninterestingHashes.contains(md5)) {
1166 return;
1167 }
1168
mtklein748ca3b2015-01-15 10:56:12 -08001169 const char* dir = FLAGS_writePath[0];
1170 if (0 == strcmp(dir, "@")) { // Needed for iOS.
1171 dir = FLAGS_resourcePath[0];
1172 }
1173 sk_mkdir(dir);
1174
1175 SkString path;
1176 if (FLAGS_nameByHash) {
1177 path = SkOSPath::Join(dir, result.md5.c_str());
1178 path.append(".");
1179 path.append(ext);
1180 if (sk_exists(path.c_str())) {
1181 return; // Content-addressed. If it exists already, we're done.
1182 }
1183 } else {
kkinnunen3e980c32015-12-23 01:33:00 -08001184 path = SkOSPath::Join(dir, task.sink.tag.c_str());
mtklein748ca3b2015-01-15 10:56:12 -08001185 sk_mkdir(path.c_str());
msarett9e707a02015-09-01 14:57:57 -07001186 path = SkOSPath::Join(path.c_str(), task.src.tag.c_str());
mtklein748ca3b2015-01-15 10:56:12 -08001187 sk_mkdir(path.c_str());
msarett9e707a02015-09-01 14:57:57 -07001188 if (strcmp(task.src.options.c_str(), "") != 0) {
1189 path = SkOSPath::Join(path.c_str(), task.src.options.c_str());
djsollen54416de2015-04-03 07:24:48 -07001190 sk_mkdir(path.c_str());
1191 }
mtklein748ca3b2015-01-15 10:56:12 -08001192 path = SkOSPath::Join(path.c_str(), task.src->name().c_str());
1193 path.append(".");
1194 path.append(ext);
1195 }
1196
mtklein748ca3b2015-01-15 10:56:12 -08001197 if (bitmap) {
mtkleina5114d72015-08-24 13:27:01 -07001198 if (!dump_png(*bitmap, path.c_str(), result.md5.c_str())) {
mtklein748ca3b2015-01-15 10:56:12 -08001199 fail(SkStringPrintf("Can't encode PNG to %s.\n", path.c_str()));
1200 return;
1201 }
1202 } else {
mtkleina5114d72015-08-24 13:27:01 -07001203 SkFILEWStream file(path.c_str());
1204 if (!file.isValid()) {
1205 fail(SkStringPrintf("Can't open %s for writing.\n", path.c_str()));
1206 return;
1207 }
mtklein748ca3b2015-01-15 10:56:12 -08001208 if (!file.writeStream(data, len)) {
1209 fail(SkStringPrintf("Can't write to %s.\n", path.c_str()));
1210 return;
1211 }
1212 }
1213 }
1214};
1215
mtklein748ca3b2015-01-15 10:56:12 -08001216/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1217
1218// Unit tests don't fit so well into the Src/Sink model, so we give them special treatment.
1219
mtklein21eaf3b2016-02-08 12:39:59 -08001220static SkTDArray<skiatest::Test> gParallelTests, gSerialTests;
mtklein748ca3b2015-01-15 10:56:12 -08001221
1222static void gather_tests() {
mtklein6c5fed22015-01-20 13:47:23 -08001223 if (!FLAGS_src.contains("tests")) {
mtklein748ca3b2015-01-15 10:56:12 -08001224 return;
1225 }
mtklein6393c062015-04-27 08:45:01 -07001226 for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; r = r->next()) {
1227 if (!in_shard()) {
1228 continue;
1229 }
halcanary87f3ba42015-01-20 09:30:20 -08001230 // Despite its name, factory() is returning a reference to
1231 // link-time static const POD data.
1232 const skiatest::Test& test = r->factory();
1233 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test.name)) {
mtklein748ca3b2015-01-15 10:56:12 -08001234 continue;
1235 }
halcanary87f3ba42015-01-20 09:30:20 -08001236 if (test.needsGpu && gpu_supported()) {
mtklein21eaf3b2016-02-08 12:39:59 -08001237 (FLAGS_gpu_threading ? gParallelTests : gSerialTests).push(test);
halcanary87f3ba42015-01-20 09:30:20 -08001238 } else if (!test.needsGpu && FLAGS_cpu) {
mtklein21eaf3b2016-02-08 12:39:59 -08001239 gParallelTests.push(test);
mtklein82d28432015-01-15 12:46:02 -08001240 }
mtklein748ca3b2015-01-15 10:56:12 -08001241 }
1242}
1243
csmartdalton008b9d82017-02-22 12:00:42 -07001244static void run_test(skiatest::Test test, const GrContextOptions& grCtxOptions) {
halcanary87f3ba42015-01-20 09:30:20 -08001245 struct : public skiatest::Reporter {
mtklein36352bf2015-03-25 18:17:31 -07001246 void reportFailed(const skiatest::Failure& failure) override {
halcanary87f3ba42015-01-20 09:30:20 -08001247 fail(failure.toString());
1248 JsonWriter::AddTestFailure(failure);
1249 }
mtklein36352bf2015-03-25 18:17:31 -07001250 bool allowExtendedTest() const override {
halcanary87f3ba42015-01-20 09:30:20 -08001251 return FLAGS_pathOpsExtended;
1252 }
mtklein36352bf2015-03-25 18:17:31 -07001253 bool verbose() const override { return FLAGS_veryVerbose; }
halcanary87f3ba42015-01-20 09:30:20 -08001254 } reporter;
djsollen824996a2015-06-12 12:06:22 -07001255
mtklein3eed7dd2016-02-24 19:07:07 -08001256 if (!FLAGS_dryRun && !is_blacklisted("_", "tests", "_", test.name)) {
mtklein21eaf3b2016-02-08 12:39:59 -08001257 start("unit", "test", "", test.name);
csmartdalton008b9d82017-02-22 12:00:42 -07001258 GrContextFactory factory(grCtxOptions);
Mike Kleinb323a5e2017-07-24 15:21:31 -04001259 test.run(&reporter, &factory);
mtklein748ca3b2015-01-15 10:56:12 -08001260 }
mtklein3eed7dd2016-02-24 19:07:07 -08001261 done("unit", "test", "", test.name);
mtklein748ca3b2015-01-15 10:56:12 -08001262}
1263
1264/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1265
caryclark83ca6282015-06-10 09:31:09 -07001266#define PORTABLE_FONT_PREFIX "Toy Liberation "
1267
mbocee6a9912016-05-31 11:42:36 -07001268static sk_sp<SkTypeface> create_from_name(const char familyName[], SkFontStyle style) {
caryclark83ca6282015-06-10 09:31:09 -07001269 if (familyName && strlen(familyName) > sizeof(PORTABLE_FONT_PREFIX)
1270 && !strncmp(familyName, PORTABLE_FONT_PREFIX, sizeof(PORTABLE_FONT_PREFIX) - 1)) {
caryclark1818acb2015-07-24 12:09:25 -07001271 return sk_tool_utils::create_portable_typeface(familyName, style);
caryclark83ca6282015-06-10 09:31:09 -07001272 }
halcanary96fcdcc2015-08-27 07:41:13 -07001273 return nullptr;
caryclark83ca6282015-06-10 09:31:09 -07001274}
1275
1276#undef PORTABLE_FONT_PREFIX
1277
mbocee6a9912016-05-31 11:42:36 -07001278extern sk_sp<SkTypeface> (*gCreateTypefaceDelegate)(const char [], SkFontStyle );
caryclark83ca6282015-06-10 09:31:09 -07001279
Mike Kleinbe28ee22017-02-06 12:46:20 -05001280int main(int argc, char** argv) {
1281 SkCommandLineFlags::Parse(argc, argv);
Brian Osman53136aa2017-07-20 15:43:35 -04001282
Brian Osmanbc8150f2017-07-24 11:38:01 -04001283 initializeEventTracingForTools();
Brian Osman53136aa2017-07-20 15:43:35 -04001284
1285#if defined(SK_BUILD_FOR_IOS)
Mike Kleinadacaef2017-02-06 09:26:14 -05001286 cd_Documents();
1287#endif
bsalomon71de3532016-04-26 14:27:21 -07001288 setbuf(stdout, nullptr);
mtklein246ba3a2016-02-23 10:39:36 -08001289 setup_crash_handler();
mtkleinafae30a2016-02-24 12:28:32 -08001290
Yuqian Liba62b4a2016-12-14 13:46:53 -05001291 gSkUseAnalyticAA = FLAGS_analyticAA;
Yuqian Lidf60e362017-07-25 11:26:31 -04001292 gSkUseDeltaAA = FLAGS_deltaAA;
liyuqian38911a72016-10-04 11:23:22 -07001293
Yuqian Li550148b2017-01-13 10:13:13 -05001294 if (FLAGS_forceAnalyticAA) {
1295 gSkForceAnalyticAA = true;
1296 }
Mike Reed7c26ca72017-07-05 15:45:52 -04001297 if (FLAGS_forceRasterPipeline) {
1298 gSkForceRasterPipelineBlitter = true;
1299 }
Yuqian Li550148b2017-01-13 10:13:13 -05001300
Mike Kleine9f187b2017-06-26 13:23:12 -04001301 // The bots like having a verbose.log to upload, so always touch the file even if --verbose.
1302 if (!FLAGS_writePath.isEmpty()) {
mtklein51c8cfc2016-03-11 12:59:09 -08001303 sk_mkdir(FLAGS_writePath[0]);
mtkleina1ce2162016-07-22 12:23:46 -07001304 gVLog = fopen(SkOSPath::Join(FLAGS_writePath[0], "verbose.log").c_str(), "w");
mtkleinc41fd922016-03-08 09:01:39 -08001305 }
Mike Kleine9f187b2017-06-26 13:23:12 -04001306 if (FLAGS_verbose) {
1307 gVLog = stderr;
1308 }
mtkleinc41fd922016-03-08 09:01:39 -08001309
csmartdalton008b9d82017-02-22 12:00:42 -07001310 GrContextOptions grCtxOptions;
1311#if SK_SUPPORT_GPU
1312 grCtxOptions.fGpuPathRenderers = CollectGpuPathRenderersFromFlags();
1313#endif
1314
mtklein5286f022016-01-22 08:18:14 -08001315 JsonWriter::DumpJson(); // It's handy for the bots to assume this is ~never missing.
commit-bot@chromium.org39e8d932014-05-29 20:14:48 +00001316 SkAutoGraphics ag;
mtklein406654b2014-09-03 15:34:37 -07001317 SkTaskGroup::Enabler enabled(FLAGS_threads);
caryclark83ca6282015-06-10 09:31:09 -07001318 gCreateTypefaceDelegate = &create_from_name;
commit-bot@chromium.orga65e2fd2014-05-30 17:23:31 +00001319
halcanary7d571242016-02-24 17:59:16 -08001320 {
1321 SkString testResourcePath = GetResourcePath("color_wheel.png");
1322 SkFILEStream testResource(testResourcePath.c_str());
1323 if (!testResource.isValid()) {
mtkleinc41fd922016-03-08 09:01:39 -08001324 info("Some resources are missing. Do you need to set --resourcePath?\n");
halcanary7d571242016-02-24 17:59:16 -08001325 }
1326 }
mtklein62bd1a62015-01-27 14:46:26 -08001327 gather_gold();
borenet09ed4802015-04-03 14:15:33 -07001328 gather_uninteresting_hashes();
mtklein62bd1a62015-01-27 14:46:26 -08001329
scroggo86737142016-02-03 12:19:11 -08001330 if (!gather_srcs()) {
1331 return 1;
1332 }
csmartdalton008b9d82017-02-22 12:00:42 -07001333 if (!gather_sinks(grCtxOptions)) {
brianosman05c987c2016-05-09 13:42:16 -07001334 return 1;
1335 }
mtklein748ca3b2015-01-15 10:56:12 -08001336 gather_tests();
mtklein21eaf3b2016-02-08 12:39:59 -08001337 gPending = gSrcs.count() * gSinks.count() + gParallelTests.count() + gSerialTests.count();
Brian Osmand0677bc2017-08-03 12:13:47 -04001338 info("%d srcs * %d sinks + %d tests == %d tasks\n",
mtkleinc41fd922016-03-08 09:01:39 -08001339 gSrcs.count(), gSinks.count(), gParallelTests.count() + gSerialTests.count(), gPending);
mtklein748ca3b2015-01-15 10:56:12 -08001340
mtklein21eaf3b2016-02-08 12:39:59 -08001341 // Kick off as much parallel work as we can, making note of any serial work we'll need to do.
1342 SkTaskGroup parallel;
1343 SkTArray<Task> serial;
1344
1345 for (auto& sink : gSinks)
1346 for (auto& src : gSrcs) {
mtklein3eed7dd2016-02-24 19:07:07 -08001347 if (src->veto(sink->flags()) ||
1348 is_blacklisted(sink.tag.c_str(), src.tag.c_str(),
1349 src.options.c_str(), src->name().c_str())) {
mtkleinf10637f2016-06-10 13:56:35 -07001350 SkAutoMutexAcquire lock(gMutex);
mtklein3eed7dd2016-02-24 19:07:07 -08001351 gPending--;
1352 continue;
1353 }
1354
mtklein21eaf3b2016-02-08 12:39:59 -08001355 Task task(src, sink);
1356 if (src->serial() || sink->serial()) {
1357 serial.push_back(task);
1358 } else {
1359 parallel.add([task] { Task::Run(task); });
mtklein748ca3b2015-01-15 10:56:12 -08001360 }
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +00001361 }
mtklein21eaf3b2016-02-08 12:39:59 -08001362 for (auto test : gParallelTests) {
csmartdalton008b9d82017-02-22 12:00:42 -07001363 parallel.add([test, grCtxOptions] { run_test(test, grCtxOptions); });
mtklein55e88b22015-01-21 15:50:13 -08001364 }
mtklein21eaf3b2016-02-08 12:39:59 -08001365
1366 // With the parallel work running, run serial tasks and tests here on main thread.
1367 for (auto task : serial) { Task::Run(task); }
csmartdalton008b9d82017-02-22 12:00:42 -07001368 for (auto test : gSerialTests) { run_test(test, grCtxOptions); }
mtklein21eaf3b2016-02-08 12:39:59 -08001369
1370 // Wait for any remaining parallel work to complete (including any spun off of serial tasks).
1371 parallel.wait();
mtkleincd50bca2016-01-05 06:20:20 -08001372 gDefinitelyThreadSafeWork.wait();
1373
mtkleinda884c42016-02-24 18:00:23 -08001374 // We'd better have run everything.
1375 SkASSERT(gPending == 0);
mtkleine027f172016-02-26 15:53:06 -08001376 // Make sure we've flushed all our results to disk.
1377 JsonWriter::DumpJson();
mtkleinda884c42016-02-24 18:00:23 -08001378
mtklein748ca3b2015-01-15 10:56:12 -08001379 // At this point we're back in single-threaded land.
caryclarkf53ce802015-06-15 06:48:30 -07001380 sk_tool_utils::release_portable_typefaces();
mtklein@google.comd36522d2013-10-16 13:02:15 +00001381
mtklein748ca3b2015-01-15 10:56:12 -08001382 if (gFailures.count() > 0) {
mtkleinc41fd922016-03-08 09:01:39 -08001383 info("Failures:\n");
mtklein748ca3b2015-01-15 10:56:12 -08001384 for (int i = 0; i < gFailures.count(); i++) {
mtkleinc41fd922016-03-08 09:01:39 -08001385 info("\t%s\n", gFailures[i].c_str());
mtklein748ca3b2015-01-15 10:56:12 -08001386 }
mtkleinc41fd922016-03-08 09:01:39 -08001387 info("%d failures\n", gFailures.count());
mtklein748ca3b2015-01-15 10:56:12 -08001388 return 1;
mtklein114c3cd2015-01-15 10:15:02 -08001389 }
mtkleinafae30a2016-02-24 12:28:32 -08001390
1391#ifdef SK_PDF_IMAGE_STATS
halcanary7a14b312015-10-01 07:28:13 -07001392 SkPDFImageDumpStats();
mtkleinafae30a2016-02-24 12:28:32 -08001393#endif // SK_PDF_IMAGE_STATS
1394
Herb Derby5a523fe2017-01-26 16:48:28 -05001395 SkGraphics::PurgeAllCaches();
mtkleinc41fd922016-03-08 09:01:39 -08001396 info("Finished!\n");
Brian Osman53136aa2017-07-20 15:43:35 -04001397
mtklein748ca3b2015-01-15 10:56:12 -08001398 return 0;
mtklein@google.comd36522d2013-10-16 13:02:15 +00001399}
jcgregorio3b27ade2014-11-13 08:06:40 -08001400
kkinnunen179a8f52015-11-20 13:32:24 -08001401// TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards.
1402// Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0.
1403namespace skiatest {
bsalomon758586c2016-04-06 14:02:39 -07001404
1405#if SK_SUPPORT_GPU
1406bool IsGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
1407 return kOpenGL_GrBackend == GrContextFactory::ContextTypeBackend(type);
1408}
bsalomondc0fcd42016-04-11 14:21:33 -07001409bool IsVulkanContextType(sk_gpu_test::GrContextFactory::ContextType type) {
1410 return kVulkan_GrBackend == GrContextFactory::ContextTypeBackend(type);
1411}
bsalomon758586c2016-04-06 14:02:39 -07001412bool IsRenderingGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
1413 return IsGLContextType(type) && GrContextFactory::IsRenderingContext(type);
1414}
1415bool IsNullGLContextType(sk_gpu_test::GrContextFactory::ContextType type) {
1416 return type == GrContextFactory::kNullGL_ContextType;
1417}
1418#else
1419bool IsGLContextType(int) { return false; }
bsalomondc0fcd42016-04-11 14:21:33 -07001420bool IsVulkanContextType(int) { return false; }
bsalomon758586c2016-04-06 14:02:39 -07001421bool IsRenderingGLContextType(int) { return false; }
1422bool IsNullGLContextType(int) { return false; }
1423#endif
1424
1425void RunWithGPUTestContexts(GrContextTestFn* test, GrContextTypeFilterFn* contextTypeFilter,
bsalomonf2f1c172016-04-05 12:59:06 -07001426 Reporter* reporter, GrContextFactory* factory) {
kkinnunen179a8f52015-11-20 13:32:24 -08001427#if SK_SUPPORT_GPU
kkinnunen3e980c32015-12-23 01:33:00 -08001428
Brian Salomon6405e712017-03-20 08:54:16 -04001429#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC)
1430 static constexpr auto kNativeGLType = GrContextFactory::kGL_ContextType;
1431#else
1432 static constexpr auto kNativeGLType = GrContextFactory::kGLES_ContextType;
1433#endif
1434
bsalomon758586c2016-04-06 14:02:39 -07001435 for (int typeInt = 0; typeInt < GrContextFactory::kContextTypeCnt; ++typeInt) {
1436 GrContextFactory::ContextType contextType = (GrContextFactory::ContextType) typeInt;
Brian Osmanaa2219c2016-12-05 10:12:17 -05001437 // Use "native" instead of explicitly trying OpenGL and OpenGL ES. Do not use GLES on
bsalomon758586c2016-04-06 14:02:39 -07001438 // desktop since tests do not account for not fixing http://skbug.com/2809
1439 if (contextType == GrContextFactory::kGL_ContextType ||
1440 contextType == GrContextFactory::kGLES_ContextType) {
Brian Salomon6405e712017-03-20 08:54:16 -04001441 if (contextType != kNativeGLType) {
bsalomon758586c2016-04-06 14:02:39 -07001442 continue;
1443 }
1444 }
csmartdaltone812d492017-02-21 12:36:05 -07001445 ContextInfo ctxInfo = factory->getContextInfo(contextType,
1446 GrContextFactory::ContextOverrides::kDisableNVPR);
Brian Osmanaa2219c2016-12-05 10:12:17 -05001447 if (contextTypeFilter && !(*contextTypeFilter)(contextType)) {
1448 continue;
1449 }
Greg Daniela5cb7812017-06-16 09:45:32 -04001450 ReporterContext ctx(reporter, SkString(GrContextFactory::ContextTypeName(contextType)));
bsalomon8b7451a2016-05-11 06:33:06 -07001451 if (ctxInfo.grContext()) {
bsalomonf2f1c172016-04-05 12:59:06 -07001452 (*test)(reporter, ctxInfo);
Robert Phillipseaa90b22017-08-01 10:36:36 -04001453 ctxInfo.grContext()->flush();
kkinnunen5219fd92015-12-10 06:28:13 -08001454 }
bsalomonf2f1c172016-04-05 12:59:06 -07001455 ctxInfo = factory->getContextInfo(contextType,
csmartdaltone812d492017-02-21 12:36:05 -07001456 GrContextFactory::ContextOverrides::kRequireNVPRSupport);
bsalomon8b7451a2016-05-11 06:33:06 -07001457 if (ctxInfo.grContext()) {
bsalomonf2f1c172016-04-05 12:59:06 -07001458 (*test)(reporter, ctxInfo);
Robert Phillipseaa90b22017-08-01 10:36:36 -04001459 ctxInfo.grContext()->flush();
kkinnunen179a8f52015-11-20 13:32:24 -08001460 }
1461 }
1462#endif
1463}
kkinnunen179a8f52015-11-20 13:32:24 -08001464} // namespace skiatest