From 6066a0c2bd7417dff7df24e9616418a1bf1c168f Mon Sep 17 00:00:00 2001 From: Nathaniel Nifong Date: Thu, 5 Mar 2020 10:27:14 -0500 Subject: [PATCH] Remove all uses of bones Change-Id: I302f43484c599a05e077545df5f053a89d63a6a6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275079 Commit-Queue: Nathaniel Nifong Reviewed-by: Kevin Lubick --- modules/canvaskit/canvaskit/example.html | 74 - modules/canvaskit/canvaskit/extra.html | 1 - modules/canvaskit/externs.js | 1579 +++++++++++----------- 3 files changed, 783 insertions(+), 871 deletions(-) diff --git a/modules/canvaskit/canvaskit/example.html b/modules/canvaskit/canvaskit/example.html index 09d5e79904..d52b74fed7 100644 --- a/modules/canvaskit/canvaskit/example.html +++ b/modules/canvaskit/canvaskit/example.html @@ -33,7 +33,6 @@

CanvasKit expands the functionality of a stock HTML canvas

- @@ -55,7 +54,6 @@ var robotoData = null; var notoserifData = null; - var bonesImageData = null; var mandrillData = null; var cdn = 'https://storage.googleapis.com/skia-cdn/misc/'; CanvasKitInit({ @@ -76,7 +74,6 @@ CanvasAPI8(CanvasKit); VertexAPI1(CanvasKit); - VertexAPI2(CanvasKit, bonesImageData); GradiantAPI1(CanvasKit); @@ -89,13 +86,6 @@ AtlasAPI1(CanvasKit, mandrillData); }); - fetch(cdn + 'bones.jpg').then((resp) => { - resp.arrayBuffer().then((buffer) => { - bonesImageData = buffer; - VertexAPI2(CanvasKit, bonesImageData); - }); - }); - fetch(cdn + 'Roboto-Regular.ttf').then((resp) => { resp.arrayBuffer().then((buffer) => { robotoData = buffer; @@ -894,70 +884,6 @@ surface.delete(); } - // bonesImageData is passed in as raw, encoded bytes. - function VertexAPI2(CanvasKit, bonesImageData) { - if (!CanvasKit || !bonesImageData) { - return; - } - const surface = CanvasKit.MakeCanvasSurface('vertex2'); - if (!surface) { - console.error('Could not make surface'); - return; - } - let paint = new CanvasKit.SkPaint(); - let bonesImage = CanvasKit.MakeImageFromEncoded(bonesImageData); - - let shader = bonesImage.makeShader(CanvasKit.TileMode.Clamp, - CanvasKit.TileMode.Clamp); - - // comment this out to see just the triangles move. - paint.setShader(shader); - - // points is the destination location on the canvas We want the output - // to be a 280x280 box (to start). - let points = [[ 0, 0 ], [ 280, 0 ], [ 280, 280 ], [ 0, 280 ]]; - // texs is the coordinates of the source in the texture - // (provided by the image shader). The image is 334x226 px big. - let texs = [[ 0, 0 ], [ 334, 0 ], [ 334, 226 ], [ 0, 226 ]]; - let boneidxs = [[1,0,0,0], [2,0,0,0], [3,0,0,0], [2,3,0,0]]; - let bonewts = [[1,0,0,0], [1,0,0,0], [1,0,0,0], [.5,.5,0,0]]; - let vertices = CanvasKit.MakeSkVertices(CanvasKit.VertexMode.TriangleFan, - points, texs, null, boneidxs, bonewts); - - function drawFrame(canvas) { - let now = Date.now(); - let bones = [ - [[1,0, // world bone (move 10px down and to the right to center) - 0,1, - 10,10]], - [[1,0, // identity bone (bone for vertices that are static) - 0,1, - 0,0]], - [[1,0, // ossilate in x bone - 0,1, - 10*Math.sin(now/500),0]], - [[1,0, // ossilate in y bone - 0,1, - 0,30*Math.cos(now/500)]], - ]; - let tVerts = vertices.applyBones(bones); - canvas.clear(CanvasKit.TRANSPARENT); - canvas.drawVertices(tVerts, CanvasKit.BlendMode.Src, paint); - - tVerts.delete(); - surface.requestAnimationFrame(drawFrame); - } - surface.requestAnimationFrame(drawFrame); - //tVerts.delete(); - //vertices.delete(); - - // bonesImage && bonesImage.delete(); - //shader && shader.delete(); - //paint.delete(); - //surface.delete(); - - } - function GradiantAPI1(CanvasKit) { const surface = CanvasKit.MakeSWCanvasSurface('gradient1'); if (!surface) { diff --git a/modules/canvaskit/canvaskit/extra.html b/modules/canvaskit/canvaskit/extra.html index d984b60cb8..28c7651025 100644 --- a/modules/canvaskit/canvaskit/extra.html +++ b/modules/canvaskit/canvaskit/extra.html @@ -51,7 +51,6 @@ var robotoData = null; var notoserifData = null; - var bonesImageData = null; var flightAnimGif = null; var skpData = null; var cdn = 'https://storage.googleapis.com/skia-cdn/misc/'; diff --git a/modules/canvaskit/externs.js b/modules/canvaskit/externs.js index 4be2d7dce0..717084d72c 100644 --- a/modules/canvaskit/externs.js +++ b/modules/canvaskit/externs.js @@ -23,787 +23,777 @@ */ var CanvasKit = { - // public API (i.e. things we declare in the pre-js file or in the cpp bindings) - Color: function() {}, - /** @return {CanvasKit.SkRect} */ - LTRBRect: function() {}, - /** @return {CanvasKit.SkRect} */ - XYWHRect: function() {}, - /** @return {CanvasKit.SkRRect} */ - RRectXY: function() {}, - /** @return {ImageData} */ - ImageData: function() {}, - - GetWebGLContext: function() {}, - MakeBlurMaskFilter: function() {}, - MakeCanvas: function() {}, - MakeCanvasSurface: function() {}, - MakeGrContext: function() {}, - /** @return {CanvasKit.SkAnimatedImage} */ - MakeAnimatedImageFromEncoded: function() {}, - /** @return {CanvasKit.SkImage} */ - MakeImage: function() {}, - /** @return {CanvasKit.SkImage} */ - MakeImageFromEncoded: function() {}, - /** @return {LinearCanvasGradient} */ - MakeLinearGradientShader: function() {}, - MakeOnScreenGLSurface: function() {}, - MakePathFromCmds: function() {}, - MakePathFromOp: function() {}, - MakePathFromSVGString: function() {}, - MakeRadialGradientShader: function() {}, - MakeRenderTarget: function() {}, - MakeSkPicture: function() {}, - MakeSWCanvasSurface: function() {}, - MakeManagedAnimation: function() {}, - MakeParticles: function() {}, - MakeSkDashPathEffect: function() {}, - MakeSkVertices: function() {}, - MakeSurface: function() {}, - /** @return {RadialCanvasGradient} */ - MakeTwoPointConicalGradientShader: function() {}, - MakeWebGLCanvasSurface: function() {}, - /** @return {TypedArray} */ - Malloc: function() {}, - /** @return {TonalColors} */ - computeTonalColors: function() {}, - currentContext: function() {}, - getColorComponents: function() {}, - getDecodeCacheLimitBytes: function() {}, - getDecodeCacheUsageBytes: function() {}, - getSkDataBytes: function() {}, - multiplyByAlpha: function() {}, - parseColorString: function() {}, - setCurrentContext: function() {}, - setDecodeCacheLimitBytes: function() {}, - - // private API (i.e. things declared in the bindings that we use - // in the pre-js file) - _MakeImage: function() {}, - _MakeLinearGradientShader: function() {}, - _MakePathFromCmds: function() {}, - _MakeRadialGradientShader: function() {}, - _MakeManagedAnimation: function() {}, - _MakeParticles: function() {}, - _MakeSkDashPathEffect: function() {}, - _MakeSkPicture: function() {}, - _MakeSkVertices: function() {}, - _MakeTwoPointConicalGradientShader: function() {}, - _decodeAnimatedImage: function() {}, - _decodeImage: function() {}, - _drawShapedText: function() {}, - _getRasterDirectSurface: function() {}, - _getRasterN32PremulSurface: function() {}, - - // The testing object is meant to expose internal functions - // for more fine-grained testing, e.g. parseColor - _testing: {}, - - // Objects and properties on CanvasKit - - GrContext: { - // public API (from C++ bindings) - getResourceCacheLimitBytes: function() {}, - getResourceCacheUsageBytes: function() {}, - releaseResourcesAndAbandonContext: function() {}, - setResourceCacheLimitBytes: function() {}, - }, - - Paragraph: { - // public API (from C++ bindings) - didExceedMaxLines: function() {}, - getAlphabeticBaseline: function() {}, - getGlyphPositionAtCoordinate: function() {}, - getHeight: function() {}, - getIdeographicBaseline: function() {}, - getLongestLine: function() {}, - getMaxIntrinsicWidth: function() {}, - getMaxWidth: function() {}, - getMinIntrinsicWidth: function() {}, - getWordBoundary: function() {}, - layout: function() {}, - - // private API - /** @return {Float32Array} */ - _getRectsForRange: function() {}, - }, - - SkRuntimeEffect: { - // public API (from C++ bindings) - Make: function() {}, - - // private API - _makeShader: function() {}, - _makeShaderWithChildren: function() {}, - }, - - ParagraphStyle: function() {}, - RSXFormBuilder: function() {}, - SkColorBuilder: function() {}, - SkRectBuilder: function() {}, - - ShapedText: { - // public API (from C++ bindings) - getBounds: function() {}, - }, - - SkAnimatedImage: { - // public API (from C++ bindings) - decodeNextFrame: function() {}, - getFrameCount: function() {}, - getRepetitionCount: function() {}, - height: function() {}, - reset: function() {}, - width: function() {}, - }, - - SkCanvas: { - // public API (from C++ bindings) - clear: function() {}, - clipPath: function() {}, - clipRRect: function() {}, - clipRect: function() {}, - concat: function() {}, - drawAnimatedImage: function() {}, - drawArc: function() {}, - drawCircle: function() {}, - drawColor: function() {}, - drawDRRect: function() {}, - drawImage: function() {}, - drawImageNine: function() {}, - drawImageRect: function() {}, - drawLine: function() {}, - drawOval: function() {}, - drawPaint: function() {}, - drawParagraph: function() {}, - drawPath: function() {}, - drawPicture: function() {}, - drawRRect: function() {}, - drawRect: function() {}, - drawRoundRect: function() {}, - drawShadow: function() {}, - drawText: function() {}, - drawTextBlob: function() {}, - drawVertices: function() {}, - flush: function() {}, - getSaveCount: function() {}, - getTotalMatrix: function() {}, - makeSurface: function() {}, - restore: function() {}, - restoreToCount: function() {}, - rotate: function() {}, - save: function() {}, - saveLayer: function() {}, - scale: function() {}, - skew: function() {}, - translate: function() {}, - - // private API - _drawAtlas: function() {}, - _drawPoints: function() {}, - _drawSimpleText: function() {}, - _readPixels: function() {}, - _writePixels: function() {}, - delete: function() {}, - }, - - SkColorFilter: { - // public API (from C++ bindings and JS interface) - MakeBlend: function() {}, - MakeCompose: function() {}, - MakeLerp: function() {}, - MakeLinearToSRGBGamma: function() {}, - MakeMatrix: function() {}, - MakeSRGBToLinearGamma: function() {}, - // private API (from C++ bindings) - _makeMatrix: function() {}, - }, - - SkColorMatrix: { - concat: function() {}, - identity: function() {}, - postTranslate: function() {}, - rotated: function() {}, - scaled: function() {}, - }, - - SkContourMeasureIter: { - next: function() {}, - }, - - SkContourMeasure: { - getPosTan: function() {}, - getSegment: function() {}, - isClosed: function() {}, - length: function() {}, - }, - - SkFont: { - // public API (from C++ bindings) - getScaleX: function() {}, - getSize: function() {}, - getSkewX: function() {}, - getTypeface: function() {}, - measureText: function() {}, - setHinting: function() {}, - setLinearMetrics: function() {}, - setScaleX: function() {}, - setSize: function() {}, - setSkewX: function() {}, - setSubpixel: function() {}, - setTypeface: function() {}, - // private API (from C++ bindings) - _getWidths: function() {}, - }, - - SkFontMgr: { - // public API (from C++ and JS bindings) - FromData: function() {}, - RefDefault: function() {}, - countFamilies: function() {}, - getFamilyName: function() {}, - - // private API - _makeTypefaceFromData: function() {}, - _fromData: function() {}, - }, - - SkImage: { - // public API (from C++ bindings) - height: function() {}, - width: function() {}, - // private API - _encodeToData: function() {}, - _encodeToDataWithFormat: function() {}, - _makeShader: function() {}, - }, - - SkImageFilter: { - MakeBlur: function() {}, - MakeColorFilter: function() {}, - MakeCompose: function() {}, - MakeMatrixTransform: function() {}, - }, - - // These are defined in interface.js - SkM44: { - identity: function() {}, - invert: function() {}, - multiply: function() {}, - rotatedUnitSinCos: function() {}, - rotated: function() {}, - scaled: function() {}, - translated: function() {}, - lookat: function() {}, - perspective: function() {}, - rc: function() {}, - transpose: function() {}, - }, - - SkMatrix: { - identity: function() {}, - invert: function() {}, - mapPoints: function() {}, - multiply: function() {}, - rotated: function() {}, - scaled: function() {}, - skewed: function() {}, - translated: function() {}, - }, - - SkMaskFilter: { - MakeBlur: function() {}, - }, - - SkPaint: { - // public API (from C++ bindings) - /** @return {CanvasKit.SkPaint} */ - copy: function() {}, - getBlendMode: function() {}, - getColor: function() {}, - getFilterQuality: function() {}, - getStrokeCap: function() {}, - getStrokeJoin: function() {}, - getStrokeMiter: function() {}, - getStrokeWidth: function() {}, - setAntiAlias: function() {}, - setBlendMode: function() {}, - setColor: function() {}, - setFilterQuality: function() {}, - setImageFilter: function() {}, - setMaskFilter: function() {}, - setPathEffect: function() {}, - setShader: function() {}, - setStrokeCap: function() {}, - setStrokeJoin: function() {}, - setStrokeMiter: function() {}, - setStrokeWidth: function() {}, - setStyle: function() {}, - - // Private API - delete: function() {}, - }, - - SkPathEffect: { - MakeDash: function() {}, - }, - - SkParticleEffect: { - // public API (from C++ bindings) - draw: function() {}, - getEffectUniform: function() {}, - getEffectUniformCount: function() {}, - getEffectUniformFloatCount: function() {}, - getEffectUniformName: function() {}, - getParticleUniformCount: function() {}, - getParticleUniformFloatCount: function() {}, - getParticleUniformName: function() {}, - getParticleUniform: function() {}, - setPosition: function() {}, - setRate: function() {}, - start: function() {}, - update: function() {}, - - // private API (from C++ bindings) - _effectUniformPtr: function() {}, - _particleUniformPtr: function() {}, - }, - - SkPath: { - // public API (from C++ bindings) - computeTightBounds: function() {}, - contains: function() {}, - /** @return {CanvasKit.SkPath} */ - copy: function() {}, - countPoints: function() {}, - equals: function() {}, - getBounds: function() {}, - getFillType: function() {}, - getPoint: function() {}, - isEmpty: function() {}, - isVolatile: function() {}, - reset: function() {}, - rewind: function() {}, - setFillType: function() {}, - setIsVolatile: function() {}, - toSVGString: function() {}, - - // private API - _addArc: function() {}, - _addOval: function() {}, - _addPath: function() {}, - _addRect: function() {}, - _addPoly: function() {}, - _addRoundRect: function() {}, - _arc: function() {}, - _arcTo: function() {}, - _close: function() {}, - _conicTo: function() {}, - _cubicTo: function() {}, - _dash: function() {}, - _lineTo: function() {}, - _moveTo: function() {}, - _op: function() {}, - _quadTo: function() {}, - _rArcTo: function() {}, - _rConicTo: function() {}, - _rCubicTo: function() {}, - _rLineTo: function() {}, - _rMoveTo: function() {}, - _rQuadTo: function() {}, - _rect: function() {}, - _simplify: function() {}, - _stroke: function() {}, - _transform: function() {}, - _trim: function() {}, - delete: function() {}, - dump: function() {}, - dumpHex: function() {}, - }, - - SkPathMeasure: { - getLength: function() {}, - getSegment: function() {}, - getPosTan: function() {}, - isClosed: function() {}, - nextContour: function() {}, - }, - - SkPicture: { - serialize: function() {}, - }, - - SkPictureRecorder: { - beginRecording: function() {}, - finishRecordingAsPicture: function() {}, - }, - - SkRect: { - fLeft: {}, - fTop: {}, - fRight: {}, - fBottom: {}, - }, - - SkRRect: { - rect: {}, - rx1: {}, - ry1: {}, - rx2: {}, - ry2: {}, - rx3: {}, - ry3: {}, - rx4: {}, - ry4: {}, - }, - - SkShader: { - Blend: function() {}, - Color: function() {}, - Empty: function() {}, - Lerp: function() {}, - MakeTwoPointConicalGradient: function() {}, - MakeLinearGradient: function() {}, - MakeRadialGradient: function() {}, - - _Blend: function() {}, - _Lerp: function() {}, - }, - - SkSurface: { - // public API (from C++ bindings) - /** @return {CanvasKit.SkCanvas} */ - getCanvas: function() {}, - /** @return {CanvasKit.SkImage} */ - makeImageSnapshot: function() {}, - makeSurface: function() {}, - grContext: {}, - - // private API - _flush: function() {}, - _getRasterN32PremulSurface: function() {}, - delete: function() {}, - }, - - SkTextBlob: { - // public API (both C++ and JS bindings) - MakeFromRSXform: function() {}, - MakeFromText: function() {}, - MakeOnPath: function() {}, - // private API (from C++ bindings) - _MakeFromRSXform: function() {}, - _MakeFromText: function() {}, - }, - - // These are defined in interface.js - SkVector: { - add: function() {}, - sub: function() {}, - dot: function() {}, - cross: function() {}, - normalize: function() {}, - mulScalar: function() {}, - length: function() {}, - lengthSquared: function() {}, - dist: function() {}, - }, - - SkVertices: { - // public API (from C++ bindings) - bounds: function() {}, - mode: function() {}, - uniqueID: function() {}, - vertexCount: function() {}, - - // private API - /** @return {CanvasKit.SkVertices} */ - _applyBones: function() {}, - }, - - _SkVerticesBuilder: { - // public API (from C++ bindings) - boneIndices: function() {}, - boneWeights: function() {}, - colors: function() {}, - detach: function() {}, - indices: function() {}, - positions: function() {}, - texCoords: function() {}, - }, - - TextStyle: function() {}, - - // Constants and Enums - gpu: {}, - skottie: {}, - - TRANSPARENT: {}, - RED: {}, - BLUE: {}, - YELLOW: {}, - CYAN: {}, - BLACK: {}, - WHITE: {}, - - MOVE_VERB: {}, - LINE_VERB: {}, - QUAD_VERB: {}, - CONIC_VERB: {}, - CUBIC_VERB: {}, - CLOSE_VERB: {}, - - NoDecoration: {}, - UnderlineDecoration: {}, - OverlineDecoration: {}, - LineThroughDecoration: {}, - - SaveLayerInitWithPrevious: {}, - SaveLayerF16ColorType: {}, - - Affinity: { - Upstream: {}, - Downstream: {}, - }, - - AlphaType: { - Opaque: {}, - Premul: {}, - Unpremul: {}, - }, - - BlendMode: { - Clear: {}, - Src: {}, - Dst: {}, - SrcOver: {}, - DstOver: {}, - SrcIn: {}, - DstIn: {}, - SrcOut: {}, - DstOut: {}, - SrcATop: {}, - DstATop: {}, - Xor: {}, - Plus: {}, - Modulate: {}, - Screen: {}, - Overlay: {}, - Darken: {}, - Lighten: {}, - ColorDodge: {}, - ColorBurn: {}, - HardLight: {}, - SoftLight: {}, - Difference: {}, - Exclusion: {}, - Multiply: {}, - Hue: {}, - Saturation: {}, - Color: {}, - Luminosity: {}, - }, - - BlurStyle: { - Normal: {}, - Solid: {}, - Outer: {}, - Inner: {}, - }, - - ClipOp: { - Difference: {}, - Intersect: {}, - }, - - ColorType: { - Alpha_8: {}, - RGB_565: {}, - ARGB_4444: {}, - RGBA_8888: {}, - RGB_888x: {}, - BGRA_8888: {}, - RGBA_1010102: {}, - RGB_101010x: {}, - Gray_8: {}, - RGBA_F16: {}, - RGBA_F32: {}, - }, - - FillType: { - Winding: {}, - EvenOdd: {}, - InverseWinding: {}, - InverseEvenOdd: {}, - }, - - FilterQuality: { - None: {}, - Low: {}, - Medium: {}, - High: {}, - }, - - FontSlant: { - Upright: {}, - Italic: {}, - Oblique: {}, - }, - - FontHinting: { - None: {}, - Slight: {}, - Normal: {}, - Full: {}, - }, - - FontWeight: { - Invisible: {}, - Thin: {}, - ExtraLight: {}, - Light: {}, - Normal: {}, - Medium: {}, - SemiBold: {}, - Bold: {}, - ExtraBold: {}, - Black: {}, - ExtraBlack: {}, - }, - - FontWidth: { - UltraCondensed: {}, - ExtraCondensed: {}, - Condensed: {}, - SemiCondensed: {}, - Normal: {}, - SemiExpanded: {}, - Expanded: {}, - ExtraExpanded: {}, - UltraExpanded: {}, - }, - - ImageFormat: { - PNG: {}, - JPEG: {}, - }, - - PaintStyle: { - Fill: {}, - Stroke: {}, - StrokeAndFill: {}, - }, - - PathOp: { - Difference: {}, - Intersect: {}, - Union: {}, - XOR: {}, - ReverseDifference: {}, - }, - - PointMode: { - Points: {}, - Lines: {}, - Polygon: {}, - }, - - RectHeightStyle: { - Tight: {}, - Max: {}, - IncludeLineSpacingMiddle: {}, - IncludeLineSpacingTop: {}, - IncludeLineSpacingBottom: {}, - }, - - RectWidthStyle: { - Tight: {}, - Max: {}, - }, - - StrokeCap: { - Butt: {}, - Round: {}, - Square: {}, - }, - - StrokeJoin: { - Miter: {}, - Round: {}, - Bevel: {}, - }, - - TextAlign: { - Left: {}, - Right: {}, - Center: {}, - Justify: {}, - Start: {}, - End: {}, - }, - - TextDirection: { - LTR: {}, - RTL: {}, - }, - - TextEncoding: { - UTF8: {}, - UTF16: {}, - UTF32: {}, - GlyphID: {}, - }, - - TileMode: { - Clamp: {}, - Repeat: {}, - Mirror: {}, - Decal: {}, - }, - - VertexMode: { - Triangles: {}, - TrianglesStrip: {}, - TriangleFan: {}, - }, - - // Things Enscriptem adds for us - - /** - * @type {Float32Array} - */ - HEAPF32: {}, - /** - * @type {Float64Array} - */ - HEAPF64: {}, - /** - * @type {Uint8Array} - */ - HEAPU8: {}, - /** - * @type {Uint16Array} - */ - HEAPU16: {}, - /** - * @type {Uint32Array} - */ - HEAPU32: {}, - /** - * @type {Int8Array} - */ - HEAP8: {}, - /** - * @type {Int16Array} - */ - HEAP16: {}, - /** - * @type {Int32Array} - */ - HEAP32: {}, - - _malloc: function() {}, - _free: function() {}, - onRuntimeInitialized: function() {}, + // public API (i.e. things we declare in the pre-js file or in the cpp bindings) + Color: function() {}, + /** @return {CanvasKit.SkRect} */ + LTRBRect: function() {}, + /** @return {CanvasKit.SkRect} */ + XYWHRect: function() {}, + /** @return {CanvasKit.SkRRect} */ + RRectXY: function() {}, + /** @return {ImageData} */ + ImageData: function() {}, + + GetWebGLContext: function() {}, + MakeBlurMaskFilter: function() {}, + MakeCanvas: function() {}, + MakeCanvasSurface: function() {}, + MakeGrContext: function() {}, + /** @return {CanvasKit.SkAnimatedImage} */ + MakeAnimatedImageFromEncoded: function() {}, + /** @return {CanvasKit.SkImage} */ + MakeImage: function() {}, + /** @return {CanvasKit.SkImage} */ + MakeImageFromEncoded: function() {}, + /** @return {LinearCanvasGradient} */ + MakeLinearGradientShader: function() {}, + MakeOnScreenGLSurface: function() {}, + MakePathFromCmds: function() {}, + MakePathFromOp: function() {}, + MakePathFromSVGString: function() {}, + MakeRadialGradientShader: function() {}, + MakeRenderTarget: function() {}, + MakeSkPicture: function() {}, + MakeSWCanvasSurface: function() {}, + MakeManagedAnimation: function() {}, + MakeParticles: function() {}, + MakeSkDashPathEffect: function() {}, + MakeSkVertices: function() {}, + MakeSurface: function() {}, + /** @return {RadialCanvasGradient} */ + MakeTwoPointConicalGradientShader: function() {}, + MakeWebGLCanvasSurface: function() {}, + /** @return {TypedArray} */ + Malloc: function() {}, + /** @return {TonalColors} */ + computeTonalColors: function() {}, + currentContext: function() {}, + getColorComponents: function() {}, + getDecodeCacheLimitBytes: function() {}, + getDecodeCacheUsageBytes: function() {}, + getSkDataBytes: function() {}, + multiplyByAlpha: function() {}, + parseColorString: function() {}, + setCurrentContext: function() {}, + setDecodeCacheLimitBytes: function() {}, + + // private API (i.e. things declared in the bindings that we use + // in the pre-js file) + _MakeImage: function() {}, + _MakeLinearGradientShader: function() {}, + _MakePathFromCmds: function() {}, + _MakeRadialGradientShader: function() {}, + _MakeManagedAnimation: function() {}, + _MakeParticles: function() {}, + _MakeSkDashPathEffect: function() {}, + _MakeSkPicture: function() {}, + _MakeSkVertices: function() {}, + _MakeTwoPointConicalGradientShader: function() {}, + _decodeAnimatedImage: function() {}, + _decodeImage: function() {}, + _drawShapedText: function() {}, + _getRasterDirectSurface: function() {}, + _getRasterN32PremulSurface: function() {}, + + // The testing object is meant to expose internal functions + // for more fine-grained testing, e.g. parseColor + _testing: {}, + + // Objects and properties on CanvasKit + + GrContext: { + // public API (from C++ bindings) + getResourceCacheLimitBytes: function() {}, + getResourceCacheUsageBytes: function() {}, + releaseResourcesAndAbandonContext: function() {}, + setResourceCacheLimitBytes: function() {}, + }, + + Paragraph: { + // public API (from C++ bindings) + didExceedMaxLines: function() {}, + getAlphabeticBaseline: function() {}, + getGlyphPositionAtCoordinate: function() {}, + getHeight: function() {}, + getIdeographicBaseline: function() {}, + getLongestLine: function() {}, + getMaxIntrinsicWidth: function() {}, + getMaxWidth: function() {}, + getMinIntrinsicWidth: function() {}, + getWordBoundary: function() {}, + layout: function() {}, + + // private API + /** @return {Float32Array} */ + _getRectsForRange: function() {}, + }, + + SkRuntimeEffect: { + // public API (from C++ bindings) + Make: function() {}, + + // private API + _makeShader: function() {}, + _makeShaderWithChildren: function() {}, + }, + + ParagraphStyle: function() {}, + RSXFormBuilder: function() {}, + SkColorBuilder: function() {}, + SkRectBuilder: function() {}, + + ShapedText: { + // public API (from C++ bindings) + getBounds: function() {}, + }, + + SkAnimatedImage: { + // public API (from C++ bindings) + decodeNextFrame: function() {}, + getFrameCount: function() {}, + getRepetitionCount: function() {}, + height: function() {}, + reset: function() {}, + width: function() {}, + }, + + SkCanvas: { + // public API (from C++ bindings) + clear: function() {}, + clipPath: function() {}, + clipRRect: function() {}, + clipRect: function() {}, + concat: function() {}, + drawAnimatedImage: function() {}, + drawArc: function() {}, + drawCircle: function() {}, + drawColor: function() {}, + drawDRRect: function() {}, + drawImage: function() {}, + drawImageNine: function() {}, + drawImageRect: function() {}, + drawLine: function() {}, + drawOval: function() {}, + drawPaint: function() {}, + drawParagraph: function() {}, + drawPath: function() {}, + drawPicture: function() {}, + drawRRect: function() {}, + drawRect: function() {}, + drawRoundRect: function() {}, + drawShadow: function() {}, + drawText: function() {}, + drawTextBlob: function() {}, + drawVertices: function() {}, + flush: function() {}, + getSaveCount: function() {}, + getTotalMatrix: function() {}, + makeSurface: function() {}, + restore: function() {}, + restoreToCount: function() {}, + rotate: function() {}, + save: function() {}, + saveLayer: function() {}, + scale: function() {}, + skew: function() {}, + translate: function() {}, + + // private API + _drawAtlas: function() {}, + _drawPoints: function() {}, + _drawSimpleText: function() {}, + _readPixels: function() {}, + _writePixels: function() {}, + delete: function() {}, + }, + + SkColorFilter: { + // public API (from C++ bindings and JS interface) + MakeBlend: function() {}, + MakeCompose: function() {}, + MakeLerp: function() {}, + MakeLinearToSRGBGamma: function() {}, + MakeMatrix: function() {}, + MakeSRGBToLinearGamma: function() {}, + // private API (from C++ bindings) + _makeMatrix: function() {}, + }, + + SkColorMatrix: { + concat: function() {}, + identity: function() {}, + postTranslate: function() {}, + rotated: function() {}, + scaled: function() {}, + }, + + SkContourMeasureIter: { + next: function() {}, + }, + + SkContourMeasure: { + getPosTan: function() {}, + getSegment: function() {}, + isClosed: function() {}, + length: function() {}, + }, + + SkFont: { + // public API (from C++ bindings) + getScaleX: function() {}, + getSize: function() {}, + getSkewX: function() {}, + getTypeface: function() {}, + measureText: function() {}, + setHinting: function() {}, + setLinearMetrics: function() {}, + setScaleX: function() {}, + setSize: function() {}, + setSkewX: function() {}, + setSubpixel: function() {}, + setTypeface: function() {}, + // private API (from C++ bindings) + _getWidths: function() {}, + }, + + SkFontMgr: { + // public API (from C++ and JS bindings) + FromData: function() {}, + RefDefault: function() {}, + countFamilies: function() {}, + getFamilyName: function() {}, + + // private API + _makeTypefaceFromData: function() {}, + _fromData: function() {}, + }, + + SkImage: { + // public API (from C++ bindings) + height: function() {}, + width: function() {}, + // private API + _encodeToData: function() {}, + _encodeToDataWithFormat: function() {}, + _makeShader: function() {}, + }, + + SkImageFilter: { + MakeBlur: function() {}, + MakeColorFilter: function() {}, + MakeCompose: function() {}, + MakeMatrixTransform: function() {}, + }, + + // These are defined in interface.js + SkM44: { + identity: function() {}, + invert: function() {}, + multiply: function() {}, + rotatedUnitSinCos: function() {}, + rotated: function() {}, + scaled: function() {}, + translated: function() {}, + lookat: function() {}, + perspective: function() {}, + rc: function() {}, + transpose: function() {}, + }, + + SkMatrix: { + identity: function() {}, + invert: function() {}, + mapPoints: function() {}, + multiply: function() {}, + rotated: function() {}, + scaled: function() {}, + skewed: function() {}, + translated: function() {}, + }, + + SkMaskFilter: { + MakeBlur: function() {}, + }, + + SkPaint: { + // public API (from C++ bindings) + /** @return {CanvasKit.SkPaint} */ + copy: function() {}, + getBlendMode: function() {}, + getColor: function() {}, + getFilterQuality: function() {}, + getStrokeCap: function() {}, + getStrokeJoin: function() {}, + getStrokeMiter: function() {}, + getStrokeWidth: function() {}, + setAntiAlias: function() {}, + setBlendMode: function() {}, + setColor: function() {}, + setFilterQuality: function() {}, + setImageFilter: function() {}, + setMaskFilter: function() {}, + setPathEffect: function() {}, + setShader: function() {}, + setStrokeCap: function() {}, + setStrokeJoin: function() {}, + setStrokeMiter: function() {}, + setStrokeWidth: function() {}, + setStyle: function() {}, + + // Private API + delete: function() {}, + }, + + SkPathEffect: { + MakeDash: function() {}, + }, + + SkParticleEffect: { + // public API (from C++ bindings) + draw: function() {}, + getEffectUniform: function() {}, + getEffectUniformCount: function() {}, + getEffectUniformFloatCount: function() {}, + getEffectUniformName: function() {}, + getParticleUniformCount: function() {}, + getParticleUniformFloatCount: function() {}, + getParticleUniformName: function() {}, + getParticleUniform: function() {}, + setPosition: function() {}, + setRate: function() {}, + start: function() {}, + update: function() {}, + + // private API (from C++ bindings) + _effectUniformPtr: function() {}, + _particleUniformPtr: function() {}, + }, + + SkPath: { + // public API (from C++ bindings) + computeTightBounds: function() {}, + contains: function() {}, + /** @return {CanvasKit.SkPath} */ + copy: function() {}, + countPoints: function() {}, + equals: function() {}, + getBounds: function() {}, + getFillType: function() {}, + getPoint: function() {}, + isEmpty: function() {}, + isVolatile: function() {}, + reset: function() {}, + rewind: function() {}, + setFillType: function() {}, + setIsVolatile: function() {}, + toSVGString: function() {}, + + // private API + _addArc: function() {}, + _addOval: function() {}, + _addPath: function() {}, + _addRect: function() {}, + _addPoly: function() {}, + _addRoundRect: function() {}, + _arc: function() {}, + _arcTo: function() {}, + _close: function() {}, + _conicTo: function() {}, + _cubicTo: function() {}, + _dash: function() {}, + _lineTo: function() {}, + _moveTo: function() {}, + _op: function() {}, + _quadTo: function() {}, + _rArcTo: function() {}, + _rConicTo: function() {}, + _rCubicTo: function() {}, + _rLineTo: function() {}, + _rMoveTo: function() {}, + _rQuadTo: function() {}, + _rect: function() {}, + _simplify: function() {}, + _stroke: function() {}, + _transform: function() {}, + _trim: function() {}, + delete: function() {}, + dump: function() {}, + dumpHex: function() {}, + }, + + SkPathMeasure: { + getLength: function() {}, + getSegment: function() {}, + getPosTan: function() {}, + isClosed: function() {}, + nextContour: function() {}, + }, + + SkPicture: { + serialize: function() {}, + }, + + SkPictureRecorder: { + beginRecording: function() {}, + finishRecordingAsPicture: function() {}, + }, + + SkRect: { + fLeft: {}, + fTop: {}, + fRight: {}, + fBottom: {}, + }, + + SkRRect: { + rect: {}, + rx1: {}, + ry1: {}, + rx2: {}, + ry2: {}, + rx3: {}, + ry3: {}, + rx4: {}, + ry4: {}, + }, + + SkShader: { + Blend: function() {}, + Color: function() {}, + Empty: function() {}, + Lerp: function() {}, + + _Blend: function() {}, + _Lerp: function() {}, + }, + + SkSurface: { + // public API (from C++ bindings) + /** @return {CanvasKit.SkCanvas} */ + getCanvas: function() {}, + /** @return {CanvasKit.SkImage} */ + makeImageSnapshot: function() {}, + makeSurface: function() {}, + grContext: {}, + + // private API + _flush: function() {}, + _getRasterN32PremulSurface: function() {}, + delete: function() {}, + }, + + SkTextBlob: { + // public API (both C++ and JS bindings) + MakeFromRSXform: function() {}, + MakeFromText: function() {}, + MakeOnPath: function() {}, + // private API (from C++ bindings) + _MakeFromRSXform: function() {}, + _MakeFromText: function() {}, + }, + + // These are defined in interface.js + SkVector: { + add: function() {}, + sub: function() {}, + dot: function() {}, + cross: function() {}, + normalize: function() {}, + mulScalar: function() {}, + length: function() {}, + lengthSquared: function() {}, + dist: function() {}, + }, + + SkVertices: { + // public API (from C++ bindings) + bounds: function() {}, + mode: function() {}, + uniqueID: function() {}, + vertexCount: function() {}, + }, + + _SkVerticesBuilder: { + colors: function() {}, + detach: function() {}, + indices: function() {}, + positions: function() {}, + texCoords: function() {}, + }, + + TextStyle: function() {}, + + // Constants and Enums + gpu: {}, + skottie: {}, + + TRANSPARENT: {}, + RED: {}, + BLUE: {}, + YELLOW: {}, + CYAN: {}, + BLACK: {}, + WHITE: {}, + + MOVE_VERB: {}, + LINE_VERB: {}, + QUAD_VERB: {}, + CONIC_VERB: {}, + CUBIC_VERB: {}, + CLOSE_VERB: {}, + + NoDecoration: {}, + UnderlineDecoration: {}, + OverlineDecoration: {}, + LineThroughDecoration: {}, + + SaveLayerInitWithPrevious: {}, + SaveLayerF16ColorType: {}, + + Affinity: { + Upstream: {}, + Downstream: {}, + }, + + AlphaType: { + Opaque: {}, + Premul: {}, + Unpremul: {}, + }, + + BlendMode: { + Clear: {}, + Src: {}, + Dst: {}, + SrcOver: {}, + DstOver: {}, + SrcIn: {}, + DstIn: {}, + SrcOut: {}, + DstOut: {}, + SrcATop: {}, + DstATop: {}, + Xor: {}, + Plus: {}, + Modulate: {}, + Screen: {}, + Overlay: {}, + Darken: {}, + Lighten: {}, + ColorDodge: {}, + ColorBurn: {}, + HardLight: {}, + SoftLight: {}, + Difference: {}, + Exclusion: {}, + Multiply: {}, + Hue: {}, + Saturation: {}, + Color: {}, + Luminosity: {}, + }, + + BlurStyle: { + Normal: {}, + Solid: {}, + Outer: {}, + Inner: {}, + }, + + ClipOp: { + Difference: {}, + Intersect: {}, + }, + + ColorType: { + Alpha_8: {}, + RGB_565: {}, + ARGB_4444: {}, + RGBA_8888: {}, + RGB_888x: {}, + BGRA_8888: {}, + RGBA_1010102: {}, + RGB_101010x: {}, + Gray_8: {}, + RGBA_F16: {}, + RGBA_F32: {}, + }, + + FillType: { + Winding: {}, + EvenOdd: {}, + InverseWinding: {}, + InverseEvenOdd: {}, + }, + + FilterQuality: { + None: {}, + Low: {}, + Medium: {}, + High: {}, + }, + + FontSlant: { + Upright: {}, + Italic: {}, + Oblique: {}, + }, + + FontHinting: { + None: {}, + Slight: {}, + Normal: {}, + Full: {}, + }, + + FontWeight: { + Invisible: {}, + Thin: {}, + ExtraLight: {}, + Light: {}, + Normal: {}, + Medium: {}, + SemiBold: {}, + Bold: {}, + ExtraBold: {}, + Black: {}, + ExtraBlack: {}, + }, + + FontWidth: { + UltraCondensed: {}, + ExtraCondensed: {}, + Condensed: {}, + SemiCondensed: {}, + Normal: {}, + SemiExpanded: {}, + Expanded: {}, + ExtraExpanded: {}, + UltraExpanded: {}, + }, + + ImageFormat: { + PNG: {}, + JPEG: {}, + }, + + PaintStyle: { + Fill: {}, + Stroke: {}, + StrokeAndFill: {}, + }, + + PathOp: { + Difference: {}, + Intersect: {}, + Union: {}, + XOR: {}, + ReverseDifference: {}, + }, + + PointMode: { + Points: {}, + Lines: {}, + Polygon: {}, + }, + + RectHeightStyle: { + Tight: {}, + Max: {}, + IncludeLineSpacingMiddle: {}, + IncludeLineSpacingTop: {}, + IncludeLineSpacingBottom: {}, + }, + + RectWidthStyle: { + Tight: {}, + Max: {}, + }, + + StrokeCap: { + Butt: {}, + Round: {}, + Square: {}, + }, + + StrokeJoin: { + Miter: {}, + Round: {}, + Bevel: {}, + }, + + TextAlign: { + Left: {}, + Right: {}, + Center: {}, + Justify: {}, + Start: {}, + End: {}, + }, + + TextDirection: { + LTR: {}, + RTL: {}, + }, + + TextEncoding: { + UTF8: {}, + UTF16: {}, + UTF32: {}, + GlyphID: {}, + }, + + TileMode: { + Clamp: {}, + Repeat: {}, + Mirror: {}, + Decal: {}, + }, + + VertexMode: { + Triangles: {}, + TrianglesStrip: {}, + TriangleFan: {}, + }, + + // Things Enscriptem adds for us + + /** + * @type {Float32Array} + */ + HEAPF32: {}, + /** + * @type {Float64Array} + */ + HEAPF64: {}, + /** + * @type {Uint8Array} + */ + HEAPU8: {}, + /** + * @type {Uint16Array} + */ + HEAPU16: {}, + /** + * @type {Uint32Array} + */ + HEAPU32: {}, + /** + * @type {Int8Array} + */ + HEAP8: {}, + /** + * @type {Int16Array} + */ + HEAP16: {}, + /** + * @type {Int32Array} + */ + HEAP32: {}, + + _malloc: function() {}, + _free: function() {}, + onRuntimeInitialized: function() {}, }; // Public API things that are newly declared in the JS should go here. @@ -848,9 +838,6 @@ CanvasKit.SkSurface.prototype.requestAnimationFrame = function() {}; CanvasKit.SkSurface.prototype.drawOnce = function() {}; CanvasKit.SkSurface.prototype.captureFrameAsSkPicture = function() {}; -/** @return {CanvasKit.SkVertices} */ -CanvasKit.SkVertices.prototype.applyBones = function() {}; - CanvasKit.SkImage.prototype.encodeToData = function() {}; CanvasKit.SkImage.prototype.makeShader = function() {}; @@ -963,21 +950,21 @@ var CanvasPattern = {}; CanvasPattern.prototype.setTransform = function() {}; var ImageData = { - /** - * @type {Uint8ClampedArray} - */ - data: {}, - height: {}, - width: {}, + /** + * @type {Uint8ClampedArray} + */ + data: {}, + height: {}, + width: {}, }; var DOMMatrix = { - a: {}, - b: {}, - c: {}, - d: {}, - e: {}, - f: {}, + a: {}, + b: {}, + c: {}, + d: {}, + e: {}, + f: {}, }; // Not sure why this is needed - might be a bug in emsdk that this isn't properly declared.