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>
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>
The only caller is CanvasKit, and SkAnimatedImage already has getBounds
(from SkDrawable) which does the same thing, except it returns
SkScalars. It also takes scaling and cropping into account, which
CanvasKit does not use, and in a future commit, it will consider
orientation. Switch CanvasKit to use getBounds.
Change-Id: Ia956f91d241641aec450f3aba99583e95a3ff386
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333222
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
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>
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>
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>
Also rm extra space in CK binding.
Change-Id: I3ec50d24cf77ed7773bd0f9c7a6a141221ecd063
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323104
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Adds a new helper that creates a GrBackendRenderTarget using
GrGpu and then wraps it in a SkSurface. Uses the SkSurface
release proc to delete the BERT using GrGpu.
Upgrades GrGpu::createTestingOnlyBackendRenderTarget to create MSAA
buffers.
Updates many tests/tool to call sites to use the helper instead of
SkSurface::MakeFromBackendTextureAsRenderTarget.
Adds syncToCpu bool to SkSurface:: and GrContext::flushAndSubmit.
Bug: skia:9832
Change-Id: I73a8f0ce09dc6523729af0814464c6b6657fda06
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293683
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
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>
Paragraph will be its own CL.
Bug: skia:10717
Change-Id: I5c0d0ff40b500ec8f8eb74e7a44402a9e9548f8e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/321519
Reviewed-by: Kevin Lubick <kjlubick@google.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Note: The polarity of the staging flag is inverted from usual because
a G3 dependency with no SkUserConfig.h relies on the legacy API.
Once this lands, we will migrate them and others, then remove the
staging API. The inverted staging flag is kind of nice, actually - I may
use that pattern in the future. It means less total CLs and it's just as
easy to flip the bit on or off during debugging.
Bug: skia:104662
Change-Id: I48cba1eeae3e2e6f79918c6d243e0666e68ec71b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310656
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
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>
This allows users to create their context with {antialias: true} and
*hope* for MSAA. This CL also updates viewer.html achieve MSAA with this
method, and if the browser doesn't give an MSAA, we simply abort.
Change-Id: Ia242d266123c4b08f15a357e1fedc449642d88d3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297597
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
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>
CanvasKit converts 4 floats to an int, just to have it be
converted back into 4 floats when it goes into the paint.
Change-Id: I93cf1c596283b83cc9452fb205b7000ceed09bb9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/293538
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Mike Reed <reed@google.com>