All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
CanvasKit.MakeImageFromCanvasImageSourcewhich takes either an HTMLImageElement, SVGImageElement, HTMLVideoElement, HTMLCanvasElement, ImageBitmap, or OffscreenCanvas and returns an SkImage. This function is an alternative to
CanvasKit.MakeImageFromEncodedfor creating SkImages when loading and decoding images. In the future, codesize of CanvasKit may be able to be reduced by removing image codecs in wasm, if browser APIs for decoding images are used along with
CanvasKit.SkPath.addVerbsPointsWeightsfor supplying many path operations (e.g. moveTo, cubicTo) at once.
CanvasKit.mallocnow has a
subarraymethod which works exactly like the normal TypedArray version. The TypedArray which it returns is also backed by WASM memory and when passed into CanvasKit will be used w/o copying the data (just like
TextStyle.colorcan correctly be a Malloc'd Float32Array.
CanvasKit.MakePathFromCmdshas been renamed to
CanvasKit.SkPath.MakeFromCmds. The alias will be removed in an upcoming release.
TypeError: Cannot perform %TypedArray%.prototype.set on a neutered ArrayBuffer.
SkSurface.reportBackendTypewhich returns either ‘CPU’ or ‘GPU’.
SkSurface.imageInfowhich returns an ImageInfo object describing the size and color properties of the surface. colorSpace is added to ImageInfo everywhere it is used.
CanvasKit.Freeto explicitly clean up memory after
CanvasKit.Malloc. All memory allocated with
CanvasKit.Mallocmust be released with
CanvasKit.Freeor it will be leaked. This can improve performance by reducing the copying of data between the JS and WASM side.
SkCanvas.drawColorIntfor when clients want to avoid the overhead of allocating an array for color components and only need 8888 color.
CanvasKit.MakeCanvasSurfaceaccepts a new enum specifying one of the three color space and pixel format combinations supported by CanvasKit.
_Make*Shaderfunctions now accept a color space argument at the end. leaving it off or passing null makes it behave as it did before, defaulting to sRGB
SkPaint.setColoraccepts a new color space argument, defaulting to sRGB.
CanvasKitInit(...)now directly returns a Promise. As such,
CanvasKitInit(...).ready()has been removed.
CanvasKit.MakeCanvasSurfaceno longer accepts width/height arguments to override those on the canvas element. Use the canvas element's width/height attributes to dictate the size of the drawing area, and use CSS width/height to set the size it will appear on the page (it is rescaled after drawing when css sizing applies).
CanvasKit.Mallocwill no longer be automatically cleaned up. Clients must use
CanvasKit.Freeto release the memory.
CanvasKit.Mallocno longer directly returns a TypedArray, but an object that can produce them with toTypedArray(). This is to avoid “detached ArrayBuffer” errors: https://github.com/emscripten-core/emscripten/issues/6747
getErrorshould be disabled. This may cause a performance improvement in some scenarios.
SkCanvas.concat44has been folded into concat (which now takes 3x2, 3x3, or 4x4 matrices). It will be removed soon.
SkCanvas.saveLayercan now be called with 1 argument (the paint). In this case the current effective clip will be used, as the current rect is assumed to be null.
no_codecsto compile.sh to remove all codec encoding and decoded code. This can save over 100 kb compressed if codecs are not needed.
MakeSkDashPathEffectwill be removed soon. Calls can be replaced with
MakeLinearGradientShaderwill be removed soon. Calls can be replaced with
MakeRadialGradientShaderwill be removed soon. Calls can be replaced with
MakeTwoPointConicalGradientShaderwill be removed soon. Calls can be replaced with
MakeSkCornerPathEffectwill be removed soon. Calls can be replaced with
MakeSkDiscretePathEffectwill be removed soon. Calls can be replaced with
SkSurface.drawOncefor drawing a single frame (in addition to already existing
SkSurface.requestAnimationFramefor animation logic).
CanvasKit.parseColorStringwhich processes color strings like “#2288FF”
SkRuntimeEffect.makeShaderWithChildren, which can take in other shaders as fragmentProcessors.
GrContext.releaseResourcesAndAbandonContextto free up WebGL contexts.
SkMatrix.multiplycan now accept any number of matrix arguments, multiplying them left-to-right.
SkFontMgr.getFamilyNameto expose the parsed font names.
CanvasKit.MakeSkPictureis now exposed. SKP support is not shipped to npm builds.
force_serialize_skphas been removed since it opt-out, not opt-in.
bin/core/. It is about half the size of the “CoreWithFonts” build.
SkAnimatedImage.getCurrentFramewhich returns an SkImage.
bin/there is the “CoreWithFonts” build that contains most functionality from 0.10.0. However, we no longer ship the Skottie animation player, nor the Particles demo. Further, PathOps are removed from this build
SkPath.simplify. Clients who need any of those features are encouraged to create a custom build using
SkPicture.DEBUGONLY_saveAsFilewas accidentally included in release builds. It has been removed. Clients who need this in a release build (e.g. to file a bug report that only reproduces in release) should do a custom build with the
SkCanvas.drawAnimatedImagewill be renamed soon. Calls can be replaced with
SkContourMeasureas an alternative to
SkParagraph.getRectsForRangenow have direction with value
MakeImageproperly in the externs file and can work with
CanvasKit.Malloc, which can be used to create a TypedArray backed by the C++ WASM memory. This can save a copy in some cases (e.g. SkColorFilter.MakeMatrix). This is an advanced feature, so use it with care.
SkCanvas.saveLayernow takes 3 or 4 params to include up to bounds, paint, SkImageFilter, flags.
SkPath.rQuadTo. Like their non-relative siblings, these are chainable.
getWordBoundary, and others.
CanvasKit.MakeBlurMaskFilterwill be renamed/moved soon to
CanvasKit.SkFontMgr.FromDatawhich takes several ArrayBuffers of font data, parses them, reading the metadata (e.g. family names) and stores them into a SkFontMgr.
no_fontcompile option should strip out more dead code related to fonts.
no_embedded_fontoption now allows creating a
SkFontMgr.FromDatainstead of always having an empty one.
CanvasKit.RRectXY). Advanced users can specify the 8 individual radii, if needed.
CanvasKit.computeTonalColors(), which returns TonalColors, which has an ambient SkColor and a spot SkColor.
CanvasKit.SkColorFilterand a variety of factories.
SkPaint.setColorFilteris the only consumer of these at the moment.
.concat()and others. Primarily for use with
MakeSkVerticesuses a builder to save a copy.
SkPath.arcTois given seven arguments, it no longer turns the first four into a
SkRectautomatically, and instead uses them as
arcTo(rx, ry, xAxisRotate, useSmallArc, isCCW, x, y)(see SkPath.h for more).
GrContexthas new methods for monitoring/setting the cache limits; tweaking these may lead to better performance in some cases.
SkCanvas.drawAtlasfor efficiently drawing multiple sprites from a sprite sheet with a set of transforms, color blends, etc.
SkRectBuilderwhich increase performance by reducing the amount of malloc/free calls per frame, given that the array size is fixed.
SkSurface.captureFrameAsSkPictureis a helper function to capture an
SkPicture, which can be dumped to disk (for debugging) with
SkImage.readPixels, which returns a TypedArray of pixel values (safe to use anywhere, doesn't need a delete()).
GrGLCapssupport for WebGL - this shouldn't have any impacts on APIs or correctness, except by perhaps fixing a few bugs in various surface types.
SkImage.makeShader- removed clampUnpremul as argument.
SkTextBlob.MakeFromRSXformwhich were needed to add the helper function
SkSurface.requestAnimationFrame- wrapper around window.requestAnimationFrame that takes care of the setup/tear down required to use CanvasKit optimally. The callback has an
SkCanvasas the first parameter - callers should draw on that.
SkCanvas.flushwill be removed soon - client should only call
CanvasKit.MakeSkVertices. The previous (and current default) behavior was for this to be true; some applications may go faster if set to false.
SkCanvas.restoreToCount(int)which can be used with the output of .save() and .saveLayer().
SkCanvas.getSurface()for making compatible surfaces (typically used as a workspace and then “saved” with
CanvasKit.MakeWebGLCanvasSurfaceno longer takes a webgl context as a first arg, only a canvas or an id of a canvas. If users want to manage their own GL contexts, they should build the
MakeManagedAnimationfor supplying external assets (like images, fonts).
SkCanvas.SkTextBlob.MakeFromText()to draw text to a canvas.
CanvasKit.TextEncodingenum. For use with
SkCanvas.drawText. At compile time, one can choose between using Harfbuzz/ICU (default) or a primitive one (“primitive_shaper”) which just does line breaking. Using Harfbuzz/ICU substantially increases code size (4.3 MB to 6.4 MB).
SkCanvas.drawText()now requires an
SkFontobject for raw strings.
SkPaint.setTypeface()which should be replaced by using
CanvasKitInit().then()interface (see 0.3.1 notes)
ready()if already loaded.
MakeCanvasSurfacecan now take a canvas element directly.
MakeWebGLCanvasSurfacecan now take a WebGL context as an integer and use it directly.
CanvasKitInit(...).then()is no longer the recommended way to initialize things. It will be removed in 0.4.0. Use
CanvasKitInit(...).ready(), which returns a real Promise.
fontmgr.MakeTypefaceFromDatato load fonts.
SkPath.setVolatile. Some animations see performance improvements by setting their paths' volatility to true.
SkPath.addRectnow correctly draws counter-clockwise vs clockwise.
CanvasKit.MakeImageShaderno longer takes encoded bytes, but an
SkImage, created from
CanvasKit.MakeImageFromEncoded. Additionally, the optional parameters
localMatrixhave been exposed.
forceMoveToas additional parameters.
SkPath.strokehas a new option
precisionIt defaults to 1.0.
fontmgr.MakeTypefaceFromDatafor more font variety.
CanvasKit.initFonts()- no longer needed.
Beginning of Changelog history