[canvaskit] Expose setVolatile (especially for animations)

Bug: skia:
Change-Id: Ifd8ef390d1b9a102baaa89804b9f6d11e8f39955
Reviewed-on: https://skia-review.googlesource.com/c/177882
Reviewed-by: Kevin Lubick <kjlubick@google.com>
This commit is contained in:
Kevin Lubick 2018-12-14 16:10:38 -05:00
parent 7cbb7a11ab
commit 2b79d1ce45
4 changed files with 9 additions and 0 deletions

View File

@ -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.

View File

@ -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++;

View File

@ -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<void(SkPath&, SkScalar, SkScalar, SkScalar, SkScalar, SkScalar, SkScalar, SkScalar, SkScalar, SkScalar)>(&ApplyTransform))
// PathEffects

View File

@ -174,7 +174,9 @@ var CanvasKit = {
getFillType: function() {},
getPoint: function() {},
isEmpty: function() {},
isVolatile: function() {},
setFillType: function() {},
setIsVolatile: function() {},
toSVGString: function() {},
// private API