jcgregorio | 3b27ade | 2014-11-13 08:06:40 -0800 | [diff] [blame] | 1 | #include "CrashHandler.h" |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 2 | #include "DMJsonWriter.h" |
| 3 | #include "DMSrcSink.h" |
tomhudson | eebc39a | 2015-02-23 12:18:05 -0800 | [diff] [blame] | 4 | #include "DMSrcSinkAndroid.h" |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 5 | #include "OverwriteLine.h" |
| 6 | #include "ProcStats.h" |
| 7 | #include "SkBBHFactory.h" |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 8 | #include "SkChecksum.h" |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 9 | #include "SkCommonFlags.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 10 | #include "SkForceLinking.h" |
| 11 | #include "SkGraphics.h" |
mtklein | e67164d | 2015-02-02 13:24:37 -0800 | [diff] [blame] | 12 | #include "SkInstCnt.h" |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 13 | #include "SkMD5.h" |
mtklein | 1d0f164 | 2014-09-08 08:05:18 -0700 | [diff] [blame] | 14 | #include "SkOSFile.h" |
mtklein | a82f562 | 2015-02-20 12:30:19 -0800 | [diff] [blame] | 15 | #include "SkTHash.h" |
mtklein | 406654b | 2014-09-03 15:34:37 -0700 | [diff] [blame] | 16 | #include "SkTaskGroup.h" |
mtklein | de6fc2b | 2015-03-12 06:28:54 -0700 | [diff] [blame] | 17 | #include "SkThreadUtils.h" |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 18 | #include "Test.h" |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 19 | #include "Timer.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 20 | |
mtklein | edc93bc | 2015-01-30 13:22:23 -0800 | [diff] [blame] | 21 | DEFINE_string(src, "tests gm skp image subset", "Source types to test."); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 22 | DEFINE_bool(nameByHash, false, |
| 23 | "If true, write to FLAGS_writePath[0]/<hash>.png instead of " |
| 24 | "to FLAGS_writePath[0]/<config>/<sourceType>/<name>.png"); |
| 25 | DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); |
mtklein | d603b22 | 2015-02-17 11:13:33 -0800 | [diff] [blame] | 26 | DEFINE_string(matrix, "1 0 0 1", |
| 27 | "2x2 scale+skew matrix to apply or upright when using " |
| 28 | "'matrix' or 'upright' in config."); |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 29 | 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] | 30 | |
mtklein | a2ef642 | 2015-01-15 13:44:22 -0800 | [diff] [blame] | 31 | DEFINE_string(blacklist, "", |
| 32 | "Space-separated config/src/name triples to blacklist. '_' matches anything. E.g. \n" |
| 33 | "'--blacklist gpu skp _' will blacklist all SKPs drawn into the gpu config.\n" |
| 34 | "'--blacklist gpu skp _ 8888 gm aarects' will also blacklist the aarects GM on 8888."); |
| 35 | |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 36 | DEFINE_string2(readPath, r, "", "If set check for equality with golden results in this directory."); |
| 37 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 38 | __SK_FORCE_IMAGE_DECODER_LINKING; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 39 | using namespace DM; |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 40 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 41 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 42 | |
| 43 | SK_DECLARE_STATIC_MUTEX(gFailuresMutex); |
| 44 | static SkTArray<SkString> gFailures; |
| 45 | |
| 46 | static void fail(ImplicitString err) { |
| 47 | SkAutoMutexAcquire lock(gFailuresMutex); |
| 48 | SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); |
| 49 | gFailures.push_back(err); |
halcanary | 9e398f7 | 2015-01-10 11:18:04 -0800 | [diff] [blame] | 50 | } |
| 51 | |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 52 | static int32_t gPending = 0; // Atomic. Total number of running and queued tasks. |
| 53 | |
| 54 | SK_DECLARE_STATIC_MUTEX(gRunningMutex); |
| 55 | static SkTArray<SkString> gRunning; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 56 | |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 57 | static void done(double ms, |
| 58 | ImplicitString config, ImplicitString src, ImplicitString name, |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 59 | ImplicitString note, ImplicitString log) { |
| 60 | SkString id = SkStringPrintf("%s %s %s", config.c_str(), src.c_str(), name.c_str()); |
| 61 | { |
| 62 | SkAutoMutexAcquire lock(gRunningMutex); |
| 63 | for (int i = 0; i < gRunning.count(); i++) { |
| 64 | if (gRunning[i] == id) { |
| 65 | gRunning.removeShuffle(i); |
| 66 | break; |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | if (!FLAGS_verbose) { |
| 71 | note = ""; |
| 72 | } |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 73 | if (!log.isEmpty()) { |
| 74 | log.prepend("\n"); |
| 75 | } |
mtklein | 6dee2ad | 2015-02-05 09:53:44 -0800 | [diff] [blame] | 76 | auto pending = sk_atomic_dec(&gPending)-1; |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 77 | SkDebugf("%s(%4dMB %5d) %s\t%s%s%s", FLAGS_verbose ? "\n" : kSkOverwriteLine |
| 78 | , sk_tools::getBestResidentSetSizeMB() |
| 79 | , pending |
| 80 | , HumanizeMs(ms).c_str() |
| 81 | , id.c_str() |
| 82 | , note.c_str() |
| 83 | , log.c_str()); |
mtklein | a17241b | 2015-01-23 05:48:00 -0800 | [diff] [blame] | 84 | // We write our dm.json file every once in a while in case we crash. |
| 85 | // Notice this also handles the final dm.json when pending == 0. |
| 86 | if (pending % 500 == 0) { |
| 87 | JsonWriter::DumpJson(); |
| 88 | } |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 89 | } |
| 90 | |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 91 | static void start(ImplicitString config, ImplicitString src, ImplicitString name) { |
| 92 | SkString id = SkStringPrintf("%s %s %s", config.c_str(), src.c_str(), name.c_str()); |
| 93 | SkAutoMutexAcquire lock(gRunningMutex); |
| 94 | gRunning.push_back(id); |
| 95 | } |
| 96 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 97 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 98 | |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 99 | struct Gold : public SkString { |
mtklein | a82f562 | 2015-02-20 12:30:19 -0800 | [diff] [blame] | 100 | Gold() : SkString("") {} |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 101 | Gold(ImplicitString sink, ImplicitString src, ImplicitString name, ImplicitString md5) |
| 102 | : SkString("") { |
| 103 | this->append(sink); |
| 104 | this->append(src); |
| 105 | this->append(name); |
| 106 | this->append(md5); |
| 107 | while (this->size() % 4) { |
| 108 | this->append("!"); // Pad out if needed so we can pass this to Murmur3. |
| 109 | } |
| 110 | } |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 111 | static uint32_t Hash(const Gold& g) { |
| 112 | return SkChecksum::Murmur3((const uint32_t*)g.c_str(), g.size()); |
| 113 | } |
| 114 | }; |
mtklein | a82f562 | 2015-02-20 12:30:19 -0800 | [diff] [blame] | 115 | static SkTHashSet<Gold, Gold::Hash> gGold; |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 116 | |
| 117 | static void add_gold(JsonWriter::BitmapResult r) { |
mtklein | a82f562 | 2015-02-20 12:30:19 -0800 | [diff] [blame] | 118 | gGold.add(Gold(r.config, r.sourceType, r.name, r.md5)); |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | static void gather_gold() { |
| 122 | if (!FLAGS_readPath.isEmpty()) { |
| 123 | SkString path(FLAGS_readPath[0]); |
| 124 | path.append("/dm.json"); |
| 125 | if (!JsonWriter::ReadJson(path.c_str(), add_gold)) { |
| 126 | fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_str())); |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 132 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 133 | template <typename T> |
| 134 | struct Tagged : public SkAutoTDelete<T> { const char* tag; }; |
| 135 | |
| 136 | static const bool kMemcpyOK = true; |
| 137 | |
| 138 | static SkTArray<Tagged<Src>, kMemcpyOK> gSrcs; |
| 139 | static SkTArray<Tagged<Sink>, kMemcpyOK> gSinks; |
| 140 | |
| 141 | static void push_src(const char* tag, Src* s) { |
| 142 | SkAutoTDelete<Src> src(s); |
| 143 | if (FLAGS_src.contains(tag) && |
| 144 | !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { |
| 145 | Tagged<Src>& s = gSrcs.push_back(); |
| 146 | s.reset(src.detach()); |
| 147 | s.tag = tag; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 148 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 149 | } |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 150 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 151 | static void gather_srcs() { |
| 152 | for (const skiagm::GMRegistry* r = skiagm::GMRegistry::Head(); r; r = r->next()) { |
| 153 | push_src("gm", new GMSrc(r->factory())); |
| 154 | } |
halcanary | fc37ad1 | 2015-01-30 07:31:19 -0800 | [diff] [blame] | 155 | for (int i = 0; i < FLAGS_skps.count(); i++) { |
| 156 | const char* path = FLAGS_skps[i]; |
| 157 | if (sk_isdir(path)) { |
| 158 | SkOSFile::Iter it(path, "skp"); |
| 159 | for (SkString file; it.next(&file); ) { |
| 160 | push_src("skp", new SKPSrc(SkOSPath::Join(path, file.c_str()))); |
| 161 | } |
| 162 | } else { |
mtklein | 8d17a13 | 2015-01-30 11:42:31 -0800 | [diff] [blame] | 163 | push_src("skp", new SKPSrc(path)); |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 164 | } |
| 165 | } |
halcanary | 23b03c3 | 2015-01-30 09:58:58 -0800 | [diff] [blame] | 166 | static const char* const exts[] = { |
| 167 | "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico", |
| 168 | "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO", |
| 169 | }; |
| 170 | for (int i = 0; i < FLAGS_images.count(); i++) { |
| 171 | const char* flag = FLAGS_images[i]; |
| 172 | if (sk_isdir(flag)) { |
| 173 | for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |
| 174 | SkOSFile::Iter it(flag, exts[j]); |
| 175 | for (SkString file; it.next(&file); ) { |
| 176 | SkString path = SkOSPath::Join(flag, file.c_str()); |
| 177 | push_src("image", new ImageSrc(path)); // Decode entire image. |
mtklein | edc93bc | 2015-01-30 13:22:23 -0800 | [diff] [blame] | 178 | push_src("subset", new ImageSrc(path, 2)); // Decode into 2 x 2 subsets |
halcanary | 23b03c3 | 2015-01-30 09:58:58 -0800 | [diff] [blame] | 179 | } |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 180 | } |
halcanary | 23b03c3 | 2015-01-30 09:58:58 -0800 | [diff] [blame] | 181 | } else if (sk_exists(flag)) { |
| 182 | // assume that FLAGS_images[i] is a valid image if it is a file. |
mtklein | 8d17a13 | 2015-01-30 11:42:31 -0800 | [diff] [blame] | 183 | push_src("image", new ImageSrc(flag)); // Decode entire image. |
mtklein | edc93bc | 2015-01-30 13:22:23 -0800 | [diff] [blame] | 184 | push_src("subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets |
mtklein | 709d2c3 | 2015-01-15 08:30:25 -0800 | [diff] [blame] | 185 | } |
mtklein | 709d2c3 | 2015-01-15 08:30:25 -0800 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 189 | static GrGLStandard get_gpu_api() { |
| 190 | if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
| 191 | if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
| 192 | return kNone_GrGLStandard; |
mtklein | 709d2c3 | 2015-01-15 08:30:25 -0800 | [diff] [blame] | 193 | } |
| 194 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 195 | static void push_sink(const char* tag, Sink* s) { |
| 196 | SkAutoTDelete<Sink> sink(s); |
| 197 | if (!FLAGS_config.contains(tag)) { |
| 198 | return; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 199 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 200 | // Try a noop Src as a canary. If it fails, skip this sink. |
| 201 | struct : public Src { |
| 202 | Error draw(SkCanvas*) const SK_OVERRIDE { return ""; } |
| 203 | SkISize size() const SK_OVERRIDE { return SkISize::Make(16, 16); } |
| 204 | Name name() const SK_OVERRIDE { return "noop"; } |
| 205 | } noop; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 206 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 207 | SkBitmap bitmap; |
| 208 | SkDynamicMemoryWStream stream; |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 209 | SkString log; |
| 210 | Error err = sink->draw(noop, &bitmap, &stream, &log); |
mtklein | 4089ef7 | 2015-03-05 08:40:28 -0800 | [diff] [blame] | 211 | if (err.isFatal()) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 212 | SkDebugf("Skipping %s: %s\n", tag, err.c_str()); |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 213 | return; |
| 214 | } |
| 215 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 216 | Tagged<Sink>& ts = gSinks.push_back(); |
| 217 | ts.reset(sink.detach()); |
| 218 | ts.tag = tag; |
| 219 | } |
| 220 | |
| 221 | static bool gpu_supported() { |
| 222 | #if SK_SUPPORT_GPU |
| 223 | return FLAGS_gpu; |
| 224 | #else |
| 225 | return false; |
| 226 | #endif |
| 227 | } |
| 228 | |
| 229 | static Sink* create_sink(const char* tag) { |
| 230 | #define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS__); } |
| 231 | if (gpu_supported()) { |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 232 | typedef GrContextFactory Gr; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 233 | const GrGLStandard api = get_gpu_api(); |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 234 | SINK("gpunull", GPUSink, Gr::kNull_GLContextType, api, 0, false, FLAGS_gpu_threading); |
| 235 | SINK("gpudebug", GPUSink, Gr::kDebug_GLContextType, api, 0, false, FLAGS_gpu_threading); |
| 236 | SINK("gpu", GPUSink, Gr::kNative_GLContextType, api, 0, false, FLAGS_gpu_threading); |
| 237 | SINK("gpudft", GPUSink, Gr::kNative_GLContextType, api, 0, true, FLAGS_gpu_threading); |
| 238 | SINK("msaa4", GPUSink, Gr::kNative_GLContextType, api, 4, false, FLAGS_gpu_threading); |
| 239 | SINK("msaa16", GPUSink, Gr::kNative_GLContextType, api, 16, false, FLAGS_gpu_threading); |
| 240 | SINK("nvprmsaa4", GPUSink, Gr::kNVPR_GLContextType, api, 4, false, FLAGS_gpu_threading); |
| 241 | SINK("nvprmsaa16", GPUSink, Gr::kNVPR_GLContextType, api, 16, false, FLAGS_gpu_threading); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 242 | #if SK_ANGLE |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 243 | SINK("angle", GPUSink, Gr::kANGLE_GLContextType, api, 0, false, FLAGS_gpu_threading); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 244 | #endif |
| 245 | #if SK_MESA |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 246 | SINK("mesa", GPUSink, Gr::kMESA_GLContextType, api, 0, false, FLAGS_gpu_threading); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 247 | #endif |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 248 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 249 | |
tomhudson | eebc39a | 2015-02-23 12:18:05 -0800 | [diff] [blame] | 250 | #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 251 | SINK("hwui", HWUISink); |
| 252 | #endif |
| 253 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 254 | if (FLAGS_cpu) { |
| 255 | SINK("565", RasterSink, kRGB_565_SkColorType); |
| 256 | SINK("8888", RasterSink, kN32_SkColorType); |
mtklein | 19f3060 | 2015-01-20 13:34:39 -0800 | [diff] [blame] | 257 | SINK("pdf", PDFSink); |
mtklein | 9c3f17d | 2015-01-28 11:35:18 -0800 | [diff] [blame] | 258 | SINK("skp", SKPSink); |
mtklein | 8a4527e | 2015-01-31 20:00:58 -0800 | [diff] [blame] | 259 | SINK("svg", SVGSink); |
| 260 | SINK("null", NullSink); |
halcanary | 47ef4d5 | 2015-03-03 09:13:09 -0800 | [diff] [blame] | 261 | SINK("xps", XPSSink); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 262 | } |
| 263 | #undef SINK |
| 264 | return NULL; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 265 | } |
| 266 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 267 | static Sink* create_via(const char* tag, Sink* wrapped) { |
| 268 | #define VIA(t, via, ...) if (0 == strcmp(t, tag)) { return new via(__VA_ARGS__); } |
mtklein | 7edca21 | 2015-01-21 13:18:51 -0800 | [diff] [blame] | 269 | VIA("pipe", ViaPipe, wrapped); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 270 | VIA("serialize", ViaSerialization, wrapped); |
mtklein | 7edca21 | 2015-01-21 13:18:51 -0800 | [diff] [blame] | 271 | VIA("tiles", ViaTiles, 256, 256, NULL, wrapped); |
| 272 | VIA("tiles_rt", ViaTiles, 256, 256, new SkRTreeFactory, wrapped); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 273 | |
mtklein | d603b22 | 2015-02-17 11:13:33 -0800 | [diff] [blame] | 274 | if (FLAGS_matrix.count() == 4) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 275 | SkMatrix m; |
mtklein | d603b22 | 2015-02-17 11:13:33 -0800 | [diff] [blame] | 276 | m.reset(); |
| 277 | m.setScaleX((SkScalar)atof(FLAGS_matrix[0])); |
| 278 | m.setSkewX ((SkScalar)atof(FLAGS_matrix[1])); |
| 279 | m.setSkewY ((SkScalar)atof(FLAGS_matrix[2])); |
| 280 | m.setScaleY((SkScalar)atof(FLAGS_matrix[3])); |
| 281 | VIA("matrix", ViaMatrix, m, wrapped); |
| 282 | VIA("upright", ViaUpright, m, wrapped); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 283 | } |
tomhudson | 64de1e1 | 2015-03-05 08:01:07 -0800 | [diff] [blame] | 284 | |
| 285 | #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 286 | VIA("androidsdk", ViaAndroidSDK, wrapped); |
| 287 | #endif |
| 288 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 289 | #undef VIA |
| 290 | return NULL; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 291 | } |
| 292 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 293 | static void gather_sinks() { |
| 294 | for (int i = 0; i < FLAGS_config.count(); i++) { |
| 295 | const char* config = FLAGS_config[i]; |
| 296 | SkTArray<SkString> parts; |
| 297 | SkStrSplit(config, "-", &parts); |
| 298 | |
| 299 | Sink* sink = NULL; |
| 300 | for (int i = parts.count(); i-- > 0;) { |
| 301 | const char* part = parts[i].c_str(); |
| 302 | Sink* next = (sink == NULL) ? create_sink(part) : create_via(part, sink); |
| 303 | if (next == NULL) { |
| 304 | SkDebugf("Skipping %s: Don't understand '%s'.\n", config, part); |
| 305 | delete sink; |
| 306 | sink = NULL; |
| 307 | break; |
| 308 | } |
| 309 | sink = next; |
| 310 | } |
| 311 | if (sink) { |
| 312 | push_sink(config, sink); |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 313 | } |
| 314 | } |
| 315 | } |
mtklein | 709d2c3 | 2015-01-15 08:30:25 -0800 | [diff] [blame] | 316 | |
mtklein | a2ef642 | 2015-01-15 13:44:22 -0800 | [diff] [blame] | 317 | static bool match(const char* needle, const char* haystack) { |
| 318 | return 0 == strcmp("_", needle) || NULL != strstr(haystack, needle); |
| 319 | } |
| 320 | |
| 321 | static ImplicitString is_blacklisted(const char* sink, const char* src, const char* name) { |
| 322 | for (int i = 0; i < FLAGS_blacklist.count() - 2; i += 3) { |
| 323 | if (match(FLAGS_blacklist[i+0], sink) && |
| 324 | match(FLAGS_blacklist[i+1], src) && |
| 325 | match(FLAGS_blacklist[i+2], name)) { |
| 326 | return SkStringPrintf("%s %s %s", |
| 327 | FLAGS_blacklist[i+0], FLAGS_blacklist[i+1], FLAGS_blacklist[i+2]); |
| 328 | } |
| 329 | } |
| 330 | return ""; |
| 331 | } |
| 332 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 333 | // The finest-grained unit of work we can run: draw a single Src into a single Sink, |
| 334 | // report any errors, and perhaps write out the output: a .png of the bitmap, or a raw stream. |
| 335 | struct Task { |
| 336 | Task(const Tagged<Src>& src, const Tagged<Sink>& sink) : src(src), sink(sink) {} |
| 337 | const Tagged<Src>& src; |
| 338 | const Tagged<Sink>& sink; |
| 339 | |
| 340 | static void Run(Task* task) { |
mtklein | a2ef642 | 2015-01-15 13:44:22 -0800 | [diff] [blame] | 341 | SkString name = task->src->name(); |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 342 | SkString note; |
mtklein | a2ef642 | 2015-01-15 13:44:22 -0800 | [diff] [blame] | 343 | SkString whyBlacklisted = is_blacklisted(task->sink.tag, task->src.tag, name.c_str()); |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 344 | if (!whyBlacklisted.isEmpty()) { |
| 345 | note.appendf(" (--blacklist %s)", whyBlacklisted.c_str()); |
| 346 | } |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 347 | SkString log; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 348 | WallTimer timer; |
| 349 | timer.start(); |
mtklein | a2ef642 | 2015-01-15 13:44:22 -0800 | [diff] [blame] | 350 | if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 351 | SkBitmap bitmap; |
| 352 | SkDynamicMemoryWStream stream; |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 353 | start(task->sink.tag, task->src.tag, name.c_str()); |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 354 | Error err = task->sink->draw(*task->src, &bitmap, &stream, &log); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 355 | if (!err.isEmpty()) { |
mtklein | 4089ef7 | 2015-03-05 08:40:28 -0800 | [diff] [blame] | 356 | timer.end(); |
| 357 | if (err.isFatal()) { |
| 358 | fail(SkStringPrintf("%s %s %s: %s", |
| 359 | task->sink.tag, |
| 360 | task->src.tag, |
| 361 | name.c_str(), |
| 362 | err.c_str())); |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 363 | } else { |
| 364 | note.appendf(" (skipped: %s)", err.c_str()); |
mtklein | 4089ef7 | 2015-03-05 08:40:28 -0800 | [diff] [blame] | 365 | } |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 366 | done(timer.fWall, task->sink.tag, task->src.tag, name, note, log); |
mtklein | 4089ef7 | 2015-03-05 08:40:28 -0800 | [diff] [blame] | 367 | return; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 368 | } |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 369 | SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); |
| 370 | |
| 371 | SkString md5; |
| 372 | if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { |
| 373 | SkMD5 hash; |
| 374 | if (data->getLength()) { |
| 375 | hash.writeStream(data, data->getLength()); |
| 376 | data->rewind(); |
| 377 | } else { |
| 378 | hash.write(bitmap.getPixels(), bitmap.getSize()); |
| 379 | } |
| 380 | SkMD5::Digest digest; |
| 381 | hash.finish(digest); |
| 382 | for (int i = 0; i < 16; i++) { |
| 383 | md5.appendf("%02x", digest.data[i]); |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | if (!FLAGS_readPath.isEmpty() && |
mtklein | a82f562 | 2015-02-20 12:30:19 -0800 | [diff] [blame] | 388 | !gGold.contains(Gold(task->sink.tag, task->src.tag, name, md5))) { |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 389 | fail(SkStringPrintf("%s not found for %s %s %s in %s", |
| 390 | md5.c_str(), |
| 391 | task->sink.tag, |
| 392 | task->src.tag, |
| 393 | name.c_str(), |
| 394 | FLAGS_readPath[0])); |
| 395 | } |
| 396 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 397 | if (!FLAGS_writePath.isEmpty()) { |
| 398 | const char* ext = task->sink->fileExtension(); |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 399 | if (data->getLength()) { |
| 400 | WriteToDisk(*task, md5, ext, data, data->getLength(), NULL); |
halcanary | 022afb8 | 2015-01-30 11:00:12 -0800 | [diff] [blame] | 401 | SkASSERT(bitmap.drawsNothing()); |
| 402 | } else if (!bitmap.drawsNothing()) { |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 403 | WriteToDisk(*task, md5, ext, NULL, 0, &bitmap); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 404 | } |
| 405 | } |
| 406 | } |
| 407 | timer.end(); |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 408 | done(timer.fWall, task->sink.tag, task->src.tag, name, note, log); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | static void WriteToDisk(const Task& task, |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 412 | SkString md5, |
| 413 | const char* ext, |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 414 | SkStream* data, size_t len, |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 415 | const SkBitmap* bitmap) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 416 | JsonWriter::BitmapResult result; |
| 417 | result.name = task.src->name(); |
| 418 | result.config = task.sink.tag; |
| 419 | result.sourceType = task.src.tag; |
| 420 | result.ext = ext; |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 421 | result.md5 = md5; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 422 | JsonWriter::AddBitmapResult(result); |
| 423 | |
| 424 | const char* dir = FLAGS_writePath[0]; |
| 425 | if (0 == strcmp(dir, "@")) { // Needed for iOS. |
| 426 | dir = FLAGS_resourcePath[0]; |
| 427 | } |
| 428 | sk_mkdir(dir); |
| 429 | |
| 430 | SkString path; |
| 431 | if (FLAGS_nameByHash) { |
| 432 | path = SkOSPath::Join(dir, result.md5.c_str()); |
| 433 | path.append("."); |
| 434 | path.append(ext); |
| 435 | if (sk_exists(path.c_str())) { |
| 436 | return; // Content-addressed. If it exists already, we're done. |
| 437 | } |
| 438 | } else { |
| 439 | path = SkOSPath::Join(dir, task.sink.tag); |
| 440 | sk_mkdir(path.c_str()); |
| 441 | path = SkOSPath::Join(path.c_str(), task.src.tag); |
| 442 | sk_mkdir(path.c_str()); |
| 443 | path = SkOSPath::Join(path.c_str(), task.src->name().c_str()); |
| 444 | path.append("."); |
| 445 | path.append(ext); |
| 446 | } |
| 447 | |
| 448 | SkFILEWStream file(path.c_str()); |
| 449 | if (!file.isValid()) { |
| 450 | fail(SkStringPrintf("Can't open %s for writing.\n", path.c_str())); |
| 451 | return; |
| 452 | } |
| 453 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 454 | if (bitmap) { |
| 455 | // We can't encode A8 bitmaps as PNGs. Convert them to 8888 first. |
| 456 | SkBitmap converted; |
| 457 | if (bitmap->info().colorType() == kAlpha_8_SkColorType) { |
| 458 | if (!bitmap->copyTo(&converted, kN32_SkColorType)) { |
| 459 | fail("Can't convert A8 to 8888.\n"); |
| 460 | return; |
| 461 | } |
| 462 | bitmap = &converted; |
| 463 | } |
| 464 | if (!SkImageEncoder::EncodeStream(&file, *bitmap, SkImageEncoder::kPNG_Type, 100)) { |
| 465 | fail(SkStringPrintf("Can't encode PNG to %s.\n", path.c_str())); |
| 466 | return; |
| 467 | } |
| 468 | } else { |
| 469 | if (!file.writeStream(data, len)) { |
| 470 | fail(SkStringPrintf("Can't write to %s.\n", path.c_str())); |
| 471 | return; |
| 472 | } |
| 473 | } |
| 474 | } |
| 475 | }; |
| 476 | |
| 477 | // Run all tasks in the same enclave serially on the same thread. |
| 478 | // They can't possibly run concurrently with each other. |
| 479 | static void run_enclave(SkTArray<Task>* tasks) { |
| 480 | for (int i = 0; i < tasks->count(); i++) { |
| 481 | Task::Run(tasks->begin() + i); |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 486 | |
| 487 | // Unit tests don't fit so well into the Src/Sink model, so we give them special treatment. |
| 488 | |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 489 | static SkTDArray<skiatest::Test> gThreadedTests, gGPUTests; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 490 | |
| 491 | static void gather_tests() { |
mtklein | 6c5fed2 | 2015-01-20 13:47:23 -0800 | [diff] [blame] | 492 | if (!FLAGS_src.contains("tests")) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 493 | return; |
| 494 | } |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 495 | for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; |
| 496 | r = r->next()) { |
| 497 | // Despite its name, factory() is returning a reference to |
| 498 | // link-time static const POD data. |
| 499 | const skiatest::Test& test = r->factory(); |
| 500 | if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test.name)) { |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 501 | continue; |
| 502 | } |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 503 | if (test.needsGpu && gpu_supported()) { |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 504 | (FLAGS_gpu_threading ? gThreadedTests : gGPUTests).push(test); |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 505 | } else if (!test.needsGpu && FLAGS_cpu) { |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 506 | gThreadedTests.push(test); |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 507 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 508 | } |
| 509 | } |
| 510 | |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 511 | static void run_test(skiatest::Test* test) { |
| 512 | struct : public skiatest::Reporter { |
| 513 | void reportFailed(const skiatest::Failure& failure) SK_OVERRIDE { |
| 514 | fail(failure.toString()); |
| 515 | JsonWriter::AddTestFailure(failure); |
| 516 | } |
| 517 | bool allowExtendedTest() const SK_OVERRIDE { |
| 518 | return FLAGS_pathOpsExtended; |
| 519 | } |
| 520 | bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbose; } |
| 521 | } reporter; |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 522 | WallTimer timer; |
| 523 | timer.start(); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 524 | if (!FLAGS_dryRun) { |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 525 | start("unit", "test", test->name); |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 526 | GrContextFactory factory; |
| 527 | test->proc(&reporter, &factory); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 528 | } |
| 529 | timer.end(); |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 530 | done(timer.fWall, "unit", "test", test->name, "", ""); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
| 534 | |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 535 | // If we're isolating all GPU-bound work to one thread (the default), this function runs all that. |
| 536 | static void run_enclave_and_gpu_tests(SkTArray<Task>* tasks) { |
| 537 | run_enclave(tasks); |
| 538 | for (int i = 0; i < gGPUTests.count(); i++) { |
| 539 | run_test(&gGPUTests[i]); |
| 540 | } |
| 541 | } |
| 542 | |
mtklein | de6fc2b | 2015-03-12 06:28:54 -0700 | [diff] [blame] | 543 | // Some runs (mostly, Valgrind) are so slow that the bot framework thinks we've hung. |
| 544 | // 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] | 545 | static void start_keepalive() { |
| 546 | struct Loop { |
| 547 | static void forever(void*) { |
| 548 | for (;;) { |
| 549 | static const int kSec = 300; |
| 550 | #if defined(SK_BUILD_FOR_WIN) |
| 551 | Sleep(kSec * 1000); |
| 552 | #else |
| 553 | sleep(kSec); |
| 554 | #endif |
mtklein | b37cb41 | 2015-03-18 05:27:14 -0700 | [diff] [blame^] | 555 | SkString running; |
| 556 | { |
| 557 | SkAutoMutexAcquire lock(gRunningMutex); |
| 558 | for (int i = 0; i < gRunning.count(); i++) { |
| 559 | running.appendf("\n\t%s", gRunning[i].c_str()); |
| 560 | } |
| 561 | } |
| 562 | SkDebugf("\nCurrently running:%s\n", running.c_str()); |
mtklein | 2e1c47e | 2015-03-12 07:16:56 -0700 | [diff] [blame] | 563 | } |
| 564 | } |
| 565 | }; |
| 566 | static SkThread* intentionallyLeaked = new SkThread(Loop::forever); |
| 567 | intentionallyLeaked->start(); |
mtklein | de6fc2b | 2015-03-12 06:28:54 -0700 | [diff] [blame] | 568 | } |
| 569 | |
jcgregorio | 3b27ade | 2014-11-13 08:06:40 -0800 | [diff] [blame] | 570 | int dm_main(); |
caryclark | 17f0b6d | 2014-07-22 10:15:34 -0700 | [diff] [blame] | 571 | int dm_main() { |
jcgregorio | 3b27ade | 2014-11-13 08:06:40 -0800 | [diff] [blame] | 572 | SetupCrashHandler(); |
commit-bot@chromium.org | 39e8d93 | 2014-05-29 20:14:48 +0000 | [diff] [blame] | 573 | SkAutoGraphics ag; |
mtklein | 406654b | 2014-09-03 15:34:37 -0700 | [diff] [blame] | 574 | SkTaskGroup::Enabler enabled(FLAGS_threads); |
mtklein | e67164d | 2015-02-02 13:24:37 -0800 | [diff] [blame] | 575 | if (FLAGS_leaks) { |
| 576 | SkInstCountPrintLeaksOnExit(); |
| 577 | } |
commit-bot@chromium.org | a65e2fd | 2014-05-30 17:23:31 +0000 | [diff] [blame] | 578 | |
mtklein | 2e1c47e | 2015-03-12 07:16:56 -0700 | [diff] [blame] | 579 | start_keepalive(); |
mtklein | de6fc2b | 2015-03-12 06:28:54 -0700 | [diff] [blame] | 580 | |
mtklein | 62bd1a6 | 2015-01-27 14:46:26 -0800 | [diff] [blame] | 581 | gather_gold(); |
| 582 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 583 | gather_srcs(); |
| 584 | gather_sinks(); |
| 585 | gather_tests(); |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 586 | |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 587 | gPending = gSrcs.count() * gSinks.count() + gThreadedTests.count() + gGPUTests.count(); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 588 | SkDebugf("%d srcs * %d sinks + %d tests == %d tasks\n", |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 589 | gSrcs.count(), gSinks.count(), gThreadedTests.count() + gGPUTests.count(), gPending); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 590 | |
| 591 | // We try to exploit as much parallelism as is safe. Most Src/Sink pairs run on any thread, |
| 592 | // 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] | 593 | // CPU tests run on any thread. GPU tests depend on --gpu_threading. |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 594 | SkTArray<Task> enclaves[kNumEnclaves]; |
| 595 | for (int j = 0; j < gSinks.count(); j++) { |
| 596 | SkTArray<Task>& tasks = enclaves[gSinks[j]->enclave()]; |
| 597 | for (int i = 0; i < gSrcs.count(); i++) { |
| 598 | tasks.push_back(Task(gSrcs[i], gSinks[j])); |
| 599 | } |
commit-bot@chromium.org | 38aeb0f | 2014-02-26 23:01:57 +0000 | [diff] [blame] | 600 | } |
| 601 | |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 602 | SkTaskGroup tg; |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 603 | tg.batch(run_test, gThreadedTests.begin(), gThreadedTests.count()); |
| 604 | for (int i = 0; i < kNumEnclaves; i++) { |
| 605 | switch(i) { |
| 606 | case kAnyThread_Enclave: |
| 607 | tg.batch(Task::Run, enclaves[i].begin(), enclaves[i].count()); |
| 608 | break; |
| 609 | case kGPU_Enclave: |
| 610 | tg.add(run_enclave_and_gpu_tests, &enclaves[i]); |
| 611 | break; |
| 612 | default: |
| 613 | tg.add(run_enclave, &enclaves[i]); |
| 614 | break; |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 615 | } |
mtklein | 55e88b2 | 2015-01-21 15:50:13 -0800 | [diff] [blame] | 616 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 617 | tg.wait(); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 618 | // At this point we're back in single-threaded land. |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 619 | |
mtklein | 2f64eec | 2015-01-15 14:20:41 -0800 | [diff] [blame] | 620 | SkDebugf("\n"); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 621 | if (gFailures.count() > 0) { |
| 622 | SkDebugf("Failures:\n"); |
| 623 | for (int i = 0; i < gFailures.count(); i++) { |
mtklein | 9dc0910 | 2015-01-15 15:47:33 -0800 | [diff] [blame] | 624 | SkDebugf("\t%s\n", gFailures[i].c_str()); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 625 | } |
| 626 | SkDebugf("%d failures\n", gFailures.count()); |
| 627 | return 1; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 628 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 629 | if (gPending > 0) { |
| 630 | SkDebugf("Hrm, we didn't seem to run everything we intended to! Please file a bug.\n"); |
| 631 | return 1; |
mtklein | 114c3cd | 2015-01-15 10:15:02 -0800 | [diff] [blame] | 632 | } |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 633 | return 0; |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 634 | } |
jcgregorio | 3b27ade | 2014-11-13 08:06:40 -0800 | [diff] [blame] | 635 | |
| 636 | #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 637 | int main(int argc, char** argv) { |
| 638 | SkCommandLineFlags::Parse(argc, argv); |
| 639 | return dm_main(); |
| 640 | } |
| 641 | #endif |