[canvaskit] Make transforms work properly
This re-works the subpath model and does transforming
of ports in JS rather than in C++; the latter was not easy
to conform to the Canvas Spec, especially for changing
transforms in the middle of a path.
Additionally adds jpeg to the available images it can produce.
Bug: skia:
Change-Id: I5a52ec341d4060198c8680aa4d3b85a26f77b6b9
Reviewed-on: https://skia-review.googlesource.com/c/172500
Reviewed-by: Kevin Lubick <kjlubick@google.com>
diff --git a/experimental/canvaskit/externs.js b/experimental/canvaskit/externs.js
index 2c60c37..c2758e4 100644
--- a/experimental/canvaskit/externs.js
+++ b/experimental/canvaskit/externs.js
@@ -97,11 +97,52 @@
},
SkMatrix: {
+ identity: function() {},
+ mapPoints: function() {},
+ multiply: function() {},
rotated: function() {},
+ scaled: function() {},
+ skewed: function() {},
+ translated: function() {},
+ },
+
+ SkPaint: {
+ // public API (from C++ bindings)
+ /** @return {CanvasKit.SkPaint} */
+ copy: function() {},
+ getStrokeCap: function() {},
+ getStrokeJoin: function() {},
+ getStrokeMiter: function() {},
+ getStrokeWidth: function() {},
+ getTextSize: function() {},
+ measureText: function() {},
+ setAntiAlias: function() {},
+ setColor: function() {},
+ setPathEffect: function() {},
+ setShader: function() {},
+ setStrokeCap: function() {},
+ setStrokeJoin: function() {},
+ setStrokeMiter: function() {},
+ setStrokeWidth: function() {},
+ setStyle: function() {},
+ setTextSize: function() {},
+
+ //private API
+ delete: function() {},
},
SkPath: {
// public API (from C++ bindings)
+ computeTightBounds: function() {},
+ /** @return {CanvasKit.SkPath} */
+ copy: function() {},
+ countPoints: function() {},
+ equals: function() {},
+ getBounds: function() {},
+ getFillType: function() {},
+ getPoint: function() {},
+ setFillType: function() {},
+ toSVGString: function() {},
// private API
_addArc: function() {},
@@ -123,23 +164,8 @@
_transform: function() {},
_trim: function() {},
delete: function() {},
- },
-
- SkPaint: {
- // public API (from C++ bindings)
- /** @return {CanvasKit.SkPaint} */
- copy: function() {},
- measureText: function() {},
- setAntiAlias: function() {},
- setColor: function() {},
- setPathEffect: function() {},
- setShader: function() {},
- setStrokeWidth: function() {},
- setStyle: function() {},
- setTextSize: function() {},
-
- //private API
- delete: function() {},
+ dump: function() {},
+ dumpHex: function() {},
},
SkRect: {
@@ -176,11 +202,6 @@
// Constants and Enums
gpu: {},
skottie: {},
- PaintStyle: {
- Fill: {},
- Stroke: {},
- StrokeAndFill: {},
- },
FillType: {
Winding: {},
@@ -194,6 +215,24 @@
JPEG: {},
},
+ PaintStyle: {
+ Fill: {},
+ Stroke: {},
+ StrokeAndFill: {},
+ },
+
+ StrokeCap: {
+ Butt: {},
+ Round: {},
+ Square: {},
+ },
+
+ StrokeJoin: {
+ Miter: {},
+ Round: {},
+ Bevel: {},
+ },
+
// Things Enscriptem adds for us
/** Represents the heap of the WASM code
@@ -258,5 +297,38 @@
StrokeOpts.prototype.cap;
StrokeOpts.prototype.join;
+var HTMLCanvas = {};
+HTMLCanvas.prototype.getContext = function() {};
+HTMLCanvas.prototype.toDataURL = function() {};
+HTMLCanvas.prototype.dispose = function() {};
+
+var CanvasRenderingContext2D = {};
+CanvasRenderingContext2D.prototype.addHitRegion = function() {};
+CanvasRenderingContext2D.prototype.arc = function() {};
+CanvasRenderingContext2D.prototype.arcTo = function() {};
+CanvasRenderingContext2D.prototype.beginPath = function() {};
+CanvasRenderingContext2D.prototype.bezierCurveTo = function() {};
+CanvasRenderingContext2D.prototype.clearHitRegions = function() {};
+CanvasRenderingContext2D.prototype.closePath = function() {};
+CanvasRenderingContext2D.prototype.drawFocusIfNeeded = function() {};
+CanvasRenderingContext2D.prototype.ellipse = function() {};
+CanvasRenderingContext2D.prototype.fillText = function() {};
+CanvasRenderingContext2D.prototype.lineTo = function() {};
+CanvasRenderingContext2D.prototype.measureText = function() {};
+CanvasRenderingContext2D.prototype.moveTo = function() {};
+CanvasRenderingContext2D.prototype.quadraticCurveTo = function() {};
+CanvasRenderingContext2D.prototype.rect = function() {};
+CanvasRenderingContext2D.prototype.removeHitRegion = function() {};
+CanvasRenderingContext2D.prototype.resetTransform = function() {};
+CanvasRenderingContext2D.prototype.rotate = function() {};
+CanvasRenderingContext2D.prototype.scale = function() {};
+CanvasRenderingContext2D.prototype.scrollPathIntoView = function() {};
+CanvasRenderingContext2D.prototype.setTransform = function() {};
+CanvasRenderingContext2D.prototype.stroke = function() {};
+CanvasRenderingContext2D.prototype.strokeText = function() {};
+CanvasRenderingContext2D.prototype.transform = function() {};
+CanvasRenderingContext2D.prototype.translate = function() {};
+
+
// Not sure why this is needed - might be a bug in emsdk that this isn't properly declared.
function loadWebAssemblyModule() {};