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/modules/pathkit | |
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/modules/pathkit')
9 files changed, 77 insertions, 36 deletions
diff --git a/chromium/third_party/skia/modules/pathkit/CHANGELOG.md b/chromium/third_party/skia/modules/pathkit/CHANGELOG.md index dc0b62811cb..9b968bd55cc 100644 --- a/chromium/third_party/skia/modules/pathkit/CHANGELOG.md +++ b/chromium/third_party/skia/modules/pathkit/CHANGELOG.md @@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed - - Updated to emscripten 1.39.6 + - Updated to emscripten 1.39.16 + +### Breaking + - `PathKitInit(...)` now directly returns a Promise. As such, `PathKitInit(...).ready()` + has been removed. ## [0.6.0] 2019-02-25 diff --git a/chromium/third_party/skia/modules/pathkit/compile.sh b/chromium/third_party/skia/modules/pathkit/compile.sh index 7d4660d321c..32cd53c0afc 100755 --- a/chromium/third_party/skia/modules/pathkit/compile.sh +++ b/chromium/third_party/skia/modules/pathkit/compile.sh @@ -93,7 +93,7 @@ echo "Compiling bitcode" --args="cc=\"${EMCC}\" \ cxx=\"${EMCXX}\" \ ar=\"${EMAR}\" \ - extra_cflags=[\"-DSK_DISABLE_READBUFFER=1\",\"-s\", \"WARN_UNALIGNED=1\", + extra_cflags=[\"-s\", \"WARN_UNALIGNED=1\", \"-s\", \"MAIN_MODULE=1\", ${EXTRA_CFLAGS} ] \ @@ -110,10 +110,9 @@ echo "Generating WASM" ${EMCXX} $RELEASE_CONF -std=c++17 \ -I. \ --bind \ +--no-entry \ --pre-js $BASE_DIR/helper.js \ --pre-js $BASE_DIR/chaining.js \ ---post-js $BASE_DIR/ready.js \ --DSK_DISABLE_READBUFFER=1 \ -fno-rtti -fno-exceptions -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 \ $WASM_CONF \ -s ERROR_ON_UNDEFINED_SYMBOLS=1 \ diff --git a/chromium/third_party/skia/modules/pathkit/npm-asmjs/README.md b/chromium/third_party/skia/modules/pathkit/npm-asmjs/README.md index ff71af1b764..ac05297a4aa 100644 --- a/chromium/third_party/skia/modules/pathkit/npm-asmjs/README.md +++ b/chromium/third_party/skia/modules/pathkit/npm-asmjs/README.md @@ -5,7 +5,7 @@ To use the library, run `npm install pathkit-asmjs` and then simply include it: <script src="/node_modules/pathkit-asmjs/bin/pathkit.js"></script> PathKitInit({ locateFile: (file) => '/node_modules/pathkit-asmjs/bin/'+file, - }).ready().then((PathKit) => { + }).then((PathKit) => { // Code goes here using PathKit }); @@ -14,7 +14,7 @@ a global `PathKitInit` that can be called to load the WASM code. The `locateFile is used to tell the JS loader where to find the .js.mem file. By default, it will look for /pathkit.js.mem, so if this is not the case, use `locateFile` to configure this properly. -The `PathKit` object returned upon resolution of the .ready() Promise is fully loaded and ready to use. +The `PathKit` object returned upon resolution of the PathKitInit Promise is fully loaded and ready to use. See the [API page](https://skia.org/user/modules/pathkit) and [example.html](https://github.com/google/skia/blob/master/modules/pathkit/npm-asmjs/example.html) @@ -29,7 +29,7 @@ used with just a few configuration changes. In the JS code, use require(): const PathKitInit = require('pathkit-asmjs/bin/pathkit.js') - PathKitInit().ready().then((PathKit) => { + PathKitInit().then((PathKit) => { // Code goes here using PathKit }) diff --git a/chromium/third_party/skia/modules/pathkit/npm-asmjs/example.html b/chromium/third_party/skia/modules/pathkit/npm-asmjs/example.html index a2fc4c18902..c50c453e1af 100644 --- a/chromium/third_party/skia/modules/pathkit/npm-asmjs/example.html +++ b/chromium/third_party/skia/modules/pathkit/npm-asmjs/example.html @@ -53,7 +53,7 @@ PathKitInit({ locateFile: (file) => '/node_modules/pathkit-asmjs/bin/'+file, - }).ready().then((PathKit) => { + }).then((PathKit) => { window.PathKit = PathKit; OutputsExample(PathKit); Path2DExample(PathKit); diff --git a/chromium/third_party/skia/modules/pathkit/npm-wasm/README.md b/chromium/third_party/skia/modules/pathkit/npm-wasm/README.md index 815e417d8f5..2e7a6d74b83 100644 --- a/chromium/third_party/skia/modules/pathkit/npm-wasm/README.md +++ b/chromium/third_party/skia/modules/pathkit/npm-wasm/README.md @@ -5,7 +5,7 @@ To use the library, run `npm install pathkit-wasm` and then simply include it: <script src="/node_modules/pathkit-wasm/bin/pathkit.js"></script> PathKitInit({ locateFile: (file) => '/node_modules/pathkit-wasm/bin/'+file, - }).ready().then((PathKit) => { + }).then((PathKit) => { // Code goes here using PathKit }); @@ -14,7 +14,7 @@ a global `PathKitInit` that can be called to load the WASM code. The `locateFile is used to tell the JS loader where to find the .wasm file. By default, it will look for /pathkit.wasm, so if this is not the case, use `locateFile` to configure this properly. -The `PathKit` object returned upon resolution of the .ready() Promise is fully loaded and ready to use. +The `PathKit` object returned upon resolution of the PathKitInit Promise is fully loaded and ready to use. See the [API page](https://skia.org/user/modules/pathkit) and [example.html](https://github.com/google/skia/blob/master/modules/pathkit/npm-wasm/example.html) @@ -29,7 +29,7 @@ used with a few configuration changes. In the JS code, use require(): const PathKitInit = require('pathkit-wasm/bin/pathkit.js') - PathKitInit().ready().then((PathKit) => { + PathKitInit().then((PathKit) => { // Code goes here using PathKit }) diff --git a/chromium/third_party/skia/modules/pathkit/npm-wasm/example.html b/chromium/third_party/skia/modules/pathkit/npm-wasm/example.html index d7c2469a992..488f6ecbed8 100644 --- a/chromium/third_party/skia/modules/pathkit/npm-wasm/example.html +++ b/chromium/third_party/skia/modules/pathkit/npm-wasm/example.html @@ -53,7 +53,7 @@ PathKitInit({ locateFile: (file) => '/node_modules/pathkit-wasm/bin/'+file, - }).ready().then((PathKit) => { + }).then((PathKit) => { window.PathKit = PathKit; OutputsExample(PathKit); Path2DExample(PathKit); diff --git a/chromium/third_party/skia/modules/pathkit/pathkit_wasm_bindings.cpp b/chromium/third_party/skia/modules/pathkit/pathkit_wasm_bindings.cpp index 56db3e186dc..30ecd21ffd5 100644 --- a/chromium/third_party/skia/modules/pathkit/pathkit_wasm_bindings.cpp +++ b/chromium/third_party/skia/modules/pathkit/pathkit_wasm_bindings.cpp @@ -259,31 +259,36 @@ SkPathOrNull EMSCRIPTEN_KEEPALIVE ResolveBuilder(SkOpBuilder& builder) { //======================================================================================== void EMSCRIPTEN_KEEPALIVE ToCanvas(const SkPath& path, emscripten::val /* Path2D or Canvas*/ ctx) { - for (auto [verb, pts, w] : SkPathPriv::Iterate(path)) { + SkPath::Iter iter(path, false); + SkPoint pts[4]; + SkPath::Verb verb; + while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { switch (verb) { - case SkPathVerb::kMove: + case SkPath::kMove_Verb: ctx.call<void>("moveTo", pts[0].x(), pts[0].y()); break; - case SkPathVerb::kLine: + case SkPath::kLine_Verb: ctx.call<void>("lineTo", pts[1].x(), pts[1].y()); break; - case SkPathVerb::kQuad: + case SkPath::kQuad_Verb: ctx.call<void>("quadraticCurveTo", pts[1].x(), pts[1].y(), pts[2].x(), pts[2].y()); break; - case SkPathVerb::kConic: + case SkPath::kConic_Verb: SkPoint quads[5]; // approximate with 2^1=2 quads. - SkPath::ConvertConicToQuads(pts[0], pts[1], pts[2], *w, quads, 1); + SkPath::ConvertConicToQuads(pts[0], pts[1], pts[2], iter.conicWeight(), quads, 1); ctx.call<void>("quadraticCurveTo", quads[1].x(), quads[1].y(), quads[2].x(), quads[2].y()); ctx.call<void>("quadraticCurveTo", quads[3].x(), quads[3].y(), quads[4].x(), quads[4].y()); break; - case SkPathVerb::kCubic: + case SkPath::kCubic_Verb: ctx.call<void>("bezierCurveTo", pts[1].x(), pts[1].y(), pts[2].x(), pts[2].y(), pts[3].x(), pts[3].y()); break; - case SkPathVerb::kClose: + case SkPath::kClose_Verb: ctx.call<void>("closePath"); break; + case SkPath::kDone_Verb: + break; } } } diff --git a/chromium/third_party/skia/modules/pathkit/perf/perfReporter.js b/chromium/third_party/skia/modules/pathkit/perf/perfReporter.js index 35fd3590bc5..d2211d231cb 100644 --- a/chromium/third_party/skia/modules/pathkit/perf/perfReporter.js +++ b/chromium/third_party/skia/modules/pathkit/perf/perfReporter.js @@ -51,6 +51,55 @@ function benchmarkAndReport(benchName, setupFn, testFn, teardownFn) { } } +// The same as benchmarkAndReport, except expects the third parameter, testFn, to return a promise +async function asyncBenchmarkAndReport(benchName, setupFn, testFn, teardownFn) { + try { + let ctx = {}; + // warmup 3 times (arbitrary choice) + setupFn(ctx); + await testFn(ctx); + await testFn(ctx); + await testFn(ctx); + teardownFn(ctx); + + ctx = {}; + setupFn(ctx); + let start = Date.now(); + let now = start; + times = 0; + // See how many times we can do it in 100ms (arbitrary choice) + while (now - start < 100) { + await testFn(ctx); + now = Date.now(); + times++; + } + + teardownFn(ctx); + + // Try to make it go for 2 seconds (arbitrarily chosen) + // Since the pre-try took 100ms, multiply by 20 to get + // approximate tries in 2s (unless now - start >> 100 ms) + let goalTimes = times * 20; + ctx = {}; + setupFn(ctx); + times = 0; + start = Date.now(); + while (times < goalTimes) { + await testFn(ctx); + times++; + } + const end = Date.now(); + teardownFn(ctx); + + const us = (end - start) * 1000 / times; + console.log(benchName, `${us} microseconds`) + return _report(us, benchName); + } catch(e) { + console.error('caught error', e); + return Promise.reject(e); + } +} + function _report(microseconds, benchName) { return fetch(REPORT_URL, { diff --git a/chromium/third_party/skia/modules/pathkit/ready.js b/chromium/third_party/skia/modules/pathkit/ready.js deleted file mode 100644 index 60f24862d9e..00000000000 --- a/chromium/third_party/skia/modules/pathkit/ready.js +++ /dev/null @@ -1,16 +0,0 @@ -// See https://github.com/kripken/emscripten/issues/5820#issuecomment-385722568 -// for context on why the .then() that comes with Module breaks things (e.g. infinite loops) -// and why the below fixes it. -Module['ready'] = function() { - return new Promise(function (resolve, reject) { - Module['onAbort'] = reject; - if (runtimeInitialized) { - resolve(Module); - } else { - addOnPostRun(function() { - resolve(Module); - }); - } - }); -} -delete Module['then'];
\ No newline at end of file |