[canvaskit] Exposed SkPath::arc. Exposed SkEncodedImageFormat enum. Exposed SkImage::encodeToData overload with arguments
These changes expose the arc function for SkPath. The ApplyAddArc function is a copy from the PathKit bindings.
Also exposed the PNG and JPEG formats from the SkEncodedImageFormat enum and the SkImage::encodeToData overload that accepts format and quality options. The direct binding of encodeToData was replaced with a pre-js wrapper that calls the appropriate private overload
We are working on a PostCSS conic gradient polyfill plugin and want to use the CanvasKit to generate it.
Problem is - it lacks the arc function that technically exists but isn't exposed. And it would be really great to have encodeToData with options since generated PNGs are quite large.
More details on the issue can be found here: https://github.com/jonathantneal/postcss-conic-gradient/issues/10
R=kjlubick@google.com
Bug: skia:
Change-Id: I3f1dc88ad308369fe62004080bcc196c4fbbf742
Reviewed-on: https://skia-review.googlesource.com/c/171046
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
diff --git a/experimental/canvaskit/externs.js b/experimental/canvaskit/externs.js
index 4ced26d..b1b8cc2 100644
--- a/experimental/canvaskit/externs.js
+++ b/experimental/canvaskit/externs.js
@@ -85,7 +85,9 @@
},
SkImage: {
- encodeToData: function() {},
+ // private API
+ _encodeToData: function() {},
+ _encodeToDataWithFormat: function() {},
},
SkPath: {
@@ -93,6 +95,7 @@
// private API
_addPath: function() {},
+ _arc: function() {},
_arcTo: function() {},
_close: function() {},
_conicTo: function() {},
@@ -174,6 +177,11 @@
INVERSE_EVENODD: {},
},
+ ImageFormat: {
+ PNG: {},
+ JPEG: {},
+ },
+
// Things Enscriptem adds for us
/** Represents the heap of the WASM code
@@ -206,6 +214,7 @@
// It's not enough to declare them above, because closure can still erase them
// unless they go on the prototype.
CanvasKit.SkPath.prototype.addPath = function() {};
+CanvasKit.SkPath.prototype.arc = function() {};
CanvasKit.SkPath.prototype.arcTo = function() {};
CanvasKit.SkPath.prototype.close = function() {};
CanvasKit.SkPath.prototype.conicTo = function() {};
@@ -226,6 +235,8 @@
CanvasKit.SkVertices.prototype.applyBones = function() {};
+CanvasKit.SkImage.prototype.encodeToData = function() {};
+
// Define StrokeOpts object
var StrokeOpts = {};
StrokeOpts.prototype.width;