diff --git a/experimental/canvaskit/CHANGELOG.md b/experimental/canvaskit/CHANGELOG.md index 7922db0249..984d428f7e 100644 --- a/experimental/canvaskit/CHANGELOG.md +++ b/experimental/canvaskit/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add Canvas2D JS layer. This mirrors the HTML Canvas API. This may be omitted at compile time it by adding `no_canvas` to the `compile.sh` invocation. - `CanvasKit.FontMgr.DefaultRef()` and `fontmgr.MakeTypefaceFromData` to load fonts. +- Exposed `SkPath.setVolatile`. Some animations see performance improvements by setting +their paths' volatility to true. ### Fixed - `SkPath.addRect` now correctly draws counter-clockwise vs clockwise. diff --git a/experimental/canvaskit/canvaskit/example.html b/experimental/canvaskit/canvaskit/example.html index 9650130807..85b9211325 100644 --- a/experimental/canvaskit/canvaskit/example.html +++ b/experimental/canvaskit/canvaskit/example.html @@ -175,6 +175,9 @@ function drawFrame() { const path = starPath(CanvasKit, X, Y); + // Some animations see performance improvements by marking their + // paths as volatile. + path.setIsVolatile(true); CanvasKit.setCurrentContext(context); const dpe = CanvasKit.MakeSkDashPathEffect([15, 5, 5, 10], i/5); i++; diff --git a/experimental/canvaskit/canvaskit_bindings.cpp b/experimental/canvaskit/canvaskit_bindings.cpp index 0fe3d33fcc..02616e7d0f 100644 --- a/experimental/canvaskit/canvaskit_bindings.cpp +++ b/experimental/canvaskit/canvaskit_bindings.cpp @@ -779,9 +779,11 @@ EMSCRIPTEN_BINDINGS(Skia) { .function("_cubicTo", &ApplyCubicTo) .function("getPoint", &SkPath::getPoint) .function("isEmpty", &SkPath::isEmpty) + .function("isVolatile", &SkPath::isVolatile) .function("_lineTo", &ApplyLineTo) .function("_moveTo", &ApplyMoveTo) .function("_quadTo", &ApplyQuadTo) + .function("setIsVolatile", &SkPath::setIsVolatile) .function("_transform", select_overload(&ApplyTransform)) // PathEffects diff --git a/experimental/canvaskit/externs.js b/experimental/canvaskit/externs.js index 3280cb3488..57a4306786 100644 --- a/experimental/canvaskit/externs.js +++ b/experimental/canvaskit/externs.js @@ -174,7 +174,9 @@ var CanvasKit = { getFillType: function() {}, getPoint: function() {}, isEmpty: function() {}, + isVolatile: function() {}, setFillType: function() {}, + setIsVolatile: function() {}, toSVGString: function() {}, // private API