scroggo | 478652e | 2015-03-25 07:11:02 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
jcgregorio | 3b27ade | 2014-11-13 08:06:40 -0800 | [diff] [blame] | 8 | #include "CrashHandler.h" |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 9 | #include "DMJsonWriter.h" |
| 10 | #include "DMSrcSink.h" |
tomhudson | eebc39a | 2015-02-23 12:18:05 -0800 | [diff] [blame] | 11 | #include "DMSrcSinkAndroid.h" |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 12 | #include "OverwriteLine.h" |
| 13 | #include "ProcStats.h" |
| 14 | #include "SkBBHFactory.h" |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 15 | #include "SkChecksum.h" |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 16 | #include "SkCommonFlags.h" |
caryclark | 83ca628 | 2015-06-10 09:31:09 -0700 | [diff] [blame] | 17 | #include "SkFontMgr.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 18 | #include "SkForceLinking.h" |
| 19 | #include "SkGraphics.h" |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 20 | #include "SkMD5.h" |
mtklein | 1b24933 | 2015-07-07 12:21:21 -0700 | [diff] [blame] | 21 | #include "SkMutex.h" |
mtklein | 1d0f164 | 2014-09-08 08:05:18 -0700 | [diff] [blame] | 22 | #include "SkOSFile.h" |
mtklein | a82f562 | 2015-02-20 12:30:19 -0800 | [diff] [blame] | 23 | #include "SkTHash.h" |
mtklein | 406654b | 2014-09-03 15:34:37 -0700 | [diff] [blame] | 24 | #include "SkTaskGroup.h" |
mtklein | de6fc2b | 2015-03-12 06:28:54 -0700 | [diff] [blame] | 25 | #include "SkThreadUtils.h" |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 26 | #include "Test.h" |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 27 | #include "Timer.h" |
caryclark | 83ca628 | 2015-06-10 09:31:09 -0700 | [diff] [blame] | 28 | #include "sk_tool_utils.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 29 | |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 30 | DEFINE_string(src, "tests gm skp image", "Source types to test."); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 31 | DEFINE_bool(nameByHash, false, |
| 32 | "If true, write to FLAGS_writePath[0]/<hash>.png instead of " |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 33 | "to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>.png"); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 34 | DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); |
mtklein | d603b22 | 2015-02-17 11:13:33 -0800 | [diff] [blame] | 35 | DEFINE_string(matrix, "1 0 0 1", |
| 36 | "2x2 scale+skew matrix to apply or upright when using " |
| 37 | "'matrix' or 'upright' in config."); |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 38 | DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?"); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 39 | |
mtklein | a2ef642 | 2015-01-15 13:44:22 -0800 | [diff] [blame] | 40 | DEFINE_string(blacklist, "", |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 41 | "Space-separated config/src/srcOptions/name quadruples to blacklist. '_' matches anything. E.g. \n" |
| 42 | "'--blacklist gpu skp _ _' will blacklist all SKPs drawn into the gpu config.\n" |
| 43 | "'--blacklist gpu skp _ _ 8888 gm _ aarects' will also blacklist the aarects GM on 8888."); |
mtklein | a2ef642 | 2015-01-15 13:44:22 -0800 | [diff] [blame] | 44 | |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 45 | DEFINE_string2(readPath, r, "", "If set check for equality with golden results in this directory."); |
| 46 | |
borenet | 09ed480 | 2015-04-03 14:15:33 -0700 | [diff] [blame] | 47 | DEFINE_string(uninterestingHashesFile, "", |
| 48 | "File containing a list of uninteresting hashes. If a result hashes to something in " |
| 49 | "this list, no image is written for that result."); |
| 50 | |
mtklein | 6393c06 | 2015-04-27 08:45:01 -0700 | [diff] [blame] | 51 | DEFINE_int32(shards, 1, "We're splitting source data into this many shards."); |
| 52 | DEFINE_int32(shard, 0, "Which shard do I run?"); |
bsalomon | 821e10e | 2015-06-04 14:15:33 -0700 | [diff] [blame] | 53 | DEFINE_bool2(pre_log, p, false, "Log before running each test. May be incomprehensible when threading"); |
mtklein | 6393c06 | 2015-04-27 08:45:01 -0700 | [diff] [blame] | 54 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 55 | __SK_FORCE_IMAGE_DECODER_LINKING; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 56 | using namespace DM; |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 57 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 58 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 59 | |
| 60 | SK_DECLARE_STATIC_MUTEX(gFailuresMutex); |
| 61 | static SkTArray<SkString> gFailures; |
| 62 | |
| 63 | static void fail(ImplicitString err) { |
| 64 | SkAutoMutexAcquire lock(gFailuresMutex); |
| 65 | SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); |
| 66 | gFailures.push_back(err); |
halcanary | 9e398f7 | 2015-01-10 11:18:04 -0800 | [diff] [blame] | 67 | } |
| 68 | |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame] | 69 | static int32_t gPending = 0; // Atomic. Total number of running and queued tasks. |
| 70 | |
| 71 | SK_DECLARE_STATIC_MUTEX(gRunningMutex); |
| 72 | static SkTArray<SkString> gRunning; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 73 | |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 74 | static void done(double ms, |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 75 | ImplicitString config, ImplicitString src, ImplicitString srcOptions, |
| 76 | ImplicitString name, ImplicitString note, ImplicitString log) { |
| 77 | SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(), |
| 78 | srcOptions.c_str(), name.c_str()); |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame] | 79 | { |
| 80 | SkAutoMutexAcquire lock(gRunningMutex); |
| 81 | for (int i = 0; i < gRunning.count(); i++) { |
| 82 | if (gRunning[i] == id) { |
| 83 | gRunning.removeShuffle(i); |
| 84 | break; |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | if (!FLAGS_verbose) { |
| 89 | note = ""; |
| 90 | } |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 91 | if (!log.isEmpty()) { |
| 92 | log.prepend("\n"); |
| 93 | } |
mtklein | 6dee2ad | 2015-02-05 09:53:44 -0800 | [diff] [blame] | 94 | auto pending = sk_atomic_dec(&gPending)-1; |
reed | 50bc051 | 2015-05-19 14:13:31 -0700 | [diff] [blame] | 95 | if (!FLAGS_quiet) { |
mtklein | 711a245 | 2015-07-08 08:49:20 -0700 | [diff] [blame] | 96 | SkDebugf("%s(%4d/%-4dMB %6d) %s\t%s%s%s", FLAGS_verbose ? "\n" : kSkOverwriteLine |
reed | 50bc051 | 2015-05-19 14:13:31 -0700 | [diff] [blame] | 97 | , sk_tools::getCurrResidentSetSizeMB() |
| 98 | , sk_tools::getMaxResidentSetSizeMB() |
| 99 | , pending |
| 100 | , HumanizeMs(ms).c_str() |
| 101 | , id.c_str() |
| 102 | , note.c_str() |
| 103 | , log.c_str()); |
| 104 | } |
mtklein | a17241b | 2015-01-23 05:48:00 -0800 | [diff] [blame] | 105 | // We write our dm.json file every once in a while in case we crash. |
| 106 | // Notice this also handles the final dm.json when pending == 0. |
| 107 | if (pending % 500 == 0) { |
| 108 | JsonWriter::DumpJson(); |
| 109 | } |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 110 | } |
| 111 | |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 112 | static void start(ImplicitString config, ImplicitString src, |
| 113 | ImplicitString srcOptions, ImplicitString name) { |
| 114 | SkString id = SkStringPrintf("%s %s %s %s", config.c_str(), src.c_str(), |
| 115 | srcOptions.c_str(), name.c_str()); |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame] | 116 | SkAutoMutexAcquire lock(gRunningMutex); |
| 117 | gRunning.push_back(id); |
| 118 | } |
| 119 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 120 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 121 | |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 122 | struct Gold : public SkString { |
mtklein | a82f562 | 2015-02-20 12:30:19 -0800 | [diff] [blame] | 123 | Gold() : SkString("") {} |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 124 | Gold(ImplicitString sink, ImplicitString src, ImplicitString srcOptions, |
| 125 | ImplicitString name, ImplicitString md5) |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 126 | : SkString("") { |
| 127 | this->append(sink); |
| 128 | this->append(src); |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 129 | this->append(srcOptions); |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 130 | this->append(name); |
| 131 | this->append(md5); |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 132 | } |
mtklein | 02f46cf | 2015-03-20 13:48:42 -0700 | [diff] [blame] | 133 | static uint32_t Hash(const Gold& g) { return SkGoodHash((const SkString&)g); } |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 134 | }; |
mtklein | a82f562 | 2015-02-20 12:30:19 -0800 | [diff] [blame] | 135 | static SkTHashSet<Gold, Gold::Hash> gGold; |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 136 | |
| 137 | static void add_gold(JsonWriter::BitmapResult r) { |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 138 | gGold.add(Gold(r.config, r.sourceType, r.sourceOptions, r.name, r.md5)); |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | static void gather_gold() { |
| 142 | if (!FLAGS_readPath.isEmpty()) { |
| 143 | SkString path(FLAGS_readPath[0]); |
| 144 | path.append("/dm.json"); |
| 145 | if (!JsonWriter::ReadJson(path.c_str(), add_gold)) { |
| 146 | fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_str())); |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 152 | |
borenet | 09ed480 | 2015-04-03 14:15:33 -0700 | [diff] [blame] | 153 | static SkTHashSet<SkString> gUninterestingHashes; |
| 154 | |
| 155 | static void gather_uninteresting_hashes() { |
| 156 | if (!FLAGS_uninterestingHashesFile.isEmpty()) { |
| 157 | SkAutoTUnref<SkData> data(SkData::NewFromFileName(FLAGS_uninterestingHashesFile[0])); |
| 158 | SkTArray<SkString> hashes; |
| 159 | SkStrSplit((const char*)data->data(), "\n", &hashes); |
| 160 | for (const SkString& hash : hashes) { |
| 161 | gUninterestingHashes.add(hash); |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 167 | |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 168 | struct TaggedSrc : public SkAutoTDelete<Src> { |
| 169 | const char* tag; |
| 170 | const char* options; |
| 171 | }; |
| 172 | |
| 173 | struct TaggedSink : public SkAutoTDelete<Sink> { |
| 174 | const char* tag; |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 175 | }; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 176 | |
| 177 | static const bool kMemcpyOK = true; |
| 178 | |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 179 | static SkTArray<TaggedSrc, kMemcpyOK> gSrcs; |
| 180 | static SkTArray<TaggedSink, kMemcpyOK> gSinks; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 181 | |
mtklein | 6393c06 | 2015-04-27 08:45:01 -0700 | [diff] [blame] | 182 | static bool in_shard() { |
| 183 | static int N = 0; |
| 184 | return N++ % FLAGS_shards == FLAGS_shard; |
| 185 | } |
| 186 | |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 187 | static void push_src(const char* tag, const char* options, Src* s) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 188 | SkAutoTDelete<Src> src(s); |
mtklein | 6393c06 | 2015-04-27 08:45:01 -0700 | [diff] [blame] | 189 | if (in_shard() && |
| 190 | FLAGS_src.contains(tag) && |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 191 | !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 192 | TaggedSrc& s = gSrcs.push_back(); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 193 | s.reset(src.detach()); |
| 194 | s.tag = tag; |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 195 | s.options = options; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 196 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 197 | } |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 198 | |
msarett | 438b2ad | 2015-04-09 12:43:10 -0700 | [diff] [blame] | 199 | static void push_codec_srcs(Path path) { |
| 200 | SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
| 201 | if (!encoded) { |
| 202 | SkDebugf("Couldn't read %s.", path.c_str()); |
| 203 | return; |
| 204 | } |
| 205 | SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
| 206 | if (NULL == codec.get()) { |
| 207 | SkDebugf("Couldn't create codec for %s.", path.c_str()); |
| 208 | return; |
| 209 | } |
| 210 | |
msarett | 0a24297 | 2015-06-11 14:27:27 -0700 | [diff] [blame] | 211 | // Choose scales for scaling tests. |
| 212 | // TODO (msarett): Add more scaling tests as we implement more flexible scaling. |
| 213 | // TODO (msarett): Implement scaling tests for SkImageDecoder in order to compare with these |
| 214 | // tests. SkImageDecoder supports downscales by integer factors. |
msarett | 1c8a587 | 2015-07-07 08:50:01 -0700 | [diff] [blame] | 215 | const float scales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f }; |
msarett | 438b2ad | 2015-04-09 12:43:10 -0700 | [diff] [blame] | 216 | |
msarett | 0a24297 | 2015-06-11 14:27:27 -0700 | [diff] [blame] | 217 | for (float scale : scales) { |
scroggo | 6f818b3 | 2015-07-13 08:17:00 -0700 | [diff] [blame] | 218 | if (scale != 1.0f && (path.endsWith(".webp") || path.endsWith(".WEBP"))) { |
| 219 | // FIXME: skbug.com/4038 Scaling webp seems to leave some pixels uninitialized/ |
| 220 | // compute their colors based on uninitialized values. |
| 221 | continue; |
| 222 | } |
msarett | 0a24297 | 2015-06-11 14:27:27 -0700 | [diff] [blame] | 223 | // Build additional test cases for images that decode natively to non-canvas types |
| 224 | switch(codec->getInfo().colorType()) { |
| 225 | case kGray_8_SkColorType: |
| 226 | push_src("image", "codec_kGray8", new CodecSrc(path, CodecSrc::kNormal_Mode, |
| 227 | CodecSrc::kGrayscale_Always_DstColorType, scale)); |
| 228 | push_src("image", "scanline_kGray8", new CodecSrc(path, CodecSrc::kScanline_Mode, |
| 229 | CodecSrc::kGrayscale_Always_DstColorType, scale)); |
| 230 | push_src("image", "scanline_subset_kGray8", new CodecSrc(path, |
| 231 | CodecSrc::kScanline_Subset_Mode, CodecSrc::kGrayscale_Always_DstColorType, |
| 232 | scale)); |
| 233 | push_src("image", "stripe_kGray8", new CodecSrc(path, CodecSrc::kStripe_Mode, |
| 234 | CodecSrc::kGrayscale_Always_DstColorType, scale)); |
| 235 | // Intentional fall through |
| 236 | // FIXME: Is this a long term solution for testing wbmps decodes to kIndex8? |
| 237 | // Further discussion on this topic is at skbug.com/3683 |
| 238 | case kIndex_8_SkColorType: |
| 239 | push_src("image", "codec_kIndex8", new CodecSrc(path, CodecSrc::kNormal_Mode, |
| 240 | CodecSrc::kIndex8_Always_DstColorType, scale)); |
| 241 | push_src("image", "scanline_kIndex8", new CodecSrc(path, CodecSrc::kScanline_Mode, |
| 242 | CodecSrc::kIndex8_Always_DstColorType, scale)); |
| 243 | push_src("image", "scanline_subset_kIndex8", new CodecSrc(path, |
| 244 | CodecSrc::kScanline_Subset_Mode, CodecSrc::kIndex8_Always_DstColorType, |
| 245 | scale)); |
| 246 | push_src("image", "stripe_kIndex8", new CodecSrc(path, CodecSrc::kStripe_Mode, |
| 247 | CodecSrc::kIndex8_Always_DstColorType, scale)); |
| 248 | break; |
| 249 | default: |
| 250 | // Do nothing |
| 251 | break; |
| 252 | } |
| 253 | |
| 254 | // Decode all images to the canvas color type |
| 255 | push_src("image", "codec", new CodecSrc(path, CodecSrc::kNormal_Mode, |
| 256 | CodecSrc::kGetFromCanvas_DstColorType, scale)); |
| 257 | push_src("image", "scanline", new CodecSrc(path, CodecSrc::kScanline_Mode, |
| 258 | CodecSrc::kGetFromCanvas_DstColorType, scale)); |
| 259 | push_src("image", "scanline_subset", new CodecSrc(path, CodecSrc::kScanline_Subset_Mode, |
| 260 | CodecSrc::kGetFromCanvas_DstColorType, scale)); |
| 261 | push_src("image", "stripe", new CodecSrc(path, CodecSrc::kStripe_Mode, |
| 262 | CodecSrc::kGetFromCanvas_DstColorType, scale)); |
scroggo | b636b45 | 2015-07-22 07:16:20 -0700 | [diff] [blame] | 263 | // Note: The only codec which supports subsets natively is SkWebpCodec, which will never |
| 264 | // report kIndex_8 or kGray_8, so there is no need to test kSubset_mode with those color |
| 265 | // types specifically requested. |
| 266 | push_src("image", "codec_subset", new CodecSrc(path, CodecSrc::kSubset_Mode, |
| 267 | CodecSrc::kGetFromCanvas_DstColorType, scale)); |
msarett | 0a24297 | 2015-06-11 14:27:27 -0700 | [diff] [blame] | 268 | } |
msarett | 438b2ad | 2015-04-09 12:43:10 -0700 | [diff] [blame] | 269 | } |
| 270 | |
scroggo | 9b77ddd | 2015-03-19 06:03:39 -0700 | [diff] [blame] | 271 | static bool codec_supported(const char* ext) { |
| 272 | // FIXME: Once other versions of SkCodec are available, we can add them to this |
| 273 | // list (and eventually we can remove this check once they are all supported). |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 274 | static const char* const exts[] = { |
scroggo | 6f5e619 | 2015-06-18 12:53:43 -0700 | [diff] [blame] | 275 | "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp", |
| 276 | "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP", |
msarett | 8c8f22a | 2015-04-01 06:58:48 -0700 | [diff] [blame] | 277 | }; |
| 278 | |
| 279 | for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
| 280 | if (0 == strcmp(exts[i], ext)) { |
| 281 | return true; |
| 282 | } |
| 283 | } |
| 284 | return false; |
scroggo | 9b77ddd | 2015-03-19 06:03:39 -0700 | [diff] [blame] | 285 | } |
| 286 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 287 | static void gather_srcs() { |
| 288 | for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->next()) { |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 289 | push_src("gm", "", new GMSrc(r->factory())); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 290 | } |
halcanary | fc37ad1 | 2015-01-30 07:31:19 -0800 | [diff] [blame] | 291 | for (int i = 0; i < FLAGS_skps.count(); i++) { |
| 292 | const char* path = FLAGS_skps[i]; |
| 293 | if (sk_isdir(path)) { |
| 294 | SkOSFile::Iter it(path, "skp"); |
| 295 | for (SkString file; it.next(&file); ) { |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 296 | push_src("skp", "", new SKPSrc(SkOSPath::Join(path, file.c_str()))); |
halcanary | fc37ad1 | 2015-01-30 07:31:19 -0800 | [diff] [blame] | 297 | } |
| 298 | } else { |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 299 | push_src("skp", "", new SKPSrc(path)); |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 300 | } |
| 301 | } |
halcanary | 23b03c3 | 2015-01-30 09:58:58 -0800 | [diff] [blame] | 302 | static const char* const exts[] = { |
| 303 | "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico", |
| 304 | "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO", |
| 305 | }; |
| 306 | for (int i = 0; i < FLAGS_images.count(); i++) { |
| 307 | const char* flag = FLAGS_images[i]; |
| 308 | if (sk_isdir(flag)) { |
| 309 | for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |
| 310 | SkOSFile::Iter it(flag, exts[j]); |
| 311 | for (SkString file; it.next(&file); ) { |
| 312 | SkString path = SkOSPath::Join(flag, file.c_str()); |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 313 | push_src("image", "decode", new ImageSrc(path)); // Decode entire image |
| 314 | push_src("image", "subset", new ImageSrc(path, 2)); // Decode into 2x2 subsets |
scroggo | 9b77ddd | 2015-03-19 06:03:39 -0700 | [diff] [blame] | 315 | if (codec_supported(exts[j])) { |
msarett | 438b2ad | 2015-04-09 12:43:10 -0700 | [diff] [blame] | 316 | push_codec_srcs(path); |
scroggo | 9b77ddd | 2015-03-19 06:03:39 -0700 | [diff] [blame] | 317 | } |
halcanary | 23b03c3 | 2015-01-30 09:58:58 -0800 | [diff] [blame] | 318 | } |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 319 | } |
halcanary | 23b03c3 | 2015-01-30 09:58:58 -0800 | [diff] [blame] | 320 | } else if (sk_exists(flag)) { |
| 321 | // assume that FLAGS_images[i] is a valid image if it is a file. |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 322 | push_src("image", "decode", new ImageSrc(flag)); // Decode entire image. |
| 323 | push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets |
msarett | 438b2ad | 2015-04-09 12:43:10 -0700 | [diff] [blame] | 324 | push_codec_srcs(flag); |
mtklein | 709d2c3 | 2015-01-15 08:30:25 -0800 | [diff] [blame] | 325 | } |
mtklein | 709d2c3 | 2015-01-15 08:30:25 -0800 | [diff] [blame] | 326 | } |
| 327 | } |
| 328 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 329 | static GrGLStandard get_gpu_api() { |
| 330 | if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
| 331 | if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
| 332 | return kNone_GrGLStandard; |
mtklein | 709d2c3 | 2015-01-15 08:30:25 -0800 | [diff] [blame] | 333 | } |
| 334 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 335 | static void push_sink(const char* tag, Sink* s) { |
| 336 | SkAutoTDelete<Sink> sink(s); |
| 337 | if (!FLAGS_config.contains(tag)) { |
| 338 | return; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 339 | } |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 340 | // Try a simple Src as a canary. If it fails, skip this sink. |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 341 | struct : public Src { |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 342 | Error draw(SkCanvas* c) const override { |
| 343 | c->drawRect(SkRect::MakeWH(1,1), SkPaint()); |
| 344 | return ""; |
| 345 | } |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 346 | SkISize size() const override { return SkISize::Make(16, 16); } |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 347 | Name name() const override { return "justOneRect"; } |
| 348 | } justOneRect; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 349 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 350 | SkBitmap bitmap; |
| 351 | SkDynamicMemoryWStream stream; |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 352 | SkString log; |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 353 | Error err = sink->draw(justOneRect, &bitmap, &stream, &log); |
mtklein | 4089ef7 | 2015-03-05 08:40:28 -0800 | [diff] [blame] | 354 | if (err.isFatal()) { |
mtklein | 05641a5 | 2015-04-21 10:49:13 -0700 | [diff] [blame] | 355 | SkDebugf("Could not run %s: %s\n", tag, err.c_str()); |
| 356 | exit(1); |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 357 | } |
| 358 | |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 359 | TaggedSink& ts = gSinks.push_back(); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 360 | ts.reset(sink.detach()); |
| 361 | ts.tag = tag; |
| 362 | } |
| 363 | |
| 364 | static bool gpu_supported() { |
| 365 | #if SK_SUPPORT_GPU |
| 366 | return FLAGS_gpu; |
| 367 | #else |
| 368 | return false; |
| 369 | #endif |
| 370 | } |
| 371 | |
| 372 | static Sink* create_sink(const char* tag) { |
| 373 | #define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS__); } |
| 374 | if (gpu_supported()) { |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 375 | typedef GrContextFactory Gr; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 376 | const GrGLStandard api = get_gpu_api(); |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 377 | SINK("gpunull", GPUSink, Gr::kNull_GLContextType, api, 0, false, FLAGS_gpu_threading); |
| 378 | SINK("gpudebug", GPUSink, Gr::kDebug_GLContextType, api, 0, false, FLAGS_gpu_threading); |
| 379 | SINK("gpu", GPUSink, Gr::kNative_GLContextType, api, 0, false, FLAGS_gpu_threading); |
| 380 | SINK("gpudft", GPUSink, Gr::kNative_GLContextType, api, 0, true, FLAGS_gpu_threading); |
| 381 | SINK("msaa4", GPUSink, Gr::kNative_GLContextType, api, 4, false, FLAGS_gpu_threading); |
| 382 | SINK("msaa16", GPUSink, Gr::kNative_GLContextType, api, 16, false, FLAGS_gpu_threading); |
| 383 | SINK("nvprmsaa4", GPUSink, Gr::kNVPR_GLContextType, api, 4, false, FLAGS_gpu_threading); |
| 384 | SINK("nvprmsaa16", GPUSink, Gr::kNVPR_GLContextType, api, 16, false, FLAGS_gpu_threading); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 385 | #if SK_ANGLE |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 386 | SINK("angle", GPUSink, Gr::kANGLE_GLContextType, api, 0, false, FLAGS_gpu_threading); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 387 | #endif |
| 388 | #if SK_MESA |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 389 | SINK("mesa", GPUSink, Gr::kMESA_GLContextType, api, 0, false, FLAGS_gpu_threading); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 390 | #endif |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 391 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 392 | |
tomhudson | eebc39a | 2015-02-23 12:18:05 -0800 | [diff] [blame] | 393 | #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 394 | SINK("hwui", HWUISink); |
| 395 | #endif |
| 396 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 397 | if (FLAGS_cpu) { |
| 398 | SINK("565", RasterSink, kRGB_565_SkColorType); |
| 399 | SINK("8888", RasterSink, kN32_SkColorType); |
mtklein | 19f3060 | 2015-01-20 13:34:39 -0800 | [diff] [blame] | 400 | SINK("pdf", PDFSink); |
mtklein | 9c3f17d | 2015-01-28 11:35:18 -0800 | [diff] [blame] | 401 | SINK("skp", SKPSink); |
mtklein | 8a4527e | 2015-01-31 20:00:58 -0800 | [diff] [blame] | 402 | SINK("svg", SVGSink); |
| 403 | SINK("null", NullSink); |
halcanary | 47ef4d5 | 2015-03-03 09:13:09 -0800 | [diff] [blame] | 404 | SINK("xps", XPSSink); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 405 | } |
| 406 | #undef SINK |
| 407 | return NULL; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 408 | } |
| 409 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 410 | static Sink* create_via(const char* tag, Sink* wrapped) { |
| 411 | #define VIA(t, via, ...) if (0 == strcmp(t, tag)) { return new via(__VA_ARGS__); } |
mtklein | 6fbf4b3 | 2015-05-06 11:35:40 -0700 | [diff] [blame] | 412 | VIA("twice", ViaTwice, wrapped); |
mtklein | 7edca21 | 2015-01-21 13:18:51 -0800 | [diff] [blame] | 413 | VIA("pipe", ViaPipe, wrapped); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 414 | VIA("serialize", ViaSerialization, wrapped); |
reed | 06a22f6 | 2015-05-05 08:11:33 -0700 | [diff] [blame] | 415 | VIA("deferred", ViaDeferred, wrapped); |
mtklein | b7e8d69 | 2015-04-07 08:30:32 -0700 | [diff] [blame] | 416 | VIA("2ndpic", ViaSecondPicture, wrapped); |
mtklein | d31c13d | 2015-05-05 12:59:56 -0700 | [diff] [blame] | 417 | VIA("sp", ViaSingletonPictures, wrapped); |
mtklein | 7edca21 | 2015-01-21 13:18:51 -0800 | [diff] [blame] | 418 | VIA("tiles", ViaTiles, 256, 256, NULL, wrapped); |
| 419 | VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 420 | |
mtklein | d603b22 | 2015-02-17 11:13:33 -0800 | [diff] [blame] | 421 | if (FLAGS_matrix.count() == 4) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 422 | SkMatrix m; |
mtklein | d603b22 | 2015-02-17 11:13:33 -0800 | [diff] [blame] | 423 | m.reset(); |
| 424 | m.setScaleX((SkScalar)atof(FLAGS_matrix[0])); |
| 425 | m.setSkewX ((SkScalar)atof(FLAGS_matrix[1])); |
| 426 | m.setSkewY ((SkScalar)atof(FLAGS_matrix[2])); |
| 427 | m.setScaleY((SkScalar)atof(FLAGS_matrix[3])); |
| 428 | VIA("matrix", ViaMatrix, m, wrapped); |
| 429 | VIA("upright", ViaUpright, m, wrapped); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 430 | } |
tomhudson | 64de1e1 | 2015-03-05 08:01:07 -0800 | [diff] [blame] | 431 | |
| 432 | #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 433 | VIA("androidsdk", ViaAndroidSDK, wrapped); |
| 434 | #endif |
| 435 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 436 | #undef VIA |
| 437 | return NULL; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 438 | } |
| 439 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 440 | static void gather_sinks() { |
| 441 | for (int i = 0; i < FLAGS_config.count(); i++) { |
| 442 | const char* config = FLAGS_config[i]; |
| 443 | SkTArray<SkString> parts; |
| 444 | SkStrSplit(config, "-", &parts); |
| 445 | |
| 446 | Sink* sink = NULL; |
| 447 | for (int i = parts.count(); i-- > 0;) { |
| 448 | const char* part = parts[i].c_str(); |
| 449 | Sink* next = (sink == NULL) ? create_sink(part) : create_via(part, sink); |
| 450 | if (next == NULL) { |
| 451 | SkDebugf("Skipping %s: Don't understand '%s'.\n", config, part); |
| 452 | delete sink; |
| 453 | sink = NULL; |
| 454 | break; |
| 455 | } |
| 456 | sink = next; |
| 457 | } |
| 458 | if (sink) { |
| 459 | push_sink(config, sink); |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 460 | } |
| 461 | } |
| 462 | } |
mtklein | 709d2c3 | 2015-01-15 08:30:25 -0800 | [diff] [blame] | 463 | |
mtklein | a2ef642 | 2015-01-15 13:44:22 -0800 | [diff] [blame] | 464 | static bool match(const char* needle, const char* haystack) { |
| 465 | return 0 == strcmp("_", needle) || NULL != strstr(haystack, needle); |
| 466 | } |
| 467 | |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 468 | static ImplicitString is_blacklisted(const char* sink, const char* src, |
| 469 | const char* srcOptions, const char* name) { |
mtklein | 0d243ff | 2015-04-03 07:51:00 -0700 | [diff] [blame] | 470 | for (int i = 0; i < FLAGS_blacklist.count() - 3; i += 4) { |
mtklein | a2ef642 | 2015-01-15 13:44:22 -0800 | [diff] [blame] | 471 | if (match(FLAGS_blacklist[i+0], sink) && |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 472 | match(FLAGS_blacklist[i+1], src) && |
| 473 | match(FLAGS_blacklist[i+2], srcOptions) && |
| 474 | match(FLAGS_blacklist[i+3], name)) { |
| 475 | return SkStringPrintf("%s %s %s %s", |
| 476 | FLAGS_blacklist[i+0], FLAGS_blacklist[i+1], |
| 477 | FLAGS_blacklist[i+2], FLAGS_blacklist[i+3]); |
mtklein | a2ef642 | 2015-01-15 13:44:22 -0800 | [diff] [blame] | 478 | } |
| 479 | } |
| 480 | return ""; |
| 481 | } |
| 482 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 483 | // The finest-grained unit of work we can run: draw a single Src into a single Sink, |
| 484 | // report any errors, and perhaps write out the output: a .png of the bitmap, or a raw stream. |
| 485 | struct Task { |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 486 | Task(const TaggedSrc& src, const TaggedSink& sink) : src(src), sink(sink) {} |
| 487 | const TaggedSrc& src; |
| 488 | const TaggedSink& sink; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 489 | |
| 490 | static void Run(Task* task) { |
mtklein | a2ef642 | 2015-01-15 13:44:22 -0800 | [diff] [blame] | 491 | SkString name = task->src->name(); |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 492 | |
| 493 | // We'll skip drawing this Src/Sink pair if: |
| 494 | // - the Src vetoes the Sink; |
| 495 | // - this Src / Sink combination is on the blacklist; |
| 496 | // - it's a dry run. |
mtklein | 99cab4e | 2015-07-31 06:43:04 -0700 | [diff] [blame^] | 497 | SkString note(task->src->veto(task->sink->flags()) ? " (veto)" : ""); |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 498 | SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag, |
| 499 | task->src.options, name.c_str()); |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame] | 500 | if (!whyBlacklisted.isEmpty()) { |
| 501 | note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); |
| 502 | } |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 503 | |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 504 | SkString log; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 505 | WallTimer timer; |
| 506 | timer.start(); |
mtklein | e0effd6 | 2015-07-29 06:37:28 -0700 | [diff] [blame] | 507 | if (!FLAGS_dryRun && note.isEmpty()) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 508 | SkBitmap bitmap; |
| 509 | SkDynamicMemoryWStream stream; |
bsalomon | 821e10e | 2015-06-04 14:15:33 -0700 | [diff] [blame] | 510 | if (FLAGS_pre_log) { |
| 511 | SkDebugf("\nRunning %s->%s", name.c_str(), task->sink.tag); |
| 512 | } |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 513 | start(task->sink.tag, task->src.tag, task->src.options, name.c_str()); |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 514 | Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 515 | if (!err.isEmpty()) { |
mtklein | 4089ef7 | 2015-03-05 08:40:28 -0800 | [diff] [blame] | 516 | timer.end(); |
| 517 | if (err.isFatal()) { |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 518 | fail(SkStringPrintf("%s %s %s %s: %s", |
mtklein | 4089ef7 | 2015-03-05 08:40:28 -0800 | [diff] [blame] | 519 | task->sink.tag, |
| 520 | task->src.tag, |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 521 | task->src.options, |
mtklein | 4089ef7 | 2015-03-05 08:40:28 -0800 | [diff] [blame] | 522 | name.c_str(), |
| 523 | err.c_str())); |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame] | 524 | } else { |
| 525 | note.appendf(" (skipped: %s)", err.c_str()); |
mtklein | 4089ef7 | 2015-03-05 08:40:28 -0800 | [diff] [blame] | 526 | } |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 527 | done(timer.fWall, task->sink.tag, task->src.tag, task->src.options, |
| 528 | name, note, log); |
mtklein | 4089ef7 | 2015-03-05 08:40:28 -0800 | [diff] [blame] | 529 | return; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 530 | } |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 531 | SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); |
| 532 | |
| 533 | SkString md5; |
| 534 | if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { |
| 535 | SkMD5 hash; |
| 536 | if (data->getLength()) { |
| 537 | hash.writeStream(data, data->getLength()); |
| 538 | data->rewind(); |
| 539 | } else { |
mtklein | 3840846 | 2015-07-08 07:25:27 -0700 | [diff] [blame] | 540 | // If we're BGRA (Linux, Windows), swizzle over to RGBA (Mac, Android). |
| 541 | // This helps eliminate multiple 0-pixel-diff hashes on gold.skia.org. |
| 542 | // (Android's general slow speed breaks the tie arbitrarily in RGBA's favor.) |
| 543 | // We might consider promoting 565 to RGBA too. |
| 544 | if (bitmap.colorType() == kBGRA_8888_SkColorType) { |
| 545 | SkBitmap swizzle; |
| 546 | SkAssertResult(bitmap.copyTo(&swizzle, kRGBA_8888_SkColorType)); |
| 547 | hash.write(swizzle.getPixels(), swizzle.getSize()); |
| 548 | } else { |
| 549 | hash.write(bitmap.getPixels(), bitmap.getSize()); |
| 550 | } |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 551 | } |
| 552 | SkMD5::Digest digest; |
| 553 | hash.finish(digest); |
| 554 | for (int i = 0; i < 16; i++) { |
| 555 | md5.appendf("%02x", digest.data[i]); |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | if (!FLAGS_readPath.isEmpty() && |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 560 | !gGold.contains(Gold(task->sink.tag, task->src.tag, |
| 561 | task->src.options, name, md5))) { |
| 562 | fail(SkStringPrintf("%s not found for %s %s %s %s in %s", |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 563 | md5.c_str(), |
| 564 | task->sink.tag, |
| 565 | task->src.tag, |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 566 | task->src.options, |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 567 | name.c_str(), |
| 568 | FLAGS_readPath[0])); |
| 569 | } |
| 570 | |
mtklein | b0531a7 | 2015-04-07 13:38:48 -0700 | [diff] [blame] | 571 | if (!FLAGS_writePath.isEmpty()) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 572 | const char* ext = task->sink->fileExtension(); |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 573 | if (data->getLength()) { |
| 574 | WriteToDisk(*task, md5, ext, data, data->getLength(), NULL); |
halcanary | 022afb8 | 2015-01-30 11:00:12 -0800 | [diff] [blame] | 575 | SkASSERT(bitmap.drawsNothing()); |
| 576 | } else if (!bitmap.drawsNothing()) { |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 577 | WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 578 | } |
| 579 | } |
| 580 | } |
| 581 | timer.end(); |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 582 | done(timer.fWall, task->sink.tag, task->src.tag, task->src.options, name, note, log); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | static void WriteToDisk(const Task& task, |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 586 | SkString md5, |
| 587 | const char* ext, |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 588 | SkStream* data, size_t len, |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 589 | const SkBitmap* bitmap) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 590 | JsonWriter::BitmapResult result; |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 591 | result.name = task.src->name(); |
| 592 | result.config = task.sink.tag; |
| 593 | result.sourceType = task.src.tag; |
| 594 | result.sourceOptions = task.src.options; |
| 595 | result.ext = ext; |
| 596 | result.md5 = md5; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 597 | JsonWriter::AddBitmapResult(result); |
| 598 | |
mtklein | b0531a7 | 2015-04-07 13:38:48 -0700 | [diff] [blame] | 599 | // If an MD5 is uninteresting, we want it noted in the JSON file, |
| 600 | // but don't want to dump it out as a .png (or whatever ext is). |
| 601 | if (gUninterestingHashes.contains(md5)) { |
| 602 | return; |
| 603 | } |
| 604 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 605 | const char* dir = FLAGS_writePath[0]; |
| 606 | if (0 == strcmp(dir, "@")) { // Needed for iOS. |
| 607 | dir = FLAGS_resourcePath[0]; |
| 608 | } |
| 609 | sk_mkdir(dir); |
| 610 | |
| 611 | SkString path; |
| 612 | if (FLAGS_nameByHash) { |
| 613 | path = SkOSPath::Join(dir, result.md5.c_str()); |
| 614 | path.append("."); |
| 615 | path.append(ext); |
| 616 | if (sk_exists(path.c_str())) { |
| 617 | return; // Content-addressed. If it exists already, we're done. |
| 618 | } |
| 619 | } else { |
| 620 | path = SkOSPath::Join(dir, task.sink.tag); |
| 621 | sk_mkdir(path.c_str()); |
| 622 | path = SkOSPath::Join(path.c_str(), task.src.tag); |
| 623 | sk_mkdir(path.c_str()); |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 624 | if (strcmp(task.src.options, "") != 0) { |
| 625 | path = SkOSPath::Join(path.c_str(), task.src.options); |
| 626 | sk_mkdir(path.c_str()); |
| 627 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 628 | path = SkOSPath::Join(path.c_str(), task.src->name().c_str()); |
| 629 | path.append("."); |
| 630 | path.append(ext); |
| 631 | } |
| 632 | |
| 633 | SkFILEWStream file(path.c_str()); |
| 634 | if (!file.isValid()) { |
| 635 | fail(SkStringPrintf("Can't open %s for writing.\n", path.c_str())); |
| 636 | return; |
| 637 | } |
| 638 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 639 | if (bitmap) { |
| 640 | // We can't encode A8 bitmaps as PNGs. Convert them to 8888 first. |
| 641 | SkBitmap converted; |
| 642 | if (bitmap->info().colorType() == kAlpha_8_SkColorType) { |
| 643 | if (!bitmap->copyTo(&converted, kN32_SkColorType)) { |
| 644 | fail("Can't convert A8 to 8888.\n"); |
| 645 | return; |
| 646 | } |
| 647 | bitmap = &converted; |
| 648 | } |
| 649 | if (!SkImageEncoder::EncodeStream(&file, *bitmap, SkImageEncoder::kPNG_Type, 100)) { |
| 650 | fail(SkStringPrintf("Can't encode PNG to %s.\n", path.c_str())); |
| 651 | return; |
| 652 | } |
| 653 | } else { |
| 654 | if (!file.writeStream(data, len)) { |
| 655 | fail(SkStringPrintf("Can't write to %s.\n", path.c_str())); |
| 656 | return; |
| 657 | } |
| 658 | } |
| 659 | } |
| 660 | }; |
| 661 | |
| 662 | // Run all tasks in the same enclave serially on the same thread. |
| 663 | // They can't possibly run concurrently with each other. |
| 664 | static void run_enclave(SkTArray<Task>* tasks) { |
| 665 | for (int i = 0; i < tasks->count(); i++) { |
| 666 | Task::Run(tasks->begin() + i); |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 671 | |
| 672 | // Unit tests don't fit so well into the Src/Sink model, so we give them special treatment. |
| 673 | |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 674 | static SkTDArray<skiatest::Test> gThreadedTests, gGPUTests; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 675 | |
| 676 | static void gather_tests() { |
mtklein | 6c5fed2 | 2015-01-20 13:47:23 -0800 | [diff] [blame] | 677 | if (!FLAGS_src.contains("tests")) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 678 | return; |
| 679 | } |
mtklein | 6393c06 | 2015-04-27 08:45:01 -0700 | [diff] [blame] | 680 | for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; r = r->next()) { |
| 681 | if (!in_shard()) { |
| 682 | continue; |
| 683 | } |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 684 | // Despite its name, factory() is returning a reference to |
| 685 | // link-time static const POD data. |
| 686 | const skiatest::Test& test = r->factory(); |
| 687 | if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test.name)) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 688 | continue; |
| 689 | } |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 690 | if (test.needsGpu && gpu_supported()) { |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 691 | (FLAGS_gpu_threading ? gThreadedTests : gGPUTests).push(test); |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 692 | } else if (!test.needsGpu && FLAGS_cpu) { |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 693 | gThreadedTests.push(test); |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 694 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 695 | } |
| 696 | } |
| 697 | |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 698 | static void run_test(skiatest::Test* test) { |
| 699 | struct : public skiatest::Reporter { |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 700 | void reportFailed(const skiatest::Failure& failure) override { |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 701 | fail(failure.toString()); |
| 702 | JsonWriter::AddTestFailure(failure); |
| 703 | } |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 704 | bool allowExtendedTest() const override { |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 705 | return FLAGS_pathOpsExtended; |
| 706 | } |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 707 | bool verbose() const override { return FLAGS_veryVerbose; } |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 708 | } reporter; |
djsollen | 824996a | 2015-06-12 12:06:22 -0700 | [diff] [blame] | 709 | |
| 710 | SkString note; |
| 711 | SkString whyBlacklisted = is_blacklisted("_", "tests", "_", test->name); |
| 712 | if (!whyBlacklisted.isEmpty()) { |
| 713 | note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); |
| 714 | } |
| 715 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 716 | WallTimer timer; |
| 717 | timer.start(); |
djsollen | 824996a | 2015-06-12 12:06:22 -0700 | [diff] [blame] | 718 | if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) { |
djsollen | 54416de | 2015-04-03 07:24:48 -0700 | [diff] [blame] | 719 | start("unit", "test", "", test->name); |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 720 | GrContextFactory factory; |
bsalomon | 821e10e | 2015-06-04 14:15:33 -0700 | [diff] [blame] | 721 | if (FLAGS_pre_log) { |
| 722 | SkDebugf("\nRunning test %s", test->name); |
| 723 | } |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 724 | test->proc(&reporter, &factory); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 725 | } |
| 726 | timer.end(); |
djsollen | 824996a | 2015-06-12 12:06:22 -0700 | [diff] [blame] | 727 | done(timer.fWall, "unit", "test", "", test->name, note, ""); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 731 | |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 732 | // If we're isolating all GPU-bound work to one thread (the default), this function runs all that. |
| 733 | static void run_enclave_and_gpu_tests(SkTArray<Task>* tasks) { |
| 734 | run_enclave(tasks); |
| 735 | for (int i = 0; i < gGPUTests.count(); i++) { |
| 736 | run_test(&gGPUTests[i]); |
| 737 | } |
| 738 | } |
| 739 | |
mtklein | de6fc2b | 2015-03-12 06:28:54 -0700 | [diff] [blame] | 740 | // Some runs (mostly, Valgrind) are so slow that the bot framework thinks we've hung. |
| 741 | // This prints something every once in a while so that it knows we're still working. |
mtklein | 2e1c47e | 2015-03-12 07:16:56 -0700 | [diff] [blame] | 742 | static void start_keepalive() { |
| 743 | struct Loop { |
| 744 | static void forever(void*) { |
| 745 | for (;;) { |
| 746 | static const int kSec = 300; |
| 747 | #if defined(SK_BUILD_FOR_WIN) |
| 748 | Sleep(kSec * 1000); |
| 749 | #else |
| 750 | sleep(kSec); |
| 751 | #endif |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame] | 752 | SkString running; |
| 753 | { |
| 754 | SkAutoMutexAcquire lock(gRunningMutex); |
| 755 | for (int i = 0; i < gRunning.count(); i++) { |
| 756 | running.appendf("\n\t%s", gRunning[i].c_str()); |
| 757 | } |
| 758 | } |
| 759 | SkDebugf("\nCurrently running:%s\n", running.c_str()); |
mtklein | 2e1c47e | 2015-03-12 07:16:56 -0700 | [diff] [blame] | 760 | } |
| 761 | } |
| 762 | }; |
| 763 | static SkThread* intentionallyLeaked = new SkThread(Loop::forever); |
| 764 | intentionallyLeaked->start(); |
mtklein | de6fc2b | 2015-03-12 06:28:54 -0700 | [diff] [blame] | 765 | } |
| 766 | |
caryclark | 83ca628 | 2015-06-10 09:31:09 -0700 | [diff] [blame] | 767 | #define PORTABLE_FONT_PREFIX "Toy Liberation " |
| 768 | |
| 769 | static SkTypeface* create_from_name(const char familyName[], SkTypeface::Style style) { |
| 770 | if (familyName && strlen(familyName) > sizeof(PORTABLE_FONT_PREFIX) |
| 771 | && !strncmp(familyName, PORTABLE_FONT_PREFIX, sizeof(PORTABLE_FONT_PREFIX) - 1)) { |
caryclark | 1818acb | 2015-07-24 12:09:25 -0700 | [diff] [blame] | 772 | return sk_tool_utils::create_portable_typeface(familyName, style); |
caryclark | 83ca628 | 2015-06-10 09:31:09 -0700 | [diff] [blame] | 773 | } |
| 774 | return NULL; |
| 775 | } |
| 776 | |
| 777 | #undef PORTABLE_FONT_PREFIX |
| 778 | |
| 779 | extern SkTypeface* (*gCreateTypefaceDelegate)(const char [], SkTypeface::Style ); |
| 780 | |
jcgregorio | 3b27ade | 2014-11-13 08:06:40 -0800 | [diff] [blame] | 781 | int dm_main(); |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 782 | int dm_main() { |
jcgregorio | 3b27ade | 2014-11-13 08:06:40 -0800 | [diff] [blame] | 783 | SetupCrashHandler(); |
commit-bot@chromium.org | 39e8d93 | 2014-05-29 20:14:48 +0000 | [diff] [blame] | 784 | SkAutoGraphics ag; |
mtklein | 406654b | 2014-09-03 15:34:37 -0700 | [diff] [blame] | 785 | SkTaskGroup::Enabler enabled(FLAGS_threads); |
caryclark | 83ca628 | 2015-06-10 09:31:09 -0700 | [diff] [blame] | 786 | gCreateTypefaceDelegate = &create_from_name; |
commit-bot@chromium.org | a65e2fd | 2014-05-30 17:23:31 +0000 | [diff] [blame] | 787 | |
mtklein | 2e1c47e | 2015-03-12 07:16:56 -0700 | [diff] [blame] | 788 | start_keepalive(); |
mtklein | de6fc2b | 2015-03-12 06:28:54 -0700 | [diff] [blame] | 789 | |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 790 | gather_gold(); |
borenet | 09ed480 | 2015-04-03 14:15:33 -0700 | [diff] [blame] | 791 | gather_uninteresting_hashes(); |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 792 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 793 | gather_srcs(); |
| 794 | gather_sinks(); |
| 795 | gather_tests(); |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 796 | |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 797 | gPending = gSrcs.count() * gSinks.count() + gThreadedTests.count() + gGPUTests.count(); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 798 | SkDebugf("%d srcs * %d sinks + %d tests == %d tasks\n", |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 799 | gSrcs.count(), gSinks.count(), gThreadedTests.count() + gGPUTests.count(), gPending); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 800 | |
| 801 | // We try to exploit as much parallelism as is safe. Most Src/Sink pairs run on any thread, |
| 802 | // but Sinks that identify as part of a particular enclave run serially on a single thread. |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 803 | // CPU tests run on any thread. GPU tests depend on --gpu_threading. |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 804 | SkTArray<Task> enclaves[kNumEnclaves]; |
| 805 | for (int j = 0; j < gSinks.count(); j++) { |
| 806 | SkTArray<Task>& tasks = enclaves[gSinks[j]->enclave()]; |
| 807 | for (int i = 0; i < gSrcs.count(); i++) { |
| 808 | tasks.push_back(Task(gSrcs[i], gSinks[j])); |
| 809 | } |
commit-bot@chromium.org | 38aeb0f | 2014-02-26 23:01:57 +0000 | [diff] [blame] | 810 | } |
| 811 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 812 | SkTaskGroup tg; |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 813 | tg.batch(run_test, gThreadedTests.begin(), gThreadedTests.count()); |
| 814 | for (int i = 0; i < kNumEnclaves; i++) { |
| 815 | switch(i) { |
| 816 | case kAnyThread_Enclave: |
| 817 | tg.batch(Task::Run, enclaves[i].begin(), enclaves[i].count()); |
| 818 | break; |
| 819 | case kGPU_Enclave: |
| 820 | tg.add(run_enclave_and_gpu_tests, &enclaves[i]); |
| 821 | break; |
| 822 | default: |
| 823 | tg.add(run_enclave, &enclaves[i]); |
| 824 | break; |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 825 | } |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 826 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 827 | tg.wait(); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 828 | // At this point we're back in single-threaded land. |
caryclark | f53ce80 | 2015-06-15 06:48:30 -0700 | [diff] [blame] | 829 | sk_tool_utils::release_portable_typefaces(); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 830 | |
mtklein | 2f64eec | 2015-01-15 14:20:41 -0800 | [diff] [blame] | 831 | SkDebugf("\n"); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 832 | if (gFailures.count() > 0) { |
| 833 | SkDebugf("Failures:\n"); |
| 834 | for (int i = 0; i < gFailures.count(); i++) { |
mtklein | 9dc0910 | 2015-01-15 15:47:33 -0800 | [diff] [blame] | 835 | SkDebugf("\t%s\n", gFailures[i].c_str()); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 836 | } |
| 837 | SkDebugf("%d failures\n", gFailures.count()); |
| 838 | return 1; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 839 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 840 | if (gPending > 0) { |
| 841 | SkDebugf("Hrm, we didn't seem to run everything we intended to! Please file a bug.\n"); |
| 842 | return 1; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 843 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 844 | return 0; |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 845 | } |
jcgregorio | 3b27ade | 2014-11-13 08:06:40 -0800 | [diff] [blame] | 846 | |
borenet | 4808757 | 2015-04-02 12:16:36 -0700 | [diff] [blame] | 847 | #if !defined(SK_BUILD_FOR_IOS) |
jcgregorio | 3b27ade | 2014-11-13 08:06:40 -0800 | [diff] [blame] | 848 | int main(int argc, char** argv) { |
| 849 | SkCommandLineFlags::Parse(argc, argv); |
| 850 | return dm_main(); |
| 851 | } |
| 852 | #endif |