@shopify/react-native-skia 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +47 -21
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +8 -5
- package/apple/MetalWindowContext.mm +4 -2
- package/apple/RNSkApplePlatformContext.h +7 -5
- package/apple/RNSkApplePlatformContext.mm +30 -29
- package/apple/SkiaCVPixelBufferUtils.mm +4 -8
- package/cpp/api/JsiSkImageFactory.h +14 -1
- package/cpp/api/JsiSkSurface.h +7 -1
- package/cpp/api/recorder/DrawingCtx.h +19 -2
- package/cpp/api/recorder/Paint.h +1 -3
- package/cpp/api/recorder/RNRecorder.h +5 -13
- package/cpp/rnskia/DawnContext.h +11 -2
- package/cpp/rnskia/DawnUtils.h +97 -6
- package/cpp/rnskia/DawnWindowContext.h +18 -11
- package/cpp/rnskia/RNSkPlatformContext.h +22 -5
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +2 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/Surface.d.ts +1 -1
- package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +3 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurface.d.ts +2 -1
- package/lib/commonjs/skia/web/JsiSkSurface.js +4 -1
- package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/commonjs/sksg/HostConfig.js +1 -1
- package/lib/commonjs/sksg/HostConfig.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.js +14 -2
- package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Player.js +6 -2
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +3 -2
- package/lib/commonjs/sksg/Recorder/commands/Paint.js +5 -4
- package/lib/commonjs/sksg/Recorder/commands/Paint.js.map +1 -1
- package/lib/commonjs/views/SkiaBaseWebView.js +4 -0
- package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +2 -1
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Surface/Surface.d.ts +1 -1
- package/lib/module/skia/types/Surface/Surface.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.d.ts +1 -0
- package/lib/module/skia/web/JsiSkImageFactory.js +3 -0
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurface.d.ts +2 -1
- package/lib/module/skia/web/JsiSkSurface.js +4 -1
- package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/module/sksg/HostConfig.js +1 -1
- package/lib/module/sksg/HostConfig.js.map +1 -1
- package/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/module/sksg/Recorder/DrawingContext.js +14 -2
- package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/module/sksg/Recorder/Player.js +6 -2
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Paint.d.ts +3 -2
- package/lib/module/sksg/Recorder/commands/Paint.js +5 -4
- package/lib/module/sksg/Recorder/commands/Paint.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.js +4 -0
- package/lib/module/views/SkiaBaseWebView.js.map +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkSurface.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/HostConfig.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/Paint.d.ts +1 -1
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +2 -1
- package/lib/typescript/src/skia/types/Surface/Surface.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +2 -1
- package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +2 -0
- package/lib/typescript/src/sksg/Recorder/commands/Paint.d.ts +3 -2
- package/package.json +1 -1
- package/react-native-skia.podspec +43 -12
- package/src/renderer/__tests__/e2e/DataEncoding.spec.tsx +6 -2
- package/src/renderer/__tests__/e2e/Paint.spec.tsx +44 -1
- package/src/skia/types/Image/ImageFactory.ts +3 -1
- package/src/skia/types/Surface/Surface.ts +1 -1
- package/src/skia/web/JsiSkImageFactory.ts +4 -0
- package/src/skia/web/JsiSkSurface.ts +4 -1
- package/src/sksg/HostConfig.ts +2 -4
- package/src/sksg/Recorder/DrawingContext.ts +15 -1
- package/src/sksg/Recorder/Player.ts +6 -2
- package/src/sksg/Recorder/commands/Paint.ts +6 -5
- package/src/views/SkiaBaseWebView.tsx +4 -0
@@ -27,15 +27,7 @@ public:
|
|
27
27
|
wgpu::Surface surface, int width, int height)
|
28
28
|
: _recorder(recorder), _device(device), _surface(surface), _width(width),
|
29
29
|
_height(height) {
|
30
|
-
|
31
|
-
config.device = _device;
|
32
|
-
config.format = DawnUtils::PreferredTextureFormat;
|
33
|
-
config.width = _width;
|
34
|
-
config.height = _height;
|
35
|
-
#ifdef __APPLE__
|
36
|
-
config.alphaMode = wgpu::CompositeAlphaMode::Premultiplied;
|
37
|
-
#endif
|
38
|
-
_surface.Configure(&config);
|
30
|
+
configureSurface();
|
39
31
|
}
|
40
32
|
|
41
33
|
sk_sp<SkSurface> getSurface() override {
|
@@ -58,7 +50,9 @@ public:
|
|
58
50
|
void present() override;
|
59
51
|
|
60
52
|
void resize(int width, int height) override {
|
61
|
-
|
53
|
+
_width = width;
|
54
|
+
_height = height;
|
55
|
+
configureSurface();
|
62
56
|
}
|
63
57
|
|
64
58
|
int getWidth() override { return _width; }
|
@@ -66,6 +60,19 @@ public:
|
|
66
60
|
int getHeight() override { return _height; }
|
67
61
|
|
68
62
|
private:
|
63
|
+
void configureSurface() {
|
64
|
+
wgpu::SurfaceConfiguration config;
|
65
|
+
config.device = _device;
|
66
|
+
config.format = DawnUtils::PreferredTextureFormat;
|
67
|
+
config.width = _width;
|
68
|
+
config.height = _height;
|
69
|
+
config.presentMode = wgpu::PresentMode::Fifo;
|
70
|
+
#ifdef __APPLE__
|
71
|
+
config.alphaMode = wgpu::CompositeAlphaMode::Premultiplied;
|
72
|
+
#endif
|
73
|
+
_surface.Configure(&config);
|
74
|
+
}
|
75
|
+
|
69
76
|
skgpu::graphite::Recorder *_recorder;
|
70
77
|
// TODO: keep device in DawnContext? Do we need it for resizing?
|
71
78
|
wgpu::Device _device;
|
@@ -74,4 +81,4 @@ private:
|
|
74
81
|
int _height;
|
75
82
|
};
|
76
83
|
|
77
|
-
} // namespace RNSkia
|
84
|
+
} // namespace RNSkia
|
@@ -105,22 +105,39 @@ public:
|
|
105
105
|
*/
|
106
106
|
virtual sk_sp<SkImage> makeImageFromNativeBuffer(void *buffer) = 0;
|
107
107
|
|
108
|
+
#if !defined(SK_GRAPHITE)
|
108
109
|
virtual sk_sp<SkImage>
|
109
110
|
makeImageFromNativeTexture(const TextureInfo &textureInfo, int width,
|
110
111
|
int height, bool mipMapped) = 0;
|
111
112
|
|
112
|
-
|
113
|
+
virtual const TextureInfo getTexture(sk_sp<SkSurface> image) = 0;
|
114
|
+
|
115
|
+
virtual const TextureInfo getTexture(sk_sp<SkImage> image) = 0;
|
116
|
+
|
113
117
|
virtual GrDirectContext *getDirectContext() = 0;
|
118
|
+
#else
|
119
|
+
sk_sp<SkImage> makeImageFromNativeTexture(const TextureInfo &textureInfo,
|
120
|
+
int width, int height,
|
121
|
+
bool mipMapped) {
|
122
|
+
throw std::runtime_error(
|
123
|
+
"makeImageFromNativeTexture not implemented yet on Graphite");
|
124
|
+
}
|
125
|
+
|
126
|
+
const TextureInfo getTexture(sk_sp<SkSurface> image) {
|
127
|
+
throw std::runtime_error(
|
128
|
+
"getTexture(surface) not implemented yet on Graphite");
|
129
|
+
}
|
130
|
+
|
131
|
+
const TextureInfo getTexture(sk_sp<SkImage> image) {
|
132
|
+
throw std::runtime_error(
|
133
|
+
"getTexture(image) not implemented yet on Graphite");
|
134
|
+
}
|
114
135
|
#endif
|
115
136
|
|
116
137
|
virtual void releaseNativeBuffer(uint64_t pointer) = 0;
|
117
138
|
|
118
139
|
virtual uint64_t makeNativeBuffer(sk_sp<SkImage> image) = 0;
|
119
140
|
|
120
|
-
virtual const TextureInfo getTexture(sk_sp<SkSurface> image) = 0;
|
121
|
-
|
122
|
-
virtual const TextureInfo getTexture(sk_sp<SkImage> image) = 0;
|
123
|
-
|
124
141
|
virtual std::shared_ptr<RNSkVideo> createVideo(const std::string &url) = 0;
|
125
142
|
|
126
143
|
/**
|
@@ -15,6 +15,7 @@ export interface ImageInfo {
|
|
15
15
|
width: number;
|
16
16
|
}
|
17
17
|
export interface ImageFactory {
|
18
|
+
MakeNull: () => SkImage;
|
18
19
|
/**
|
19
20
|
* Return an Image backed by the encoded data, but attempt to defer decoding until the image
|
20
21
|
* is actually used/drawn. This deferral allows the system to cache the result, either on the
|
@@ -58,7 +59,7 @@ export interface ImageFactory {
|
|
58
59
|
*
|
59
60
|
* @returns Returns a valid SkImage, if the texture is invalid, an error is thrown.
|
60
61
|
*/
|
61
|
-
MakeImageFromNativeTextureUnstable: (texture: unknown, width: number, height: number, mipmapped?: boolean) => SkImage;
|
62
|
+
MakeImageFromNativeTextureUnstable: (texture: unknown, width: number, height: number, mipmapped?: boolean, outputImage?: SkImage) => SkImage;
|
62
63
|
/**
|
63
64
|
* Returns an image that will be a screenshot of the view represented by
|
64
65
|
* the view tag
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AlphaType","exports"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\nimport type { NativeBuffer } from \"../NativeBuffer\";\n\nimport type { ColorType } from \"./ColorType\";\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport interface ImageInfo {\n alphaType: AlphaType;\n // TODO: add support for color space\n // colorSpace: ColorSpace;\n colorType: ColorType;\n height: number;\n width: number;\n}\n\nexport interface ImageFactory {\n /**\n * Return an Image backed by the encoded data, but attempt to defer decoding until the image\n * is actually used/drawn. This deferral allows the system to cache the result, either on the\n * CPU or on the GPU, depending on where the image is drawn.\n * This decoding uses the codecs that have been compiled into CanvasKit. If the bytes are\n * invalid (or an unrecognized codec), null will be returned. See Image.h for more details.\n * @param data - Data object with bytes of data\n * @returns If the encoded format is not supported, or subset is outside of the bounds of the decoded\n * image, nullptr is returned.\n */\n MakeImageFromEncoded: (encoded: SkData) => SkImage | null;\n\n /**\n * Return an Image backed by a given native buffer.\n * The native buffer must be a valid owning reference.\n *\n * For instance, this API is used by\n * [react-native-vision-camera](https://github.com/mrousavy/react-native-vision-camera)\n * to render a Skia Camera preview.\n *\n * - On Android; This is an `AHardwareBuffer*`\n * - On iOS, this is a `CVPixelBufferRef`\n * @param nativeBuffer A strong `uintptr_t` pointer to the native buffer\n * @throws Throws an error if the Image could not be created, for example when the given\n * native buffer is invalid.\n */\n MakeImageFromNativeBuffer: (nativeBuffer: NativeBuffer) => SkImage;\n\n /**\n *\n * Return an Image backed by a given native texture.\n *\n * The native texture must be a valid owning reference.\n *\n * This API might be used to integrate with other libraries using gpu textures,\n * or to transfer images between different threads.\n *\n * @param texture A native texture handle\n * @param width The width of the texture\n * @param height The height of the texture\n * @param mipmapped Whether the texture is mipmapped\n * @throws Throws an error if the Image could not be created, for example when the given native texture is invalid.\n *\n * @returns Returns a valid SkImage, if the texture is invalid, an error is thrown.\n */\n MakeImageFromNativeTextureUnstable: (\n texture: unknown,\n width: number,\n height: number,\n mipmapped?: boolean\n ) => SkImage;\n\n /**\n * Returns an image that will be a screenshot of the view represented by\n * the view tag\n * @param viewTag - The tag of the view to make an image from.\n * @returns Returns a valid SkImage, if the view tag is invalid, nullptr is returned.\n */\n MakeImageFromViewTag: (viewTag: number) => Promise<SkImage | null>;\n\n /**\n * Returns an image with the given pixel data and format.\n * Note that we will always make a copy of the pixel data, because of inconsistencies in\n * behavior between GPU and CPU (i.e. the pixel data will be turned into a GPU texture and\n * not modifiable after creation).\n *\n * @param info\n * @param data - bytes representing the pixel data.\n * @param bytesPerRow\n */\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): SkImage | null;\n}\n"],"mappings":";;;;;;IAMYA,SAAS,GAAAC,OAAA,CAAAD,SAAA,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["AlphaType","exports"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\nimport type { NativeBuffer } from \"../NativeBuffer\";\n\nimport type { ColorType } from \"./ColorType\";\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport interface ImageInfo {\n alphaType: AlphaType;\n // TODO: add support for color space\n // colorSpace: ColorSpace;\n colorType: ColorType;\n height: number;\n width: number;\n}\n\nexport interface ImageFactory {\n MakeNull: () => SkImage;\n /**\n * Return an Image backed by the encoded data, but attempt to defer decoding until the image\n * is actually used/drawn. This deferral allows the system to cache the result, either on the\n * CPU or on the GPU, depending on where the image is drawn.\n * This decoding uses the codecs that have been compiled into CanvasKit. If the bytes are\n * invalid (or an unrecognized codec), null will be returned. See Image.h for more details.\n * @param data - Data object with bytes of data\n * @returns If the encoded format is not supported, or subset is outside of the bounds of the decoded\n * image, nullptr is returned.\n */\n MakeImageFromEncoded: (encoded: SkData) => SkImage | null;\n\n /**\n * Return an Image backed by a given native buffer.\n * The native buffer must be a valid owning reference.\n *\n * For instance, this API is used by\n * [react-native-vision-camera](https://github.com/mrousavy/react-native-vision-camera)\n * to render a Skia Camera preview.\n *\n * - On Android; This is an `AHardwareBuffer*`\n * - On iOS, this is a `CVPixelBufferRef`\n * @param nativeBuffer A strong `uintptr_t` pointer to the native buffer\n * @throws Throws an error if the Image could not be created, for example when the given\n * native buffer is invalid.\n */\n MakeImageFromNativeBuffer: (nativeBuffer: NativeBuffer) => SkImage;\n\n /**\n *\n * Return an Image backed by a given native texture.\n *\n * The native texture must be a valid owning reference.\n *\n * This API might be used to integrate with other libraries using gpu textures,\n * or to transfer images between different threads.\n *\n * @param texture A native texture handle\n * @param width The width of the texture\n * @param height The height of the texture\n * @param mipmapped Whether the texture is mipmapped\n * @throws Throws an error if the Image could not be created, for example when the given native texture is invalid.\n *\n * @returns Returns a valid SkImage, if the texture is invalid, an error is thrown.\n */\n MakeImageFromNativeTextureUnstable: (\n texture: unknown,\n width: number,\n height: number,\n mipmapped?: boolean,\n outputImage?: SkImage\n ) => SkImage;\n\n /**\n * Returns an image that will be a screenshot of the view represented by\n * the view tag\n * @param viewTag - The tag of the view to make an image from.\n * @returns Returns a valid SkImage, if the view tag is invalid, nullptr is returned.\n */\n MakeImageFromViewTag: (viewTag: number) => Promise<SkImage | null>;\n\n /**\n * Returns an image with the given pixel data and format.\n * Note that we will always make a copy of the pixel data, because of inconsistencies in\n * behavior between GPU and CPU (i.e. the pixel data will be turned into a GPU texture and\n * not modifiable after creation).\n *\n * @param info\n * @param data - bytes representing the pixel data.\n * @param bytesPerRow\n */\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): SkImage | null;\n}\n"],"mappings":";;;;;;IAMYA,SAAS,GAAAC,OAAA,CAAAD,SAAA,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA","ignoreList":[]}
|
@@ -32,7 +32,7 @@ export interface SkSurface extends SkJSIInstance<"Surface"> {
|
|
32
32
|
|
33
33
|
example: https://fiddle.skia.org/c/@Surface_makeImageSnapshot
|
34
34
|
*/
|
35
|
-
makeImageSnapshot(bounds?: SkRect): SkImage;
|
35
|
+
makeImageSnapshot(bounds?: SkRect, outputImage?: SkImage): SkImage;
|
36
36
|
/**
|
37
37
|
* Make sure any queued draws are sent to the screen or the GPU.
|
38
38
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["Surface.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\nimport type { SkCanvas } from \"../Canvas\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkRect } from \"../Rect\";\n\nexport interface SkSurface extends SkJSIInstance<\"Surface\"> {\n /** Returns Canvas that draws into the surface. Subsequent calls return the\n same Canvas. Canvas returned is managed and owned by Surface, and is\n deleted when Surface is deleted.\n\n @return drawing Canvas for Surface\n\n example: https://fiddle.skia.org/c/@Surface_getCanvas\n */\n getCanvas(): SkCanvas;\n\n /**\n * Returns the backend texture of the surface.\n * The returned object can be used to create a Skia Image object.\n * The returned object is backend specific and should be used with caution.\n * It is the caller's responsibility to ensure that the texture is not used after the surface is deleted\n * or draw operations are performed on the surface.\n * The returned object may be null if the surface does not have a backend texture.\n *\n * @return backend texture of the surface or null\n */\n getNativeTextureUnstable(): unknown;\n\n /** Returns Image capturing Surface contents. Subsequent drawing to\n Surface contents are not captured.\n\n @param bounds A rectangle specifying the subset of the surface that\n is of interest.\n @return Image initialized with Surface contents\n\n example: https://fiddle.skia.org/c/@Surface_makeImageSnapshot\n */\n makeImageSnapshot(bounds?: SkRect): SkImage;\n\n /**\n * Make sure any queued draws are sent to the screen or the GPU.\n */\n flush(): void;\n\n /**\n * Returns the possibly scaled width of the surface.\n */\n width(): number;\n\n /**\n * Returns the possibly scaled height of the surface.\n */\n height(): number;\n}\n"],"mappings":"","ignoreList":[]}
|
1
|
+
{"version":3,"names":[],"sources":["Surface.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\nimport type { SkCanvas } from \"../Canvas\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkRect } from \"../Rect\";\n\nexport interface SkSurface extends SkJSIInstance<\"Surface\"> {\n /** Returns Canvas that draws into the surface. Subsequent calls return the\n same Canvas. Canvas returned is managed and owned by Surface, and is\n deleted when Surface is deleted.\n\n @return drawing Canvas for Surface\n\n example: https://fiddle.skia.org/c/@Surface_getCanvas\n */\n getCanvas(): SkCanvas;\n\n /**\n * Returns the backend texture of the surface.\n * The returned object can be used to create a Skia Image object.\n * The returned object is backend specific and should be used with caution.\n * It is the caller's responsibility to ensure that the texture is not used after the surface is deleted\n * or draw operations are performed on the surface.\n * The returned object may be null if the surface does not have a backend texture.\n *\n * @return backend texture of the surface or null\n */\n getNativeTextureUnstable(): unknown;\n\n /** Returns Image capturing Surface contents. Subsequent drawing to\n Surface contents are not captured.\n\n @param bounds A rectangle specifying the subset of the surface that\n is of interest.\n @return Image initialized with Surface contents\n\n example: https://fiddle.skia.org/c/@Surface_makeImageSnapshot\n */\n makeImageSnapshot(bounds?: SkRect, outputImage?: SkImage): SkImage;\n\n /**\n * Make sure any queued draws are sent to the screen or the GPU.\n */\n flush(): void;\n\n /**\n * Returns the possibly scaled width of the surface.\n */\n width(): number;\n\n /**\n * Returns the possibly scaled height of the surface.\n */\n height(): number;\n}\n"],"mappings":"","ignoreList":[]}
|
@@ -5,6 +5,7 @@ import { JsiSkImage } from "./JsiSkImage";
|
|
5
5
|
import type { JsiSkSurface } from "./JsiSkSurface";
|
6
6
|
export declare class JsiSkImageFactory extends Host implements ImageFactory {
|
7
7
|
constructor(CanvasKit: CanvasKit);
|
8
|
+
MakeNull(): JsiSkImage;
|
8
9
|
MakeImageFromViewTag(viewTag: number): Promise<SkImage | null>;
|
9
10
|
MakeImageFromNativeBuffer(buffer: NativeBuffer, surface?: JsiSkSurface, image?: JsiSkImage): JsiSkImage;
|
10
11
|
MakeImageFromEncoded(encoded: SkData): JsiSkImage | null;
|
@@ -12,6 +12,9 @@ class JsiSkImageFactory extends _Host.Host {
|
|
12
12
|
constructor(CanvasKit) {
|
13
13
|
super(CanvasKit);
|
14
14
|
}
|
15
|
+
MakeNull() {
|
16
|
+
return new _JsiSkImage.JsiSkImage(this.CanvasKit, null);
|
17
|
+
}
|
15
18
|
MakeImageFromViewTag(viewTag) {
|
16
19
|
const view = viewTag;
|
17
20
|
// TODO: Implement screenshot from view in React JS
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_types","require","_Host","_JsiSkImage","_JsiSkData","JsiSkImageFactory","Host","constructor","CanvasKit","MakeImageFromViewTag","viewTag","view","console","log","Promise","resolve","MakeImageFromNativeBuffer","buffer","surface","image","isNativeBufferWeb","Error","img","HTMLImageElement","HTMLVideoElement","ImageBitmap","MakeLazyImageFromTextureSource","CanvasKitWebGLBuffer","toImage","MakeImageFromCanvasImageSource","
|
1
|
+
{"version":3,"names":["_types","require","_Host","_JsiSkImage","_JsiSkData","JsiSkImageFactory","Host","constructor","CanvasKit","MakeNull","JsiSkImage","MakeImageFromViewTag","viewTag","view","console","log","Promise","resolve","MakeImageFromNativeBuffer","buffer","surface","image","isNativeBufferWeb","Error","img","HTMLImageElement","HTMLVideoElement","ImageBitmap","MakeLazyImageFromTextureSource","CanvasKitWebGLBuffer","toImage","MakeImageFromCanvasImageSource","makeImageFromTextureSource","updateTextureFromSource","MakeImageFromEncoded","encoded","JsiSkData","fromValue","MakeImageFromNativeTextureUnstable","throwNotImplementedOnRNWeb","MakeImage","info","data","bytesPerRow","alphaType","getEnum","colorSpace","ColorSpace","SRGB","colorType","height","width","exports"],"sources":["JsiSkImageFactory.ts"],"sourcesContent":["import type { CanvasKit, Image } from \"canvaskit-wasm\";\n\nimport { CanvasKitWebGLBuffer, isNativeBufferWeb } from \"../types\";\nimport type {\n SkData,\n ImageInfo,\n SkImage,\n NativeBuffer,\n ImageFactory,\n} from \"../types\";\n\nimport { Host, getEnum, throwNotImplementedOnRNWeb } from \"./Host\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkData } from \"./JsiSkData\";\nimport type { JsiSkSurface } from \"./JsiSkSurface\";\nimport type { CanvasKitWebGLBufferImpl } from \"./CanvasKitWebGLBufferImpl\";\n\nexport class JsiSkImageFactory extends Host implements ImageFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeNull() {\n return new JsiSkImage(this.CanvasKit, null as unknown as Image);\n }\n\n MakeImageFromViewTag(viewTag: number): Promise<SkImage | null> {\n const view = viewTag as unknown as HTMLElement;\n // TODO: Implement screenshot from view in React JS\n console.log(view);\n return Promise.resolve(null);\n }\n\n MakeImageFromNativeBuffer(\n buffer: NativeBuffer,\n surface?: JsiSkSurface,\n image?: JsiSkImage\n ) {\n if (!isNativeBufferWeb(buffer)) {\n throw new Error(\"Invalid NativeBuffer\");\n }\n if (!surface) {\n let img: Image;\n if (\n buffer instanceof HTMLImageElement ||\n buffer instanceof HTMLVideoElement ||\n buffer instanceof ImageBitmap\n ) {\n img = this.CanvasKit.MakeLazyImageFromTextureSource(buffer);\n } else if (buffer instanceof CanvasKitWebGLBuffer) {\n img = (\n buffer as CanvasKitWebGLBuffer as CanvasKitWebGLBufferImpl\n ).toImage();\n } else {\n img = this.CanvasKit.MakeImageFromCanvasImageSource(buffer);\n }\n return new JsiSkImage(this.CanvasKit, img);\n } else if (!image) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const img = (surface as any).makeImageFromTextureSource(buffer) as Image;\n return new JsiSkImage(this.CanvasKit, img);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const img = (surface as any).updateTextureFromSource(\n image,\n buffer\n ) as Image;\n return new JsiSkImage(this.CanvasKit, img);\n }\n }\n\n MakeImageFromEncoded(encoded: SkData) {\n const image = this.CanvasKit.MakeImageFromEncoded(\n JsiSkData.fromValue(encoded)\n );\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n MakeImageFromNativeTextureUnstable() {\n return throwNotImplementedOnRNWeb<SkImage>();\n }\n\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number) {\n // see toSkImageInfo() from canvaskit\n const image = this.CanvasKit.MakeImage(\n {\n alphaType: getEnum(this.CanvasKit, \"AlphaType\", info.alphaType),\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n colorType: getEnum(this.CanvasKit, \"ColorType\", info.colorType),\n height: info.height,\n width: info.width,\n },\n JsiSkData.fromValue(data),\n bytesPerRow\n );\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAIO,MAAMI,iBAAiB,SAASC,UAAI,CAAyB;EAClEC,WAAWA,CAACC,SAAoB,EAAE;IAChC,KAAK,CAACA,SAAS,CAAC;EAClB;EAEAC,QAAQA,CAAA,EAAG;IACT,OAAO,IAAIC,sBAAU,CAAC,IAAI,CAACF,SAAS,EAAE,IAAwB,CAAC;EACjE;EAEAG,oBAAoBA,CAACC,OAAe,EAA2B;IAC7D,MAAMC,IAAI,GAAGD,OAAi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AC/CE,oBAAS,CAACC,SAAS,CAACF,OAAO,CAC7B,CAAC;IACD,IAAId,KAAK,KAAK,IAAI,EAAE;MAClB,OAAO,IAAI;IACb;IACA,OAAO,IAAIX,sBAAU,CAAC,IAAI,CAACF,SAAS,EAAEa,KAAK,CAAC;EAC9C;EAEAiB,kCAAkCA,CAAA,EAAG;IACnC,OAAO,IAAAC,gCAA0B,EAAU,CAAC;EAC9C;EAEAC,SAASA,CAACC,IAAe,EAAEC,IAAY,EAAEC,WAAmB,EAAE;IAC5D;IACA,MAAMtB,KAAK,GAAG,IAAI,CAACb,SAAS,CAACgC,SAAS,CACpC;MACEI,SAAS,EAAE,IAAAC,aAAO,EAAC,IAAI,CAACrC,SAAS,EAAE,WAAW,EAAEiC,IAAI,CAACG,SAAS,CAAC;MAC/DE,UAAU,EAAE,IAAI,CAACtC,SAAS,CAACuC,UAAU,CAACC,IAAI;MAC1CC,SAAS,EAAE,IAAAJ,aAAO,EAAC,IAAI,CAACrC,SAAS,EAAE,WAAW,EAAEiC,IAAI,CAACQ,SAAS,CAAC;MAC/DC,MAAM,EAAET,IAAI,CAACS,MAAM;MACnBC,KAAK,EAAEV,IAAI,CAACU;IACd,CAAC,EACDf,oBAAS,CAACC,SAAS,CAACK,IAAI,CAAC,EACzBC,WACF,CAAC;IACD,IAAItB,KAAK,KAAK,IAAI,EAAE;MAClB,OAAO,IAAI;IACb;IACA,OAAO,IAAIX,sBAAU,CAAC,IAAI,CAACF,SAAS,EAAEa,KAAK,CAAC;EAC9C;AACF;AAAC+B,OAAA,CAAA/C,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { CanvasKit, Surface } from "canvaskit-wasm";
|
2
2
|
import type { SkCanvas, SkImage, SkRect, SkSurface } from "../types";
|
3
3
|
import { HostObject } from "./Host";
|
4
|
+
import { JsiSkImage } from "./JsiSkImage";
|
4
5
|
export declare class JsiSkSurface extends HostObject<Surface, "Surface"> implements SkSurface {
|
5
6
|
constructor(CanvasKit: CanvasKit, ref: Surface);
|
6
7
|
dispose: () => void;
|
@@ -8,6 +9,6 @@ export declare class JsiSkSurface extends HostObject<Surface, "Surface"> impleme
|
|
8
9
|
width(): number;
|
9
10
|
height(): number;
|
10
11
|
getCanvas(): SkCanvas;
|
11
|
-
makeImageSnapshot(bounds?: SkRect): SkImage;
|
12
|
+
makeImageSnapshot(bounds?: SkRect, outputImage?: JsiSkImage): SkImage;
|
12
13
|
getNativeTextureUnstable(): unknown;
|
13
14
|
}
|
@@ -30,8 +30,11 @@ class JsiSkSurface extends _Host.HostObject {
|
|
30
30
|
getCanvas() {
|
31
31
|
return new _JsiSkCanvas.JsiSkCanvas(this.CanvasKit, this.ref.getCanvas());
|
32
32
|
}
|
33
|
-
makeImageSnapshot(bounds) {
|
33
|
+
makeImageSnapshot(bounds, outputImage) {
|
34
34
|
const image = this.ref.makeImageSnapshot(bounds ? Array.from(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, bounds)) : undefined);
|
35
|
+
if (outputImage) {
|
36
|
+
outputImage.ref = image;
|
37
|
+
}
|
35
38
|
return new _JsiSkImage.JsiSkImage(this.CanvasKit, image);
|
36
39
|
}
|
37
40
|
getNativeTextureUnstable() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_Host","require","_JsiSkCanvas","_JsiSkImage","_JsiSkRect","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","JsiSkSurface","HostObject","constructor","CanvasKit","ref","dispose","flush","width","height","getCanvas","JsiSkCanvas","makeImageSnapshot","bounds","image","Array","from","JsiSkRect","fromValue","undefined","JsiSkImage","getNativeTextureUnstable","console","warn","exports"],"sources":["JsiSkSurface.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { SkCanvas, SkImage, SkRect, SkSurface } from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkCanvas } from \"./JsiSkCanvas\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkSurface\n extends HostObject<Surface, \"Surface\">\n implements SkSurface\n{\n constructor(CanvasKit: CanvasKit, ref: Surface) {\n super(CanvasKit, ref, \"Surface\");\n }\n\n dispose = () => {\n this.ref.dispose();\n };\n\n flush() {\n this.ref.flush();\n }\n\n width() {\n return this.ref.width();\n }\n\n height() {\n return this.ref.height();\n }\n\n getCanvas(): SkCanvas {\n return new JsiSkCanvas(this.CanvasKit, this.ref.getCanvas());\n }\n\n makeImageSnapshot(bounds?: SkRect): SkImage {\n const image = this.ref.makeImageSnapshot(\n bounds\n ? Array.from(JsiSkRect.fromValue(this.CanvasKit, bounds))\n : undefined\n );\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n getNativeTextureUnstable(): unknown {\n console.warn(\"getBackendTexture is not implemented on Web\");\n return null;\n }\n}\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAAwC,SAAAI,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA;AAEjC,MAAMgB,YAAY,SACfC,gBAAU,CAEpB;EACEC,WAAWA,CAACC,SAAoB,EAAEC,GAAY,EAAE;IAC9C,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,SAAS,CAAC;IAACvB,eAAA,kBAGzB,MAAM;MACd,IAAI,CAACuB,GAAG,CAACC,OAAO,CAAC,CAAC;IACpB,CAAC;EAJD;EAMAC,KAAKA,CAAA,EAAG;IACN,IAAI,CAACF,GAAG,CAACE,KAAK,CAAC,CAAC;EAClB;EAEAC,KAAKA,CAAA,EAAG;IACN,OAAO,IAAI,CAACH,GAAG,CAACG,KAAK,CAAC,CAAC;EACzB;EAEAC,MAAMA,CAAA,EAAG;IACP,OAAO,IAAI,CAACJ,GAAG,CAACI,MAAM,CAAC,CAAC;EAC1B;EAEAC,SAASA,CAAA,EAAa;IACpB,OAAO,IAAIC,wBAAW,CAAC,IAAI,CAACP,SAAS,EAAE,IAAI,CAACC,GAAG,CAACK,SAAS,CAAC,CAAC,CAAC;EAC9D;EAEAE,iBAAiBA,CAACC,MAAe,EAAW;
|
1
|
+
{"version":3,"names":["_Host","require","_JsiSkCanvas","_JsiSkImage","_JsiSkRect","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","JsiSkSurface","HostObject","constructor","CanvasKit","ref","dispose","flush","width","height","getCanvas","JsiSkCanvas","makeImageSnapshot","bounds","outputImage","image","Array","from","JsiSkRect","fromValue","undefined","JsiSkImage","getNativeTextureUnstable","console","warn","exports"],"sources":["JsiSkSurface.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { SkCanvas, SkImage, SkRect, SkSurface } from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkCanvas } from \"./JsiSkCanvas\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkSurface\n extends HostObject<Surface, \"Surface\">\n implements SkSurface\n{\n constructor(CanvasKit: CanvasKit, ref: Surface) {\n super(CanvasKit, ref, \"Surface\");\n }\n\n dispose = () => {\n this.ref.dispose();\n };\n\n flush() {\n this.ref.flush();\n }\n\n width() {\n return this.ref.width();\n }\n\n height() {\n return this.ref.height();\n }\n\n getCanvas(): SkCanvas {\n return new JsiSkCanvas(this.CanvasKit, this.ref.getCanvas());\n }\n\n makeImageSnapshot(bounds?: SkRect, outputImage?: JsiSkImage): SkImage {\n const image = this.ref.makeImageSnapshot(\n bounds\n ? Array.from(JsiSkRect.fromValue(this.CanvasKit, bounds))\n : undefined\n );\n if (outputImage) {\n outputImage.ref = image;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n getNativeTextureUnstable(): unknown {\n console.warn(\"getBackendTexture is not implemented on Web\");\n return null;\n }\n}\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAAwC,SAAAI,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAA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IACD,IAAIN,WAAW,EAAE;MACfA,WAAW,CAACT,GAAG,GAAGU,KAAK;IACzB;IACA,OAAO,IAAIM,sBAAU,CAAC,IAAI,CAACjB,SAAS,EAAEW,KAAK,CAAC;EAC9C;EAEAO,wBAAwBA,CAAA,EAAY;IAClCC,OAAO,CAACC,IAAI,CAAC,6CAA6C,CAAC;IAC3D,OAAO,IAAI;EACb;AACF;AAACC,OAAA,CAAAxB,YAAA,GAAAA,YAAA","ignoreList":[]}
|
@@ -100,7 +100,7 @@ const sksgHostConfig = exports.sksgHostConfig = {
|
|
100
100
|
preparePortalMount: () => {
|
101
101
|
debug("preparePortalMount");
|
102
102
|
},
|
103
|
-
cloneInstance(instance, _type, _oldProps, newProps,
|
103
|
+
cloneInstance(instance, _type, _oldProps, newProps, keepChildren, _newChildSet) {
|
104
104
|
debug("cloneInstance");
|
105
105
|
return {
|
106
106
|
type: instance.type,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_constants","_typeddash","NoEventPriority","DEBUG","debug","args","console","log","exports","currentUpdatePriority","sksgHostConfig","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","propsWithChildren","_container","children","props","instance","appendInitialChild","parentInstance","child","push","finalizeInitialChildren","commitMount","prepareForCommit","resetAfterCommit","container","redraw","getPublicInstance","node","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","prepareUpdate","_instance","oldProps","newProps","propsAreEqual","shallowEq","preparePortalMount","cloneInstance","_oldProps","_updatePayload","keepChildren","_recyclableInstance","createContainerChildSet","appendChildToContainerChildSet","childSet","finalizeContainerChildren","newChildren","root","replaceContainerChildren","cloneHiddenInstance","cloneHiddenTextInstance","getCurrentEventPriority","DefaultEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","_node","getInstanceFromNode","prepareScopeUpdate","_scopeInstance","getInstanceFromScope","shouldAttemptEagerTransition","trackSchedulerEvent","resolveEventType","resolveEventTimeStamp","requestPostPaintCallback","maySuspendCommit","preloadInstance","startSuspendingCommit","suspendInstance","waitForCommitToBeReady","NotPendingTransition","HostTransitionContext","createContext","setCurrentUpdatePriority","newPriority","getCurrentUpdatePriority","resolveUpdatePriority","resetFormInstance"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport { createContext } from \"react\";\nimport type { Fiber, HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType } from \"../dom/types\";\nimport { shallowEq } from \"../renderer/typeddash\";\n\nimport type { Node } from \"./Node\";\nimport type { Container } from \"./Container\";\n\ntype EventPriority = number;\nconst NoEventPriority = 0;\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node;\n\ntype Props = object;\ntype TextInstance = Node;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = object;\ntype UpdatePayload = Container;\ntype ChildSet = Node[];\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\nlet currentUpdatePriority: EventPriority = NoEventPriority;\n\nexport const sksgHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n supportsMutation: false,\n isPrimaryRenderer: false,\n supportsPersistence: true,\n supportsHydration: false,\n //supportsMicrotask: true,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return {};\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return {};\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n propsWithChildren,\n _container,\n _hostContext,\n _internalInstanceHandle\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { children, ...props } = propsWithChildren as any;\n debug(\"createInstance\", type);\n const instance = {\n type,\n props,\n children: [],\n };\n return instance;\n },\n\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance) {\n parentInstance.children.push(child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_container: Container) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container: Container) {\n debug(\"resetAfterCommit\");\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (_container) => {\n debug(\"clearContainer\");\n },\n\n prepareUpdate(\n _instance: Instance,\n _type: string,\n oldProps: Props,\n newProps: Props,\n container: Container,\n _hostContext: HostContext\n ) {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n return container;\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n cloneInstance(\n instance,\n _type,\n _oldProps,\n newProps,\n _updatePayload,\n _internalInstanceHandle,\n keepChildren: boolean,\n _recyclableInstance: null | Instance\n ) {\n debug(\"cloneInstance\");\n return {\n type: instance.type,\n props: { ...newProps },\n children: keepChildren ? [...instance.children] : [],\n };\n },\n\n createContainerChildSet(): ChildSet {\n debug(\"createContainerChildSet\");\n return [];\n },\n\n appendChildToContainerChildSet(\n childSet: ChildSet,\n child: Instance | TextInstance\n ): void {\n childSet.push(child);\n },\n\n finalizeContainerChildren(container: Container, newChildren: ChildSet) {\n debug(\"finalizeContainerChildren\");\n container.root = newChildren;\n },\n\n replaceContainerChildren(container: Container, newChildren: ChildSet) {\n container.root = newChildren;\n },\n\n cloneHiddenInstance(\n _instance: Instance,\n _type: string,\n _props: Props\n ): Instance {\n debug(\"cloneHiddenInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n\n cloneHiddenTextInstance(_instance: Instance, _text: string): TextInstance {\n debug(\"cloneHiddenTextInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: (_node: Instance) => {},\n getInstanceFromNode: function (_node): Fiber | null | undefined {\n throw new Error(\"Function not implemented.\");\n },\n prepareScopeUpdate: function (_scopeInstance, _instance): void {\n throw new Error(\"Function not implemented.\");\n },\n getInstanceFromScope: function (_scopeInstance): Instance | null {\n throw new Error(\"Function not implemented.\");\n },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n shouldAttemptEagerTransition: () => false,\n trackSchedulerEvent: () => {},\n resolveEventType: () => null,\n resolveEventTimeStamp: () => -1.1,\n requestPostPaintCallback() {},\n maySuspendCommit: () => false,\n preloadInstance: () => true, // true indicates already loaded\n startSuspendingCommit() {},\n suspendInstance() {},\n waitForCommitToBeReady: () => null,\n NotPendingTransition: null,\n HostTransitionContext: createContext(null),\n setCurrentUpdatePriority(newPriority: number) {\n currentUpdatePriority = newPriority;\n },\n getCurrentUpdatePriority() {\n return currentUpdatePriority;\n },\n resolveUpdatePriority() {\n if (currentUpdatePriority !== NoEventPriority) {\n return currentUpdatePriority;\n }\n return DefaultEventPriority;\n },\n resetFormInstance() {},\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAGA,IAAAE,UAAA,GAAAF,OAAA;AANA;;AAYA,MAAMG,eAAe,GAAG,CAAC;AAEzB,MAAMC,KAAK,GAAG,KAAK;AACZ,MAAMC,KAAK,GAAGA,CAAC,GAAGC,IAAoC,KAAK;EAChE,IAAIF,KAAK,EAAE;IACTG,OAAO,CAACC,GAAG,CAAC,GAAGF,IAAI,CAAC;EACtB;AACF,CAAC;AAACG,OAAA,CAAAJ,KAAA,GAAAA,KAAA;AA8BF,IAAIK,qBAAoC,GAAGP,eAAe;AAEnD,MAAMQ,cAA8B,GAAAF,OAAA,CAAAE,cAAA,GAAG;EAC5C;AACF;AACA;EACEC,gBAAgB,EAAE,KAAK;EACvBC,iBAAiB,EAAE,KAAK;EACxBC,mBAAmB,EAAE,IAAI;EACzBC,iBAAiB,EAAE,KAAK;EACxB;EACAC,eAAe,EAAEC,UAAU;EAC3BC,aAAa,EAAEC,YAAY;EAC3BC,SAAS,EAAE,CAAC,CAAC;EAEbC,kBAAkB,EAAGC,sBAAiC,IAAK;IACzDjB,KAAK,CAAC,oBAAoB,CAAC;IAC3B,OAAO,CAAC,CAAC;EACX,CAAC;EAEDkB,mBAAmBA,CAACC,kBAAkB,EAAEC,KAAK,EAAEH,sBAAsB,EAAE;IACrEjB,KAAK,CAAC,qBAAqB,CAAC;IAC5B,OAAO,CAAC,CAAC;EACX,CAAC;EAEDqB,oBAAoBA,CAACD,KAAK,EAAEE,MAAM,EAAE;IAClC,OAAO,KAAK;EACd,CAAC;EAEDC,kBAAkBA,CAChBC,KAAK,EACLP,sBAAsB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G,CAAC,CAAC;EAC1BC,eAAeA,CAAA,EAAG,CAAC,CAAC;EACpBC,sBAAsB,EAAEA,CAAA,KAAM,IAAI;EAClCC,oBAAoB,EAAE,IAAI;EAC1BC,qBAAqB,eAAE,IAAAC,oBAAa,EAAC,IAAI,CAAC;EAC1CC,wBAAwBA,CAACC,WAAmB,EAAE;IAC5C5F,qBAAqB,GAAG4F,WAAW;EACrC,CAAC;EACDC,wBAAwBA,CAAA,EAAG;IACzB,OAAO7F,qBAAqB;EAC9B,CAAC;EACD8F,qBAAqBA,CAAA,EAAG;IACtB,IAAI9F,qBAAqB,KAAKP,eAAe,EAAE;MAC7C,OAAOO,qBAAqB;IAC9B;IACA,OAAOqE,+BAAoB;EAC7B,CAAC;EACD0B,iBAAiBA,CAAA,EAAG,CAAC;AACvB,CAAC","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_react","require","_constants","_typeddash","NoEventPriority","DEBUG","debug","args","console","log","exports","currentUpdatePriority","sksgHostConfig","supportsMutation","isPrimaryRenderer","supportsPersistence","supportsHydration","scheduleTimeout","setTimeout","cancelTimeout","clearTimeout","noTimeout","getRootHostContext","_rootContainerInstance","getChildHostContext","_parentHostContext","_type","shouldSetTextContent","_props","createTextInstance","_text","_hostContext","_internalInstanceHandle","Error","createInstance","type","propsWithChildren","_container","children","props","instance","appendInitialChild","parentInstance","child","push","finalizeInitialChildren","commitMount","prepareForCommit","resetAfterCommit","container","redraw","getPublicInstance","node","commitTextUpdate","_textInstance","_oldText","_newText","clearContainer","prepareUpdate","_instance","oldProps","newProps","propsAreEqual","shallowEq","preparePortalMount","cloneInstance","_oldProps","keepChildren","_newChildSet","createContainerChildSet","appendChildToContainerChildSet","childSet","finalizeContainerChildren","newChildren","root","replaceContainerChildren","cloneHiddenInstance","cloneHiddenTextInstance","getCurrentEventPriority","DefaultEventPriority","beforeActiveInstanceBlur","afterActiveInstanceBlur","detachDeletedInstance","_node","getInstanceFromNode","prepareScopeUpdate","_scopeInstance","getInstanceFromScope","shouldAttemptEagerTransition","trackSchedulerEvent","resolveEventType","resolveEventTimeStamp","requestPostPaintCallback","maySuspendCommit","preloadInstance","startSuspendingCommit","suspendInstance","waitForCommitToBeReady","NotPendingTransition","HostTransitionContext","createContext","setCurrentUpdatePriority","newPriority","getCurrentUpdatePriority","resolveUpdatePriority","resetFormInstance"],"sources":["HostConfig.ts"],"sourcesContent":["/*global NodeJS*/\nimport { createContext } from \"react\";\nimport type { Fiber, HostConfig } from \"react-reconciler\";\nimport { DefaultEventPriority } from \"react-reconciler/constants\";\n\nimport type { NodeType } from \"../dom/types\";\nimport { shallowEq } from \"../renderer/typeddash\";\n\nimport type { Node } from \"./Node\";\nimport type { Container } from \"./Container\";\n\ntype EventPriority = number;\nconst NoEventPriority = 0;\n\nconst DEBUG = false;\nexport const debug = (...args: Parameters<typeof console.log>) => {\n if (DEBUG) {\n console.log(...args);\n }\n};\n\ntype Instance = Node;\n\ntype Props = object;\ntype TextInstance = Node;\ntype SuspenseInstance = Instance;\ntype HydratableInstance = Instance;\ntype PublicInstance = Instance;\ntype HostContext = object;\ntype UpdatePayload = Container;\ntype ChildSet = Node[];\ntype TimeoutHandle = NodeJS.Timeout;\ntype NoTimeout = -1;\n\ntype SkiaHostConfig = HostConfig<\n NodeType,\n Props,\n Container,\n Instance,\n TextInstance,\n SuspenseInstance,\n HydratableInstance,\n PublicInstance,\n HostContext,\n UpdatePayload,\n ChildSet,\n TimeoutHandle,\n NoTimeout\n>;\nlet currentUpdatePriority: EventPriority = NoEventPriority;\n\nexport const sksgHostConfig: SkiaHostConfig = {\n /**\n * This function is used by the reconciler in order to calculate current time for prioritising work.\n */\n supportsMutation: false,\n isPrimaryRenderer: false,\n supportsPersistence: true,\n supportsHydration: false,\n //supportsMicrotask: true,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n\n getRootHostContext: (_rootContainerInstance: Container) => {\n debug(\"getRootHostContext\");\n return {};\n },\n\n getChildHostContext(_parentHostContext, _type, _rootContainerInstance) {\n debug(\"getChildHostContext\");\n return {};\n },\n\n shouldSetTextContent(_type, _props) {\n return false;\n },\n\n createTextInstance(\n _text,\n _rootContainerInstance,\n _hostContext,\n _internalInstanceHandle\n ) {\n debug(\"createTextInstance\");\n // return SpanNode({}, text) as SkNode;\n throw new Error(\"Text nodes are not supported yet\");\n },\n\n createInstance(\n type,\n propsWithChildren,\n _container,\n _hostContext,\n _internalInstanceHandle\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const { children, ...props } = propsWithChildren as any;\n debug(\"createInstance\", type);\n const instance = {\n type,\n props,\n children: [],\n };\n return instance;\n },\n\n appendInitialChild(parentInstance: Instance, child: Instance | TextInstance) {\n parentInstance.children.push(child);\n },\n\n finalizeInitialChildren(\n parentInstance,\n _type,\n _props,\n _rootContainerInstance,\n _hostContext\n ) {\n debug(\"finalizeInitialChildren\", parentInstance);\n return false;\n },\n\n commitMount() {\n // if finalizeInitialChildren = true\n debug(\"commitMount\");\n },\n\n prepareForCommit(_container: Container) {\n debug(\"prepareForCommit\");\n return null;\n },\n\n resetAfterCommit(container: Container) {\n debug(\"resetAfterCommit\");\n container.redraw();\n },\n\n getPublicInstance(node: Instance) {\n debug(\"getPublicInstance\");\n return node;\n },\n\n commitTextUpdate: (\n _textInstance: TextInstance,\n _oldText: string,\n _newText: string\n ) => {\n // textInstance.instance = newText;\n },\n\n clearContainer: (_container) => {\n debug(\"clearContainer\");\n },\n\n prepareUpdate(\n _instance: Instance,\n _type: string,\n oldProps: Props,\n newProps: Props,\n container: Container,\n _hostContext: HostContext\n ) {\n debug(\"prepareUpdate\");\n const propsAreEqual = shallowEq(oldProps, newProps);\n if (propsAreEqual) {\n return null;\n }\n return container;\n },\n\n preparePortalMount: () => {\n debug(\"preparePortalMount\");\n },\n\n cloneInstance(\n instance,\n _type,\n _oldProps,\n newProps,\n keepChildren,\n _newChildSet\n ) {\n debug(\"cloneInstance\");\n return {\n type: instance.type,\n props: { ...newProps },\n children: keepChildren ? [...instance.children] : [],\n };\n },\n\n createContainerChildSet(): ChildSet {\n debug(\"createContainerChildSet\");\n return [];\n },\n\n appendChildToContainerChildSet(\n childSet: ChildSet,\n child: Instance | TextInstance\n ): void {\n childSet.push(child);\n },\n\n finalizeContainerChildren(container: Container, newChildren: ChildSet) {\n debug(\"finalizeContainerChildren\");\n container.root = newChildren;\n },\n\n replaceContainerChildren(container: Container, newChildren: ChildSet) {\n container.root = newChildren;\n },\n\n cloneHiddenInstance(\n _instance: Instance,\n _type: string,\n _props: Props\n ): Instance {\n debug(\"cloneHiddenInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n\n cloneHiddenTextInstance(_instance: Instance, _text: string): TextInstance {\n debug(\"cloneHiddenTextInstance\");\n throw new Error(\"Not yet implemented.\");\n },\n // see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874\n getCurrentEventPriority: () => DefaultEventPriority,\n beforeActiveInstanceBlur: () => {},\n afterActiveInstanceBlur: () => {},\n detachDeletedInstance: (_node: Instance) => {},\n getInstanceFromNode: function (_node): Fiber | null | undefined {\n throw new Error(\"Function not implemented.\");\n },\n prepareScopeUpdate: function (_scopeInstance, _instance): void {\n throw new Error(\"Function not implemented.\");\n },\n getInstanceFromScope: function (_scopeInstance): Instance | null {\n throw new Error(\"Function not implemented.\");\n },\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n shouldAttemptEagerTransition: () => false,\n trackSchedulerEvent: () => {},\n resolveEventType: () => null,\n resolveEventTimeStamp: () => -1.1,\n requestPostPaintCallback() {},\n maySuspendCommit: () => false,\n preloadInstance: () => true, // true indicates already loaded\n startSuspendingCommit() {},\n suspendInstance() {},\n waitForCommitToBeReady: () => null,\n NotPendingTransition: null,\n HostTransitionContext: createContext(null),\n setCurrentUpdatePriority(newPriority: number) {\n currentUpdatePriority = newPriority;\n },\n getCurrentUpdatePriority() {\n return currentUpdatePriority;\n },\n resolveUpdatePriority() {\n if (currentUpdatePriority !== NoEventPriority) {\n return currentUpdatePriority;\n }\n return DefaultEventPriority;\n },\n resetFormInstance() {},\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAGA,IAAAE,UAAA,GAAAF,OAAA;AANA;;AAYA,MAAMG,eAAe,GAAG,CAAC;AAEzB,MAAMC,KAAK,GAAG,KAAK;AACZ,MAAMC,KAAK,GAAGA,CAAC,GAAGC,IAAoC,KAAK;EAChE,IAAIF,KAAK,EAAE;IACTG,OAAO,CAACC,GAAG,CAAC,GAAGF,IAAI,CAAC;EACtB;AACF,CAAC;AAACG,OAAA,CAAAJ,KAAA,GAAAA,KAAA;AA8BF,IAAIK,qBAAoC,GAAGP,eAAe;AAEnD,MAAMQ,cAA8B,GAAAF,OAAA,CAAAE,cAAA,GAAG;EAC5C;AACF;AACA;EACEC,gBAAgB,EAAE,KAAK;EACvBC,iBAAiB,EAAE,KAAK;EACxBC,mBAAmB,EAAE,IAAI;EACzBC,iBAAiB,EAAE,KAAK;EACxB;EACAC,eAAe,EAAEC,UAAU;EAC3BC,aAAa,EAAEC,YAAY;EAC3BC,SAAS,EAAE,CAAC,CAAC;EAEbC,kBAAkB,EAAGC,sBAAiC,IAAK;IACzDjB,KAAK,CAAC,oBAAoB,CAAC;IAC3B,OAAO,CAAC,CAAC;EACX,CAAC;EAEDkB,mBAAmBA,CAACC,kBAAkB,EAAEC,KAAK,EAAEH,sBAAsB,EAAE;IACrEjB,KAAK,CAAC,qBAAqB,CAAC;IAC5B,OAAO,CAAC,CAAC;EACX,CAAC;EAEDqB,oBAAoBA,CAACD,KAAK,EAAEE,MAAM,EAAE;IAClC,OAAO,KAAK;EACd,CAAC;EAEDC,kBAAkBA,CAChBC,KAAK,EACLP,sBAAsB,EACtBQ,YAAY,EACZC,uBAAuB,EACvB;IACA1B,KAAK,CAAC,oBAAoB,CAAC;IAC3B;IACA,MAAM,IAAI2B,KAAK,CAAC,kCAAk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C,oBAAa,EAAC,IAAI,CAAC;EAC1CC,wBAAwBA,CAACC,WAAmB,EAAE;IAC5C3F,qBAAqB,GAAG2F,WAAW;EACrC,CAAC;EACDC,wBAAwBA,CAAA,EAAG;IACzB,OAAO5F,qBAAqB;EAC9B,CAAC;EACD6F,qBAAqBA,CAAA,EAAG;IACtB,IAAI7F,qBAAqB,KAAKP,eAAe,EAAE;MAC7C,OAAOO,qBAAqB;IAC9B;IACA,OAAOoE,+BAAoB;EAC7B,CAAC;EACD0B,iBAAiBA,CAAA,EAAG,CAAC;AACvB,CAAC","ignoreList":[]}
|
@@ -14,5 +14,7 @@ export declare const createDrawingContext: (Skia: Skia, paintPool: SkPaint[], ca
|
|
14
14
|
readonly paint: SkPaint;
|
15
15
|
restorePaint: () => SkPaint | undefined;
|
16
16
|
materializePaint: () => void;
|
17
|
+
getOpacity: () => number;
|
18
|
+
setOpacity: (newOpacity: number) => void;
|
17
19
|
};
|
18
20
|
export type DrawingContext = ReturnType<typeof createDrawingContext>;
|
@@ -14,11 +14,13 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
14
14
|
const imageFilters = [];
|
15
15
|
const pathEffects = [];
|
16
16
|
const paintDeclarations = [];
|
17
|
+
const opacities = [];
|
17
18
|
let nextPaintIndex = 1;
|
18
19
|
|
19
|
-
// Initialize first paint
|
20
|
+
// Initialize first paint and opacity
|
20
21
|
paintPool[0] = Skia.Paint();
|
21
22
|
paints.push(paintPool[0]);
|
23
|
+
opacities.push(1);
|
22
24
|
|
23
25
|
// Methods (formerly class methods)
|
24
26
|
const savePaint = () => {
|
@@ -29,8 +31,15 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
29
31
|
const nextPaint = paintPool[nextPaintIndex];
|
30
32
|
nextPaint.assign(getCurrentPaint()); // Reuse allocation by copying properties
|
31
33
|
paints.push(nextPaint);
|
34
|
+
opacities.push(opacities[opacities.length - 1]);
|
32
35
|
nextPaintIndex++;
|
33
36
|
};
|
37
|
+
const getOpacity = () => {
|
38
|
+
return opacities[opacities.length - 1];
|
39
|
+
};
|
40
|
+
const setOpacity = newOpacity => {
|
41
|
+
opacities[opacities.length - 1] = Math.max(0, Math.min(1, newOpacity));
|
42
|
+
};
|
34
43
|
const saveBackdropFilter = () => {
|
35
44
|
let imageFilter = null;
|
36
45
|
const imgf = imageFilters.pop();
|
@@ -51,6 +60,7 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
51
60
|
return paints[paints.length - 1];
|
52
61
|
};
|
53
62
|
const restorePaint = () => {
|
63
|
+
opacities.pop();
|
54
64
|
return paints.pop();
|
55
65
|
};
|
56
66
|
const materializePaint = () => {
|
@@ -99,7 +109,9 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
|
|
99
109
|
},
|
100
110
|
// the "getter" for the current paint
|
101
111
|
restorePaint,
|
102
|
-
materializePaint
|
112
|
+
materializePaint,
|
113
|
+
getOpacity,
|
114
|
+
setOpacity
|
103
115
|
};
|
104
116
|
};
|
105
117
|
exports.createDrawingContext = createDrawingContext;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createDrawingContext","Skia","paintPool","canvas","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","nextPaintIndex","Paint","push","savePaint","length","nextPaint","assign","getCurrentPaint","saveBackdropFilter","imageFilter","imgf","pop","cf","ImageFilter","MakeColorFilter","saveLayer","undefined","restore","restorePaint","materializePaint","setColorFilter","reduceRight","inner","outer","ColorFilter","MakeCompose","setShader","setImageFilter","setPathEffect","PathEffect","paint","exports"],"sources":["DrawingContext.ts"],"sourcesContent":["import type {\n Skia,\n SkCanvas,\n SkColorFilter,\n SkPaint,\n SkShader,\n SkImageFilter,\n SkPathEffect,\n} from \"../../skia/types\";\n\nexport const createDrawingContext = (\n Skia: Skia,\n paintPool: SkPaint[],\n canvas: SkCanvas\n) => {\n \"worklet\";\n\n // State (formerly class fields)\n const paints: SkPaint[] = [];\n const colorFilters: SkColorFilter[] = [];\n const shaders: SkShader[] = [];\n const imageFilters: SkImageFilter[] = [];\n const pathEffects: SkPathEffect[] = [];\n const paintDeclarations: SkPaint[] = [];\n\n let nextPaintIndex = 1;\n\n // Initialize first paint\n paintPool[0] = Skia.Paint();\n paints.push(paintPool[0]);\n\n // Methods (formerly class methods)\n const savePaint = () => {\n // Get next available paint from pool or create new one if needed\n if (nextPaintIndex >= paintPool.length) {\n paintPool.push(Skia.Paint());\n }\n\n const nextPaint = paintPool[nextPaintIndex];\n nextPaint.assign(getCurrentPaint()); // Reuse allocation by copying properties\n paints.push(nextPaint);\n nextPaintIndex++;\n };\n\n const saveBackdropFilter = () => {\n let imageFilter: SkImageFilter | null = null;\n const imgf = imageFilters.pop();\n if (imgf) {\n imageFilter = imgf;\n } else {\n const cf = colorFilters.pop();\n if (cf) {\n imageFilter = Skia.ImageFilter.MakeColorFilter(cf, null);\n }\n }\n canvas.saveLayer(undefined, null, imageFilter);\n canvas.restore();\n };\n\n // Equivalent to the `get paint()` getter in the original class\n const getCurrentPaint = () => {\n return paints[paints.length - 1];\n };\n\n const restorePaint = () => {\n return paints.pop();\n };\n\n const materializePaint = () => {\n // Color Filters\n if (colorFilters.length > 0) {\n getCurrentPaint().setColorFilter(\n colorFilters.reduceRight((inner, outer) =>\n inner ? Skia.ColorFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n // Shaders\n if (shaders.length > 0) {\n getCurrentPaint().setShader(shaders[shaders.length - 1]);\n }\n // Image Filters\n if (imageFilters.length > 0) {\n getCurrentPaint().setImageFilter(\n imageFilters.reduceRight((inner, outer) =>\n inner ? Skia.ImageFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Path Effects\n if (pathEffects.length > 0) {\n getCurrentPaint().setPathEffect(\n pathEffects.reduceRight((inner, outer) =>\n inner ? Skia.PathEffect.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Clear arrays\n colorFilters.length = 0;\n shaders.length = 0;\n imageFilters.length = 0;\n pathEffects.length = 0;\n };\n\n // Return an object containing the Skia reference, the canvas, and the methods\n return {\n // Public fields\n Skia,\n canvas,\n paints,\n colorFilters,\n shaders,\n imageFilters,\n pathEffects,\n paintDeclarations,\n paintPool,\n\n // Public methods\n savePaint,\n saveBackdropFilter,\n get paint() {\n return paints[paints.length - 1];\n }, // the \"getter\" for the current paint\n restorePaint,\n materializePaint,\n };\n};\n\nexport type DrawingContext = ReturnType<typeof createDrawingContext>;\n"],"mappings":";;;;;;AAUO,MAAMA,oBAAoB,GAAGA,CAClCC,IAAU,EACVC,SAAoB,EACpBC,MAAgB,KACb;EACH,SAAS;;EAET;EACA,MAAMC,MAAiB,GAAG,EAAE;EAC5B,MAAMC,YAA6B,GAAG,EAAE;EACxC,MAAMC,OAAmB,GAAG,EAAE;EAC9B,MAAMC,YAA6B,GAAG,EAAE;EACxC,MAAMC,WAA2B,GAAG,EAAE;EACtC,MAAMC,iBAA4B,GAAG,EAAE;
|
1
|
+
{"version":3,"names":["createDrawingContext","Skia","paintPool","canvas","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","Paint","push","savePaint","length","nextPaint","assign","getCurrentPaint","getOpacity","setOpacity","newOpacity","Math","max","min","saveBackdropFilter","imageFilter","imgf","pop","cf","ImageFilter","MakeColorFilter","saveLayer","undefined","restore","restorePaint","materializePaint","setColorFilter","reduceRight","inner","outer","ColorFilter","MakeCompose","setShader","setImageFilter","setPathEffect","PathEffect","paint","exports"],"sources":["DrawingContext.ts"],"sourcesContent":["import type {\n Skia,\n SkCanvas,\n SkColorFilter,\n SkPaint,\n SkShader,\n SkImageFilter,\n SkPathEffect,\n} from \"../../skia/types\";\n\nexport const createDrawingContext = (\n Skia: Skia,\n paintPool: SkPaint[],\n canvas: SkCanvas\n) => {\n \"worklet\";\n\n // State (formerly class fields)\n const paints: SkPaint[] = [];\n const colorFilters: SkColorFilter[] = [];\n const shaders: SkShader[] = [];\n const imageFilters: SkImageFilter[] = [];\n const pathEffects: SkPathEffect[] = [];\n const paintDeclarations: SkPaint[] = [];\n const opacities: number[] = [];\n\n let nextPaintIndex = 1;\n\n // Initialize first paint and opacity\n paintPool[0] = Skia.Paint();\n paints.push(paintPool[0]);\n opacities.push(1);\n\n // Methods (formerly class methods)\n const savePaint = () => {\n // Get next available paint from pool or create new one if needed\n if (nextPaintIndex >= paintPool.length) {\n paintPool.push(Skia.Paint());\n }\n\n const nextPaint = paintPool[nextPaintIndex];\n nextPaint.assign(getCurrentPaint()); // Reuse allocation by copying properties\n paints.push(nextPaint);\n opacities.push(opacities[opacities.length - 1]);\n nextPaintIndex++;\n };\n\n const getOpacity = () => {\n return opacities[opacities.length - 1];\n };\n\n const setOpacity = (newOpacity: number) => {\n opacities[opacities.length - 1] = Math.max(0, Math.min(1, newOpacity));\n };\n\n const saveBackdropFilter = () => {\n let imageFilter: SkImageFilter | null = null;\n const imgf = imageFilters.pop();\n if (imgf) {\n imageFilter = imgf;\n } else {\n const cf = colorFilters.pop();\n if (cf) {\n imageFilter = Skia.ImageFilter.MakeColorFilter(cf, null);\n }\n }\n canvas.saveLayer(undefined, null, imageFilter);\n canvas.restore();\n };\n\n // Equivalent to the `get paint()` getter in the original class\n const getCurrentPaint = () => {\n return paints[paints.length - 1];\n };\n\n const restorePaint = () => {\n opacities.pop();\n return paints.pop();\n };\n\n const materializePaint = () => {\n // Color Filters\n if (colorFilters.length > 0) {\n getCurrentPaint().setColorFilter(\n colorFilters.reduceRight((inner, outer) =>\n inner ? Skia.ColorFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n // Shaders\n if (shaders.length > 0) {\n getCurrentPaint().setShader(shaders[shaders.length - 1]);\n }\n // Image Filters\n if (imageFilters.length > 0) {\n getCurrentPaint().setImageFilter(\n imageFilters.reduceRight((inner, outer) =>\n inner ? Skia.ImageFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Path Effects\n if (pathEffects.length > 0) {\n getCurrentPaint().setPathEffect(\n pathEffects.reduceRight((inner, outer) =>\n inner ? Skia.PathEffect.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Clear arrays\n colorFilters.length = 0;\n shaders.length = 0;\n imageFilters.length = 0;\n pathEffects.length = 0;\n };\n\n // Return an object containing the Skia reference, the canvas, and the methods\n return {\n // Public fields\n Skia,\n canvas,\n paints,\n colorFilters,\n shaders,\n imageFilters,\n pathEffects,\n paintDeclarations,\n paintPool,\n\n // Public methods\n savePaint,\n saveBackdropFilter,\n get paint() {\n return paints[paints.length - 1];\n }, // the \"getter\" for the current paint\n restorePaint,\n materializePaint,\n getOpacity,\n setOpacity,\n };\n};\n\nexport type DrawingContext = ReturnType<typeof createDrawingContext>;\n"],"mappings":";;;;;;AAUO,MAAMA,oBAAoB,GAAGA,CAClCC,IAAU,EACVC,SAAoB,EACpBC,MAAgB,KACb;EACH,SAAS;;EAET;EACA,MAAMC,MAAiB,GAAG,EAAE;EAC5B,MAAMC,YAA6B,GAAG,EAAE;EACxC,MAAMC,OAAmB,GAAG,EAAE;EAC9B,MAAMC,YAA6B,GAAG,EAAE;EACxC,MAAMC,WAA2B,GAAG,EAAE;EACtC,MAAMC,iBAA4B,GAAG,EAAE;EACvC,MAAMC,SAAmB,GAAG,EAAE;EAE9B,IAAIC,cAAc,GAAG,CAAC;;EAEtB;EACAT,SAAS,CAAC,CAAC,CAAC,GAAGD,IAAI,CAACW,KAAK,CAAC,CAAC;EAC3BR,MAAM,CAACS,IAAI,CAACX,SAAS,CAAC,CAAC,CAAC,CAAC;EACzBQ,SAAS,CAACG,IAAI,CAAC,CAAC,CAAC;;EAEjB;EACA,MAAMC,SAAS,GAAGA,CAAA,KAAM;IACtB;IACA,IAAIH,cAAc,IAAIT,SAAS,CAACa,MAAM,EAAE;MACtCb,SAAS,CAACW,IAAI,CAACZ,IAAI,CAACW,KAAK,CAAC,CAAC,CAAC;IAC9B;IAEA,MAAMI,SAAS,GAAGd,SAAS,CAACS,cAAc,CAAC;IAC3CK,SAAS,CAACC,MAAM,CAACC,eAAe,CAAC,CAAC,CA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IAAI;IACJE,MAAM;IACNC,MAAM;IACNC,YAAY;IACZC,OAAO;IACPC,YAAY;IACZC,WAAW;IACXC,iBAAiB;IACjBP,SAAS;IAET;IACAY,SAAS;IACTW,kBAAkB;IAClB,IAAIsB,KAAKA,CAAA,EAAG;MACV,OAAO3C,MAAM,CAACA,MAAM,CAACW,MAAM,GAAG,CAAC,CAAC;IAClC,CAAC;IAAE;IACHoB,YAAY;IACZC,gBAAgB;IAChBjB,UAAU;IACVC;EACF,CAAC;AACH,CAAC;AAAC4B,OAAA,CAAAhD,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
@@ -32,7 +32,7 @@ function play(ctx, _command) {
|
|
32
32
|
ctx.paints.push(command.props.paint);
|
33
33
|
} else {
|
34
34
|
ctx.savePaint();
|
35
|
-
(0, _Paint.setPaintProperties)(ctx.Skia, ctx
|
35
|
+
(0, _Paint.setPaintProperties)(ctx.Skia, ctx, command.props);
|
36
36
|
}
|
37
37
|
} else if ((0, _Core.isCommand)(command, _Core.CommandType.RestorePaint)) {
|
38
38
|
ctx.restorePaint();
|
@@ -66,7 +66,11 @@ function play(ctx, _command) {
|
|
66
66
|
} else if ((0, _Core.isCommand)(command, _Core.CommandType.RestoreCTM)) {
|
67
67
|
ctx.canvas.restore();
|
68
68
|
} else {
|
69
|
-
|
69
|
+
// TODO: is a copy needed here?
|
70
|
+
// apply opacity to the current paint.
|
71
|
+
const paint = ctx.paint.copy();
|
72
|
+
paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());
|
73
|
+
const paints = [paint, ...ctx.paintDeclarations];
|
70
74
|
ctx.paintDeclarations = [];
|
71
75
|
paints.forEach(p => {
|
72
76
|
ctx.paints.push(p);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_Drawing","require","_Box","_ColorFilters","_CTM","_ImageFilters","_Paint","_PathEffects","_Shaders","_Core","play","ctx","_command","isGroup","children","forEach","child","command","materializeCommand","isCommand","CommandType","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","isDrawCommand","SavePaint","props","paints","push","savePaint","setPaintProperties","Skia","RestorePaint","restorePaint","ComposeColorFilter","composeColorFilters","RestorePaintDeclaration","Error","MaterializePaint","isPushColorFilter","pushColorFilter","isPushShader","pushShader","isPushImageFilter","pushImageFilter","isPushPathEffect","pushPathEffect","ComposePathEffect","composePathEffects","ComposeImageFilter","composeImageFilters","PushBlurMaskFilter","setBlurMaskFilter","SaveCTM","saveCTM","RestoreCTM","restore","p","isBoxCommand","drawBox","DrawPaint","drawPaint","DrawImage","drawImage","DrawCircle","drawCircle","DrawPoints","drawPoints","DrawPath","drawPath","DrawRect","drawRect","DrawRRect","drawRRect","DrawOval","drawOval","DrawLine","drawLine","DrawPatch","drawPatch","DrawVertices","drawVertices","DrawDiffRect","drawDiffRect","DrawText","drawText","DrawTextPath","drawTextPath","DrawTextBlob","drawTextBlob","DrawGlyphs","drawGlyphs","DrawPicture","drawPicture","DrawImageSVG","drawImageSVG","DrawParagraph","drawParagraph","DrawAtlas","drawAtlas","console","warn","type","replay","commands","exports"],"sources":["Player.ts"],"sourcesContent":["import {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n isGroup,\n materializeCommand,\n} from \"./Core\";\nimport type { Command } from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nfunction play(ctx: DrawingContext, _command: Command) {\n \"worklet\";\n if (isGroup(_command)) {\n _command.children.forEach((child) => play(ctx, child));\n return;\n }\n const command = materializeCommand(_command);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n ctx.savePaint();\n setPaintProperties(ctx.Skia, ctx.paint, command.props);\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n const paints = [ctx.paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n}\n\nexport const replay = (ctx: DrawingContext, commands: Command[]) => {\n \"worklet\";\n commands.forEach((command) => {\n play(ctx, command);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAqBA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAKA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAUA,SAASS,IAAIA,CAACC,GAAmB,EAAEC,QAAiB,EAAE;EACpD,SAAS;;EACT,IAAI,IAAAC,aAAO,EAACD,QAAQ,CAAC,EAAE;IACrBA,QAAQ,CAACE,QAAQ,CAACC,OAAO,CAAEC,KAAK,IAAKN,IAAI,CAACC,GAAG,EAAEK,KAAK,CAAC,CAAC;IACtD;EACF;EACA,MAAMC,OAAO,GAAG,IAAAC,wBAAkB,EAACN,QAAQ,CAAC;EAC5C,IAAI,IAAAO,eAAS,EAACF,OAAO,EAAEG,iBAAW,CAACC,kBAAkB,CAAC,EAAE;IACtDV,GAAG,CAACW,kBAAkB,CAAC,CAAC;EAC1B,CAAC,MAAM,IAAI,IAAAH,eAAS,EAACF,OAAO,EAAEG,iBAAW,CAACG,SAAS,CAAC,EAAE;IACpDZ,GAAG,CAACa,gBAAgB,CAAC,CAAC;IACtB,MAAMC,KAAK,GAAGd,GAAG,CAACe,iBAAiB,CAACC,GAAG,CAAC,CAAC;IACzChB,GAAG,CAACiB,MAAM,CAACC,SAAS,CAACJ,KAAK,CAAC;EAC7B,CAAC,MAAM,IAAI,IAAAK,mBAAa,EAACb,OAAO,EAAEG,iBAAW,CAACW,SAA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AAAC8F,OAAA,CAAAF,MAAA,GAAAA,MAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_Drawing","require","_Box","_ColorFilters","_CTM","_ImageFilters","_Paint","_PathEffects","_Shaders","_Core","play","ctx","_command","isGroup","children","forEach","child","command","materializeCommand","isCommand","CommandType","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","isDrawCommand","SavePaint","props","paints","push","savePaint","setPaintProperties","Skia","RestorePaint","restorePaint","ComposeColorFilter","composeColorFilters","RestorePaintDeclaration","Error","MaterializePaint","isPushColorFilter","pushColorFilter","isPushShader","pushShader","isPushImageFilter","pushImageFilter","isPushPathEffect","pushPathEffect","ComposePathEffect","composePathEffects","ComposeImageFilter","composeImageFilters","PushBlurMaskFilter","setBlurMaskFilter","SaveCTM","saveCTM","RestoreCTM","restore","copy","setAlphaf","getAlphaf","getOpacity","p","isBoxCommand","drawBox","DrawPaint","drawPaint","DrawImage","drawImage","DrawCircle","drawCircle","DrawPoints","drawPoints","DrawPath","drawPath","DrawRect","drawRect","DrawRRect","drawRRect","DrawOval","drawOval","DrawLine","drawLine","DrawPatch","drawPatch","DrawVertices","drawVertices","DrawDiffRect","drawDiffRect","DrawText","drawText","DrawTextPath","drawTextPath","DrawTextBlob","drawTextBlob","DrawGlyphs","drawGlyphs","DrawPicture","drawPicture","DrawImageSVG","drawImageSVG","DrawParagraph","drawParagraph","DrawAtlas","drawAtlas","console","warn","type","replay","commands","exports"],"sources":["Player.ts"],"sourcesContent":["import {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n isGroup,\n materializeCommand,\n} from \"./Core\";\nimport type { Command } from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nfunction play(ctx: DrawingContext, _command: Command) {\n \"worklet\";\n if (isGroup(_command)) {\n _command.children.forEach((child) => play(ctx, child));\n return;\n }\n const command = materializeCommand(_command);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n ctx.savePaint();\n setPaintProperties(ctx.Skia, ctx, command.props);\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n // TODO: is a copy needed here?\n // apply opacity to the current paint.\n const paint = ctx.paint.copy();\n paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());\n const paints = [paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n}\n\nexport const replay = (ctx: DrawingContext, commands: Command[]) => {\n \"worklet\";\n commands.forEach((command) => {\n play(ctx, command);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAqBA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAKA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAUA,SAASS,IAAIA,CAACC,GAAmB,EAAEC,QAAiB,EAAE;EACpD,SAAS;;EACT,IAAI,IAAAC,aAAO,EAACD,QAAQ,CAAC,EAAE;IACrBA,QAAQ,CAACE,QAAQ,CAACC,OAAO,CAAEC,KAAK,IAAKN,IAAI,CAACC,GAAG,EAAEK,KAAK,CAAC,CAAC;IACtD;EACF;EACA,MAAMC,OAAO,GAAG,IAAAC,wBAAkB,EAACN,QAAQ,CAAC;EAC5C,IAAI,IAAAO,eAAS,EAACF,OAAO,EAAEG,iBAAW,CAACC,kBAAkB,CAAC,EAAE;IACtDV,GAAG,CAACW,kBAAkB,CAAC,CAAC;EAC1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,EAACb,OAAO,EAAEG,iBAAW,CAACwF,SAAS,CAAC,EAAE;QACxD,IAAAC,kBAAS,EAAClG,GAAG,EAAEM,OAAO,CAACe,KAAK,CAAC;MAC/B,CAAC,MAAM;QACL8E,OAAO,CAACC,IAAI,CAAC,oBAAoB9F,OAAO,CAAC+F,IAAI,EAAE,CAAC;MAClD;MACArG,GAAG,CAACsB,MAAM,CAACN,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC;EACJ;AACF;AAEO,MAAMsF,MAAM,GAAGA,CAACtG,GAAmB,EAAEuG,QAAmB,KAAK;EAClE,SAAS;;EACTA,QAAQ,CAACnG,OAAO,CAAEE,OAAO,IAAK;IAC5BP,IAAI,CAACC,GAAG,EAAEM,OAAO,CAAC;EACpB,CAAC,CAAC;AACJ,CAAC;AAACkG,OAAA,CAAAF,MAAA,GAAAA,MAAA","ignoreList":[]}
|
@@ -1,3 +1,4 @@
|
|
1
1
|
import type { PaintProps } from "../../../dom/types";
|
2
|
-
import type {
|
3
|
-
|
2
|
+
import type { Skia } from "../../../skia/types";
|
3
|
+
import type { DrawingContext } from "../DrawingContext";
|
4
|
+
export declare const setPaintProperties: (Skia: Skia, ctx: DrawingContext, { opacity, color, blendMode, strokeWidth, style, strokeJoin, strokeCap, strokeMiter, antiAlias, dither, }: PaintProps) => void;
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.setPaintProperties = void 0;
|
7
7
|
var _nodes = require("../../../dom/nodes");
|
8
8
|
var _types = require("../../../skia/types");
|
9
|
-
const setPaintProperties = (Skia,
|
9
|
+
const setPaintProperties = (Skia, ctx, {
|
10
10
|
opacity,
|
11
11
|
color,
|
12
12
|
blendMode,
|
@@ -20,14 +20,15 @@ const setPaintProperties = (Skia, paint, {
|
|
20
20
|
}) => {
|
21
21
|
"worklet";
|
22
22
|
|
23
|
+
const {
|
24
|
+
paint
|
25
|
+
} = ctx;
|
23
26
|
if (opacity !== undefined) {
|
24
|
-
|
27
|
+
ctx.setOpacity(ctx.getOpacity() * opacity);
|
25
28
|
}
|
26
29
|
if (color !== undefined) {
|
27
|
-
const currentOpacity = paint.getAlphaf();
|
28
30
|
paint.setShader(null);
|
29
31
|
paint.setColor((0, _nodes.processColor)(Skia, color));
|
30
|
-
paint.setAlphaf(currentOpacity * paint.getAlphaf());
|
31
32
|
}
|
32
33
|
if (blendMode !== undefined) {
|
33
34
|
paint.setBlendMode(_types.BlendMode[(0, _nodes.enumKey)(blendMode)]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_nodes","require","_types","setPaintProperties","Skia","
|
1
|
+
{"version":3,"names":["_nodes","require","_types","setPaintProperties","Skia","ctx","opacity","color","blendMode","strokeWidth","style","strokeJoin","strokeCap","strokeMiter","antiAlias","dither","paint","undefined","setOpacity","getOpacity","setShader","setColor","processColor","setBlendMode","BlendMode","enumKey","setStrokeWidth","setStyle","PaintStyle","setStrokeJoin","StrokeJoin","setStrokeCap","StrokeCap","setStrokeMiter","setAntiAlias","setDither","exports"],"sources":["Paint.ts"],"sourcesContent":["import { enumKey, processColor } from \"../../../dom/nodes\";\nimport type { PaintProps } from \"../../../dom/types\";\nimport {\n BlendMode,\n PaintStyle,\n StrokeCap,\n StrokeJoin,\n} from \"../../../skia/types\";\nimport type { Skia } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport const setPaintProperties = (\n Skia: Skia,\n ctx: DrawingContext,\n {\n opacity,\n color,\n blendMode,\n strokeWidth,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n antiAlias,\n dither,\n }: PaintProps\n) => {\n \"worklet\";\n const { paint } = ctx;\n\n if (opacity !== undefined) {\n ctx.setOpacity(ctx.getOpacity() * opacity);\n }\n if (color !== undefined) {\n paint.setShader(null);\n paint.setColor(processColor(Skia, color));\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (dither !== undefined) {\n paint.setDither(dither);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AASO,MAAME,kBAAkB,GAAGA,CAChCC,IAAU,EACVC,GAAmB,EACnB;EACEC,OAAO;EACPC,KAAK;EACLC,SAAS;EACTC,WAAW;EACXC,KAAK;EACLC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,SAAS;EACTC;AACU,CAAC,KACV;EACH,SAAS;;EACT,MAAM;IAAEC;EAAM,CAAC,GAAGX,GAAG;EAErB,IAAIC,OAAO,KAAKW,SAAS,EAAE;IACzBZ,GAAG,CAACa,UAAU,CAACb,GAAG,CAACc,UAAU,CAAC,CAAC,GAAGb,OAAO,CAAC;EAC5C;EACA,IAAIC,KAAK,KAAKU,SAAS,EAAE;IACvBD,KAAK,CAACI,SAAS,CAAC,IAAI,CAAC;IACrBJ,KAAK,CAACK,QAAQ,CAAC,IAAAC,mBAAY,EAAClB,IAAI,EAAEG,KAAK,CAAC,CAAC;EAC3C;EACA,IAAIC,SAAS,KAAKS,SAAS,EAAE;IAC3BD,KAAK,CAACO,YAAY,CAACC,gBAAS,CAAC,IAAAC,cAAO,EAACjB,SAAS,CAAC,CAAC,CAAC;EACnD;EACA,IAAIC,WAAW,KAAKQ,SAAS,EAAE;IAC7BD,KAAK,CAACU,cAAc,CAACjB,WAAW,CAAC;EACnC;EACA,IAAIC,KAAK,KAAKO,SAAS,EAAE;IACvBD,KAAK,CAACW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