Commit Graph

254 Commits

Author SHA1 Message Date
Kevin Lubick
0676317b1f [canvaskit] Deploy 0.25.0
Change-Id: I1af79766e6e781b8190a3aa266fc7e8eb7d1b0df
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378256
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2021-03-02 12:45:42 +00:00
Kevin Lubick
3b760b6fa8 [canvaskit] Add full build to npm release.
Also rename //modules/canvaskit/canvaskit to //modules/canvaskit/npm_build
to make it more clear the purpose of that folder (what we ship to
npm and stage our builds for local testing).

Bug: skia:11203
Change-Id: I4299ded97d14f4155c36798d60e88a660ce6fe6a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372392
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2021-02-23 14:40:43 +00:00
Kevin Lubick
3dbca47568 [canvaskit] Remove Font.measureText and Font.getWidths
This had been previously deprecated.

Bug: skia:10717
Change-Id: Ic57ed835c13cfa7812099a3ef20ed7ff5aa62f7f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371339
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2021-02-23 14:27:50 +00:00
Kevin Lubick
58605b0466 [canvaskit] Remove ShapedText API.
The Paragraph API is what should be used.

Bug: skia:10717
Change-Id: I135aff09bffae0718045b5c744f8e774e2ee1bce
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371338
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2021-02-23 14:27:50 +00:00
Kevin Lubick
26f4962b3f [canvaskit] Deploy 0.24.0 to npm
Change-Id: I393da195a2754ec3355f031fb6af12de34932620
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372077
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2021-02-18 19:10:54 +00:00
Florin Malita
4f14135f5e [skottie/ck] Expose logs in JS API
Plumb a JS logger object, and forward errors/warnings to its methods:

  onError(err_str, json_node_str)
  onWarning(wrn_str, json_node_str)

Change-Id: I796aeb313c4a693accafe04edf80178b227ab118
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370937
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
2021-02-17 17:57:16 +00:00
Kevin Lubick
8172d16577 [canvaskit] Remove exposition of SkData
Change-Id: I5a7c2e30b2adc4b8947743ac82a800e96a7005b1
Bug: skia:10717
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370879
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2021-02-17 15:47:06 +00:00
Kevin Lubick
a0fea40486 [canvaskit] Deploy 0.23.0
Change-Id: I436340f365f144c0cffc9cfb55af4199f5a4cf12
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366397
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2021-02-04 19:09:15 +00:00
Brian Osman
f2f3d52ad5 Add CanvasKit bindings for SkRuntimeEffect's uniform data
Written to use the exact same names and semantics as particles.

Cq-Include-Trybots: luci.skia.skia.primary:Test-Debian10-EMCC-GCE-CPU-AVX2-wasm-Release-All-CanvasKit,Test-Debian10-EMCC-GCE-GPU-AVX2-wasm-Release-All-CanvasKit
Change-Id: I4031efbce06527a519f1ce8c261f79231554e1ef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365701
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-02-04 17:43:28 +00:00
Kevin Lubick
70b6729a05 [canvaskit] Add error callback for runtime effect constructor
It would otherwise be difficult/tedious/not-backwards-compatible
to return the RuntimeEffect AND the error message.

Change-Id: I9bdbafb653398ccbb72e6e762ec4b6af294f9110
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365483
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
2021-02-03 17:35:23 +00:00
Kevin Lubick
e9e8e5d771 [canvaskit] Replace Postan value array with Float32Array.
Change-Id: Ie0e8a9271ef1b68551473fb9a1bcc9442f063efe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362477
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2021-02-02 15:22:07 +00:00
Kevin Lubick
d62738d094 [canvaskit] Remove deprecated PathMeasure
This will make cleaning up the PosTan value easier.

Change-Id: I13aa12f94c560bf8539aa2edb1f9e13779635692
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362458
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2021-02-02 15:22:07 +00:00
Kevin Lubick
f6040ef2a7 [canvaskit] Remove value_array for vector3
Also removes the size value_objects, which appear unused.

Change-Id: Iecfc05b6c285b981415121943b7b43e2216516cd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362339
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2021-02-02 15:22:07 +00:00
Kevin Lubick
ed96264ad7 [canvaskit] Replace Point value_array with Float32Array
Using value_array (and value_object), while convenient,
adds a measurable overhead. This removes the Point value_object
and replaces it as a return value with Float32Array
(similar to rects). For inputs of a single point, I just
split it into x and y. For inputs with two points, I used
a _scratchFourFloats (formerly _scratchRect) bit of memory.

Two subtle decisions here:
 - Why not use scratch memory for a single point? The cost of
   having one extra param is a small/negligible price to pay
   for less complex code.
 - Why not accept Malloc objects? Again, simplicity. Accommodating
   Malloc would make the code harder to read and require more
   checks. I don't know if anyone wants to have malloced points;
   if they do, we can probably accommodate that.

Change-Id: I1b1c29f62e01c2f1c8c1218f58e3bad642214322
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362097
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2021-02-02 15:22:07 +00:00
Kevin Lubick
3364579f83 [canvaskit] Move matrix helpers to their own file and make optional.
Change-Id: I904a491134d5e3b19de8b7c34dcde30f1fd2487e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362037
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2021-02-01 20:01:07 +00:00
Brian Osman
383168902b Particle refactor: Only have one code string, uniforms, etc.
Leverage the field visitor to temporarily support effects with the old
JSON layout.

See also: https://skia-review.googlesource.com/c/buildbot/+/363784

Change-Id: Ifab128172089fe9e570be96d7067c6c9d25aae9b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363878
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
2021-02-01 19:29:48 +00:00
Mike Reed
99da77ae93 Pass sampling to drawImage
Bug: skia:7650
Change-Id: Ia0e02023ab65267e0be17ee1509c8562fe55d75a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362180
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-01-29 18:53:48 +00:00
Mike Reed
0ab283aaf2 Revert "Hide SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING flag"
This reverts commit 5817fe1069.

Reason for revert: broke GifTest

Original change's description:
> Hide SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING flag
>
> Bug: skia:7650
> Change-Id: I7924efdbbb957c0453c5444796dc31f0b0f7459b
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361437
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Kevin Lubick <kjlubick@google.com>

TBR=kjlubick@google.com,reed@google.com

Change-Id: I1e6dc844b8780b332ef94234bed2e8fbdf60f8cf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:7650
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/362179
Reviewed-by: Mike Reed <reed@google.com>
2021-01-29 17:25:45 +00:00
Mike Reed
5817fe1069 Hide SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING flag
Bug: skia:7650
Change-Id: I7924efdbbb957c0453c5444796dc31f0b0f7459b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361437
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2021-01-29 17:06:48 +00:00
Kevin Lubick
6de1e52d0b [canvaskit] Properly downsample 4x4 matrices.
Also address feedback from Tuesday.

Change-Id: I4497e4112c758a071c834045d20a009397184254
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356837
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2021-01-21 18:14:04 +00:00
Kevin Lubick
cbaea295f5 [canvaskit] Expose getShadowLocalBounds
Bug: skia:11146
Change-Id: Ib08a96c8d0ca0f4ca2b489b3793e45f642cb231f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/353034
Reviewed-by: Yegor Jbanov <yjbanov@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2021-01-13 20:24:26 +00:00
Brian Salomon
4878b3e33c Remove Improved Perlin Noise
Is not used by a major client and can be implemented using runtime
effects for users who want this noise.

Bug: skia:10536
Change-Id: Iaa06e6e1406b808c7f8dc0f76621fecf2becabf5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/352057
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-01-11 15:27:26 +00:00
Kevin Lubick
5779a86072 [canvaskit] Add docs and example for flags
Change-Id: I9ad8a591b9f9dc5c454bfa30405244e49ad6b593
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/350816
Reviewed-by: Yegor Jbanov <yjbanov@google.com>
2021-01-07 16:38:58 +00:00
Kevin Lubick
70019c6085 [canvaskit] Fix bug if webgl context not available
Bug: skia:11107
Change-Id: Ibf697a2c0b471ea79bee1a33d8230086509147ca
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347677
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-12-28 14:47:43 +00:00
Kevin Lubick
81da68af2e [canvaskit] Update to 0.22.0
We also include the CHANGELOG in the release notes.

Change-Id: Icbdedf124c114c2f4be757f408a437fda71c40ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345288
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-12-17 15:10:15 +00:00
Kevin Lubick
2d6334988b [canvaskit] Modify drawImageNine API to handle Filter quality
Bug: skia:11099
Change-Id: Ia019bd5107d5646d6e314876610ecdeb37004e36
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345277
Reviewed-by: Mike Reed <reed@google.com>
2020-12-17 14:58:58 +00:00
Kevin Lubick
72f407636e [canvaskit] Expose sampling variants of drawImage and drawImageRect
Change-Id: I91f40374de1861385bddb977917f2e7a24fb6a27
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345130
Reviewed-by: Mike Reed <reed@google.com>
2020-12-16 21:19:58 +00:00
Kevin Lubick
b9a818471d [canvaskit] Update to 0.21.0
Change-Id: Id093d3026bdb406b66374839820ae44a7696a981
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345096
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-12-16 17:44:47 +00:00
Kevin Lubick
5df97bb89b [canvaskit] Replace core build with profile build in npm
Change-Id: I22cbaf1ee6469444e0a272d8d894ccbccdcbd24c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343997
Reviewed-by: Yegor Jbanov <yjbanov@google.com>
2020-12-14 17:46:02 +00:00
Kevin Lubick
035cd91cfb [canvaskit] Update to emsdk 2.0.10
(also update pathkit).

Bug: skia:11077
Change-Id: I7d06e05ed8f445313bedee055af5ded79c7b40b0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343505
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-12-14 15:27:28 +00:00
Kevin Lubick
652d790355 [canvaskit] Remove filterquality on paint.
Bug: skia:7650
Change-Id: I16c7940b4bc0be100a45ea983e0a684416363976
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343441
Reviewed-by: Mike Reed <reed@google.com>
2020-12-11 20:27:27 +00:00
Kevin Lubick
f7fdf1aa29 [canvaskit] Add API for deleting webgl ctx
Change-Id: I55e70cc1ae6b16d642dd63170e9402bd3c192d5f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343101
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-12-11 12:29:17 +00:00
Kevin Lubick
f3b959c000 [canvaskit] Respect Exif metadata for animated images.
Change-Id: I58a5095ea3314a21d895f34a4b8cab9484c29b1d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340717
Reviewed-by: Leon Scroggins <scroggo@google.com>
2020-12-07 11:10:07 +00:00
Kevin Lubick
e7c1a731ff [canvaskit] Remove 2d point arrays from API.
I kept in an array of Color (Float32Array) because it's very convenient
and not worth the hassle of removing.

Change-Id: I34c430c2b5112b6d073b049a81994e946428f21c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340797
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-12-07 11:09:49 +00:00
Kevin Lubick
658cb7173a [canvaskit] Fix drawPoints to be flattened point array
Bug: skia:11012
Change-Id: I0866f791f6fba82d073b5b5acd37aa8509b6fdef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339836
Reviewed-by: Yegor Jbanov <yjbanov@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-12-02 15:07:57 +00:00
Kevin Lubick
ae0d3ffe6d [canvaskit] Document and tweak MakeImage API
Change-Id: I84b8bc8b84e0b79ea4a8a6b53bb3358e0ec9c138
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335665
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-11-18 17:43:56 +00:00
Kevin Lubick
83bbd7c0ad [canvaskit] Roll to 0.20.0
Change-Id: I5025a5ca8deca45dfe3e222e3bf4b6f047416eb4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334419
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-11-12 15:48:12 +00:00
Kevin Lubick
6df5cd28db [canvaskit] Revert raster change.
Drawing to a Premul Raster Surface and then copying out Unpremul pixels
was 15x slower. Drawing to an Unpremul Raster surface was a little
slower than the previous RasterDirect surface.

Out of an abundance of caution, I'm going back to the way things were.
We can revisit drawing to a Raster surface in the future.

This also adds better error handling to the SkottieFrames test which
thankfully caught this regression.

Bug: skia:10717
Change-Id: Ib8b9d490c92e013c3311adb1d08de5fa0fc0351c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334356
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-11-12 14:49:47 +00:00
Kevin Lubick
59bafeeaa7 [canvaskit] Deprecate measureText
After discussion on https://skia-review.googlesource.com/c/skia/+/334096
we decided to remove this misleading API.

Bug: skia:10480
Change-Id: I3daeb6251d5fed829742cfe39c7cade4f19e5a43
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334101
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-11-11 22:49:10 +00:00
Kevin Lubick
15d7a38b04 [canvaskit] Use Raster instead of RasterDirect for Canvas2D surface
This also refactors some internal names to be more consistent
with the normal naming convention.

Bug: skia:10717
Change-Id: I69a0d95aaca359e121b3ff84002d0b5f7cadb260
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334041
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-11-11 22:48:53 +00:00
Kevin Lubick
a502878308 [canvaskit] Add support for woff2 fonts
Requested by Flutter. This adds about 80k of code size
due in large part to the brotli decoding logic.

This also updates the check_deps error to point at
a doc on how to create a new GOB mirror.

Brotli version is 1.0.9; the latest as of today.

Change-Id: I1580cb2189ff1205a9bffca3d887ff2b98a4042e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333218
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2020-11-10 15:07:26 +00:00
Kevin Lubick
b8123cc877 [canvaskit] Clean up readPixels API on Canvas and Image
This makes both APIs have the same arguments with the two
source coordinates first and all the destination params
(image info, optional buffer, optional rowBytes) after.

Bug: skia:10717
Change-Id: I483e4f33f24e226793db6113d5ba5b1955cd892e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332622
Reviewed-by: Mike Reed <reed@google.com>
2020-11-06 18:22:14 +00:00
Kevin Lubick
c4ab08710d [canvaskit] Add option for readPixels to use pre-malloc'd data
Bug: skia:10565
Change-Id: I777f887794cd0524ced4d65e86bd285a854386e5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331858
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-11-04 14:50:48 +00:00
Kevin Lubick
9fe83916e0 [canvaskit] Add fast pass for saveLayerPaint
Bug: skia:10586
Change-Id: I11c0de6181f73f4388e6b40d6869fce2265f34ea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331361
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Yegor Jbanov <yjbanov@google.com>
2020-11-04 14:49:34 +00:00
Kevin Lubick
e677f4ada0 [canvaskit] Properly expose getLineMetrics
This had previously been incompletely exposed. This does so
properly, by returning a JSArray of JSObjects with the metrics.

I am purposely not exposing fLineMetrics until that is explicitly
requested, as it looks complicated.

Bug: skia:10614
Change-Id: If3a2154e8ee39d8adcf416b4513b33a955c2482f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331359
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Julia Lavrova <jlavrova@google.com>
2020-11-04 14:49:16 +00:00
Kevin Lubick
a8f4c91114 [canvaskit] Expose MakeRasterDirectSurface
This will let clients have faster access to the drawn data
and give them control about calling Canvas2D.putImageData.

Bug: skia:10565
Change-Id: Ia3da7867be3f671ab20fdb182ec758b77c0f63b8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331316
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-11-04 14:10:14 +00:00
Kevin Lubick
162d757c3a [canvaskit] Expose Perlin Noise shaders.
Change-Id: I2515efb06dd1a2b02f71922503462572eea0f346
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327197
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2020-10-15 17:10:00 +00:00
Kevin Lubick
421ba88d15 [canvaskit] Clean up Shader docs/types/names
There should be no functional changes.

I also address some forgotten changes to canvaskit-wasm-tests.ts
from CLs last week.

Bug: skia:10717
Change-Id: If02f60813af0aa42acd637639e40f4d6d0b38bd7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327157
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-10-15 17:09:24 +00:00
Adlai Holler
1a364272be Migrate debugger & canvaskit to GrDirectContext
Change-Id: I57e0b28da89870cd9c7708283b64613368008c54
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327158
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-10-15 16:07:06 +00:00
Kevin Lubick
ffc20c2764 [canvaskit] Clean up some APIs related to Path factories
These were uncovered during the recent documentation fiesta.

This also adds a test for the previously untested
CanvasKit.Path.MakeFromOp API.

Bug: skia:10717
Change-Id: Icd3d31ec0f8d61bd399e76abdbf7b5c6395c4d85
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324626
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-10-09 17:42:47 +00:00
Kevin Lubick
a96e080962 [canvaskit] Attempt to turn off rtti
This removes a little bit of hackery in paragraph bindings
that was needed to work around rtti and virtual methods
and embind.

Bug: skia:10794
Change-Id: I5ed15e805105bed866b9d6ebc0de1f70823d35ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324057
Auto-Submit: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-10-08 20:21:39 +00:00
Kevin Lubick
9eaca48f46 [canvaskit] Update emsdk to 2.0.6
Of note, I had to explicitly export _malloc and _free, since
we use those directly in the binding layer.

Code size change:
 -20k on JS (-1k compressed)
 -21k on WASM (-15k compressed)

Bug: skia:10419, skia:10794
Change-Id: Id7670b6fcbf1524ad3155a863db51eb49aa24811
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323979
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-10-08 16:38:10 +00:00
Kevin Lubick
fc1f96f0f0 [canvaskit] Update npm to 0.19.0
This pushes the big name changes.

Change-Id: I8e2ab1707dc2e78cf03173d96d42691b703c7038
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323887
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-10-08 12:51:59 +00:00
Kevin Lubick
54c1b3dd43 [canvaskit] Remove Sk from nearly all function/type names.
This is a massive breaking change for all existing users of CanvasKit.

It will be (one of the only) changes in 0.19.0 to make the transition
easier.

Suggested reviewing order:
 - index.d.ts (to see type changes). Notice SkPicture still has Sk
   prefix, but no other types do (this felt "right" since Sk is
   part of the name of the type, but I can be swayed on this).
 - canvaskit-wasm-tests.ts
 - tests/*.spec.js
 - interface.js and helper.js
 - html examples
 - markdown files

Change-Id: I3b3d3815df2078f986893df3c70101d6248c117d
Docs-Preview: https://skia.org/?cl=322617
Bug: skia:10717
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/322617
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-10-07 21:01:32 +00:00
Kevin Lubick
98ce8ae8ea [canvaskit] Update to 0.18.1 (including typescript types/docs).
Bug: skia:10717
Change-Id: I97b03b3ceea6ad0a66c6c2471782c9b7ebf274fa
Docs-Preview: https://skia.org/?cl=322577
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/322577
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-10-06 13:10:21 +00:00
Kevin Lubick
750261f41a [canvaskit] Update npm to 0.18.0
0.18.1 should add docs
0.19.0 should remove Sk prefix

Change-Id: I21ef6e0735186bffc215a5855d3d53f405bde0fb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/322318
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-10-05 12:19:56 +00:00
Kevin Lubick
3d00e3a3fc [canvaskit] Flesh out remaining docs for core CanvasKit.
This adds docs or stubs for everything that is on the main CanvasKit
object.

Paragraph, Particles, and Skottie will be their own CLs.

Bug: skia:10717
Change-Id: I0f5027d73b2ac7d127f3a03a8f1aaa15f694ae38
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/321789
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-10-05 11:47:40 +00:00
Kevin Lubick
97440de4b9 [canvaskit] Add docs/types for Canvas.
This is the object with the most APIs by far.

Some APIs are stubbed out temporarily and will be given more
detail in a follow-up CL.

Bug: skia:10717
Change-Id: Iff5d4269303e7102ad79de90f20640918f403ff4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320770
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-10-05 11:46:20 +00:00
Harry Terkelsen
223ffcdff9 Add more paragraph bindings to CanvasKit
Change-Id: Ib02b6504724e4d7cfa197a3508f8c0b84b4135bf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313146
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Yegor Jbanov <yjbanov@google.com>
Auto-Submit: Harry Terkelsen <het@google.com>
2020-10-04 12:56:57 +00:00
Kevin Lubick
7d96c5cdd3 [canvaskit] Fix computeTightBounds
I noticed it was broken and untested when writing docs.

Change-Id: I5254b7bd50fde8a361c72ccbd7380809d31ccc08
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/321464
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-10-02 14:06:24 +00:00
Kevin Lubick
9ecb3abfdf [canvaskit] Add Initial Typescript definitions/types.
Medium-term goal is to contribute to https://github.com/DefinitelyTyped/DefinitelyTyped

Bug: skia:10717
Change-Id: I5941e51cd384778240c5cffd0baad3a2bdb06f2a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320257
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-09-29 21:52:25 +00:00
Kevin Lubick
30793855f3 [canvaskit] Expose Glyph ID APIs
Note: I intend to make shaping.html live in demos.skia.org, but
that is hard to verify it works until the APIs land.

Change-Id: I3af1cf8ded316f616d05ee60198393ed9c9a284f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319130
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-09-25 19:56:20 +00:00
Kevin Lubick
22aa7d7915 [canvaskit] Remove unnecessary ColorTypes
If we have removed any in error, we are happy to add them
back in upon request.

Bug: skia:10717
Change-Id: Ic7be83d6205866e12a9488be83034f15450eb098
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/316842
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-09-15 13:45:34 +00:00
Kevin Lubick
c9bece21e0 [canvaskit] Replace drawAnimatedImage with drawFrameAtImage.
This allows paint to be used (instead of the less-desirable
drawDrawable impl).

Bug: skia:10717
Change-Id: Id132e7b2bc189303e866f66d90f389bc29c02fb8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/316840
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-09-15 13:45:34 +00:00
Kevin Lubick
a1c2117004 [canvaskit] Add drawRect4f as example 'fast path' API
I added 3 tests, one using the drawRect API naively,
one using drawRect with a Malloc'd array, and one using
the drawRect4f.

rough local measurements:
 - [baseline with tip of tree code]: 50ms
 - naive drawRect: 40ms
 - drawRect with malloc: 28ms
 - drawRect4f: 27ms

I also tried the benchmarks locally with taking in paint
as a const reference. I did not see any changes, but that
could just be small sample size. I plan to land the code
as is for now, collect a bit of data in Perf and then try
landing the const reference stuff and see if we get
something measurable.

To aid this, I added in a helper list of tests to only run
some benchmarks easily.

Change-Id: I2d8c5296e93f05be45fc12059955fb9d9e339d83
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/315143
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-09-03 14:53:42 +00:00
Kevin Lubick
f8823b5726 Reland "[canvaskit] Change SkRects to be arrays, not objects."
This is a reland of bdc214a50e

The CPU version of SkottieWasm is timing out for reasons unknown,
but the GPU version is happy. I think we can get rid of the CPU
version of the job since it has been more or less superseded by
the SkottieFrames one (and the latter is more stable).

Original change's description:
> [canvaskit] Change SkRects to be arrays, not objects.
>
> This changes several APIs, so there are lots of breaking
> notes in the Changelog.
>
> This made the "draw 100 colored regions" benchmark about
> 20% faster (1ms -> .8ms).
>
> In theory, rendering should stay the same.
>
> Change-Id: Ib80b15e2d980ad5d568fff4460d2b529766c1b36
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/312491
> Reviewed-by: Nathaniel Nifong <nifong@google.com>

Change-Id: I674aba85ecfb30b72e94cbaf89b2d97bfae3b7a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/315142
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-09-03 14:31:38 +00:00
Kevin Lubick
be72801f29 Reland "[canvaskit] Replace RRect objects with TypedArrays."
This reverts commit 370de72763.

Reason for revert: Unrelated to breakage

Original change's description:
> Revert "[canvaskit] Replace RRect objects with TypedArrays."
> 
> Revert submission 314622
> 
> Reason for revert: breaking wasm bots
> Reverted Changes:
> Ia1ba13814:[canvaskit] Replace RRect objects with TypedArrays...
> Ib80b15e2d:[canvaskit] Change SkRects to be arrays, not objec...
> I790b2d6fc:[canvaskit] Add drawRect4f as example 'fast path' ...
> 
> Change-Id: I3912ffeb446b497e4e03a6260e51cae1e664bd83
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314894
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>

TBR=kjlubick@google.com,michaelludwig@google.com,nifong@google.com

# Not skipping CQ checks because this is a reland.

Change-Id: I9b1e38fd36f635146b3b518142bbc4626007700f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/315141
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-09-03 11:57:24 +00:00
Michael Ludwig
370de72763 Revert "[canvaskit] Replace RRect objects with TypedArrays."
Revert submission 314622

Reason for revert: breaking wasm bots
Reverted Changes:
Ia1ba13814:[canvaskit] Replace RRect objects with TypedArrays...
Ib80b15e2d:[canvaskit] Change SkRects to be arrays, not objec...
I790b2d6fc:[canvaskit] Add drawRect4f as example 'fast path' ...

Change-Id: I3912ffeb446b497e4e03a6260e51cae1e664bd83
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314894
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-09-02 21:21:48 +00:00
Michael Ludwig
1f49ceb404 Revert "[canvaskit] Change SkRects to be arrays, not objects."
Revert submission 314622

Reason for revert: breaking wasm bots
Reverted Changes:
Ia1ba13814:[canvaskit] Replace RRect objects with TypedArrays...
Ib80b15e2d:[canvaskit] Change SkRects to be arrays, not objec...
I790b2d6fc:[canvaskit] Add drawRect4f as example 'fast path' ...

Change-Id: Ie6e4c57ba412ca9ff8e4446b06681b51029da2d6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314893
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-09-02 21:21:36 +00:00
Michael Ludwig
55289ae4c6 Revert "[canvaskit] Add drawRect4f as example 'fast path' API"
Revert submission 314622

Reason for revert: breaking wasm bots
Reverted Changes:
Ia1ba13814:[canvaskit] Replace RRect objects with TypedArrays...
Ib80b15e2d:[canvaskit] Change SkRects to be arrays, not objec...
I790b2d6fc:[canvaskit] Add drawRect4f as example 'fast path' ...

Change-Id: I295791532a2d27bff41f706fa8ed37e0499c27d7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314892
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-09-02 21:21:20 +00:00
Kevin Lubick
2753b12ff5 [canvaskit] Add drawRect4f as example 'fast path' API
I added 3 tests, one using the drawRect API naively,
one using drawRect with a Malloc'd array, and one using
the drawRect4f.

rough local measurements:
 - [baseline with tip of tree code]: 50ms
 - naive drawRect: 40ms
 - drawRect with malloc: 28ms
 - drawRect4f: 27ms

I also tried the benchmarks locally with taking in paint
as a const reference. I did not see any changes, but that
could just be small sample size. I plan to land the code
as is for now, collect a bit of data in Perf and then try
landing the const reference stuff and see if we get
something measurable.

To aid this, I added in a helper list of tests to only run
some benchmarks easily.

Change-Id: I790b2d6fc32c125a4d371768fffb19ab22633d4e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314622
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-09-02 20:10:30 +00:00
Kevin Lubick
bdc214a50e [canvaskit] Change SkRects to be arrays, not objects.
This changes several APIs, so there are lots of breaking
notes in the Changelog.

This made the "draw 100 colored regions" benchmark about
20% faster (1ms -> .8ms).

In theory, rendering should stay the same.

Change-Id: Ib80b15e2d980ad5d568fff4460d2b529766c1b36
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/312491
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-09-02 20:10:30 +00:00
Kevin Lubick
c9498efc8e [canvaskit] Replace RRect objects with TypedArrays.
This is about 2.5x faster.

Will try to do the same for Rects in a followup CL.

Change-Id: Ia1ba1381435f4eee2fcf4f0cc2738e3306edd5f9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/312304
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-09-02 20:10:30 +00:00
Brian Osman
767f444feb SkRuntimeEffect SkSL has a new signature for main()
There is no more 'inout half4 color'. Effects return their output color.
If an effect wants the input color, it must use the (already existing)
approach of sampling a nullptr input shader.

The change is guarded for Chromium (so we can update their runtime color
filters in skia_renderer.cc).

For the GPU backend, FPs can now override usesExplicitReturn to indicate
that their emitCode will generate a return statement. If that's true,
then writeProcessorFunction doesn't inject the automatic return of the
output color, and emitFragProc will *always* wrap that FP in a helper
function, even as a top-level FP. GrSkSLFP opts in to this behavior, so
that the user-supplied return becomes the actual return in the FP's
emitCode.

Adapting the skvm code to this wasn't too bad: It looks fragile (what
happens if there are multiple returns?), but that's not really possible
today, without varying control flow.

Bug: skia:10613

Change-Id: I205b81fd87dd32bab30b6d6d5fc78853485da036
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310756
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-08-25 13:36:28 +00:00
Kevin Lubick
2f9a098439 [canvaskit] Remove getproc when creating WebGL interface
This saves about 15kb of wasm code size (4kb gzipped), 11kb
of JS code size (2kb gzipped) and about 10ms
when creating a new surface (~35ms -> 25ms in a local test).

This also gates the webgl code more strongly (off unless you
really request it), since the headers won't be available
except in an emscripten environment.

Change-Id: I303f6c342c72e7cfe29be241f55ae8f5631a3f75
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311916
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-08-20 14:55:50 +00:00
Kevin Lubick
157577b866 [canvaskit,pathkit] Update to emsdk 2.0
There was a break that was solved by adding -lGL to our link
steps. I discovered a few extra flags to aid in debugging builds
and I've left those in (they aren't too noisy IMO).

This changes the base dockerfile to use the official emscripten one.

Code size delta for full build is +5 kb

For future reference, emsdk decides which "library JS" files to
pull in using a83ba99d60/tools/building.py (L1553)
Those JS files live in src (e.g. a83ba99d60/src/library_html5_webgl.js (L222))
and define functions that the C++ code can call.

I'd like to follow-up on what -lEGL is doing.

Also, since the new image no longer has depot_tools, we need
to make docker/skia-wasm-release/Dockerfile install it.

Change-Id: I5a38e61e5080e9c4cb1e0a7e031509bcb107ff86
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311726
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-08-20 14:55:50 +00:00
Nathaniel Nifong
2000c64e2b Publish version 0.17.3
Change-Id: I08199a86f59e33ed87ee48b879b405f496d03f67
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308166
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Commit-Queue: Nathaniel Nifong <nifong@google.com>
2020-08-05 15:23:05 +00:00
Harry Terkelsen
10f019c506 [CanvasKit] Expose TypefaceFontProvider.
Change-Id: I950a3a4f45b7b4a106299576bc918531054b23f6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307873
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-08-04 20:55:21 +00:00
Nathaniel Nifong
e09b314405 Add ParagraphBuilder.pushPaintStyle to allow text to be colors with paints.
Previously one could not color text with paints, even though TextStyle's foregroundColor and
backgroundColor fields are SkPaints. Canvaskit only exposed these as colors in order to allow
SimpleTextStyle to be a value object that would not have to be deleted by the user.

CanvasKit.Paint is a bound SkPaint. I wanted to allow a user to pass a paint to be used
in a text style without alterting SimpleTextStyle's status as a value-object.

So I've added a new bound method, pushPaintStyle which acts just like pushStyle but allows
a foreground and background paint to be supplied which are used to override the existing paints.

The user is responsible for deleting these paints.

Sorry for the kludgy design, if you have got a more elegant way, I'm open to suggestions.

Change-Id: Ib78464171346fe9f717f6d5b9d9428b1d0278498
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307596
Commit-Queue: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Julia Lavrova <jlavrova@google.com>
2020-08-04 13:23:06 +00:00
Kevin Lubick
ab47abfca3 [canvaskit] Publish 0.17.2
Change-Id: Ia6d3ec1a38498468bb6b30059f94ded0d68800a2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305196
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-07-22 17:15:02 +00:00
Harry Terkelsen
d2093b13c8 Set fCanUseDoLoops = false for WebGL 1.0
Change-Id: Ie55e876638246a444c32b169ed3830cd7b0fbab3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304861
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-07-22 01:27:56 +00:00
Kevin Lubick
ce4587d430 [canvaskit] Update to 0.17.1
These changes were supposed to land yesterday, but I forgot.

Change-Id: I46aca428482f9812c1b025f9735ebe2c0ac02bf1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304602
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-07-21 14:48:20 +00:00
Kevin Lubick
d9926908b5 [canvaskit] Enable some options on npm build
This also makes the effects deserialization available via compile flag.

Change-Id: Ib6692499a619205ac480a8823ce7de12c0a5a723
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303596
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-07-20 14:35:18 +00:00
Kevin Lubick
6249da8a83 [canvaskit] Publish 0.17.0 to npm
Change-Id: I764a1720a44440a9fb8de0c78ebec02808473876
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303922
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-07-20 14:10:45 +00:00
Kevin Lubick
3ba1777ceb [npm] Support npm publish flow
See go/npm-publish and b/160246223

Change-Id: I5a92a19ae6be814ca9a98679cfe39184f7cdb184
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303580
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
2020-07-20 11:29:36 +00:00
Nathaniel Nifong
a237f9ec12 Run both puppeteer tests in a WebGL 1 and 2 configuration.
Change-Id: Iaaef7d1ac96eec1813d3b0340ecabcbec90e3923
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300982
Commit-Queue: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-07-17 20:36:37 +00:00
Nathaniel Nifong
d0c9d0cb7f Replace arcTo with three functions for it's overloads.
I found this to be about 15% faster on a benchmark designed to stress these functions.

https://github.com/flutter/flutter/issues/61305

Change-Id: I9dc2a8396e54c55464bb71562de0c07c853e829c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303024
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Nathaniel Nifong <nifong@google.com>
2020-07-17 19:08:03 +00:00
Nathaniel Nifong
2d7afd4824 fix heap-buffer-overflow by not returning string from reportBackendType
Change-Id: I2dbced29f9d43454e35e3ff9fbbb97d11fef29a2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303623
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Nathaniel Nifong <nifong@google.com>
2020-07-17 16:42:30 +00:00
Nathaniel Nifong
6130d5079d Helper function for camera setup
Change-Id: I839fea29c2e56cfc2a4e4557da3197bf211513eb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/299654
Commit-Queue: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-07-07 00:30:03 +00:00
Kevin Lubick
d9b9e5ec4b [canvaskit] High performance Path APIs
https://skia-review.googlesource.com/c/skia/+/297896 draws
several paths with over 1000 points (one has ~250k) and
was pretty slow. We already had a way to provide a flat(ish)
array of all the verbs, points and weights mushed together
(although that should be cleaned up to prefer taking a 1d
array).

This adds an additional way to provide multiple verbs,
points, (and optionally weights, if conics are used) to CanvasKit.
This makes things dramatically faster because of batch copying
the values between JS and WASM (or using Malloc).

Additionally, the above CL revealed a need to be able to
use a subsection of a Malloc'd array efficiently. Thus,
I added subarray as a method of the Malloc object, which
can be used effectively as a pointer (i.e. no copying).

Change-Id: I2c1d26b25118fb9949e878b1b519d93efcfa5019
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297841
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2020-06-24 12:40:49 +00:00
Elliot Evans
2879619a29 Added CanvasKit.MakeImageFromCanvasImageSource which is useful as an alternative to
CanvasKit.MakeImageFromEncoded, when used with Browser APIs for loading/decoding images.

 - `CanvasKit.MakeImageFromCanvasImageSource` takes either an HTMLImageElement,
   SVGImageElement, HTMLVideoElement, HTMLCanvasElement, ImageBitmap, or OffscreenCanvas and returns
   an SkImage. This function is an alternative to `CanvasKit.MakeImageFromEncoded` for creating
   SkImages when loading and decoding images. In the future, codesize of CanvasKit may be able to be
   reduced by removing image codecs in wasm, if browser APIs for decoding images are used along with
   `CanvasKit.MakeImageFromCanvasImageSource` instead of `CanvasKit.MakeImageFromEncoded`.
-  Three usage examples of `CanvasKit.MakeImageFromCanvasImageSource` in core.spec.ts. These 
   examples use browser APIs to decode images including 2d canvas, bitmaprenderer canvas, 
   HTMLImageElement and Blob.
-  Added support for asynchronous callbacks in perfs and tests.

Here are notes on the image decoding approaches we tested and perfed in the process of finding ways 
to use Browser APIs to decode images:

1. pipeline:
  ArrayBuffer → ImageData → ctx.putImageData →
  context.getImageData → Uint8Array → CanvasKit.MakeImage
 Problem: ImageData constructor expects decoded bytes already.

2. interface.js - CanvasKit.ExperimentalCanvas2DMakeImageFromEncoded (async function)
pipeline:
  ArrayBuffer → Blob -> HTMLImageElement ->
  draw on Canvas2d -> context.getImageData → Uint8Array →
  CanvasKit.MakeImage
 Works
⏱ Performance: 3rd place (in my testing locally)

3. interface.js - CanvasKit.ExperimentalCanvas2DMakeImageFromEncoded2 (async function)
  ArrayBuffer → Blob → ImageBitmap → draw on Canvas2d →
  context.getImageData → Uint8Array → CanvasKit.MakeImage
 Works
⏱ Performance: 2nd place (in my testing locally)

4. interface.js - CanvasKit.ExperimentalCanvas2DMakeImageFromEncoded3 (async function)
  ArrayBuffer → Blob → ImageBitmap →
  draw on canvas 1 using bitmaprenderer context →
  draw canvas 1 on canvas 2 using drawImage → context2d.getImageData →
  Uint8Array → CanvasKit.MakeImage
 Works
⏱ Performance: 1st place (in my testing locally) - quite surprising, this in some ways seems to be a more roundabout way of CanvasKit.ExperimentalCanvas2DMakeImageFromEncoded2, but it seems bitmaprenderer context is fairly fast.

Bug: skia:10360
Change-Id: I6fe94b8196dfd1ad0d8929f04bb1697da537ca18
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295390
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-06-15 19:35:09 +00:00
Kevin Lubick
261333283e [canvaskit] Fix bug with TextStyle color
This updates an existing test and adds a new one to make
sure we don't regress.

Change-Id: If94eb3fb205852750d6fb9483e20c07d88b4da10
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295560
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-06-12 15:40:13 +00:00
Nathaniel Nifong
d05fd0c7d2 Accept Flat Uint32Array, Float32Array, or 2d Float32Array as the color argument to MakeLinearGradient
TODO:
  1. Accept a Color builder or a TypeArray from CanvasKit.Malloc
  2. Apply the same treatment to all other gradient functions, MakeSkVertices, and drawAtlas
Change-Id: I94fa67a3c00d7b1ecdc004af4ffd3193404c1a30
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294707
Commit-Queue: Nathaniel Nifong <nifong@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-06-11 13:51:53 +00:00
Kevin Lubick
a4ae8d0375 [canvaskit] Roll 0.16.2
Change-Id: Ic1e6fe8fb25c84dd333a528d38752b09d132d5d5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294708
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-06-05 21:08:52 +00:00
Kevin Lubick
e7b329e1ee [canvaskit] Fix freeing of memory in computeTonalColors
Change-Id: I82317cf762362a4fb74933d7d7145555d397c850
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294700
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-06-05 20:23:29 +00:00
Kevin Lubick
69e46da716 [canvaskit] Fix infrequent crash in SkFontMgr.FromData
The bug here is very subtle, as is the mitigation.

Quick background on WASM memory, there is an object
called wasmMemory (which might be hoisted into scope for
CanvasKit's pre-js functions), of type WebAssembly.Memory
which is a resizable ArrayBuffer. Emscripten provides the
JS code to initialize this and handle size increases.
Emscripten also provides TypedArray "views" into this buffer.
These are called CanvasKit.HEAPU8, CanvasKit.HEAPF32, etc.

When there is a call to CanvasKit._malloc, wasmMemory may
be resized. If that happens, the previous TypedArray views
become invalid. However, in the same call to _malloc,
emscripten will refresh the views [1]. So, dealing with
CanvasKit.HEAPU8 directly (quick aside, we never expect clients
to mess with these views, only us in our glue JS code
[e.g. interface.js]), should always be safe because if they
were to be invalidated in a call to _malloc, the views would
be refreshed before _malloc continues.

The problem that existed before was when we were passing
CanvasKit.HEAP* as a parameter to a function, in which the
function would call _malloc before using the typed array
parameter:
  //... let us suppose wasmMemory is backed by ArrayBuffer D
  copy1dArray(arr, HEAPU32);
  // The HEAPU32 TypedArray (backed by ArrayBuffer D) is stored
  // to a function parameter "dest"
    function copy1dArray(arr, dest, ptr) {
    // ...
    if (!ptr) {
      ptr = CanvasKit._malloc(arr.length * dest.BYTES_PER_ELEMENT);
      // Suppose _malloc needs to resize wasmMemory and is
      // now backed by ArrayBuffer E.
      // Note: The field CanvasKit.HEAPU32 is correctly backed
      // by ArrayBuffer E, but variable dest still points to a
      // TypedArray backed by ArrayBuffer D.
    }
    // dest.set will fail with a "neutered ArrayBuffer" error
    // because ArrayBuffer D is effectively gone (replaced by E).
    dest.set(arr, ptr / dest.BYTES_PER_ELEMENT);

The fix here is to pass in the field name indicating the TypedArray
view we want to write our data into instead of using the
view itself as the parameter.

[1] e427159553/src/preamble.js (L344)


Change-Id: I46cfb98f8bdf928b61690a5ced034a5961356398
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294516
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-06-05 13:32:46 +00:00
Kevin Lubick
024d42fdd6 [canvaskit] roll v0.16.1
Change-Id: Ieb00340af7b157efbbbba995fd936ce98465d4ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294297
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-06-04 14:39:07 +00:00
Kevin Lubick
9adc1d4f7d [canvaskit] Fix JS representation of Color
Change-Id: I4f7a54a758eb7a3c28970dde58c847a27a9c3f25
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294256
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-06-04 12:43:32 +00:00
Kevin Lubick
625dc60e8b [canvaskit] Publish v0.16.0
Change-Id: I9199c2129ed694e7b6f1a306452bb336a7a39989
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293853
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-06-03 18:14:32 +00:00
Kevin Lubick
93f1a38fb5 [canvaskit] Add flexibility to setColor API
Change-Id: Ib0946bb05bc5cbf485a6687e46c7e61312bcd24c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293344
Reviewed-by: Yegor Jbanov <yjbanov@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-06-03 11:38:54 +00:00