There's some flakes on the _dommatrix test. This adds an extra assertion
to maybe shed some light on that flake.
Change-Id: I548d3294c8f3c620a9702e4d4889da745a2d91fe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293764
Reviewed-by: Kevin Lubick <kjlubick@google.com>
At startup, we allocate a few scratch arrays and then use those
instead of having to malloc and free a bunch of arrays during
runtime.
The benchmark that was added is a bit noisy (probably because
of the garbage collection going on from the created Float32Arrays),
but a few percent faster.
We also don't set the paragraph background/foreground colors to
transparent because we check them being falsey before sending them
over the wire. I noticed that if foreground was transparent black,
no text shows up at all, which was unexpected.
Change-Id: I9f3a590a122d7de222cb5f58ea40e86b2d261c96
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292685
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Surface clients can now specify a dirty rect that will constrain HTML canvas
repaints to a particular region.
Bug: NONE
Change-Id: Ia77d6e864c061297bfc82cfa09030523052ee0e1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293056
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Fix a bug with paragraph text direction that an incorrect unit test wasn't detecting.
Change-Id: I73418ea8a90da097078d93ddf8692a55488f672f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292366
Commit-Queue: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
If ever CanvasKit accepts an array as a parameter, if the array
provided was produced by Malloc, CanvasKit will use the pointer
of that array and not free it after.
Change-Id: I4806a48e5e030edd787944f652984ea3516b3022
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292561
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Fixes release-cpu build issue, un-revert cl 289733
Color space arguments accepted at surface creation, paint, gradient, and other call sites.
Works correctly only when chrome happens to be rendering itself in the same color space
the canvaskit user has chosen, there's not yet end to end color management of
canvases supported in browsers.
readPixels not yet working due to possible chrome bug.
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289733
Commit-Queue: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Change-Id: I65ce1c643dac57e14b8476f598c96b12b7e040ce
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291896
breaks CPU-backed canvaskit build
This reverts commit 3d52abc846.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> Wide color gamut support and working example.
>
> Color space arguments accepted at surface creation, paint, gradient, and other call sites.
> Works correctly only when chrome happens to be rendering itself in the same color space
> the canvaskit user has chosen, there's not yet end to end color management of
> canvases supported in browsers.
>
> readPixels not yet working due to possible chrome bug.
>
> Change-Id: I3dea5b16c60a3871cd2a54f86716f4a438a90135
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289733
> Commit-Queue: Nathaniel Nifong <nifong@google.com>
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
TBR=kjlubick@google.com,brianosman@google.com,nifong@google.com
Change-Id: I2e03155c2512eec6730ecccda19df78174146008
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291339
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Nathaniel Nifong <nifong@google.com>
Color space arguments accepted at surface creation, paint, gradient, and other call sites.
Works correctly only when chrome happens to be rendering itself in the same color space
the canvaskit user has chosen, there's not yet end to end color management of
canvases supported in browsers.
readPixels not yet working due to possible chrome bug.
Change-Id: I3dea5b16c60a3871cd2a54f86716f4a438a90135
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289733
Commit-Queue: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Changes are largely mechanical. Non-mechanical changes to support newer
versions of emscripten are enumerated below, in format ${EMSCRIPTEN_VERSION}:
${RELEVANT_CHANGE}.
- 1.39.9: TOTAL_MEMORY has been renamed INITIAL_MEMORY.
- 1.39.12: passing of linker flags to wasm-ld has changed in a way that requires
supplying `--no-entry` to avoid error message "wasm-ld: error: entry symbol
not defined (pass --no-entry to suppress): main".
- 1.39.16: The factory function created by using `MODULARIZE` build option now
returns a Promise instead of the module instance. As such, the ready.js
workaround is removed. Note this is a breaking API change for CanvasKit,
which now uses just `then()` and not `ready().then()`.
- 1.38.33: `emsdk install` hasn't required the `-64bit` suffix on version names
since `1.38.33`, so we remove them. E.g. `emsdk install sdk-1.39.6-64bit`
simply becomes `emsdk install sdk-1.39.16`.
cf. https://github.com/emscripten-core/emscripten/blob/master/ChangeLog.md
Bug: NONE
Change-Id: Iabec4bd5ad7db2e0715ad42c2e4cf7d67b192b4c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291182
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Change-Id: I2d95c63de18125e6258709b48b03abd7904b7537
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278596
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Adding in the mono rasterizer on freetype adds 12k of code size
(6k compressed), so we make it opt out and don't ship to npm with it.
Bug: skia:10192
Change-Id: I8352adbeaec288800ae1ca4709144860e9a1e84c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288546
Reviewed-by: Ben Wagner <bungeman@google.com>
Will need followups on Vertices and SkSL to use these handles.
Change-Id: If775cb01168f601541e889bfa2421129e505b4a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282416
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This reduces the skm44_concat benchmark from 2us to .35us, a 5x
speedup.
SkCanvas.concat now takes a 3x2, 3x3, or 4x4 matrix and upscales
them all to 4x4. This makes concat44 redundant.
Removes redundant null checks for matrices, since freeing(0)
in WASM is fine like it is in C++.
Change-Id: I44a776ffd0babb81d8a34f9d94ae4d7831d02b55
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281721
Reviewed-by: Mike Reed <reed@google.com>
Would be nice to eventually follow up with test involving camera.
Change-Id: I264d0a0dc3467a971103264df21701c094323b80
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281719
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Note to the reviewer: Look at tests/util.js first and then
look at the others. Gerrit lets you ignore whitespace changes,
which I would recommend for this.
This emulates tests on the C++ side and dramatically reduces
boilerplate on the test code.
This also uses the beforeEach(async () => {}) trick to save
a lot of promise resolutions before each tests.
I try to clean up the style a bit as I go, seriously thinking
about adding eslint for at least the tests.
Change-Id: Iced4abb57f66572035ab5d1a54b374055e8aaa58
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281439
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
This means we take DOMMatrix everywhere now.
This reduced the *_makeShader benchmark by ~25% (4 us -> 3 us)
and cleaned up several callsites.
Trimming this down saves ~3kb in uncompressed code size.
Change-Id: Ie677c7ebb7bc97ed8cd4d4851a039b78b6f8079d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281018
Reviewed-by: Mike Reed <reed@google.com>
This does a head to head comparison for our JS-implemented
SkMatrix (DOMMatrix is tens of times slower) and adds support.
There are a few APIs (e.g. on Canvas) that don't yet support this.
This is because I want to experiment with the speed difference
between SimpleMatrix and emscripten's bindings and us just allocating
an array for the user on the WASM heap.
Change-Id: I47086dd6b40cbd522c6b85e5f9b1a7e819f54f9d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280957
Reviewed-by: Kevin Lubick <kjlubick@google.com>
This is a reland of 4e79b6730d
Original change's description:
> Switch to using a Float32Array (bound as value array) for color.
>
> Change-Id: I1bcca931954b1399c79f4074a3d57a68847ac785
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/276757
> Commit-Queue: Nathaniel Nifong <nifong@google.com>
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
Change-Id: If6b9097b2fcd6b9dbf75c6dd22138e0b2531e70d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278780
Commit-Queue: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
This reverts commit 4e79b6730d.
Reason for revert: Bad canvaskit GM images
Original change's description:
> Switch to using a Float32Array (bound as value array) for color.
>
> Change-Id: I1bcca931954b1399c79f4074a3d57a68847ac785
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/276757
> Commit-Queue: Nathaniel Nifong <nifong@google.com>
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
TBR=kjlubick@google.com,nifong@google.com
Change-Id: I2f5e995ccee415a49f813b5ba61c095acbc445b5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278766
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
For API simplicity, if the rectangle is to be omitted, the client
should only provide the paint. (emscripten already does parameter
count checking, so let's use that instead of doing it ourselves).
This also adds tests to help verify the new behavior.
Revert "Revert "Allow null rect for saveLayer""
This reverts commit 7957d53c80.
Bug: skia:10043
Change-Id: I9ed8caabbfc77deab1ca3d9b1a415489e012528f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277399
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Dan Field <dnfield@google.com>
This also adds a helper option to writing canvas2d spec tests
to see the CanvasKit option side by side with the real canvas
version.
Bug: skia:9940, skia:9947
Change-Id: Ia8fc4e1332d3896933b86291181bc3ba890d26ed
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275618
Reviewed-by: Florin Malita <fmalita@chromium.org>
This is handy for interacting with <input type=color>
Change-Id: I7946c08ef10a2481016885d58cc52f76f5cd40e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272344
Reviewed-by: Kevin Lubick <kjlubick@google.com>
We accidentally were not waiting until all font files were loaded before
trying to process them.
Bug: skia:9858
Change-Id: I10decd5fbf0aa46e300d2ce5255f24f1ac1c12d4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268626
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Adds a test to load different font types. Currently supported:
- .ttf
- .otf
- .ttc
Not supported:
- .woff
- .woff2
This only increases code size by ~4kb, so that big glyph table
has still been successfully removed.
Bug: skia:9829
Change-Id: I0231578b2abf4f36df57ff8073b7697d16606373
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/267180
Reviewed-by: Ben Wagner <bungeman@google.com>
I belatedly realized that drawOnce's test would always be blank now
that drawOnce is async.
Change-Id: If30bbdd895039bd8de050a59dd348ba6849c5835
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266631
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
The existing |SkSurface.requestAnimationFrame| API provides a convenient way of
drawing Skia animations using the same idiom as the well known
|Window.requestAnimationFrame|. It gracefully handles providing the caller with
access to the right canvas, as well as flushing after the user-supplied
callback.
The new |SkSurface.drawOnce| API added in this change provides the same
conveniences around access to the right canvas and flushing, but for the
use-case where the user wishes to draw a single frame only. Importantly, this
new API disposes of the SkSurface upon completion, i.e. frees the memory
associated with the underlying pixel storage an surface. This avoids memory
leaks that occur when |SkSurface.requestAnimationFrame| is used for single-frame
purposes.
Bug: NONE
Change-Id: Ic4e48e65dffc4809513ceaf72260ac0432b98952
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265604
Reviewed-by: Kevin Lubick <kjlubick@google.com>