@shopify/react-native-skia 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.cpp +34 -14
- package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.h +2 -1
- package/cpp/api/JsiSkImageFactory.h +3 -3
- package/cpp/rnskia/RNSkPlatformContext.h +1 -1
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +1 -1
- package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.mm +2 -2
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +3 -3
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.d.ts +2 -2
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +3 -3
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.d.ts +2 -2
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkNativeBufferFactory.d.ts +1 -1
- package/lib/module/skia/web/JsiSkNativeBufferFactory.js +1 -1
- package/lib/module/skia/web/JsiSkNativeBufferFactory.js.map +1 -1
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +3 -3
- package/lib/typescript/src/skia/types/NativeBuffer/NativeBufferFactory.d.ts +2 -2
- package/lib/typescript/src/skia/web/JsiSkNativeBufferFactory.d.ts +1 -1
- package/package.json +1 -1
- package/src/skia/types/Image/ImageFactory.ts +3 -3
- package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +2 -2
- package/src/skia/web/JsiSkNativeBufferFactory.ts +1 -1
@@ -16,16 +16,13 @@ namespace RNSkia {
|
|
16
16
|
thread_local SkiaOpenGLContext ThreadContextHolder::ThreadSkiaOpenGLContext;
|
17
17
|
|
18
18
|
sk_sp<SkImage>
|
19
|
-
SkiaOpenGLSurfaceFactory::makeImageFromHardwareBuffer(void *buffer
|
19
|
+
SkiaOpenGLSurfaceFactory::makeImageFromHardwareBuffer(void *buffer,
|
20
|
+
bool requireKnownFormat) {
|
20
21
|
#if __ANDROID_API__ >= 26
|
21
22
|
// Setup OpenGL and Skia:
|
22
23
|
if (!SkiaOpenGLHelper::createSkiaDirectContextIfNecessary(
|
23
|
-
&ThreadContextHolder::ThreadSkiaOpenGLContext)) {
|
24
|
-
|
25
|
-
RNSkLogger::logToConsole(
|
26
|
-
"Could not create Skia Surface from native window / surface. "
|
27
|
-
"Failed creating Skia Direct Context");
|
28
|
-
return nullptr;
|
24
|
+
&ThreadContextHolder::ThreadSkiaOpenGLContext)) [[unlikely]] {
|
25
|
+
throw std::runtime_error("Failed to create Skia Context for this Thread!");
|
29
26
|
}
|
30
27
|
const AHardwareBuffer *hardwareBuffer =
|
31
28
|
static_cast<AHardwareBuffer *>(buffer);
|
@@ -35,23 +32,46 @@ SkiaOpenGLSurfaceFactory::makeImageFromHardwareBuffer(void *buffer) {
|
|
35
32
|
|
36
33
|
AHardwareBuffer_Desc description;
|
37
34
|
AHardwareBuffer_describe(hardwareBuffer, &description);
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
GrBackendFormat format;
|
36
|
+
switch (description.format) {
|
37
|
+
// TODO: find out if we can detect, which graphic buffers support
|
38
|
+
// GR_GL_TEXTURE_2D
|
39
|
+
case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
|
40
|
+
case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:
|
41
|
+
format = GrBackendFormats::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_EXTERNAL);
|
42
|
+
case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
|
43
|
+
format = GrBackendFormats::MakeGL(GR_GL_RGBA16F, GR_GL_TEXTURE_EXTERNAL);
|
44
|
+
case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
|
45
|
+
format = GrBackendFormats::MakeGL(GR_GL_RGB565, GR_GL_TEXTURE_EXTERNAL);
|
46
|
+
case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
|
47
|
+
format = GrBackendFormats::MakeGL(GR_GL_RGB10_A2, GR_GL_TEXTURE_EXTERNAL);
|
48
|
+
case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
|
49
|
+
format = GrBackendFormats::MakeGL(GR_GL_RGB8, GR_GL_TEXTURE_EXTERNAL);
|
50
|
+
#if __ANDROID_API__ >= 33
|
51
|
+
case AHARDWAREBUFFER_FORMAT_R8_UNORM:
|
52
|
+
format = GrBackendFormats::MakeGL(GR_GL_R8, GR_GL_TEXTURE_EXTERNAL);
|
53
|
+
#endif
|
54
|
+
default:
|
55
|
+
if (requireKnownFormat) {
|
56
|
+
format = GrBackendFormat();
|
57
|
+
} else {
|
58
|
+
format = GrBackendFormats::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_EXTERNAL);
|
59
|
+
}
|
42
60
|
}
|
43
|
-
GrBackendFormat format =
|
44
|
-
GrBackendFormats::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_EXTERNAL);
|
45
61
|
|
46
62
|
auto backendTex = MakeGLBackendTexture(
|
47
63
|
ThreadContextHolder::ThreadSkiaOpenGLContext.directContext.get(),
|
48
64
|
const_cast<AHardwareBuffer *>(hardwareBuffer), description.width,
|
49
65
|
description.height, &deleteImageProc, &updateImageProc, &deleteImageCtx,
|
50
66
|
false, format, false);
|
67
|
+
if (!backendTex.isValid()) [[unlikely]] {
|
68
|
+
throw std::runtime_error(
|
69
|
+
"Failed to convert HardwareBuffer to OpenGL Texture!");
|
70
|
+
}
|
51
71
|
sk_sp<SkImage> image = SkImages::BorrowTextureFrom(
|
52
72
|
ThreadContextHolder::ThreadSkiaOpenGLContext.directContext.get(),
|
53
73
|
backendTex, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType,
|
54
|
-
kOpaque_SkAlphaType, nullptr);
|
74
|
+
kOpaque_SkAlphaType, nullptr, deleteImageProc, deleteImageCtx);
|
55
75
|
return image;
|
56
76
|
#else
|
57
77
|
throw std::runtime_error(
|
@@ -149,7 +149,8 @@ public:
|
|
149
149
|
*/
|
150
150
|
static sk_sp<SkSurface> makeOffscreenSurface(int width, int height);
|
151
151
|
|
152
|
-
static sk_sp<SkImage>
|
152
|
+
static sk_sp<SkImage>
|
153
|
+
makeImageFromHardwareBuffer(void *buffer, bool requireKnownFormat = false);
|
153
154
|
|
154
155
|
/**
|
155
156
|
* Creates a windowed Skia Surface holder.
|
@@ -29,11 +29,11 @@ public:
|
|
29
29
|
|
30
30
|
JSI_HOST_FUNCTION(MakeImageFromNativeBuffer) {
|
31
31
|
jsi::BigInt pointer = arguments[0].asBigInt(runtime);
|
32
|
-
const uintptr_t
|
33
|
-
void *rawPointer = reinterpret_cast<void *>(
|
32
|
+
const uintptr_t nativeBufferPointer = pointer.asUint64(runtime);
|
33
|
+
void *rawPointer = reinterpret_cast<void *>(nativeBufferPointer);
|
34
34
|
auto image = getContext()->makeImageFromNativeBuffer(rawPointer);
|
35
35
|
if (image == nullptr) {
|
36
|
-
throw std::runtime_error("Failed to convert
|
36
|
+
throw std::runtime_error("Failed to convert NativeBuffer to SkImage!");
|
37
37
|
}
|
38
38
|
return jsi::Object::createFromHostObject(
|
39
39
|
runtime, std::make_shared<JsiSkImage>(getContext(), std::move(image)));
|
@@ -137,7 +137,7 @@ public:
|
|
137
137
|
* Creates an image from a native buffer.
|
138
138
|
* - On iOS, this is a `CVPixelBufferRef`
|
139
139
|
* - On Android, this is a `AHardwareBuffer*`
|
140
|
-
* @param buffer The native
|
140
|
+
* @param buffer The native buffer.
|
141
141
|
* @return sk_sp<SkImage>
|
142
142
|
*/
|
143
143
|
virtual sk_sp<SkImage> makeImageFromNativeBuffer(void *buffer) = 0;
|
@@ -75,7 +75,7 @@ uint64_t RNSkiOSPlatformContext::makeNativeBuffer(sk_sp<SkImage> image) {
|
|
75
75
|
if (image == nullptr) {
|
76
76
|
throw std::runtime_error(
|
77
77
|
"Failed to convert image to BGRA_8888 colortype! Only BGRA_8888 "
|
78
|
-
"
|
78
|
+
"NativeBuffers are supported.");
|
79
79
|
}
|
80
80
|
}
|
81
81
|
|
@@ -130,8 +130,8 @@ sk_sp<SkImage> SkiaMetalSurfaceFactory::makeTextureFromCVPixelBuffer(
|
|
130
130
|
}
|
131
131
|
default:
|
132
132
|
[[unlikely]] {
|
133
|
-
throw std::runtime_error("Failed to convert
|
134
|
-
"
|
133
|
+
throw std::runtime_error("Failed to convert NativeBuffer to SkImage - "
|
134
|
+
"NativeBuffer has unsupported PixelFormat! " +
|
135
135
|
std::to_string(static_cast<int>(format)));
|
136
136
|
}
|
137
137
|
}
|
@@ -46,7 +46,7 @@ export interface ImageFactory {
|
|
46
46
|
MakeImageFromEncoded: (encoded: SkData) => SkImage | null;
|
47
47
|
/**
|
48
48
|
* Return an Image backed by a given native buffer.
|
49
|
-
* The
|
49
|
+
* The native buffer must be a valid owning reference.
|
50
50
|
*
|
51
51
|
* For instance, this API is used by
|
52
52
|
* [react-native-vision-camera](https://github.com/mrousavy/react-native-vision-camera)
|
@@ -54,9 +54,9 @@ export interface ImageFactory {
|
|
54
54
|
*
|
55
55
|
* - On Android; This is an `AHardwareBuffer*`
|
56
56
|
* - On iOS, this is a `CVPixelBufferRef`
|
57
|
-
* @param nativeBuffer A strong `uintptr_t` pointer to the native
|
57
|
+
* @param nativeBuffer A strong `uintptr_t` pointer to the native buffer
|
58
58
|
* @throws Throws an error if the Image could not be created, for example when the given
|
59
|
-
*
|
59
|
+
* native buffer is invalid.
|
60
60
|
*/
|
61
61
|
MakeImageFromNativeBuffer: (nativeBuffer: NativeBuffer) => SkImage;
|
62
62
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AlphaType","exports","ColorType"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\nimport type { NativeBuffer } from \"../NativeBuffer\";\n\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport enum ColorType {\n Unknown, // uninitialized\n Alpha_8, // pixel with alpha in 8-bit byte\n RGB_565, // pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word\n ARGB_4444, // pixel with 4 bits for alpha, red, green, blue; in 16-bit word\n RGBA_8888, // pixel with 8 bits for red, green, blue, alpha; in 32-bit word\n RGB_888x, // pixel with 8 bits each for red, green, blue; in 32-bit word\n BGRA_8888, // pixel with 8 bits for blue, green, red, alpha; in 32-bit word\n RGBA_1010102, // 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word\n BGRA_1010102, // 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word\n RGB_101010x, // pixel with 10 bits each for red, green, blue; in 32-bit word\n BGR_101010x, // pixel with 10 bits each for blue, green, red; in 32-bit word\n BGR_101010x_XR, // pixel with 10 bits each for blue, green, red; in 32-bit word, extended range\n RGBA_10x6, // pixel with 10 used bits (most significant) followed by 6 unused\n Gray_8, // pixel with grayscale level in 8-bit byte\n RGBA_F16Norm, // pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word\n RGBA_F16, // pixel with half floats for red, green, blue, alpha; in 64-bit word\n RGBA_F32, // pixel using C float for red, green, blue, alpha; in 128-bit word\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
|
1
|
+
{"version":3,"names":["AlphaType","exports","ColorType"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\nimport type { NativeBuffer } from \"../NativeBuffer\";\n\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport enum ColorType {\n Unknown, // uninitialized\n Alpha_8, // pixel with alpha in 8-bit byte\n RGB_565, // pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word\n ARGB_4444, // pixel with 4 bits for alpha, red, green, blue; in 16-bit word\n RGBA_8888, // pixel with 8 bits for red, green, blue, alpha; in 32-bit word\n RGB_888x, // pixel with 8 bits each for red, green, blue; in 32-bit word\n BGRA_8888, // pixel with 8 bits for blue, green, red, alpha; in 32-bit word\n RGBA_1010102, // 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word\n BGRA_1010102, // 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word\n RGB_101010x, // pixel with 10 bits each for red, green, blue; in 32-bit word\n BGR_101010x, // pixel with 10 bits each for blue, green, red; in 32-bit word\n BGR_101010x_XR, // pixel with 10 bits each for blue, green, red; in 32-bit word, extended range\n RGBA_10x6, // pixel with 10 used bits (most significant) followed by 6 unused\n Gray_8, // pixel with grayscale level in 8-bit byte\n RGBA_F16Norm, // pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word\n RGBA_F16, // pixel with half floats for red, green, blue, alpha; in 64-bit word\n RGBA_F32, // pixel using C float for red, green, blue, alpha; in 128-bit word\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 * 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":";;;;;;IAKYA,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;AAAA,IAOTE,SAAS,GAAAD,OAAA,CAAAC,SAAA,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA,OAiBT"}
|
@@ -12,7 +12,7 @@ export interface NativeBufferFactory {
|
|
12
12
|
*/
|
13
13
|
MakeFromImage: (image: SkImage) => NativeBuffer;
|
14
14
|
/**
|
15
|
-
* Release a
|
15
|
+
* Release a native buffer that was created with `MakeFromImage`.
|
16
16
|
*/
|
17
|
-
Release: (
|
17
|
+
Release: (nativeBuffer: NativeBuffer) => void;
|
18
18
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isNativeBufferAddr","buffer","BigInt","exports","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport type NativeBuffer<\n T extends bigint | ArrayBuffer | CanvasImageSource | unknown = unknown\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n buffer instanceof VideoFrame ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a native buffer.\n */\n MakeFromImage: (image: SkImage) => NativeBuffer;\n /**\n * Release a
|
1
|
+
{"version":3,"names":["isNativeBufferAddr","buffer","BigInt","exports","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport type NativeBuffer<\n T extends bigint | ArrayBuffer | CanvasImageSource | unknown = unknown\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n buffer instanceof VideoFrame ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a native buffer.\n */\n MakeFromImage: (image: SkImage) => NativeBuffer;\n /**\n * Release a native buffer that was created with `MakeFromImage`.\n */\n Release: (nativeBuffer: NativeBuffer) => void;\n}\n"],"mappings":";;;;;;AAUO,MAAMA,kBAAkB,GAC7BC,MAAoB,IACWA,MAAM,YAAYC,MAAM;AAACC,OAAA,CAAAH,kBAAA,GAAAA,kBAAA;AACnD,MAAMI,iBAAiB,GAC5BH,MAAoB,IAEpBA,MAAM,YAAYI,gBAAgB,IAClCJ,MAAM,YAAYK,iBAAiB,IACnCL,MAAM,YAAYM,WAAW,IAC7BN,MAAM,YAAYO,eAAe,IACjCP,MAAM,YAAYQ,UAAU,IAC5BR,MAAM,YAAYS,gBAAgB,IAClCT,MAAM,YAAYU,eAAe;AAACR,OAAA,CAAAC,iBAAA,GAAAA,iBAAA;AAE7B,MAAMQ,kBAAkB,GAC7BX,MAAoB,IACWA,MAAM,YAAYY,WAAW;AAACV,OAAA,CAAAS,kBAAA,GAAAA,kBAAA"}
|
@@ -4,5 +4,5 @@ import { Host } from "./Host";
|
|
4
4
|
export declare class JsiSkNativeBufferFactory extends Host implements NativeBufferFactory {
|
5
5
|
constructor(CanvasKit: CanvasKit);
|
6
6
|
MakeFromImage(image: SkImage): NativeBuffer;
|
7
|
-
Release(
|
7
|
+
Release(_nativeBuffer: NativeBuffer): void;
|
8
8
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_Host","require","JsiSkNativeBufferFactory","Host","constructor","CanvasKit","MakeFromImage","image","info","getImageInfo","uint8ClampedArray","Uint8ClampedArray","readPixels","imageData","ImageData","width","height","canvas","OffscreenCanvas","ctx","getContext","Error","putImageData","Release","
|
1
|
+
{"version":3,"names":["_Host","require","JsiSkNativeBufferFactory","Host","constructor","CanvasKit","MakeFromImage","image","info","getImageInfo","uint8ClampedArray","Uint8ClampedArray","readPixels","imageData","ImageData","width","height","canvas","OffscreenCanvas","ctx","getContext","Error","putImageData","Release","_nativeBuffer","exports"],"sources":["JsiSkNativeBufferFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport {\n type NativeBuffer,\n type NativeBufferFactory,\n type SkImage,\n} from \"../types\";\n\nimport { Host } from \"./Host\";\n\nexport class JsiSkNativeBufferFactory\n extends Host\n implements NativeBufferFactory\n{\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeFromImage(image: SkImage): NativeBuffer {\n const info = image.getImageInfo();\n const uint8ClampedArray = new Uint8ClampedArray(image.readPixels()!);\n const imageData = new ImageData(uint8ClampedArray, info.width, info.height);\n const canvas = new OffscreenCanvas(info.width, info.height);\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) {\n throw new Error(\"Failed to get 2d context from canvas\");\n }\n ctx.putImageData(imageData, 0, 0);\n return canvas;\n }\n\n Release(_nativeBuffer: NativeBuffer) {\n // it's a noop on Web\n }\n}\n"],"mappings":";;;;;;AAQA,IAAAA,KAAA,GAAAC,OAAA;AAEO,MAAMC,wBAAwB,SAC3BC,UAAI,CAEd;EACEC,WAAWA,CAACC,SAAoB,EAAE;IAChC,KAAK,CAACA,SAAS,CAAC;EAClB;EAEAC,aAAaA,CAACC,KAAc,EAAgB;IAC1C,MAAMC,IAAI,GAAGD,KAAK,CAACE,YAAY,CAAC,CAAC;IACjC,MAAMC,iBAAiB,GAAG,IAAIC,iBAAiB,CAACJ,KAAK,CAACK,UAAU,CAAC,CAAE,CAAC;IACpE,MAAMC,SAAS,GAAG,IAAIC,SAAS,CAACJ,iBAAiB,EAAEF,IAAI,CAACO,KAAK,EAAEP,IAAI,CAACQ,MAAM,CAAC;IAC3E,MAAMC,MAAM,GAAG,IAAIC,eAAe,CAACV,IAAI,CAACO,KAAK,EAAEP,IAAI,CAACQ,MAAM,CAAC;IAC3D,MAAMG,GAAG,GAAGF,MAAM,CAACG,UAAU,CAAC,IAAI,CAAC;IACnC,IAAI,CAACD,GAAG,EAAE;MACR,MAAM,IAAIE,KAAK,CAAC,sCAAsC,CAAC;IACzD;IACAF,GAAG,CAACG,YAAY,CAACT,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;IACjC,OAAOI,MAAM;EACf;EAEAM,OAAOA,CAACC,aAA2B,EAAE;IACnC;EAAA;AAEJ;AAACC,OAAA,CAAAvB,wBAAA,GAAAA,wBAAA"}
|
@@ -46,7 +46,7 @@ export interface ImageFactory {
|
|
46
46
|
MakeImageFromEncoded: (encoded: SkData) => SkImage | null;
|
47
47
|
/**
|
48
48
|
* Return an Image backed by a given native buffer.
|
49
|
-
* The
|
49
|
+
* The native buffer must be a valid owning reference.
|
50
50
|
*
|
51
51
|
* For instance, this API is used by
|
52
52
|
* [react-native-vision-camera](https://github.com/mrousavy/react-native-vision-camera)
|
@@ -54,9 +54,9 @@ export interface ImageFactory {
|
|
54
54
|
*
|
55
55
|
* - On Android; This is an `AHardwareBuffer*`
|
56
56
|
* - On iOS, this is a `CVPixelBufferRef`
|
57
|
-
* @param nativeBuffer A strong `uintptr_t` pointer to the native
|
57
|
+
* @param nativeBuffer A strong `uintptr_t` pointer to the native buffer
|
58
58
|
* @throws Throws an error if the Image could not be created, for example when the given
|
59
|
-
*
|
59
|
+
* native buffer is invalid.
|
60
60
|
*/
|
61
61
|
MakeImageFromNativeBuffer: (nativeBuffer: NativeBuffer) => SkImage;
|
62
62
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AlphaType","ColorType"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\nimport type { NativeBuffer } from \"../NativeBuffer\";\n\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport enum ColorType {\n Unknown, // uninitialized\n Alpha_8, // pixel with alpha in 8-bit byte\n RGB_565, // pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word\n ARGB_4444, // pixel with 4 bits for alpha, red, green, blue; in 16-bit word\n RGBA_8888, // pixel with 8 bits for red, green, blue, alpha; in 32-bit word\n RGB_888x, // pixel with 8 bits each for red, green, blue; in 32-bit word\n BGRA_8888, // pixel with 8 bits for blue, green, red, alpha; in 32-bit word\n RGBA_1010102, // 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word\n BGRA_1010102, // 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word\n RGB_101010x, // pixel with 10 bits each for red, green, blue; in 32-bit word\n BGR_101010x, // pixel with 10 bits each for blue, green, red; in 32-bit word\n BGR_101010x_XR, // pixel with 10 bits each for blue, green, red; in 32-bit word, extended range\n RGBA_10x6, // pixel with 10 used bits (most significant) followed by 6 unused\n Gray_8, // pixel with grayscale level in 8-bit byte\n RGBA_F16Norm, // pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word\n RGBA_F16, // pixel with half floats for red, green, blue, alpha; in 64-bit word\n RGBA_F32, // pixel using C float for red, green, blue, alpha; in 128-bit word\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
|
1
|
+
{"version":3,"names":["AlphaType","ColorType"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\nimport type { NativeBuffer } from \"../NativeBuffer\";\n\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport enum ColorType {\n Unknown, // uninitialized\n Alpha_8, // pixel with alpha in 8-bit byte\n RGB_565, // pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word\n ARGB_4444, // pixel with 4 bits for alpha, red, green, blue; in 16-bit word\n RGBA_8888, // pixel with 8 bits for red, green, blue, alpha; in 32-bit word\n RGB_888x, // pixel with 8 bits each for red, green, blue; in 32-bit word\n BGRA_8888, // pixel with 8 bits for blue, green, red, alpha; in 32-bit word\n RGBA_1010102, // 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word\n BGRA_1010102, // 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word\n RGB_101010x, // pixel with 10 bits each for red, green, blue; in 32-bit word\n BGR_101010x, // pixel with 10 bits each for blue, green, red; in 32-bit word\n BGR_101010x_XR, // pixel with 10 bits each for blue, green, red; in 32-bit word, extended range\n RGBA_10x6, // pixel with 10 used bits (most significant) followed by 6 unused\n Gray_8, // pixel with grayscale level in 8-bit byte\n RGBA_F16Norm, // pixel with half floats in [0,1] for red, green, blue, alpha; in 64-bit word\n RGBA_F16, // pixel with half floats for red, green, blue, alpha; in 64-bit word\n RGBA_F32, // pixel using C float for red, green, blue, alpha; in 128-bit word\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 * 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":"AAKA,WAAYA,SAAS,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA;AAOrB,WAAYC,SAAS,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA,OAiBT"}
|
@@ -12,7 +12,7 @@ export interface NativeBufferFactory {
|
|
12
12
|
*/
|
13
13
|
MakeFromImage: (image: SkImage) => NativeBuffer;
|
14
14
|
/**
|
15
|
-
* Release a
|
15
|
+
* Release a native buffer that was created with `MakeFromImage`.
|
16
16
|
*/
|
17
|
-
Release: (
|
17
|
+
Release: (nativeBuffer: NativeBuffer) => void;
|
18
18
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isNativeBufferAddr","buffer","BigInt","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport type NativeBuffer<\n T extends bigint | ArrayBuffer | CanvasImageSource | unknown = unknown\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n buffer instanceof VideoFrame ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a native buffer.\n */\n MakeFromImage: (image: SkImage) => NativeBuffer;\n /**\n * Release a
|
1
|
+
{"version":3,"names":["isNativeBufferAddr","buffer","BigInt","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport type NativeBuffer<\n T extends bigint | ArrayBuffer | CanvasImageSource | unknown = unknown\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n buffer instanceof VideoFrame ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a native buffer.\n */\n MakeFromImage: (image: SkImage) => NativeBuffer;\n /**\n * Release a native buffer that was created with `MakeFromImage`.\n */\n Release: (nativeBuffer: NativeBuffer) => void;\n}\n"],"mappings":"AAUA,OAAO,MAAMA,kBAAkB,GAC7BC,MAAoB,IACWA,MAAM,YAAYC,MAAM;AACzD,OAAO,MAAMC,iBAAiB,GAC5BF,MAAoB,IAEpBA,MAAM,YAAYG,gBAAgB,IAClCH,MAAM,YAAYI,iBAAiB,IACnCJ,MAAM,YAAYK,WAAW,IAC7BL,MAAM,YAAYM,eAAe,IACjCN,MAAM,YAAYO,UAAU,IAC5BP,MAAM,YAAYQ,gBAAgB,IAClCR,MAAM,YAAYS,eAAe;AAEnC,OAAO,MAAMC,kBAAkB,GAC7BV,MAAoB,IACWA,MAAM,YAAYW,WAAW"}
|
@@ -4,5 +4,5 @@ import { Host } from "./Host";
|
|
4
4
|
export declare class JsiSkNativeBufferFactory extends Host implements NativeBufferFactory {
|
5
5
|
constructor(CanvasKit: CanvasKit);
|
6
6
|
MakeFromImage(image: SkImage): NativeBuffer;
|
7
|
-
Release(
|
7
|
+
Release(_nativeBuffer: NativeBuffer): void;
|
8
8
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Host","JsiSkNativeBufferFactory","constructor","CanvasKit","MakeFromImage","image","info","getImageInfo","uint8ClampedArray","Uint8ClampedArray","readPixels","imageData","ImageData","width","height","canvas","OffscreenCanvas","ctx","getContext","Error","putImageData","Release","
|
1
|
+
{"version":3,"names":["Host","JsiSkNativeBufferFactory","constructor","CanvasKit","MakeFromImage","image","info","getImageInfo","uint8ClampedArray","Uint8ClampedArray","readPixels","imageData","ImageData","width","height","canvas","OffscreenCanvas","ctx","getContext","Error","putImageData","Release","_nativeBuffer"],"sources":["JsiSkNativeBufferFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport {\n type NativeBuffer,\n type NativeBufferFactory,\n type SkImage,\n} from \"../types\";\n\nimport { Host } from \"./Host\";\n\nexport class JsiSkNativeBufferFactory\n extends Host\n implements NativeBufferFactory\n{\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeFromImage(image: SkImage): NativeBuffer {\n const info = image.getImageInfo();\n const uint8ClampedArray = new Uint8ClampedArray(image.readPixels()!);\n const imageData = new ImageData(uint8ClampedArray, info.width, info.height);\n const canvas = new OffscreenCanvas(info.width, info.height);\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) {\n throw new Error(\"Failed to get 2d context from canvas\");\n }\n ctx.putImageData(imageData, 0, 0);\n return canvas;\n }\n\n Release(_nativeBuffer: NativeBuffer) {\n // it's a noop on Web\n }\n}\n"],"mappings":"AAQA,SAASA,IAAI,QAAQ,QAAQ;AAE7B,OAAO,MAAMC,wBAAwB,SAC3BD,IAAI,CAEd;EACEE,WAAWA,CAACC,SAAoB,EAAE;IAChC,KAAK,CAACA,SAAS,CAAC;EAClB;EAEAC,aAAaA,CAACC,KAAc,EAAgB;IAC1C,MAAMC,IAAI,GAAGD,KAAK,CAACE,YAAY,CAAC,CAAC;IACjC,MAAMC,iBAAiB,GAAG,IAAIC,iBAAiB,CAACJ,KAAK,CAACK,UAAU,CAAC,CAAE,CAAC;IACpE,MAAMC,SAAS,GAAG,IAAIC,SAAS,CAACJ,iBAAiB,EAAEF,IAAI,CAACO,KAAK,EAAEP,IAAI,CAACQ,MAAM,CAAC;IAC3E,MAAMC,MAAM,GAAG,IAAIC,eAAe,CAACV,IAAI,CAACO,KAAK,EAAEP,IAAI,CAACQ,MAAM,CAAC;IAC3D,MAAMG,GAAG,GAAGF,MAAM,CAACG,UAAU,CAAC,IAAI,CAAC;IACnC,IAAI,CAACD,GAAG,EAAE;MACR,MAAM,IAAIE,KAAK,CAAC,sCAAsC,CAAC;IACzD;IACAF,GAAG,CAACG,YAAY,CAACT,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;IACjC,OAAOI,MAAM;EACf;EAEAM,OAAOA,CAACC,aAA2B,EAAE;IACnC;EAAA;AAEJ"}
|
@@ -46,7 +46,7 @@ export interface ImageFactory {
|
|
46
46
|
MakeImageFromEncoded: (encoded: SkData) => SkImage | null;
|
47
47
|
/**
|
48
48
|
* Return an Image backed by a given native buffer.
|
49
|
-
* The
|
49
|
+
* The native buffer must be a valid owning reference.
|
50
50
|
*
|
51
51
|
* For instance, this API is used by
|
52
52
|
* [react-native-vision-camera](https://github.com/mrousavy/react-native-vision-camera)
|
@@ -54,9 +54,9 @@ export interface ImageFactory {
|
|
54
54
|
*
|
55
55
|
* - On Android; This is an `AHardwareBuffer*`
|
56
56
|
* - On iOS, this is a `CVPixelBufferRef`
|
57
|
-
* @param nativeBuffer A strong `uintptr_t` pointer to the native
|
57
|
+
* @param nativeBuffer A strong `uintptr_t` pointer to the native buffer
|
58
58
|
* @throws Throws an error if the Image could not be created, for example when the given
|
59
|
-
*
|
59
|
+
* native buffer is invalid.
|
60
60
|
*/
|
61
61
|
MakeImageFromNativeBuffer: (nativeBuffer: NativeBuffer) => SkImage;
|
62
62
|
/**
|
@@ -12,7 +12,7 @@ export interface NativeBufferFactory {
|
|
12
12
|
*/
|
13
13
|
MakeFromImage: (image: SkImage) => NativeBuffer;
|
14
14
|
/**
|
15
|
-
* Release a
|
15
|
+
* Release a native buffer that was created with `MakeFromImage`.
|
16
16
|
*/
|
17
|
-
Release: (
|
17
|
+
Release: (nativeBuffer: NativeBuffer) => void;
|
18
18
|
}
|
@@ -4,5 +4,5 @@ import { Host } from "./Host";
|
|
4
4
|
export declare class JsiSkNativeBufferFactory extends Host implements NativeBufferFactory {
|
5
5
|
constructor(CanvasKit: CanvasKit);
|
6
6
|
MakeFromImage(image: SkImage): NativeBuffer;
|
7
|
-
Release(
|
7
|
+
Release(_nativeBuffer: NativeBuffer): void;
|
8
8
|
}
|
package/package.json
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
"setup-skia-web": "./scripts/setup-canvaskit.js"
|
8
8
|
},
|
9
9
|
"title": "React Native Skia",
|
10
|
-
"version": "1.2.
|
10
|
+
"version": "1.2.3",
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
12
12
|
"main": "lib/module/index.js",
|
13
13
|
"react-native": "src/index.ts",
|
@@ -54,7 +54,7 @@ export interface ImageFactory {
|
|
54
54
|
|
55
55
|
/**
|
56
56
|
* Return an Image backed by a given native buffer.
|
57
|
-
* The
|
57
|
+
* The native buffer must be a valid owning reference.
|
58
58
|
*
|
59
59
|
* For instance, this API is used by
|
60
60
|
* [react-native-vision-camera](https://github.com/mrousavy/react-native-vision-camera)
|
@@ -62,9 +62,9 @@ export interface ImageFactory {
|
|
62
62
|
*
|
63
63
|
* - On Android; This is an `AHardwareBuffer*`
|
64
64
|
* - On iOS, this is a `CVPixelBufferRef`
|
65
|
-
* @param nativeBuffer A strong `uintptr_t` pointer to the native
|
65
|
+
* @param nativeBuffer A strong `uintptr_t` pointer to the native buffer
|
66
66
|
* @throws Throws an error if the Image could not be created, for example when the given
|
67
|
-
*
|
67
|
+
* native buffer is invalid.
|
68
68
|
*/
|
69
69
|
MakeImageFromNativeBuffer: (nativeBuffer: NativeBuffer) => SkImage;
|
70
70
|
|
@@ -32,7 +32,7 @@ export interface NativeBufferFactory {
|
|
32
32
|
*/
|
33
33
|
MakeFromImage: (image: SkImage) => NativeBuffer;
|
34
34
|
/**
|
35
|
-
* Release a
|
35
|
+
* Release a native buffer that was created with `MakeFromImage`.
|
36
36
|
*/
|
37
|
-
Release: (
|
37
|
+
Release: (nativeBuffer: NativeBuffer) => void;
|
38
38
|
}
|