Skip to content

Commit

Permalink
⬆️ Upgrade CanvasKit version (#1991)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon authored Nov 20, 2023
1 parent 74911b8 commit 0b818a2
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 36 deletions.
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"ws": "^8.11.0"
},
"dependencies": {
"canvaskit-wasm": "0.38.2",
"canvaskit-wasm": "0.39.1",
"react-reconciler": "^0.27.0"
},
"eslintIgnore": [
Expand Down
3 changes: 3 additions & 0 deletions package/src/skia/__tests__/Enums.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const checkEnum = <T>(skiaEnum: T, canvasKitEnum: EmbindEnum) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
const selectedEnum = canvasKitEnum[namedKey];
if (namedKey === undefined || selectedEnum === undefined) {
console.log({ skiaEnum, canvasKitEnum, key, namedKey, expected });
}
expect(selectedEnum).toBeDefined();
expect(expected).toBe(selectedEnum.value);
});
Expand Down
55 changes: 30 additions & 25 deletions package/src/skia/types/Image/ImageFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,41 @@ export enum AlphaType {
}

export enum ColorType {
Unknown, //!< uninitialized
Alpha_8, //!< pixel with alpha in 8-bit byte
RGB_565, //!< pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
ARGB_4444, //!< pixel with 4 bits for alpha, red, green, blue; in 16-bit word
RGBA_8888, //!< pixel with 8 bits for red, green, blue, alpha; in 32-bit word
RGB_888x, //!< pixel with 8 bits each for red, green, blue; in 32-bit word
BGRA_8888, //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word
RGBA_1010102, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
BGRA_1010102, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
RGB_101010x, //!< pixel with 10 bits each for red, green, blue; in 32-bit word
BGR_101010x, //!< pixel with 10 bits each for blue, green, red; in 32-bit word
BGR_101010x_XR, //!< pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
Gray_8, //!< pixel with grayscale level in 8-bit byte
RGBA_F16Norm, //!< pixel with half floats in [0,1] for red, green, blue, alpha;
// in 64-bit word
RGBA_F16, //!< pixel with half floats for red, green, blue, alpha;
// in 64-bit word
RGBA_F32, //!< pixel using C float for red, green, blue, alpha; in 128-bit word
Unknown, // uninitialized
Alpha_8, // pixel with alpha in 8-bit byte
RGB_565, // pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
ARGB_4444, // pixel with 4 bits for alpha, red, green, blue; in 16-bit word
RGBA_8888, // pixel with 8 bits for red, green, blue, alpha; in 32-bit word
RGB_888x, // pixel with 8 bits each for red, green, blue; in 32-bit word
BGRA_8888, // pixel with 8 bits for blue, green, red, alpha; in 32-bit word
RGBA_1010102, // 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
BGRA_1010102, // 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
RGB_101010x, // pixel with 10 bits each for red, green, blue; in 32-bit word
BGR_101010x, // pixel with 10 bits each for blue, green, red; in 32-bit word
BGR_101010x_XR, // pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
RGBA_10x6, // pixel with 10 used bits (most significant) followed by 6 unused
Gray_8, // pixel with grayscale level in 8-bit byte
RGBA_F16Norm, // pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word
RGBA_F16, // pixel with half floats for red, green, blue, alpha; in 64-bit word
RGBA_F32, // pixel using C float for red, green, blue, alpha; in 128-bit word

// The following 6 colortypes are just for reading from - not for rendering to
R8G8_unorm, //!< pixel with a uint8_t for red and green
R8G8_unorm, // pixel with a uint8_t for red and green

A16_float, //!< pixel with a half float for alpha
R16G16_float, //!< pixel with a half float for red and green
A16_float, // pixel with a half float for alpha
R16G16_float, // pixel with a half float for red and green

A16_unorm, // pixel with a little endian uint16_t for alpha
R16G16_unorm, // pixel with a little endian uint16_t for red and green
R16G16B16A16_unorm, // pixel with a little endian uint16_t for red, green, blue, and alpha

A16_unorm, //!< pixel with a little endian uint16_t for alpha
R16G16_unorm, //!< pixel with a little endian uint16_t for red and green
R16G16B16A16_unorm, //!< pixel with a little endian uint16_t for red, green, blue
// and alpha
SRGBA_8888,
R8_unorm,

// The `kN32_SkColorType` is platform dependent in the original enum,
// and TypeScript doesn't support conditional compilation natively.
// You might need to handle it differently based on your use case.
N32_SkColorType, // either BGRA_8888 or RGBA_8888 based on the platform
}

export interface ImageInfo {
Expand Down
2 changes: 0 additions & 2 deletions package/src/skia/web/JsiSkFontMgrFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export class JsiSkFontMgrFactory extends Host implements FontMgrFactory {
if (!fontMgr) {
throw new Error("Couldn't create system font manager");
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
return new JsiSkFontMgr(this.CanvasKit, fontMgr);
}
}
4 changes: 0 additions & 4 deletions package/src/skia/web/JsiSkTypefaceFontProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ export class JsiSkTypefaceFontProvider
throw new NotImplementedOnRNWeb();
}
countFamilies() {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
return this.ref.countFamilies();
}
getFamilyName(index: number) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
return this.ref.getFamilyName(index);
}
registerFont(typeface: SkTypeface, familyName: string) {
Expand Down
15 changes: 11 additions & 4 deletions package/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2582,6 +2582,11 @@
"@typescript-eslint/types" "6.10.0"
eslint-visitor-keys "^3.4.1"

"@webgpu/[email protected]":
version "0.1.21"
resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.21.tgz#b181202daec30d66ccd67264de23814cfd176d3a"
integrity sha512-pUrWq3V5PiSGFLeLxoGqReTZmiiXwY3jRkIG5sLLKjyqNxrwm/04b4nw7LSmGWJcKk59XOM/YRTUwOzo4MMlow==

abort-controller@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392"
Expand Down Expand Up @@ -3110,10 +3115,12 @@ caniuse-lite@^1.0.30001400:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001400.tgz#3038bee70d8b875604cd8833cb0e5e254ee0281a"
integrity sha512-Mv659Hn65Z4LgZdJ7ge5JTVbE3rqbJaaXgW5LEI9/tOaXclfIZ8DW7D7FCWWWmWiiPS7AC48S8kf3DApSxQdgA==

[email protected]:
version "0.38.2"
resolved "https://registry.yarnpkg.com/canvaskit-wasm/-/canvaskit-wasm-0.38.2.tgz#b6c2be236670fd0f18977b9026652b2c0e201fee"
integrity sha512-ieRb6DO4yL91qUfyRgmyhp2Hi1KmQ9lIMfKacxHVlfp/CpKCkzgAxRGUbCsJFzwLKjs9fufGrIyvnzEYRwm1XQ==
[email protected]:
version "0.39.1"
resolved "https://registry.yarnpkg.com/canvaskit-wasm/-/canvaskit-wasm-0.39.1.tgz#c3c8f3962cbabbedf246f7bcf90e859013c7eae9"
integrity sha512-Gy3lCmhUdKq+8bvDrs9t8+qf7RvcjuQn+we7vTVVyqgOVO1UVfHpsnBxkTZw+R4ApEJ3D5fKySl9TU11hmjl/A==
dependencies:
"@webgpu/types" "0.1.21"

chalk@^1.0.0:
version "1.1.3"
Expand Down

0 comments on commit 0b818a2

Please sign in to comment.