diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/third_party/skia/dm/DM.cpp | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/skia/dm/DM.cpp')
-rw-r--r-- | chromium/third_party/skia/dm/DM.cpp | 159 |
1 files changed, 82 insertions, 77 deletions
diff --git a/chromium/third_party/skia/dm/DM.cpp b/chromium/third_party/skia/dm/DM.cpp index d4df03d9a11..1a2e059a04f 100644 --- a/chromium/third_party/skia/dm/DM.cpp +++ b/chromium/third_party/skia/dm/DM.cpp @@ -154,7 +154,6 @@ static DEFINE_bool(rasterize_pdf, false, "Rasterize PDFs when possible."); static DEFINE_bool(runVerifiers, false, "if true, run SkQP-style verification of GM-produced images."); - #if defined(__MSVC_RUNTIME_CHECKS) #include <rtcapi.h> int RuntimeCheckErrorFunc(int errorType, const char* filename, int linenumber, @@ -206,13 +205,13 @@ static void info(const char* fmt) { } } -static SkTArray<SkString> gFailures; +static SkTArray<SkString>* gFailures = new SkTArray<SkString>; static void fail(const SkString& err) { static SkSpinlock mutex; SkAutoSpinlock lock(mutex); SkDebugf("\n\nFAILURE: %s\n\n", err.c_str()); - gFailures.push_back(err); + gFailures->push_back(err); } struct Running { @@ -231,19 +230,19 @@ static void dump_json() { } // We use a spinlock to make locking this in a signal handler _somewhat_ safe. -static SkSpinlock gMutex; -static int gPending; -static SkTArray<Running> gRunning; +static SkSpinlock* gMutex = new SkSpinlock; +static int gPending; +static SkTArray<Running>* gRunning = new SkTArray<Running>; static void done(const char* config, const char* src, const char* srcOptions, const char* name) { SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name); vlog("done %s\n", id.c_str()); int pending; { - SkAutoSpinlock lock(gMutex); - for (int i = 0; i < gRunning.count(); i++) { - if (gRunning[i].id == id) { - gRunning.removeShuffle(i); + SkAutoSpinlock lock(*gMutex); + for (int i = 0; i < gRunning->count(); i++) { + if (gRunning->at(i).id == id) { + gRunning->removeShuffle(i); break; } } @@ -258,10 +257,10 @@ static void done(const char* config, const char* src, const char* srcOptions, co int curr = sk_tools::getCurrResidentSetSizeMB(), peak = sk_tools::getMaxResidentSetSizeMB(); - SkAutoSpinlock lock(gMutex); + SkAutoSpinlock lock(*gMutex); info("\n%dMB RAM, %dMB peak, %d queued, %d active:\n", - curr, peak, gPending - gRunning.count(), gRunning.count()); - for (auto& task : gRunning) { + curr, peak, gPending - gRunning->count(), gRunning->count()); + for (auto& task : *gRunning) { task.dump(); } } @@ -270,14 +269,14 @@ static void done(const char* config, const char* src, const char* srcOptions, co static void start(const char* config, const char* src, const char* srcOptions, const char* name) { SkString id = SkStringPrintf("%s %s %s %s", config, src, srcOptions, name); vlog("start %s\n", id.c_str()); - SkAutoSpinlock lock(gMutex); - gRunning.push_back({id,SkGetThreadID()}); + SkAutoSpinlock lock(*gMutex); + gRunning->push_back({id,SkGetThreadID()}); } static void find_culprit() { // Assumes gMutex is locked. SkThreadID thisThread = SkGetThreadID(); - for (auto& task : gRunning) { + for (auto& task : *gRunning) { if (task.thread == thisThread) { info("Likely culprit:\n"); task.dump(); @@ -300,7 +299,7 @@ static void find_culprit() { #undef _ }; - SkAutoSpinlock lock(gMutex); + SkAutoSpinlock lock(*gMutex); const DWORD code = e->ExceptionRecord->ExceptionCode; info("\nCaught exception %u", code); @@ -310,7 +309,7 @@ static void find_culprit() { } } info(", was running:\n"); - for (auto& task : gRunning) { + for (auto& task : *gRunning) { task.dump(); } find_culprit(); @@ -339,13 +338,13 @@ static void find_culprit() { static void (*previous_handler[max_of(SIGABRT,SIGBUS,SIGFPE,SIGILL,SIGSEGV,SIGTERM)+1])(int); static void crash_handler(int sig) { - SkAutoSpinlock lock(gMutex); + SkAutoSpinlock lock(*gMutex); info("\nCaught signal %d [%s] (%dMB RAM, peak %dMB), was running:\n", sig, strsignal(sig), sk_tools::getCurrResidentSetSizeMB(), sk_tools::getMaxResidentSetSizeMB()); - for (auto& task : gRunning) { + for (auto& task : *gRunning) { task.dump(); } find_culprit(); @@ -398,10 +397,10 @@ struct Gold : public SkString { } }; }; -static SkTHashSet<Gold, Gold::Hash> gGold; +static SkTHashSet<Gold, Gold::Hash>* gGold = new SkTHashSet<Gold, Gold::Hash>; static void add_gold(JsonWriter::BitmapResult r) { - gGold.add(Gold(r.config, r.sourceType, r.sourceOptions, r.name, r.md5)); + gGold->add(Gold(r.config, r.sourceType, r.sourceOptions, r.name, r.md5)); } static void gather_gold() { @@ -417,12 +416,12 @@ static void gather_gold() { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #if defined(SK_BUILD_FOR_WIN) - static const char* kNewline = "\r\n"; + static constexpr char kNewline[] = "\r\n"; #else - static const char* kNewline = "\n"; + static constexpr char kNewline[] = "\n"; #endif -static SkTHashSet<SkString> gUninterestingHashes; +static SkTHashSet<SkString>* gUninterestingHashes = new SkTHashSet<SkString>; static void gather_uninteresting_hashes() { if (!FLAGS_uninterestingHashesFile.isEmpty()) { @@ -439,10 +438,10 @@ static void gather_uninteresting_hashes() { SkTArray<SkString> hashes; SkStrSplit(contents.c_str(), kNewline, &hashes); for (const SkString& hash : hashes) { - gUninterestingHashes.add(hash); + gUninterestingHashes->add(hash); } info("FYI: loaded %d distinct uninteresting hashes from %d lines\n", - gUninterestingHashes.count(), hashes.count()); + gUninterestingHashes->count(), hashes.count()); } } @@ -457,10 +456,10 @@ struct TaggedSink : public std::unique_ptr<Sink> { SkString tag; }; -static const bool kMemcpyOK = true; +static constexpr bool kMemcpyOK = true; -static SkTArray<TaggedSrc, kMemcpyOK> gSrcs; -static SkTArray<TaggedSink, kMemcpyOK> gSinks; +static SkTArray<TaggedSrc, kMemcpyOK>* gSrcs = new SkTArray<TaggedSrc, kMemcpyOK>; +static SkTArray<TaggedSink, kMemcpyOK>* gSinks = new SkTArray<TaggedSink, kMemcpyOK>; static bool in_shard() { static int N = 0; @@ -471,7 +470,7 @@ static void push_src(const char* tag, ImplicitString options, Src* s) { std::unique_ptr<Src> src(s); if (in_shard() && FLAGS_src.contains(tag) && !CommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { - TaggedSrc& s = gSrcs.push_back(); + TaggedSrc& s = gSrcs->push_back(); s.reset(src.release()); s.tag = tag; s.options = options; @@ -611,6 +610,7 @@ static void push_image_gen_src(Path path, ImageGenSrc::Mode mode, SkAlphaType al push_src("image", folder, src); } +#ifdef SK_ENABLE_ANDROID_UTILS static void push_brd_src(Path path, CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleSize) { SkString folder("brd_android_codec"); @@ -669,6 +669,7 @@ static void push_brd_srcs(Path path, bool gray) { } } } +#endif // SK_ENABLE_ANDROID_UTILS static void push_codec_srcs(Path path) { sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str())); @@ -797,6 +798,7 @@ static void push_codec_srcs(Path path) { } } +#ifdef SK_ENABLE_ANDROID_UTILS static const char* const brdExts[] = { "jpg", "jpeg", "png", "webp", "JPG", "JPEG", "PNG", "WEBP", @@ -808,6 +810,7 @@ static void push_codec_srcs(Path path) { break; } } +#endif } // Push image generator GPU test. @@ -902,7 +905,7 @@ static void push_sink(const SkCommandLineConfig& config, Sink* s) { // Try a simple Src as a canary. If it fails, skip this sink. struct : public Src { - Result draw(SkCanvas* c) const override { + Result draw(GrContext*, SkCanvas* c) const override { c->drawRect(SkRect::MakeWH(1,1), SkPaint()); return Result::Ok(); } @@ -919,7 +922,7 @@ static void push_sink(const SkCommandLineConfig& config, Sink* s) { exit(1); } - TaggedSink& ts = gSinks.push_back(); + TaggedSink& ts = gSinks->push_back(); ts.reset(sink.release()); ts.tag = config.getTag(); } @@ -946,6 +949,8 @@ static Sink* create_sink(const GrContextOptions& grCtxOptions, const SkCommandLi return new GPUPrecompileTestingSink(gpuConfig, grCtxOptions); } else if (gpuConfig->getUseDDLSink()) { return new GPUDDLSink(gpuConfig, grCtxOptions); + } else if (gpuConfig->getOOPRish()) { + return new GPUOOPRSink(gpuConfig, grCtxOptions); } else { return new GPUSink(gpuConfig, grCtxOptions); } @@ -1067,7 +1072,7 @@ static bool gather_sinks(const GrContextOptions& grCtxOptions, bool defaultConfi // If we're using the default configs, we're okay. defaultConfigs || // Otherwise, make sure that all specified configs have become sinks. - configs.count() == gSinks.count()) { + configs.count() == gSinks->count()) { return true; } return false; @@ -1098,7 +1103,7 @@ static bool is_blacklisted(const char* sink, const char* src, // Even when a Task Sink reports to be non-threadsafe (e.g. GPU), we know things like // .png encoding are definitely thread safe. This lets us offload that work to CPU threads. -static SkTaskGroup gDefinitelyThreadSafeWork; +static SkTaskGroup* gDefinitelyThreadSafeWork = new SkTaskGroup; // The finest-grained unit of work we can run: draw a single Src into a single Sink, // report any errors, and perhaps write out the output: a .png of the bitmap, or a raw stream. @@ -1146,7 +1151,7 @@ struct Task { // We're likely switching threads here, so we must capture by value, [=] or [foo,bar]. SkStreamAsset* data = stream.detachAsStream().release(); - gDefinitelyThreadSafeWork.add([task,name,bitmap,data]{ + gDefinitelyThreadSafeWork->add([task,name,bitmap,data]{ std::unique_ptr<SkStreamAsset> ownedData(data); std::unique_ptr<HashAndEncode> hashAndEncode; @@ -1168,8 +1173,8 @@ struct Task { } if (!FLAGS_readPath.isEmpty() && - !gGold.contains(Gold(task.sink.tag, task.src.tag, - task.src.options, name, md5))) { + !gGold->contains(Gold(task.sink.tag, task.src.tag, + task.src.options, name, md5))) { fail(SkStringPrintf("%s not found for %s %s %s %s in %s", md5.c_str(), task.sink.tag.c_str(), @@ -1204,21 +1209,18 @@ struct Task { h = (int)CGRectGetHeight(bounds); SkBitmap rasterized; - rasterized.allocPixels( - SkImageInfo::Make(w,h, kRGBA_8888_SkColorType, kPremul_SkAlphaType)); + rasterized.allocPixels(SkImageInfo::Make( + w, h, kRGBA_8888_SkColorType, kPremul_SkAlphaType)); rasterized.eraseColor(SK_ColorWHITE); - SkUniqueCFRef<CGColorSpaceRef> cs{ - CGColorSpaceCreateDeviceRGB()}; - CGBitmapInfo info = kCGBitmapByteOrder32Big - | kCGImageAlphaPremultipliedLast; + SkUniqueCFRef<CGColorSpaceRef> cs{CGColorSpaceCreateDeviceRGB()}; + CGBitmapInfo info = kCGBitmapByteOrder32Big | + (CGBitmapInfo)kCGImageAlphaPremultipliedLast; - SkUniqueCFRef<CGContextRef> ctx{ - CGBitmapContextCreate(rasterized.getPixels(), - w,h,8,rasterized.rowBytes(), cs.get(),info)}; + SkUniqueCFRef<CGContextRef> ctx{CGBitmapContextCreate( + rasterized.getPixels(), w,h,8, rasterized.rowBytes(), cs.get(), info)}; CGContextDrawPDFPage(ctx.get(), page); - // Skip calling hashAndEncode->write(SkMD5*)... we want the .pdf's hash. hashAndEncode.reset(new HashAndEncode(rasterized)); WriteToDisk(task, md5, "png", nullptr,0, &rasterized, hashAndEncode.get()); @@ -1346,7 +1348,7 @@ struct Task { // If an MD5 is uninteresting, we want it noted in the JSON file, // but don't want to dump it out as a .png (or whatever ext is). - if (gUninterestingHashes.contains(md5)) { + if (gUninterestingHashes->contains(md5)) { return; } @@ -1423,7 +1425,8 @@ struct Task { // Unit tests don't fit so well into the Src/Sink model, so we give them special treatment. -static SkTDArray<skiatest::Test> gParallelTests, gSerialTests; +static SkTDArray<skiatest::Test>* gParallelTests = new SkTDArray<skiatest::Test>; +static SkTDArray<skiatest::Test>* gSerialTests = new SkTDArray<skiatest::Test>; static void gather_tests() { if (!FLAGS_src.contains("tests")) { @@ -1437,9 +1440,9 @@ static void gather_tests() { continue; } if (test.needsGpu && FLAGS_gpu) { - gSerialTests.push_back(test); + gSerialTests->push_back(test); } else if (!test.needsGpu && FLAGS_cpu) { - gParallelTests.push_back(test); + gParallelTests->push_back(test); } } } @@ -1521,7 +1524,7 @@ int main(int argc, char** argv) { // TODO(dogben): This is a bit ugly. Find a cleaner way to do this. bool defaultConfigs = true; for (int i = 0; i < argc; i++) { - static const char* kConfigArg = "--config"; + static constexpr char kConfigArg[] = "--config"; if (strcmp(argv[i], kConfigArg) == 0) { defaultConfigs = false; break; @@ -1531,42 +1534,44 @@ int main(int argc, char** argv) { return 1; } gather_tests(); - gPending = gSrcs.count() * gSinks.count() + gParallelTests.count() + gSerialTests.count(); + gPending = gSrcs->count() * gSinks->count() + gParallelTests->count() + gSerialTests->count(); info("%d srcs * %d sinks + %d tests == %d tasks\n", - gSrcs.count(), gSinks.count(), gParallelTests.count() + gSerialTests.count(), gPending); + gSrcs->count(), gSinks->count(), gParallelTests->count() + gSerialTests->count(), + gPending); // Kick off as much parallel work as we can, making note of any serial work we'll need to do. SkTaskGroup parallel; SkTArray<Task> serial; - for (auto& sink : gSinks) - for (auto& src : gSrcs) { - if (src->veto(sink->flags()) || - is_blacklisted(sink.tag.c_str(), src.tag.c_str(), - src.options.c_str(), src->name().c_str())) { - SkAutoSpinlock lock(gMutex); - gPending--; - continue; - } + for (TaggedSink& sink : *gSinks) { + for (TaggedSrc& src : *gSrcs) { + if (src->veto(sink->flags()) || + is_blacklisted(sink.tag.c_str(), src.tag.c_str(), + src.options.c_str(), src->name().c_str())) { + SkAutoSpinlock lock(*gMutex); + gPending--; + continue; + } - Task task(src, sink); - if (src->serial() || sink->serial()) { - serial.push_back(task); - } else { - parallel.add([task] { Task::Run(task); }); + Task task(src, sink); + if (src->serial() || sink->serial()) { + serial.push_back(task); + } else { + parallel.add([task] { Task::Run(task); }); + } } } - for (auto test : gParallelTests) { + for (skiatest::Test& test : *gParallelTests) { parallel.add([test, grCtxOptions] { run_test(test, grCtxOptions); }); } // With the parallel work running, run serial tasks and tests here on main thread. - for (auto task : serial) { Task::Run(task); } - for (auto test : gSerialTests) { run_test(test, grCtxOptions); } + for (Task& task : serial) { Task::Run(task); } + for (skiatest::Test& test : *gSerialTests) { run_test(test, grCtxOptions); } // Wait for any remaining parallel work to complete (including any spun off of serial tasks). parallel.wait(); - gDefinitelyThreadSafeWork.wait(); + gDefinitelyThreadSafeWork->wait(); // At this point we're back in single-threaded land. @@ -1575,12 +1580,12 @@ int main(int argc, char** argv) { // Make sure we've flushed all our results to disk. dump_json(); - if (gFailures.count() > 0) { + if (!gFailures->empty()) { info("Failures:\n"); - for (int i = 0; i < gFailures.count(); i++) { - info("\t%s\n", gFailures[i].c_str()); + for (const SkString& fail : *gFailures) { + info("\t%s\n", fail.c_str()); } - info("%d failures\n", gFailures.count()); + info("%d failures\n", gFailures->count()); return 1; } |