Commit Graph

25 Commits

Author SHA1 Message Date
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
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
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
Florin Malita
d7389b003a [canvaskit] Fix for OffscreenCanvas-unaware browsers
Uncaught (in promise) ReferenceError: OffscreenCanvas is not defined
    at Object.a.MakeWebGLCanvasSurface

Change-Id: I896007cd5534cd009a8bc7254078bcf5686c5ff0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/312401
Commit-Queue: Florin Malita <fmalita@chromium.org>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Auto-Submit: Florin Malita <fmalita@chromium.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-08-21 14:15:30 +00:00
Kevin Lubick
204c3be1cd [canvaskit] Remove fringe EGL dependency.
This removes about 5 kb of wasm code size (2 kb gzipped),
20 kb of js code size (4kb gzipped).
I think I can remove getproc (which is a somewhat large
function made up of a lot of string data) with some clever
adjustments of macros in a follow-on CL.

Change-Id: If3a4b30681e13abddea8e84d62297e90316ed7cf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/311817
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2020-08-20 14:55:50 +00:00
Elliot Evans
683bbe01ff Modify CanvasKit to work in a Web Worker and add a demo of it in action.
In this CL:
- Modify modules/canvaskit/gpu.js to support the use of OffscreenCanvas.
- Add a CanvasKit demos.skia.org demo for CanvasKit in a Web Worker.

Change-Id: I8c26bd94f2aa5b3c09cf149b056b910b0e4cd602
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304320
Reviewed-by: Elliot Evans <elliotevans@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Nathaniel Nifong <nifong@google.com>
Commit-Queue: Elliot Evans <elliotevans@google.com>
2020-07-21 22:21:06 +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
Bryce Thomas
9331ca0704 CanvasKit: implement client-supplied dirty rect support for software surface.
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>
2020-06-01 12:05:08 +00:00
Chris Dalton
062d2d9a5d Bump default GrResourceCache size to 256MB
Consider rendering an SkPicture to a 1080p, 4x msaa render target:

  1920 * 1080 * (4 color bytes + 1 stencil byte) * 4 samples = 40Mb!

But SkCanvas::drawPicture calls saveLayer, which allocates a duplicate
render target:

  40Mb * 2 = 80Mb!!

So with the original 96MB, a quite conservative msaa render target
almost blows out the entire resource cache just on the backing. This
CL bumps up the default cache size to 256MB.

Change-Id: I756c62f4ee6b9c62b1a3e535f31e15a1ecc3d63f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292265
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2020-05-27 20:38:08 +00:00
Nathaniel Nifong
b1ebbb19bc Wide color gamut support and working example.
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
2020-05-26 20:13:33 +00:00
Chris Dalton
38e33df982 Disable WebGL antialias in CanvasKit
We were accidentally turning on MSAA via the "antialias" context attrib,
then feeding the render target into Ganesh and saying it was non-MSAA.

This will cause rendering artifacts in Ganesh if MSAA is unknowingly
enabled when we try to do coverage-based AA.

Also, the WebGL spec does not give us control over the exact sample
count or even guarantee that "antialias" means MSAA, so I think it's
best to leave that flag disabled by default. If a client wants MSAA,
they can create their own offscreen surface and blit it into the main
canvas.

Change-Id: I45f1596bfe9258963cff4b5d0a3921c5ba43145f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291029
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-05-21 22:19:05 +00:00
Nathaniel Nifong
67e21a1925 Revert "Wide color gamut support and working example."
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>
2020-05-21 20:22:08 +00:00
Nathaniel Nifong
3d52abc846 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>
2020-05-21 19:26:11 +00:00
Kevin Lubick
e70af51c1a [canvaskit] Properly fix Safari (detect if WebGL2 is not available)
I believe we had incorrectly been using the wrong emscripten-provided
helper to make our WebGL contexts. Thus, the parameter that was
specifying webGL 1 vs 2 was not getting properly passed in
(I believe because of a closure-induced problem in minification).

I validated this build on my local Mac+Safari test harness.

Bug: skia:10171
Change-Id: Ifd5e55a6b64407bf84168e118d8dda4738ef5487
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289885
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2020-05-14 19:15:25 +00:00
Kevin Lubick
5766e3bd11 [canvaskit] Set Safari to webl 1
Bug: skia:10171
Change-Id: I2015a617338d975360fc228f4a061bba401eeb8c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285656
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2020-04-27 14:24:24 +00:00
Kevin Lubick
1496758da4 [canvaskit] Request an 8 bit stencil buffer from the WebGL 1/2 context
We hadn't been requesting one, but told Skia we had one, which caused
issues.

Bug: skia:9564
Change-Id: I9a2e78a528778a386225cdcbbb2d2b3d8f705f05
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254801
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-11-15 17:21:48 +00:00
Kevin Lubick
f6a9d20e95 [canvaskit] Fix null dereference when GrContext cannot be made
This happens when validation fails, for example.

Change-Id: Idbd552fbce51c5cf1543fc7a0a34a87230264d6e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/253658
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2019-11-08 14:58:04 +00:00
Hal Canary
e054d3cf3d CanvasKit: Switch to WebGL 2.0
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Debian9-EMCC-GCE-GPU-AVX2-wasm-Release-All-CanvasKit,Test-Debian9-EMCC-GCE-CPU-AVX2-wasm-Release-All-CanvasKit

Bug: skia:9052
Change-Id: I444031276aea90d82f289b16ba6cd36de5192abd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248927
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2019-10-16 18:45:46 +00:00
Kevin Lubick
c7755d9470 [canvaskit] Bump GPU resource cache to 256MB
Wrong file was previously edited.

Change-Id: I2e78d102ca85a22268481d1958b983e41d72ee3e
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206271
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-05 18:06:18 +00:00
Florin Malita
e797dfba63 Revert "[canvaskit] Bump GPU resource cache to 256MB"
This reverts commit a93aa74a39.

Reason for revert: Busted skottie.skia.org

Original change's description:
> [canvaskit] Bump GPU resource cache to 256MB
> 
> Bug: skia:
> Change-Id: I398ef2e79076018f3f62e62a2040052eeaf60784
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206066
> Commit-Queue: Florin Malita <fmalita@chromium.org>
> Reviewed-by: Kevin Lubick <kjlubick@google.com>

TBR=kjlubick@google.com,fmalita@chromium.org

Change-Id: I0e6181a6ded0adc40531f936fc495f89400516a1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206077
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-04-04 16:53:41 +00:00
Florin Malita
a93aa74a39 [canvaskit] Bump GPU resource cache to 256MB
Bug: skia:
Change-Id: I398ef2e79076018f3f62e62a2040052eeaf60784
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206066
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2019-04-04 15:49:01 +00:00
Kevin Lubick
cd54466473 Expose gpu cache knobs
Change-Id: I5911593812ebf6fd235c6a3fc2acfa740c7687aa
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/203164
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-25 11:48:25 +00:00
Kevin Lubick
359a7e305c [canvaskit] Add requestAnimationFrame to SkSurface
Bug: skia:
Change-Id: I8a15c10d0d8f20098d0e5357ffd602db97c50c84
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201986
Reviewed-by: Mike Reed <reed@google.com>
2019-03-20 14:42:35 +00:00
Kevin Lubick
832787ac6c [canvaskit] Fallback to CPU more gracefully
This should also trim down code size since WebGL should never want
GrGLMakeAssembledGLInterface only GrGLMakeAssembledGLESInterface

Bug: skia:
Change-Id: I9246d467847eeb91517c56075077b3e26c4ee336
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201223
Reviewed-by: Nathaniel Nifong <nifong@google.com>
2019-03-14 20:25:25 +00:00
Kevin Lubick
3f67f411d8 [canvaskit] Move from experimental to modules
Bug: skia:
Change-Id: I2ffd54cf81c974f3a80103e1726a06067cc90d82
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/200044
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2019-03-11 21:09:52 +00:00