Commit Graph

179 Commits

Author SHA1 Message Date
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