Breaking Changes:
- All method calls that mutate a path now return the same JS path
object to allow chaining (moveTo, lineTo, trim, op, simplify, etc).
Pre-existing code likely will need to have some delete() methods
removed because the path will be deleted multiple times. See
chaining.js for this code (basically, we wrote our own binding code
since the default code wasn't quite flexible enough)
- GetCanvasFillType -> GetFillTypeString (Was in https://skia-review.googlesource.com/c/skia/+/147209)
Since Canvas and SVG use the same strings, it seemed logical to make
them share.
- stroke() now takes a single object instead of 3 params. This object
currently can have up to 4 params, cap, join, width, miter_limit.
This object can be expanded on in future versions as more configuration
options are added.
As per custom with v0 software, we bump the minor version to 0.2.X
to indicate breaking changes in a pre-release software package.
Other changes of note:
- Simple tests added for effects (see effects.specs.js) A follow up
CL will handle the Gold (correctness tests)
- Simple tests added for equals and copy constructors (from https://skia-review.googlesource.com/c/skia/+/147209)
- Added transform() to allow for arbitrary matrix transforms
- Added SimpleMatrix as a value_array, which means users can
provide a 9 element array which will be converted to SimpleMatrix
and then SkMatrix on the C++ side.
- Renamed helpers_externs.js to externs.js and expanded it greatly.
This was necessitated by the code written in chaining.js
- Fixed a few bugs in previous tests (svg gold test race condition,
uncaught exception in svg reporting)
See also https://skia-review.googlesource.com/c/skia/+/147209 which
allows .moveTo .lineTo, etc to chain on the C++ SkPath.
Bug: skia:8216
Change-Id: I7450cd8b7b5377cf15c962b02d161677b62d7e15
Reviewed-on: https://skia-review.googlesource.com/147115
Reviewed-by: Mike Reed <reed@google.com>
To get the gold images out of the browser tests, this adds
testReporter.js and pathkit_aggregator.go. testReporter bundles
up the output as a base64 encoded PNG and sends it over the local
network to pathkit_aggregator. pathkit_aggregator will keep
a list of test results reported in this way and write the PNGs
to /OUT of the container (which is the swarming output directory).
Finally, after all the tests are run, the helper script "test_pathkit.sh"
makes a POST request that creates the JSON file that gold expects
(following the schema https://github.com/google/skia-buildbot/blob/master/golden/docs/INGESTION.md)
pathkit_aggregator takes many command line arguments which control
the keys that Gold needs in order to ingest and handle the data.
Of note, this creates a new set (i.e. source_type) of gold images
called "pathkit", which will distinguish it from "gm", "image", etc.
There will be at least 2 sub-sets of "pathkit" images, "canvas" and "svg",
(representing the 2 output types of PathKit). This CL doesn't
quite handle SVG yet, as it needs a way to convert SVG to PNG in the
browser and will be addressed in a follow up CL.
A "standard" gm is sized at 600x600. This was arbitrarily picked.
Note that the functions in testReporter.js return Promises based
on the fetch requests to post the data. This eliminates the race
condition between the /report_gold_data and /dump_json since
running the karma tests won't return until all reports are done.
Other changes of note:
- Adds go to karma-chrome-tests container.
- renames recipe_modules/build/wasm.py -> pathkit.py to be consistent with
the name of test_pathkit.py and make for easier grepping.
- Increases the JS test timeout to 10s (up from 5) to hopefully avoid
the flakes seen in the Debug Test.
Bug: skia:8216
Change-Id: Ic2cad54f3d19cc16601cf2e9a87798db1e6887a2
Reviewed-on: https://skia-review.googlesource.com/147042
Reviewed-by: Stephan Altmueller <stephana@google.com>
API Changes (nothing should be breaking):
- Exposes conic, although all output formats (SVG, Canvas) need conics
to be approximated with quads. Tests have been added to verify this
happens.
- Add .dash(), .trim(), .stroke() and examples for them.
- Expose Stroke enums (StrokeJoin, StrokeCap)
Adds tests for the cubic part and clean up a few spacing things.
There are some changes to the C++ code to simplify the build -
otherwise, I need to appease the linker and add add in a bunch
of files that may or may not get optimized out. Best make them
not even be compiled, just to make sure.
Bug: skia:8216
Change-Id: I1da3aaab1891f14a5b3dc01bb6523b4fd9a87b04
Reviewed-on: https://skia-review.googlesource.com/146650
Reviewed-by: Florin Malita <fmalita@chromium.org>
Because of https://skia-review.googlesource.com/c/skia/+/146165 and
https://skia-review.googlesource.com/c/skia/+/146100 we have a way
to turn PathOps tests into JSON, which has input paths (as Cmd arrays),
combination verb and expected output.
In this CL, we make tests from the JSON, compare them to the expected
output and, optionally, create SVGs to visualize the difference if any.
API changes (nothing breaking on release builds):
- Exposes SkRect as a JS Object. No need to call delete() on this.
- expose path.getBounds() and path.computeTightBounds()
- Remove SkRegion exposure (debug/test only), which was going to be
used for this purpose, but the approach in this CL works fine.
- Add loadCmdsTypedArray(cmd) helper function to JS [see helper.js].
This was previously known as `floatTypedArrayFrom2D` in the
old shell.html, and is now exposed to avoid clients having to
implement this boilerplate by themselves.
- Add set/getFillType - mostly for testing the difference between
a Winding and an EvenOdd path.
Bug: skia:8216
Change-Id: I2cd25ce2e1e7f285c79c596678678e62135963f0
Reviewed-on: https://skia-review.googlesource.com/146524
Reviewed-by: Cary Clark <caryclark@google.com>
This adds a few JS tests (see *.spec.test) and runs them
using Karma and a Docker image containing Karma, node, and
Chrome (currently at 68).
We only add a Debug Test here because the Release version
has some test helpers (e.g. Region) compiled out. If those
end up not mattering for tests, we can add in a Release version.
Bug: skia:8216
Change-Id: Ica6ab3a4f21688cfa175a90d42c2254d38e8fcf1
Reviewed-on: https://skia-review.googlesource.com/145723
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Reviewed-by: Eric Boren <borenet@google.com>
push -> push_back
add some aliases to match std::vector: count, reserve, ...
Bug: skia:
Change-Id: I1921c31d0d6e5ed3d622a0def6054c697be2d02f
Reviewed-on: https://skia-review.googlesource.com/145884
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
This makes our calls to emscripten::val a bit more consistent.
Adds in the macro SkPathOrVal to self-document where it's really
a SkPath we are returning, but C++ doesn't realize SkPath and
emscripten::val::null() can be the same type. Casting SkPath
via emscripten::val() is basically a no-op, since Emscripten bind
seems to be doing it under the hood anyway.
No functional changes, except when there would be a failure,
methods will return null instead of an empty SkPath.
Bug: skia:8216
Change-Id: I1fff620d5aa50ec4a57f76e706d8d005ea26605f
Reviewed-on: https://skia-review.googlesource.com/145728
Reviewed-by: Cary Clark <caryclark@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Adds arc, arcTo, rect and Path2D names for quadTo, cubicTo, close.
Adds conic verb support (approximated with 2 quads).
Breaking changes:
Some functions have been moved to be member functions:
PathKit.Simplify(path) -> path.simplify()
PathKit.ToCanvas(path, ctx) -> path.toCanvas(ctx)
PathKit.ToSVGString(path) -> path.toSVGString()
PathKit.ToPath2D(path) -> path.toPath2D()
PathKit.ToCmds(path) -> path.toCmds()
PathKit.ResolveBuilder(builder) -> builder.resolve()
PathKit.GetBoundaryPathFromRegion(region) -> region.getBoundaryPath()
Pathkit.ApplyPathOp(pathOne, pathTwo, op) still exists, but there's
now also pathOne.op(pathTwo, op) for cases when that's easier.
As per custom with version 0.x.y projects, I'm bumping the
minor version (in npm) for these breaking changes instead of the
major version (which will happen when we are version >= 1.0.0).
This also has some small improvements to the output code size.
The biggest jump was from enabling the closure compiler on the
helper JS, which trimmed it down by about 40%. Using the closure
compiler requires the JRE on the bots, which prompted the emsdk-base
image change.
Bug: skia:8216
Change-Id: I40902d23380093c34d1679df0255bcb0eaa77b01
Reviewed-on: https://skia-review.googlesource.com/145420
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
This adds a job to build it and adds it to the npm
under /bin/debug.
The debug build is useful for clients because it
has all the debug symbols, which makes it possible to
see which WASM calls are taking the longest when using
DevTools' Performance testing.
Bug: skia:8216
Change-Id: I3068cb395f29c1de927508cf15c419f5af284eb7
Reviewed-on: https://skia-review.googlesource.com/145337
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
This creates a new named cache docker for this and future
docker-based jobs to use, to avoid permission snafus with
the normal "work" named cache.
Remove old WASM build, which was using the janky CIPD
emsdk asset and wasn't really exercising what we needed.
Bug: skia:8216
Change-Id: I993bba38b4978ca5eebb97e5b5b21729d55a072d
Reviewed-on: https://skia-review.googlesource.com/145140
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Eric Boren <borenet@google.com>
- Remove some old API with VerbArgs that we didn't really like.
- move from experimental/wasm -> experimental/pathkit and rename
wasm_main.cpp to pathkit_wasm_bindings (more descriptive).
- Make compile.sh nicer to use (with some form of command line args).
- Use MODULARIZE=1 to make this play nicer with other WASM libraries
and easier to import.
- Add seperate ToCanvas() API
- Move Region stuff behind the PATHKIT_TESTING flag (saves 100k on
binary size).
- Add npm package for wasm version. asm.js version should also be
supported for older browsers.
- Remove shell.html, which was largely too complicated. Replace it with
example.html, which is more succinct and demos the more relevant APIs.
See https://www.npmjs.com/package/experimental-pathkit-wasm
Bug: skia:8216
Change-Id: I15f14dd8acd77331729998ae3e30d73e4b006761
Reviewed-on: https://skia-review.googlesource.com/144790
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
The most interesting part is using variadic calls to push all verb data
in one native -> JS go. This speeds up SkPathToVerbsArgsArray and
SkPathToCmdArray by 30-35%.
Other misc changes:
* use SkPath::RawIter instead of Iter
* add a VisitPath helper to cut down on boiler plate
* use uintptr_t for pointer arguments (just in case we get to wasm64
some day)
Change-Id: Ia0240f0e00e81db78eb1e9b48b31abbb3e33bfaf
Reviewed-on: https://skia-review.googlesource.com/140984
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
See shell.html::entrypoint() for the JS side of things.
See wasm_main.cpp for the C++ side of things
(EMSCRIPTEN_BINDINGS at the bottom is what glues the two parts
together - in general the strings are for JS and the not strings
are the C++)
To build this yourself, follow the getting started instructions:
https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html
and download this patch. Then, update compile.sh to point at your
sdk and run it (e.g. $SKIA_ROOT/experimental/wasm/compile.sh)
Then navigate a browser (e.g. Chrome) to
http://localhost:8000/out/wasm/pathkit.html
So far, can compile with compile.sh, but not really with
GN/ninja (the compilation into many object files and a link
at the end seems to mess emscripten up)
Bug: skia:
Change-Id: If6b300e2b102469e17841265c7866f1a81094d70
Reviewed-on: https://skia-review.googlesource.com/137422
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This reverts commit 2a2f675926.
Reason for revert: this appears to be what is holding up the Chrome roll.
Original change's description:
> SkTypes: extract SkTo
>
> Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09
> Reviewed-on: https://skia-review.googlesource.com/133620
> Reviewed-by: Mike Klein <mtklein@google.com>
TBR=mtklein@google.com,halcanary@google.com
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Iafd738aedfb679a23c061a51afe4b98a8d4cdfae
Reviewed-on: https://skia-review.googlesource.com/134504
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
* relocate all SkSG-related files under modules/sksg/
* fix various tidbits to make non-sksg builds possible
* drop obsolete SampleSGInval.cpp
Change-Id: I54e6c5bb1a09f45030fa8d607b3eb3f7cba78957
Reviewed-on: https://skia-review.googlesource.com/130025
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
- limit the maximum number of points
- round instead of trunc (more accurate when interpolating)
- reserve the path verb/pts space upfront
Bug: oss-fuzz:8223
Change-Id: Ib6fb83e56c05b16e292789be81f1a48a9c529211
Reviewed-on: https://skia-review.googlesource.com/128017
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This is safe because count == 0 will produce an empty path.
Bug: oss-fuzz:8213
Change-Id: Ie3b546c614ba22eef1ba16a182016c2edd0bd641
Reviewed-on: https://skia-review.googlesource.com/127323
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
BindProperty can already check for no-op static props, so let's use it.
TBR=
Change-Id: If1c327871702b57ad9e6db9a8b112c6775cb7f53
Reviewed-on: https://skia-review.googlesource.com/127140
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Rapidjson's array [] operator asserts the index is valid (instead of
returning a null value when out-of-range) -> we must check.
Bug: skia:7918
Change-Id: Ice4a6e6670a824da0d423da4a6f92414cd0dc252
Reviewed-on: https://skia-review.googlesource.com/126441
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
- pull latest RapidJSON under third_party/externals/rapidjson
(note: and older RS version is already pulled as part of angle2,
and it is also checked in G3)
- add a thin Json porting layer (SkottieJson) to isolate RS
idiosyncrasies
- convert Skottie to use the new helpers
- parse the DOM in-place (based on local experiments this is the
fastest method)
Ta-da: Skottie now parses JSON ~10x faster!
Change-Id: Ida9099638f88ed025fee83055c8cd8680ee27176
Reviewed-on: https://skia-review.googlesource.com/125744
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
For straight lines, Lottie exports control points conincident with the
vertices. We can detect this case and emit more efficient lineTo's.
One wrinkle: we can only apply this power-reduction post-interpolation
(otherwise the path verbs and point count would not be guaranteed to
match). Hence we store explicit shape data and defer the SkPath
conversion.
TBR=
Change-Id: I7818be464eabee6096d2078440843243a55c6e98
Reviewed-on: https://skia-review.googlesource.com/124800
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
When the mask stack contains exactly one opaque mask path, we can apply as
a clip.
TBR=
Change-Id: Iadff7534bfa4925557bfbddd59529113f4958d0d
Reviewed-on: https://skia-review.googlesource.com/124000
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Change-Id: Ib0042cf412fe3c5fa600b7ae644d16740457535e
Reviewed-on: https://skia-review.googlesource.com/121354
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Split into Adapter and Value CUs.
No real changes, just shuffling things around.
TBR=
Change-Id: I50eaeb3950f4c59e7d7027955b3f49ca2a346e59
Reviewed-on: https://skia-review.googlesource.com/116186
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Bug: skia:7688
Change-Id: I5b4f9b3aba7d696d09c1c2f0634c8c866e5ba99d
Reviewed-on: https://skia-review.googlesource.com/115077
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Stephan Altmueller <stephana@google.com>
Commit-Queue: Heather Miller <hcm@google.com>