1# CanvasKit Changelog 2All notable changes to this project will be documented in this file. 3 4The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 7## [Unreleased] 8 9### Added 10 - `CanvasKit.MakeLazyImageFromTextureSource`, which is similar to 11 `Surface.makeImageFromTextureSource`, but can be re-used across different WebGL contexts. 12 13### Breaking 14 - `Surface.makeImageFromTextureSource` now takes an optional ImageInfo or PartialImageInfo 15 instead of optional width and height. Sensible defaults will be used if not supplied. 16 17### Fixed 18 - Some `Surface` methods would not properly switch to the right WebGL context. 19 - Warnings about `INVALID_ENUM: enable: invalid capability` should be reduced/eliminated. 20 21### Removed 22 - `FontMgr.MakeTypefaceFromData` and `FontMgr.RefDefault` have been removed in favor of 23 `Typeface.MakeFreeTypeFaceFromData` 24 25### Changed 26 - `make release`, `make debug`, and variants put the output in a different location (./build). 27 - Example .html files load CanvasKit from the new location (./build). 28 29### Type Changes (index.d.ts) 30 - `Surface.requestAnimationFrame` and `Surface.drawOnce` are properly documented. 31 - Fixed typo in TextStyle (decrationStyle => decorationStyle) 32 33## [0.30.0] - 2021-09-15 34 35### Removed 36 - `Surface.grContext` and `Surface.openGLversion` - these had been undocumented and are no longer 37 exposed. 38 - `CanvasKit.setCurrentContext` and `CanvasKit.currentContext`. Existing calls can be deleted. 39 40### Changed 41 - CanvasKit APIs now handle switching between WebGL contexts automatically. 42 - Reduced overhead when switching between WebGL contexts. 43 44### Type Changes (index.d.ts) 45 - `Canvas.drawImage*` calls are correctly documented as accepting an optional `Paint` or null. 46 47## [0.29.0] - 2021-08-06 48 49### Added 50 - `Path.makeAsWinding` has been added to convert paths with an EvenOdd FillType to the 51 equivalent area using the Winding FillType. 52 53### Breaking 54 - `Paint.getBlendMode()` has been removed. 55 - `Canvas.drawImageAtCurrentFrame()` has been removed. 56 - FilterQuality enum removed -- pass `FilterOptions` | `CubicResampler` instead. 57 58### Type Changes (index.d.ts) 59 - Replaced all `object` with actual types, including `AnimationMarker`. 60 61## [0.28.1] - 2021-06-28 62 63### Added 64 - `Typeface.MakeFreeTypeFaceFromData` as a more convenient way to create a Typeface from the bytes 65 of a .ttf, .woff, or .woff2 file. 66 - `Typeface.getGlyphIDs` - provides the same functionality as `Font.getGlyphIDs`. 67 68### Changed 69 - ICU has been updated from v65 to v69. 70 - Freetype has been updated from f9350be to ff40776. 71 72### Fixed 73 - We should no longer have to decode the same font multiple times (skbug.com/12112) 74 - `Font.getGlyphIDs` had the wrong type for the third argument. It is now correctly a Uint16Array. 75 76### Deprecated 77 - `FontMgr.MakeTypefaceFromData` will be removed in favor of `Typeface.MakeFreeTypeFaceFromData` 78 - `FontMgr.RefDefault` will be removed in an upcoming version. It's only real use was 79 for `FontMgr.MakeTypefaceFromData`. 80 81## [0.28.0] - 2021-06-17 82 83### Added 84 - `Surface.makeImageFromTexture` and `Surface.makeImageFromTextureSource` as easy ways to provide 85 CanvasKit with a WebGL texture and interact with WebGL texture sources (e.g. <video>) 86 87### Changed 88 - We now build/ship with emscripten 2.0.20. 89 90### Breaking 91 - `Path.toCmds()` returns a flattened Float32Array instead of a 2D Array. 92 - `Canvaskit.Path.MakeFromCmds` no longer accepts a 2D Array. Inputs must be flattened, 93 but can be an array, a TypedArray, or a MallocObj. 94 - `CanvasKit.*Builder` have all been removed. Clients should use Malloc instead. 95 96### Removed 97 - `CanvasKit.Shader.MakeLerp`, the same effect can be easily generated with `RuntimeEffect` 98 99### Known Bugs 100 - On legacy (non-ANGLE) SwiftShader, certain paths that require tessellation may not be drawn 101 correctly when using a WebGL-backed surface. (skbug.com/11965) 102 103## [0.27.0] - 2021-05-20 104 105### Added 106 - `Font.getGlyphIntercepts()` 107 108### Fixed 109 - Bug with images using certain exif metadata. (skbug.com/11968) 110 111### Removed 112 - `Canvas.flush`, which had been previously deprecated. `Surface.flush` is the preferred method. 113 - `AnimatedImage.getCurrentFrame`, which had been previously deprecated. 114 `AnimatedImage.makeImageAtCurrentFrame` is the replacement, which behaves exactly the same. 115 116## [0.26.0] - 2021-04-23 117 118### Added 119 - Add 'isEmbolden, setEmbolden' to 'Font' 120 - Add 'drawGlyphs' to 'Canvas' 121 - Add `drawPatch` to `Canvas`. 122 - Add `Strut` as a `RectHeightStyle` enum. 123 - `CanvasKit.RuntimeEffect` now supports integer uniforms in the SkSL. These are still passed 124 to `RuntimeEffect.makeShader` as floats (like all other uniforms), and will be converted to 125 integers internally, to match the expectations of the shader. 126 - Add 'halfLeading' to `TextStyle` and `StrutStyle`. 127 - `ParagraphStyle` now accepts textHeightBehavior. 128 129### Removed 130 - `Picture.saveAsFile()`, in favor of `Picture.serialize()` where clients can control how to 131 store/encode the bytes. 132 133## [0.25.1] - 2021-03-30 134 135### Added 136 - Skottie accessors for dynamic text properties (text string, font size). 137 - Optional sampling parameter to drawAtlas (paint filter-quality is ignored/deprecated) 138 139### Fixed 140 - Fonts should not be leaked https://bugs.chromium.org/p/skia/issues/detail?id=11778 141 142## [0.25.0] - 2021-03-02 143 144### Added 145 - A full build of CanvasKit is now in /bin/full. 146 - `CanvasKit.rt_effect` to test if the RuntimeEffect code was compiled in. 147 148### Breaking 149 - The `ShapedText` type has been removed. Clients who want ShapedText should use the 150 Paragraph APIs. 151 152### Removed 153 - `Font.measureText`, which had been previously deprecated. Clients should use either 154 Paragraph APIs or `Font.getGlyphWidths` instead (the latter does no shaping). 155 - `Font.getWidths`, which had been previously deprecated. Clients should use `Font.getGlyphWidths`. 156 157### Type Changes (index.d.ts) 158 - Documentation added for `managed_skottie`, `particles`, and `skottie` feature constants. 159 160## [0.24.0] - 2021-02-18 161 162### Added 163 - The Skottie factory (MakeManagedAnimation) now accepts an optional logger object. 164 165### Breaking 166 - `CanvasKit.getDataBytes` has been removed, as has the Data type. The 2 APIS that returned 167 Data now return Uint8Array containing the bytes directly. These are `Image.encodeToData` 168 (now named `Image.encodeToBytes`) and `SkPicture.serialize`. These APIs return null if 169 the encoding or serialization failed. 170 171### Type Changes (index.d.ts) 172 - `Image.encodeToDataWithFormat` was incorrectly documented as its own thing. 173 174## [0.23.0] - 2021-02-04 175 176### Added 177 - Constants for the shadow flags. Of note, some of these values can be used on previous releases. 178 - `getShadowLocalBounds()` to estimate the bounds of the shadows drawn by `Canvas.drawShadow`. 179 - compile.sh now takes "no_matrix", which will omit the helper JS to deal with 3x3, 4x4 and 180 SkColorMatrix (in case clients have logic to deal with that themselves). 181 - `CanvasKit.RuntimeEffect.Make` now takes an optional callback function that will be called 182 with any compilation error. 183 - `CanvasKit.RuntimeEffect` now exposes uniforms. The number, dimensions, and name of each 184 uniform can be queried, using `RuntimeEffect.getUniformCount`, `RuntimeEffect.getUniform`, and 185 `RuntimeEffect.getUniformName`. The total number of floats across all uniforms (that must be 186 passed to `RuntimeEffect.makeShader`) can be queried with `RuntimeEffect.getUniformFloatCount`. 187 188### Breaking 189 - `MakeImprovedNoise` is removed. 190 - Particles now use a single code string containing both Effect and Particle code. Uniform APIs are 191 now shared between Effect and Particle programs, and are no longer prefixed with `Effect` or 192 `Particle`. For example, instead of `ParticleEffect.getEffectUniform` and 193 `ParticleEffect.getParticleUniform`, there is now just: `ParticleEffect.getUniform`. 194 195### Changed 196 - `Path.getPoint()` and `SkottieAnimation.size()` now return a TypedArray instead of a normal 197 array. Additionally, they take an optional parameter to allow the result to be copied into 198 that provided TypedArray instead of a new one being allocated. 199 - APIs that passed in points should have less overhead (and now can accept a TypedArray). 200 - `Canvas.drawShadow()` now accepts zPlaneParams and lightPos as Malloc'ed and regular 201 Float32Arrays. `getShadowLocalBounds()` does as well. 202 - `ContourMeasure.getPosTan` returns a Float32Array instead of a normal array. Additionally, 203 this method takes an optional parameter to allow the result to be copied into 204 that provided Float32Array instead of a new one being allocated. 205 206### Fixed 207 - Improper error returned when a WebGL context could not be used. 208 - 4x4 matrices are "downsampled" properly if necessary to 3x3 matrices by removing the third 209 column and the third row. 210 - `SkottieAnimation.size()` was incorrectly returning an object. It now returns a TypedArray of 211 length 2 (w, h). 212 213### Deprecated 214 - `Canvas.drawImageRect`, `Canvas.drawImage`, `Canvas.drawAtlas`, 215 These rely on the Paint's FilterQuality, which is going away. Pass sampling options explicitly. 216 217### Removed 218 - `PathMeasure`, which was deprecated and replaced with `ContourMeasure`. 219 220## [0.22.0] - 2020-12-17 221 222### Added 223 - `Canvas.drawImageCubic`, `Canvas.drawImageOptions`, `Canvas.drawImageRectCubic`, 224 `Canvas.drawImageRectOptions` to replace functionality that previously required FilterQuality. 225 - A copy of this changelog is published in NPM releases for easier discovery. 226 227### Breaking 228 - `Canvas.drawImageNine` now takes a required FilterMode (the Paint still is optional). 229 230## [0.21.0] - 2020-12-16 231 232### Added 233 - `getImageInfo()` and `getColorSpace()` to the `Image` type. 234 - `CanvasKit.deleteContext()` for deleting WebGL contexts when done with them, resizing, etc. 235 - `Image.makeCopyWithDefaultMipmaps()` for use with `Image.makeShaderOptions`; necessary if 236 choosing a `MipmapMode` that is not `None`. 237 238### Breaking 239 - `Path.addPoly()` no longer accepts a 2d array of points, but a flattened 1d array. 240 - `MakeVertices()` no longer accepts 2d arrays of points or texture coordinates, but 241 flattened 1d arrays in both places. 242 - `Paint.setFilterQuality`, `Paint.getFilterQuality`, `Image.makeShader` have been removed. 243 The new way to specify interpolation settings is with the newly added `Image.makeShader*` 244 methods. `Image.makeShaderCubic` is a replacement for high quality; `Image.makeShaderOptions` 245 is for medium/low. 246 247### Changed 248 - `MakeImage` is now documented in the Typescript types (index.d.ts). The parameters have been 249 streamlined to align with other, similar APIs. 250 - `MakeAnimatedImageFromEncoded` respects Exif metadata. `MakeImageFromEncoded` already did so 251 (and continues to do so). 252 - The Canvas2D emulation layer always uses high quality image smoothing (this drastically 253 simplifies the underlying code). 254 - We now compile CanvasKit with emsdk 2.0.10 when testing and deploying to npm. 255 - Instead of shipping a "core" build to npm, we ship a "profiling" build, which is the same as 256 the main build, just with unmangled function calls and other debugging info useful for 257 determining where runtime is spent. 258 259### Fixed 260 - `Canvas.drawPoints` correctly takes a flattened Array or TypedArray of points (as the 261 documentation says), not a 2D array. 262 263### Type Changes (index.d.ts) 264 - Documented additional type for InputFlexibleColorArray. 265 266## [0.20.0] - 2020-11-12 267 268### Added 269 - `MakeFractalNoise`, `MakeImprovedNoise`, and `MakeTurbulence` have been added to 270 `CanvasKit.Shader`. 271 - `MakeRasterDirectSurface` for giving the user direct access to drawn pixels. 272 - `getLineMetrics` to Paragraph. 273 - `Canvas.saveLayerPaint` as an experimental, undocumented "fast path" if one only needs to pass 274 the paint. 275 - Support for .woff and .woff2 fonts. Disable .woff2 for reduced code size by supplying 276 no_woff2 to compile.sh. (This removes the code to do brotli decompression). 277 278### Breaking 279 - `CanvasKit.MakePathFromSVGString` was renamed to `CanvasKit.Path.MakeFromSVGString` 280 - `CanvasKit.MakePathFromOp` was renamed to `CanvasKit.Path.MakeFromOp` 281 - The API for `Canvas.readPixels` and `Image.readPixels` has been reworked to more accurately 282 reflect the C++ backend and each other. bytesPerRow is now a required parameter. They take an 283 ImageInfo object to specify the output format. Additionally they take an optional malloc'd 284 object as the last parameter. If provided, the data will be copied into there instead of 285 allocating a new buffer. 286 287### Changed 288 - We now compile CanvasKit with emsdk 2.0.6 when testing and deploying to npm. 289 - We no longer compile with rtti on, saving about 1% in code size. 290 - `CanvasKit.Shader.Blend`, `...Color`, and `...Lerp` have been renamed to 291 `CanvasKit.Shader.MakeBlend`, `...MakeColor` and `...MakeLerp` to align with naming conventions. 292 The old names will be removed in an upcoming release. 293 294### Removed 295 - `CanvasKit.MakePathFromCmds`; Was deprecated in favor of `CanvasKit.Path.MakeFromCmds`. 296 - `new CanvasKit.Path(path)` in favor of existing `path.copy()`. 297 - Unused internal APIs (_getRasterN32PremulSurface, Drawable) 298 - `measureText` from the CanvasContext2D emulation layer due to deprecation of measureText. 299 300### Deprecated 301 - `Font.getWidths` in favor of `Font.getGlyphIDs` and `Font.getGlyphWidths`. 302 - `Font.measureText` in favor of the Paragraph APIs (which actually do shaping). 303 304### Type Changes (index.d.ts) 305 - Return value for MakeFromCmds correctly reflects the possibility of null. 306 - `CanvasKit.GrContext` was renamed to `CanvasKit.GrDirectContext`. 307 - Add docs/types for Shader Gradients (e.g. `CanvasKit.Shader.MakeLinearGradient`). 308 309## [0.19.0] - 2020-10-08 310 311### Breaking 312 - "Sk" has been removed from all names. e.g. `new CanvasKit.SkPaint()` becomes 313 `new CanvasKit.Paint()`. See `./types/index.d.ts` for all the new names. 314 315### Removed 316 - `Surface.captureFrameAsSkPicture`; it was deprecated previously. 317 - `CanvasKit.MakeSkCornerPathEffect`, `CanvasKit.MakeSkDiscretePathEffect`, 318 `CanvasKit.MakeBlurMaskFilter`, `CanvasKit.MakeSkDashPathEffect`, 319 `CanvasKit.MakeLinearGradientShader`, `CanvasKit.MakeRadialGradientShader`, 320 `CanvasKit.MakeTwoPointConicalGradientShader`; these were deprecated previously and have 321 replacements like `CanvasKit.PathEffect.MakeDash`. 322 - `Canvas.concat44`; it was deprecated previously, just use `Canvas.concat` 323 324## [0.18.1] - 2020-10-06 325 326### Added 327 - Typescript types (and documentation) are now in the types subfolder. We will keep these updated 328 as we make changes to the CanvasKit library. 329 330## [0.18.0] - 2020-10-05 331 332### Breaking 333 - SkRect are no longer returned from `CanvasKit.LTRBRect`, `CanvasKit.XYWHRect` nor 334 are accepted as JS objects. Instead, the format is 4 floats in either an array, a 335 Float32Array or a piece of memory returned by CanvasKit.Malloc. These floats are the 336 left, top, right, bottom numbers of the rectangle. 337 - SkIRect (Rectangles with Integer values) are no longer accepted as JS objects. 338 Instead, the format is 4 ints in either an array, an Int32Array or a piece of memory 339 returned by CanvasKit.Malloc. These ints are the left, top, right, bottom numbers of 340 the rectangle. 341 - SkRRect (Rectangles with rounded corners) are no longer returned from `CanvasKit.RRectXY` 342 nor are accepted as JS objects. Instead, the format is 12 floats in either an array, a 343 Float32Array or a piece of memory returned by CanvasKit.Malloc. The first 4 floats 344 are the left, top, right, bottom numbers of the rectangle and then 4 sets of points 345 starting in the upper left corner and going clockwise. This change allows for faster 346 transfer between JS and WASM code. 347 - `SkPath.addRoundRect` has been replaced with `SkPath.addRRect`. The same functionality 348 can be had with the `CanvasKit.RRectXY` helper. 349 - `SkPath.addRect` no longer accepts 4 floats as separate arguments. It only accepts 350 an SkRect (an array/Float32Array of 4 floats) and an optional boolean for 351 determining clockwise or counter-clockwise directionality. 352 - The order of `SkCanvas.saveLayer` arguments is slightly different (more consistent). 353 It is now `paint, bounds, backdrop, flags` 354 355### Changed 356 - We now compile CanvasKit with emsdk 2.0.0 when testing and deploying to npm. 357 - WebGL interface creation is a little leaner in terms of code size and speed. 358 - The signature of `main` used with SkSL passed to `CanvasKit.SkRuntimeEffect.Make` has changed. 359 There is no longer an `inout half4 color` parameter, effects must return their color instead. 360 Valid signatures are now `half4 main()` or `half4 main(float2 coord)`. 361 - `SkPath.getBounds`, `SkShapedText.getBounds`, and `SkVertices.bounds` now 362 take an optional argument. If a Float32Array with length 4 or greater is 363 provided, the bounds will be copied into this array instead of allocating 364 a new one. 365 - `SkCanvas.drawAnimatedImage` has been removed in favor of calling 366 `SkCanvas.drawImageAtCurrentFrame` or `SkAnimatedImage.makeImageAtCurrentFrame` and then 367 `SkCanvas.drawImage`. 368 - `SkTextBlob.MakeFromRSXform` also accepts a (possibly Malloc'd) Float32Array of RSXforms ( 369 see SkRSXform for more.) 370 371### Removed 372 - `SkCanvas.drawRoundRect` has been removed in favor of `SkCanvas.drawRRect` 373 The same functionality can be had with the `CanvasKit.RRectXY` helper. 374 - `SkPath.arcTo` which had been deprecated in favor of `SkPath.arcToOval`, 375 `SkPath.arcToRotated`, `SkPath.arcToTangent`. 376 - Extraneous ColorTypes from `ColorType` enum. 377 378### Added 379 - `CanvasKit.LTRBiRect` and `CanvasKit.XYWHiRect` as helpers to create SkIRects. 380 - `SkCanvas.drawRect4f` as a somewhat experimental way to have array-free APIs for clients that 381 already have their own representation of Rect. This is experimental because we don't know 382 if it's faster/better under real-world use and because we don't want to commit to having these 383 for all Rect APIs (and for similar types) until it has baked in a bit. 384 - Added the following to `TextStyle`: 385 - `decorationStyle` 386 - `textBaseline` 387 - `letterSpacing` 388 - `wordSpacing` 389 - `heightMultiplier` 390 - `locale` 391 - `shadows` 392 - `fontFeatures` 393 - Added `strutStyle` to `ParagraphStyle`. 394 - Added `addPlaceholder` to `ParagraphBuilder`. 395 - Added `getRectsForPlaceholders` to `Paragraph`. 396 - `SkFont.getGlyphIDs`, `SkFont.getGlyphBounds`, `SkFont.getGlyphWidths` for turning code points 397 into GlyphIDs and getting the associated metrics with those glyphs. Note: glyph ids are only 398 valid for the font of which they were requested. 399 - `SkTextBlob.MakeFromRSXformGlyphs` and `SkTextBlob.MakeFromGlyphs` as a way to build TextBlobs 400 using GlyphIDs instead of code points. 401 - `CanvasKit.MallocGlyphIDs` as a helper for pre-allocating space on the WASM heap for Glyph IDs. 402 403### Deprecated 404 - `SkAnimatedImage.getCurrentFrame`; prefer `SkAnimatedImage.makeImageAtCurrentFrame` (which 405 follows the establishing naming convention). 406 - `SkSurface.captureFrameAsSkPicture` will be removed in a future release. Callers can simply 407 use `SkPictureRecorder` directly. 408 - `CanvasKit.FourFloatArrayHelper` and related helpers (mostly helping with drawAtlas). 409 `CanvasKit.Malloc` is the better tool and will replace these soon. 410 - `SkPathMeasure`; SkContourMeasureIter has all the same functionality and a cleaner pattern. 411 412### Fixed 413 - Addressed Memory leak in `SkCanvas.drawText`. 414 - Made SkTextBlob hang on to less memory during its lifetime. 415 - `SkPath.computeTightBounds()` works again. Like getBounds() it takes an optional argument 416 to put the bounds into. 417 418## [0.17.3] - 2020-08-05 419 420### Added 421 - Added `CanvasKit.TypefaceFontProvider`, which can be used to register fonts 422 with a font family alias. For example, "Roboto Light" may be registered with 423 the alias "Roboto", and it will be used when "Roboto" is used with a light 424 font weight. 425 - Added `CanvasKit.ParagraphBuilder.MakeFromFontProvider` to make a 426 `ParagraphBuilder` from a `TypefaceFontProvider`. 427 - Added `CanvasKit.ParagraphBuilder.pushPaintStyle` which can be used to stroke or fill 428 text with paints instead of simple colors. 429 430## [0.17.2] - 2020-07-22 431 432### Fixed 433 - Shader programs are no longer generated with `do-while` loops in WebGL 1.0. 434 435## [0.17.1] - 2020-07-21 436 437### Added 438 - Compile option to deserialize effects in skps `include_effects_deserialization`. 439 440### Changed 441 - Pathops and SKP deserialization/serialization enabled on the npm build. 442 443## [0.17.0] - 2020-07-20 444 445### Added 446 - Added `CanvasKit.MakeImageFromCanvasImageSource` which takes either an HTMLImageElement, 447 SVGImageElement, HTMLVideoElement, HTMLCanvasElement, ImageBitmap, or OffscreenCanvas and returns 448 an SkImage. This function is an alternative to `CanvasKit.MakeImageFromEncoded` for creating 449 SkImages when loading and decoding images. In the future, codesize of CanvasKit may be able to be 450 reduced by removing image codecs in wasm, if browser APIs for decoding images are used along with 451 `CanvasKit.MakeImageFromCanvasImageSource` instead of `CanvasKit.MakeImageFromEncoded`. 452 - Three usage examples of `CanvasKit.MakeImageFromCanvasImageSource` in core.spec.ts. 453 - Added support for asynchronous callbacks in perfs and tests. 454 - `CanvasKit.SkPath.MakeFromVerbsPointsWeights` and `CanvasKit.SkPath.addVerbsPointsWeights` for 455 supplying many path operations (e.g. moveTo, cubicTo) at once. 456 - The object returned by `CanvasKit.malloc` now has a `subarray` method which works exactly like 457 the normal TypedArray version. The TypedArray which it returns is also backed by WASM memory 458 and when passed into CanvasKit will be used w/o copying the data (just like 459 `Malloc.toTypedArray`). 460 - `SkM44.setupCamera` to return a 4x4 matrix which sets up a perspective view from a camera. 461 - `SkPath.arcToOval`, `SkPath.arcToTangent`, and `SkPath.arcToRotated` to replace the three 462 overloads of `SkPath.arcTo`. https://github.com/flutter/flutter/issues/61305 463 464### Changed 465 - In all places where color arrays are accepted (gradient makers, drawAtlas, and MakeSkVertices), 466 You can now provide either flat Float32Arrays of float colors, Uint32Arrays of int colors, or 467 2d Arrays of Float32Array(4) colors. The one thing you should not pass is an Array of numbers, 468 since canvaskit wouldn't be able to tell whether they're ints or floats without checking them all. 469 The fastest choice for gradients is the flat Float32Array, the fastest choice for drawAtlas and 470 MakeSkVertices is the flat Uint32Array. 471 - Color arrays may also be objects created with CanvasKit.Malloc 472 - renamed `reportBackendType` to `reportBackendTypeIsGPU` and made it return a boolean 473 - `MakeWebGLCanvasSurface` can now accept an optional dictionary of WebGL context attributes that 474 can be used to override default attributes. 475 476### Fixed 477 - `TextStyle.color` can correctly be a Malloc'd Float32Array. 478 - Support wombat-dressing-room. go/npm-publish 479 480### Deprecated 481 - `CanvasKit.MakePathFromCmds` has been renamed to `CanvasKit.SkPath.MakeFromCmds`. The alias 482 will be removed in an upcoming release. 483 - `SkPath.arcTo` Separated into three functions. 484 485## [0.16.2] - 2020-06-05 486 487### Fixed 488 - A bug where loading fonts (and other memory intensive calls) would cause CanvasKit 489 to infrequently crash with 490 `TypeError: Cannot perform %TypedArray%.prototype.set on a neutered ArrayBuffer`. 491 - Incorrectly freeing Malloced colors passed into computeTonalColors. 492 493## [0.16.1] - 2020-06-04 494 495### Fixed 496 - Colors are unsigned to be compatible with Flutter Web and previous behavior, not 497 signed ints. 498 499## [0.16.0] - 2020-06-03 500 501### Added 502 - Support for wide-gamut color spaces DisplayP3 and AdobeRGB. However, correct representation on a 503 WCG monitor requires that the browser is rendering everything to the DisplayP3 or AdobeRGB 504 profile, since there is not yet any way to indicate to the browser that a canvas element has a 505 non-sRGB color space. See color support example in extra.html. Only supported for WebGL2 backed 506 surfaces. 507 - Added `SkSurface.reportBackendType` which returns either 'CPU' or 'GPU'. 508 - Added `SkSurface.imageInfo` which returns an ImageInfo object describing the size and color 509 properties of the surface. colorSpace is added to ImageInfo everywhere it is used. 510 - `CanvasKit.Free` to explicitly clean up memory after `CanvasKit.Malloc`. All memory allocated 511 with `CanvasKit.Malloc` must be released with `CanvasKit.Free` or it will be leaked. This can 512 improve performance by reducing the copying of data between the JS and WASM side. 513 - `CanvasKit.ColorAsInt`, `SkPaint.setColorComponents`, `SkPaint.setColorInt`, 514 `SkCanvas.drawColorComponents`, `SkCanvas.drawColorInt` for when clients want 515 to avoid the overhead of allocating an array for color components and only need 8888 color. 516 517### Changed 518 - We now compile/ship with Emscripten v1.39.16. 519 - `CanvasKit.MakeCanvasSurface` accepts a new enum specifying one of the three color space and 520 pixel format combinations supported by CanvasKit. 521 - all `_Make*Shader` functions now accept a color space argument at the end. leaving it off or 522 passing null makes it behave as it did before, defaulting to sRGB 523 - `SkPaint.setColor` accepts a new color space argument, defaulting to sRGB. 524 - Fewer allocations required to send Color and Matrices between JS and WASM layer. 525 - All APIs that take a 1 dimensional array should also accept the object returned by Malloc. It is 526 recommended to pass the Malloc object, as the TypedArray could be invalidated any time 527 CanvasKit needs to allocate memory and needs to resize to accommodate. 528 529### Breaking 530 - `CanvasKitInit(...)` now directly returns a Promise. As such, `CanvasKitInit(...).ready()` 531 has been removed. 532 - `CanvasKit.MakeCanvasSurface` no longer accepts width/height arguments to override those on 533 the canvas element. Use the canvas element's width/height attributes to dictate the size of 534 the drawing area, and use CSS width/height to set the size it will appear on the page 535 (it is rescaled after drawing when css sizing applies). 536 - Memory returned by `CanvasKit.Malloc` will no longer be automatically cleaned up. Clients 537 must use `CanvasKit.Free` to release the memory. 538 - `CanvasKit.Malloc` no longer directly returns a TypedArray, but an object that can produce 539 them with toTypedArray(). This is to avoid "detached ArrayBuffer" errors: 540 <https://github.com/emscripten-core/emscripten/issues/6747> 541 542### Fixed 543 - WebGL context is no longer created with "antialias" flag. Using "antialias" caused poor AA 544 quality in Ganesh when trying to do coverage-based AA with MSAA unknowingly enabled. It also 545 reduced performance. 546 547## [0.15.0] - 2020-05-14 548 549### Added 550 - Support for DOMMatrix on all APIs that take SkMatrix (i.e. arrays or Float32Arrays of length 6/9/16). 551 - setEdging and setEmbeddedBitmaps to SkFont. You can disable the ability to draw aliased fonts (and save some code 552 size) with the compile.sh argument `no_alias_font`. 553 554### Removed 555 - Previously deprecated functions `MakeSkDashPathEffect`, `MakeLinearGradientShader`, 556 `MakeRadialGradientShader`, `MakeTwoPointConicalGradientShader`, `MakeSkCornerPathEffect`, 557 `MakeSkDiscretePathEffect` 558 559### Changed 560 - CanvasKit colors are now represented with a TypedArray of four floats. 561 - Calls to `getError` should be disabled. This may cause a performance improvement in some scenarios. 562 563### Removed 564 - SkPaint.setColorf is obsolete and removed. setColor accepts a CanvasKit color which is 565 always composed of floats. 566 - localmatrix option for `SkShader.Lerp` and `SkShader.Blend`. 567 568### Deprecated 569 - `SkCanvas.concat44` has been folded into concat (which now takes 3x2, 3x3, or 4x4 matrices). It will 570 be removed soon. 571 572### Fixed 573 - Memory leak in paragraph binding code (https://github.com/flutter/flutter/issues/56938) 574 - Safari now properly uses WebGL1 instead of WebGL2 when WebGL2 is not available (skbug.com/10171). 575 576## [0.14.0] - 2020-03-18 577 578### Added 579 - `SkShader.MakeSweepGradient` 580 - `SkCanvas.saveLayer` can now be called with 1 argument (the paint). In this case the current 581 effective clip will be used, as the current rect is assumed to be null. 582 - `SkPaint.setAlphaf` 583 - Clients can supply `no_codecs` to compile.sh to remove all codec encoding and decoded code. 584 This can save over 100 kb compressed if codecs are not needed. 585 586### Deprecated 587 - `MakeSkDashPathEffect` will be removed soon. Calls can be replaced with 588 `SkPathEffect.MakeDash`. 589 - `MakeLinearGradientShader` will be removed soon. Calls can be replaced with 590 `SkShader.MakeLinearGradient`. 591 - `MakeRadialGradientShader` will be removed soon. Calls can be replaced with 592 `SkShader.MakeRadialGradient`. 593 - `MakeTwoPointConicalGradientShader` will be removed soon. Calls can be replaced with 594 `SkShader.MakeTwoPointConicalGradient`. 595 596### Fixed 597 - Shadows are properly draw on fillRect and strokeRect in the canvas2d emulation layer. 598 - Shadow offsets properly ignore the CTM in the canvas2d emulation layer. 599 600### Changed 601 - Stop compiling jpeg and webp encoders by default. This results in a 100kb binary size reduction. 602 Clients that need these encoders can supply `force_encode_webp` or `force_encode_jpeg` to 603 compile.sh. 604 605### Removed 606 - Removed inverse filltypes. 607 - Removed StrokeAndFill paint style. 608 - Removed TextEncoding enum (it was only used internally). All functions assume UTF-8. 609 610## [0.13.0] - 2020-02-28 611 612### Deprecated 613 - `MakeSkCornerPathEffect` will be removed soon. Calls can be replaced with 614 `SkPathEffect.MakeCorner`. 615 - `MakeSkDiscretePathEffect` will be removed soon. Calls can be replaced with 616 `SkPathEffect.MakeDiscrete`. 617 618### Added 619 - `SkSurface.drawOnce` for drawing a single frame (in addition to already existing 620 `SkSurface.requestAnimationFrame` for animation logic). 621 - `CanvasKit.parseColorString` which processes color strings like "#2288FF" 622 - Particles module now exposes effect uniforms, which can be modified for live-updating. 623 - Experimental 4x4 matrices added in `SkM44`. 624 - Vector math functions added in `SkVector`. 625 - `SkRuntimeEffect.makeShaderWithChildren`, which can take in other shaders as fragmentProcessors. 626 - `GrContext.releaseResourcesAndAbandonContext` to free up WebGL contexts. 627 - A few methods on `SkFont`: `setHinting`, `setLinearMetrics`, `setSubpixel`. 628 629### Changed 630 - We now compile/ship with Emscripten v1.39.6. 631 - `SkMatrix.multiply` can now accept any number of matrix arguments, multiplying them 632 left-to-right. 633 - SkMatrix.invert now returns null when the matrix is not invertible. Previously it would return an 634 identity matrix. Callers must determine what behavior would be appropriate in this situation. 635 - In Canvas2D compatibility layer, the underlying SkFont will have setSubpixel(true). 636 - Bones are removed from Vertices builder 637 638### Fixed 639 - Support for .otf fonts (.woff and .woff2 still not supported). 640 641## [0.12.0] - 2020-01-22 642 643### Added 644 - `SkFontMgr.countFamilies` and `SkFontMgr.getFamilyName` to expose the parsed font names. 645 646### Changed 647 - SKP serialization/deserialization now available (can be disabled with the 'no_skp'). 648 `SkPicture.DEBUGONLY_saveAsFile` renamed to `SkPicture.saveAsFile` and 649 `CanvasKit.MakeSkPicture` is now exposed. SKP support is not shipped to npm builds. 650 `force_serialize_skp` has been removed since it opt-out, not opt-in. 651 652### Fixed 653 - Bug that sometimes resulted in 'Cannot perform Construct on a neutered ArrayBuffer' 654 - Bug with SkImage.readPixels (skbug.com/9788) 655 - Bug with transparent colors in Canvas2d mode (skbug.com/9800) 656 657## [0.11.0] - 2020-01-10 658 659### Added 660 - A "Core" build that removes Fonts, the Skottie animation player, the Particles demo, 661 and PathOps is available in `bin/core/`. It is about half the size of the "CoreWithFonts" 662 build. 663 - Experimental Runtime shader available for custom builds. 664 - WebP support. 665 - `SkAnimatedImage.getCurrentFrame` which returns an SkImage. 666 667### Fixed 668 - `CanvasKit.SaveLayerInitWithPrevious` and `CanvasKit.SaveLayerF16ColorType` constants. 669 - Some compilation configurations, for example, those with no fonts or just one of particles/skottie. 670 671### Changed 672 - Small tweaks to compilation settings to reduce code size and linkage time. 673 - JS functions are no longer provided when the underlying c++ calls have been compiled out. 674 675### Removed 676 - `SkShader.Empty` 677 - Support for Type 1 Fonts. These are ancient and removing them saves about 135k 678 of code size. 679 680### Breaking 681 - In an effort to reduce code size for most clients, npm now contains two CanvasKit builds. 682 In `bin/` there is the "CoreWithFonts" build that contains most functionality from 0.10.0. 683 However, we no longer ship the Skottie animation player, nor the Particles demo. Further, 684 PathOps are removed from this build `MakePathFromOp`, `SkPath.op` and `SkPath.simplify`. 685 Clients who need any of those features are encouraged to create a custom build using 686 `compile.sh`. 687 - `SkPicture.DEBUGONLY_saveAsFile` was accidentally included in release builds. It has been 688 removed. Clients who need this in a release build (e.g. to file a bug report that only 689 reproduces in release) should do a custom build with the `force_serialize_skp` flag given. 690 691### Deprecated 692 - `SkCanvas.drawAnimatedImage` will be renamed soon. Calls can be replaced with `SkCanvas.drawImage` 693 and `SkAnimatedImage.getCurrentFrame`. 694 695## [0.10.0] - 2019-12-09 696 697### Added 698 - `SkContourMeasureIter` and `SkContourMeasure` as an alternative to `SkPathMeasure`. 699 - CanvasKit image decode cache helpers: getDecodeCacheLimitBytes(), setDecodeCacheLimitBytes(), 700 and getDecodeCacheUsedBytes(). 701 - `SkShader.Blend`, `SkShader.Color`, `SkShader.Empty`, `SkShader.Lerp`. 702 703### Changed 704 - The returned values from `SkParagraph.getRectsForRange` now have direction with value 705 `CanvasKit.TextDirection`. 706 707### Fixed 708 - `MakeImage` properly in the externs file and can work with `CanvasKit.Malloc`. 709 710## [0.9.0] - 2019-11-18 711### Added 712 - Experimental `CanvasKit.Malloc`, which can be used to create a 713 TypedArray backed by the C++ WASM memory. This can save a copy in some cases 714 (e.g. SkColorFilter.MakeMatrix). This is an advanced feature, so use it with care. 715 - `SkCanvas.clipRRect`, `SkCanvas.drawColor` 716 - Blur, ColorFilter, Compose, MatrixTransform SkImageFilters. Can be used with `SkPaint.setImageFilter`. 717 - `SkCanvas.saveLayer` now takes 3 or 4 params to include up to bounds, paint, SkImageFilter, flags. 718 - `SkPath.rArcTo`, `SkPath.rConicTo`, `SkPath.rCubicTo`, `SkPath.rLineTo`, `SkPath.rMoveTo`, 719 `SkPath.rQuadTo`. Like their non-relative siblings, these are chainable. 720 - Add `width()`, `height()`, `reset()`, `getFrameCount()` to SkAnimatedImage. 721 - `SkCanvas.drawImageNine`, `SkCanvas.drawPoints` and related `PointMode` enum. 722 - `SkPath.addPoly` 723 - `SkPathMeasure.getSegment` 724 - More information on SkParagraph API, eg. `getLongestLine()`, `getWordBoundary`, and others. 725 726### Deprecated 727 - `CanvasKit.MakeBlurMaskFilter` will be renamed/moved soon to `CanvasKit.SkMaskFilter.MakeBlur`. 728 729### Changed 730 - Use newer version of Freetype2 (Tracking Skia's DEPS now). 731 - Use newer versions of libpng and zlib (Tracking Skia's DEPS now). 732 733### Fixed 734 - null dereference when sometimes falling back to CPU. 735 - Actually ask WebGL for a stencil buffer. 736 - Can opt out of Paragraph API with no_paragraph passed into compile.sh or when using primitive_shaper. 737 738## [0.8.0] - 2019-10-21 739 740### Added 741 - `CanvasKit.MakeAnimatedImageFromEncoded`, `SkCanvas.drawAnimatedImage`. 742 - `CanvasKit.SkFontMgr.FromData` which takes several ArrayBuffers of font data, parses 743 them, reading the metadata (e.g. family names) and stores them into a SkFontMgr. 744 - SkParagraph as an optional set of APIs for dealing with text layout. 745 746### Changed 747 - The `no_font` compile option should strip out more dead code related to fonts. 748 - and `no_embedded_font` option now allows creating a `SkFontMgr.FromData` instead of 749 always having an empty one. 750 - Updated to emscripten 1.38.47 751 - Switch to WebGL 2.0, but fall back to 1.0 when unavailable - bug.skia.org/9052 752 753### Fixed 754 - Null terminator bug in draw text - skbug.com/9314 755 756## [0.7.0] - 2019-09-18 757 758### Added 759 - `SkCanvas.drawCircle()`, `SkCanvas.getSaveCount()` 760 - `SkPath.offset()`, `SkPath.drawOval` 761 - `SkRRect` support (`SkCanvas.drawRRect`, `SkCanvas.drawDRRect`, `CanvasKit.RRectXY`). 762 Advanced users can specify the 8 individual radii, if needed. 763 - `CanvasKit.computeTonalColors()`, which returns TonalColors, which has an 764 ambient SkColor and a spot SkColor. 765 - `CanvasKit.SkColorFilter` and a variety of factories. `SkPaint.setColorFilter` is the only 766 consumer of these at the moment. 767 - `CanvasKit.SkColorMatrix` with functions `.identity()`, `.scaled()`, `.concat()` and 768 others. Primarily for use with `CanvasKit.SkColorFilter.MakeMatrix`. 769 770### Changed 771 - `MakeSkVertices` uses a builder to save a copy. 772 773### Breaking 774 - When `SkPath.arcTo` is given seven arguments, it no longer turns the first four into 775 a `SkRect` automatically, and instead uses them as 776 `arcTo(rx, ry, xAxisRotate, useSmallArc, isCCW, x, y)` (see SkPath.h for more). 777 778## [0.6.0] - 2019-05-06 779 780### Added 781 - `SkSurface.grContext` now exposed. `GrContext` has new methods for monitoring/setting 782 the cache limits; tweaking these may lead to better performance in some cases. 783 `getResourceCacheLimitBytes`, `setResourceCacheLimitBytes`, `getResourceCacheUsageBytes` 784 - `SkCanvas.drawAtlas` for efficiently drawing multiple sprites from a sprite sheet with 785 a set of transforms, color blends, etc. 786 - `SkColorBuilder`, `RSXFormBuilder`, `SkRectBuilder` which increase performance by 787 reducing the amount of malloc/free calls per frame, given that the array size is fixed. 788 - Basic `SkPicture` support. `SkSurface.captureFrameAsSkPicture` is a helper function to 789 capture an `SkPicture`, which can be dumped to disk (for debugging) with 790 `SkPicture.DEBUGONLY_saveAsFile`. 791 - `SkImage.readPixels`, which returns a TypedArray of pixel values (safe to use 792 anywhere, doesn't need a delete()). 793 794### Changed 795 - Better `GrGLCaps` support for WebGL - this shouldn't have any impacts on APIs or 796 correctness, except by perhaps fixing a few bugs in various surface types. 797 - Use unsigned ints for SkColor on the JS side - this shouldn't have any impacts 798 unless clients have pre-computed colors, in which case, they will need to re-compute them. 799 - [breaking] Moved `CanvasKit.MakeImageShader` to `SkImage.makeShader` - removed clampUnpremul 800 as argument. 801 802## [0.5.1] - 2019-03-21 803 804### Added 805 - `SkPathMeasure`, `RSXFormBuilder`, `SkFont.getWidths`, `SkTextBlob.MakeFromRSXform` 806 which were needed to add the helper function `SkTextBlob.MakeOnPath`. 807 - `SkSurface.requestAnimationFrame` - wrapper around window.requestAnimationFrame that 808 takes care of the setup/tear down required to use CanvasKit optimally. The callback 809 has an `SkCanvas` as the first parameter - callers should draw on that. 810 811### Changed 812 - Location in Skia Git repo now `modules/canvaskit` (was `experimental/canvaskit`) 813 814### Fixed 815 - Extern bug in `CanvasKit.SkMatrix.invert` 816 - Fallback to CPU now properly refreshes the canvas to get access to the 817 CanvasRenderingContext2D. 818 - Compile flags for better WebGL1 support for some graphics cards. 819 - Antialias bug on large oval paths <https://crbug.com/skia/8873> 820 821### Deprecated 822 - `SkCanvas.flush` will be removed soon - client should only call `SkSurface.flush` 823 824 825## [0.5.0] - 2019-03-08 826 827### Added 828 - isVolitile option to `CanvasKit.MakeSkVertices`. The previous (and current default) behavior 829 was for this to be true; some applications may go faster if set to false. 830 - `SkCanvas.saveLayer(rect, paint)` 831 - `SkCanvas.restoreToCount(int)` which can be used with the output of .save() and .saveLayer(). 832 - Optional particles library from modules/particles. `See CanvasKit.MakeParticles(json)`; 833 - More public APIs for working with Surfaces/Contexts `GetWebGLContext`, 834 `MakeGrContext`, `MakeOnScreenGLSurface`, `MakeRenderTarget`. 835 - `SkSurface.getSurface()` and `SkCanvas.getSurface()` for making compatible surfaces (typically 836 used as a workspace and then "saved" with `surface.makeImageSnapshot()`) 837 838### Breaking 839 - `CanvasKit.MakeWebGLCanvasSurface` no longer takes a webgl context as a first arg, only a 840 canvas or an id of a canvas. If users want to manage their own GL contexts, they should build 841 the `SkSurface` themselves with `GetWebGLContext` -> `MakeGrContext` -> 842 `MakeOnScreenGLSurface`. 843 844## [0.4.1] - 2019-03-01 845 846### Added 847 - Optional arguments to `MakeManagedAnimation` for supplying external assets (like images, fonts). 848 849## [0.4.0] - 2019-02-25 850 851### Added 852 - `SkPath.addRoundRect`, `SkPath.reset`, `SkPath.rewind` exposed. 853 - `SkCanvas.drawArc`, `SkCanvas.drawLine`, `SkCanvas.drawOval`, `SkCanvas.drawRoundRect` exposed. 854 - Can import/export a SkPath to an array of commands. See `CanvasKit.MakePathFromCmds` and 855 `SkPath.toCmds`. 856 - `SkCanvas.drawTextBlob()` and `SkCanvas.SkTextBlob.MakeFromText()` to draw text to a canvas. 857 - `CanvasKit.TextEncoding` enum. For use with `SkTextBlob`. 858 - Text shaping with `ShapedText` object and `SkCanvas.drawText`. At compile time, one can choose 859 between using Harfbuzz/ICU (default) or a primitive one ("primitive_shaper") which just does 860 line breaking. Using Harfbuzz/ICU substantially increases code size (4.3 MB to 6.4 MB). 861 862### Changed 863 - `SkCanvas.drawText()` now requires an `SkFont` object for raw strings. 864 865 866### Removed 867 - `SkPaint.setTextSize()`, `SkPaint.getTextSize()`, `SkPaint.setTypeface()` 868 which should be replaced by using `SkFont`. 869 - Deprecated `CanvasKitInit().then()` interface (see 0.3.1 notes) 870 871 872### Fixed 873 - Potential bug in `ready()` if already loaded. 874 875## [0.3.1] - 2019-01-04 876### Added 877 - `SkFont` now exposed. 878 - `MakeCanvasSurface` can now take a canvas element directly. 879 - `MakeWebGLCanvasSurface` can now take a WebGL context as an integer and use it directly. 880 881### Changed 882 - `CanvasKitInit(...).then()` is no longer the recommended way to initialize things. 883It will be removed in 0.4.0. Use `CanvasKitInit(...).ready()`, which returns a real Promise. 884 885### Removed 886- `SkPaint.measureText` - use `SkFont.measureText` instead. 887 888## [0.3.0] - 2018-12-18 889 890### Added 891- Add Canvas2D JS layer. This mirrors the HTML Canvas API. This may be omitted at compile time 892 it by adding `no_canvas` to the `compile.sh` invocation. 893- `CanvasKit.FontMgr.DefaultRef()` and `fontmgr.MakeTypefaceFromData` to load fonts. 894- Exposed `SkPath.setVolatile`. Some animations see performance improvements by setting 895their paths' volatility to true. 896 897### Fixed 898- `SkPath.addRect` now correctly draws counter-clockwise vs clockwise. 899 900### Changed 901- `CanvasKit.MakeImageShader` no longer takes encoded bytes, but an `SkImage`, created from 902 `CanvasKit.MakeImageFromEncoded`. Additionally, the optional parameters `clampIfUnpremul` 903 and `localMatrix` have been exposed. 904- `SkPath.arcTo` now takes `startAngle`, `sweepAngle`, `forceMoveTo` as additional parameters. 905- `SkPath.stroke` has a new option `precision` It defaults to 1.0. 906- CanvasKit comes with one font (NotoMono) instead of the Skia TestTypeface. Clients are encouraged 907 to use the new `fontmgr.MakeTypefaceFromData` for more font variety. 908 909### Removed 910- `CanvasKit.initFonts()` - no longer needed. 911 912 913## [0.2.1] - 2018-11-20 914Beginning of Changelog history 915