@shopify/react-native-skia 0.1.220 → 0.1.222
Sign up to get free protection for your applications and to get access to all the features.
- package/android/cpp/rnskia-android/RNSkAndroidView.h +3 -0
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +1 -0
- package/android/cpp/rnskia-android/SkiaOpenGLHelper.h +0 -1
- package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.h +46 -6
- package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +3 -3
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +8 -14
- package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +93 -105
- package/cpp/api/JsiSkCanvas.h +38 -1
- package/cpp/api/JsiSkImage.h +66 -1
- package/cpp/api/JsiSkImageInfo.h +19 -0
- package/cpp/utils/RNSkLog.h +3 -3
- package/cpp/utils/RNSkTypedArray.h +41 -0
- package/lib/commonjs/skia/types/Canvas.d.ts +9 -1
- package/lib/commonjs/skia/types/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Image/Image.d.ts +13 -0
- package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +14 -11
- package/lib/commonjs/skia/types/Image/ImageFactory.js +14 -11
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/Host.d.ts +2 -1
- package/lib/commonjs/skia/web/Host.js +10 -1
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +2 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +11 -0
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js +1 -3
- package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.d.ts +3 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +22 -0
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js +0 -4
- package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
- package/lib/module/skia/types/Canvas.d.ts +9 -1
- package/lib/module/skia/types/Canvas.js.map +1 -1
- package/lib/module/skia/types/Image/Image.d.ts +13 -0
- package/lib/module/skia/types/Image/Image.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +14 -11
- package/lib/module/skia/types/Image/ImageFactory.js +14 -11
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/web/Host.d.ts +2 -1
- package/lib/module/skia/web/Host.js +6 -0
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.d.ts +2 -1
- package/lib/module/skia/web/JsiSkCanvas.js +12 -1
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkFontMgrFactory.js +1 -3
- package/lib/module/skia/web/JsiSkFontMgrFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.d.ts +3 -1
- package/lib/module/skia/web/JsiSkImage.js +25 -1
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkTypefaceFontProvider.d.ts +2 -2
- package/lib/module/skia/web/JsiSkTypefaceFontProvider.js +0 -4
- package/lib/module/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
- package/lib/typescript/src/skia/types/Canvas.d.ts +9 -1
- package/lib/typescript/src/skia/types/Image/Image.d.ts +13 -0
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +14 -11
- package/lib/typescript/src/skia/web/Host.d.ts +2 -1
- package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +2 -1
- package/lib/typescript/src/skia/web/JsiSkImage.d.ts +3 -1
- package/lib/typescript/src/skia/web/JsiSkTypefaceFontProvider.d.ts +2 -2
- package/package.json +2 -2
- package/src/skia/types/Canvas.ts +14 -1
- package/src/skia/types/Image/Image.ts +20 -0
- package/src/skia/types/Image/ImageFactory.ts +30 -25
- package/src/skia/web/Host.ts +3 -1
- package/src/skia/web/JsiSkCanvas.ts +13 -1
- package/src/skia/web/JsiSkFontMgrFactory.ts +0 -2
- package/src/skia/web/JsiSkImage.ts +36 -3
- package/src/skia/web/JsiSkTypefaceFontProvider.ts +0 -4
package/cpp/utils/RNSkLog.h
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
#include <jsi/jsi.h>
|
8
8
|
#include <string>
|
9
9
|
|
10
|
-
#
|
10
|
+
#if defined(ANDROID) || defined(__ANDROID__)
|
11
11
|
#include <android/log.h>
|
12
12
|
#endif
|
13
13
|
|
@@ -26,7 +26,7 @@ public:
|
|
26
26
|
* @param message Message to be written out
|
27
27
|
*/
|
28
28
|
static void logToConsole(std::string message) {
|
29
|
-
#
|
29
|
+
#if defined(ANDROID) || defined(__ANDROID__)
|
30
30
|
__android_log_write(ANDROID_LOG_INFO, "RNSkia", message.c_str());
|
31
31
|
#endif
|
32
32
|
|
@@ -46,7 +46,7 @@ public:
|
|
46
46
|
|
47
47
|
static char buffer[512];
|
48
48
|
vsnprintf(buffer, sizeof(buffer), fmt, args);
|
49
|
-
#
|
49
|
+
#if defined(ANDROID) || defined(__ANDROID__)
|
50
50
|
__android_log_write(ANDROID_LOG_INFO, "RNSkia", buffer);
|
51
51
|
#endif
|
52
52
|
#ifdef TARGET_OS_IPHONE
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "SkImage.h"
|
4
|
+
#include <jsi/jsi.h>
|
5
|
+
|
6
|
+
namespace RNSkia {
|
7
|
+
|
8
|
+
namespace jsi = facebook::jsi;
|
9
|
+
|
10
|
+
class RNSkTypedArray {
|
11
|
+
public:
|
12
|
+
static jsi::Value getTypedArray(jsi::Runtime &runtime,
|
13
|
+
const jsi::Value &value, SkImageInfo &info) {
|
14
|
+
auto reqSize = info.computeMinByteSize();
|
15
|
+
if (reqSize > 0) {
|
16
|
+
if (value.isObject()) {
|
17
|
+
auto typedArray = value.asObject(runtime);
|
18
|
+
auto size = static_cast<size_t>(
|
19
|
+
typedArray.getProperty(runtime, "byteLength").asNumber());
|
20
|
+
if (size >= reqSize) {
|
21
|
+
return typedArray;
|
22
|
+
}
|
23
|
+
} else {
|
24
|
+
if (info.colorType() == kRGBA_F32_SkColorType) {
|
25
|
+
auto arrayCtor =
|
26
|
+
runtime.global().getPropertyAsFunction(runtime, "Float32Array");
|
27
|
+
return arrayCtor.callAsConstructor(runtime,
|
28
|
+
static_cast<double>(reqSize / 4));
|
29
|
+
} else {
|
30
|
+
auto arrayCtor =
|
31
|
+
runtime.global().getPropertyAsFunction(runtime, "Uint8Array");
|
32
|
+
return arrayCtor.callAsConstructor(runtime,
|
33
|
+
static_cast<double>(reqSize));
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
return jsi::Value::null();
|
38
|
+
}
|
39
|
+
};
|
40
|
+
|
41
|
+
} // namespace RNSkia
|
@@ -2,7 +2,7 @@ import type { SkPaint } from "./Paint";
|
|
2
2
|
import type { SkRect } from "./Rect";
|
3
3
|
import type { SkFont } from "./Font";
|
4
4
|
import type { SkPath } from "./Path";
|
5
|
-
import type { SkImage, MipmapMode, FilterMode } from "./Image";
|
5
|
+
import type { SkImage, MipmapMode, FilterMode, ImageInfo } from "./Image";
|
6
6
|
import type { SkSVG } from "./SVG";
|
7
7
|
import type { SkColor } from "./Color";
|
8
8
|
import type { SkRRect } from "./RRect";
|
@@ -378,4 +378,12 @@ export interface SkCanvas {
|
|
378
378
|
* @param skp
|
379
379
|
*/
|
380
380
|
drawPicture(skp: SkPicture): void;
|
381
|
+
/** Read Image pixels
|
382
|
+
*
|
383
|
+
* @param srcX - x-axis upper left corner of the rectangle to read from
|
384
|
+
* @param srcY - y-axis upper left corner of the rectangle to read from
|
385
|
+
* @param imageInfo - describes the pixel format and dimensions of the data to read into
|
386
|
+
* @return Float32Array or Uint8Array with data or null if the read failed.
|
387
|
+
*/
|
388
|
+
readPixels(srcX: number, srcY: number, imageInfo: ImageInfo): Float32Array | Uint8Array | null;
|
381
389
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ClipOp","SaveLayerFlag"],"sources":["Canvas.ts"],"sourcesContent":["import type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkFont } from \"./Font\";\nimport type { SkPath } from \"./Path\";\nimport type { SkImage, MipmapMode, FilterMode } from \"./Image\";\nimport type { SkSVG } from \"./SVG\";\nimport type { SkColor } from \"./Color\";\nimport type { SkRRect } from \"./RRect\";\nimport type { BlendMode } from \"./Paint/BlendMode\";\nimport type { SkPoint, PointMode } from \"./Point\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { SkImageFilter } from \"./ImageFilter\";\nimport type { SkVertices } from \"./Vertices\";\nimport type { SkTextBlob } from \"./TextBlob\";\nimport type { SkPicture } from \"./Picture\";\n\nexport enum ClipOp {\n Difference,\n Intersect,\n}\n\nexport enum SaveLayerFlag {\n SaveLayerInitWithPrevious = 1 << 2,\n SaveLayerF16ColorType = 1 << 4,\n}\n\nexport interface SkCanvas {\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix, and optionally-provided paint.\n * @param img\n * @param left\n * @param top\n * @param paint\n */\n drawImage: (image: SkImage, x: number, y: number, paint?: SkPaint) => void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * @param img\n * @param src\n * @param dest\n * @param paint\n * @param fastSample - if false, will filter strictly within src.\n */\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param left\n * @param top\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the provided sampling options if necessary.\n * @param img\n * @param left\n * @param top\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the provided image stretched proportionally to fit into dst rectangle.\n * The center rectangle divides the image into nine sections: four sides, four corners, and\n * the center.\n * @param img\n * @param center\n * @param dest\n * @param filter - what technique to use when sampling the image\n * @param paint\n */\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param src\n * @param dest\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the provided sampling options if necessary.\n * @param img\n * @param src\n * @param dest\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /** Fills clip with SkPaint paint. SkPaint components, SkShader,\n SkColorFilter, SkImageFilter, and SkBlendMode affect drawing;\n SkMaskFilter and SkPathEffect in paint are ignored.\n\n @param paint graphics state used to fill SkCanvas\n\n example: https://fiddle.skia.org/c/@Canvas_drawPaint\n */\n drawPaint: (paint: SkPaint) => void;\n\n /** Draws line segment from (x0, y0) to (x1, y1) using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint stroke width describes the line thickness;\n SkPaint::Cap draws the end rounded or square;\n SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.\n\n @param x0 start of line segment on x-axis\n @param y0 start of line segment on y-axis\n @param x1 end of line segment on x-axis\n @param y1 end of line segment on y-axis\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawLine\n */\n drawLine: (\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n paint: SkPaint\n ) => void;\n /** Draws SkRect rect using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint::Style determines if rectangle is stroked or filled;\n if stroked, SkPaint stroke width describes the line thickness, and\n SkPaint::Join draws the corners rounded or square.\n\n @param rect rectangle to draw\n @param paint stroke or fill, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawRect\n */\n drawRect: (rect: SkRect, paint: SkPaint) => void;\n\n /**\n * Draws a circle at (cx, cy) with the given radius.\n * @param cx\n * @param cy\n * @param radius\n * @param paint\n */\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint): void;\n\n /**\n * Draws the given vertices (a triangle mesh) using the current clip, current matrix, and the\n * provided paint.\n * If paint contains an Shader and vertices does not contain texCoords, the shader\n * is mapped using the vertices' positions.\n * If vertices colors are defined in vertices, and Paint paint contains Shader,\n * BlendMode mode combines vertices colors with Shader.\n * @param verts\n * @param mode\n * @param paint\n */\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint): void;\n\n /**\n * Draws a cubic patch defined by 12 control points [top, right, bottom, left] with optional\n * colors and shader-coordinates [4] specifed for each corner [top-left, top-right, bottom-right, bottom-left]\n * @param cubics 12 points : 4 connected cubics specifying the boundary of the patch\n * @param colors optional colors interpolated across the patch\n * @param texs optional shader coordinates interpolated across the patch\n * @param mode Specifies how shader and colors blend (if both are specified)\n * @param paint\n */\n drawPatch(\n cubics: readonly SkPoint[],\n colors?: readonly SkColor[] | null,\n texs?: readonly SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ): void;\n\n /**\n * Restores state to a previous stack value.\n * @param saveCount\n */\n restoreToCount(saveCount: number): void;\n\n /**\n * Draws the given points using the current clip, current matrix, and the provided paint.\n *\n * See Canvas.h for more on the mode and its interaction with paint.\n * @param mode\n * @param points\n * @param paint\n */\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint): void;\n\n /** Draws arc using clip, SkMatrix, and SkPaint paint.\n\n Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus\n sweepAngle. startAngle and sweepAngle are in degrees.\n\n startAngle of zero places start point at the right middle edge of oval.\n A positive sweepAngle places arc end point clockwise from start point;\n a negative sweepAngle places arc end point counterclockwise from start point.\n sweepAngle may exceed 360 degrees, a full circle.\n If useCenter is true, draw a wedge that includes lines from oval\n center to arc end points. If useCenter is false, draw arc between end points.\n\n If SkRect oval is empty or sweepAngle is zero, nothing is drawn.\n\n @param oval SkRect bounds of oval containing arc to draw\n @param startAngle angle in degrees where arc begins\n @param sweepAngle sweep angle in degrees; positive is clockwise\n @param useCenter if true, include the center of the oval\n @param paint SkPaint stroke or fill, blend, color, and so on, used to draw\n */\n drawArc: (\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) => void;\n\n /**\n * Draws the given rectangle with rounded corners using the current clip, current matrix,\n * and the provided paint.\n * @param rrect\n * @param paint\n */\n drawRRect(rrect: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws RRect outer and inner using clip, Matrix, and Paint paint.\n * outer must contain inner or the drawing is undefined.\n * @param outer\n * @param inner\n * @param paint\n */\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws an oval bounded by the given rectangle using the current clip, current matrix,\n * and the provided paint.\n * @param oval\n * @param paint\n */\n drawOval(oval: SkRect, paint: SkPaint): void;\n\n /** Draws SkPath path using clip, SkMatrix, and SkPaint paint.\n SkPath contains an array of path contour, each of which may be open or closed.\n\n In paint: SkPaint::Style determines if SkRRect is stroked or filled:\n if filled, SkPath::FillType determines whether path contour describes inside or\n outside of fill; if stroked, SkPaint stroke width describes the line thickness,\n SkPaint::Cap describes line ends, and SkPaint::Join describes how\n corners are drawn.\n\n @param path SkPath to draw\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawPath\n */\n drawPath: (path: SkPath, paint: SkPaint) => void;\n\n /**\n * Draw the given text at the location (x, y) using the provided paint and font. The text will\n * be drawn as is; no shaping, left-to-right, etc.\n * @param str\n * @param x\n * @param y\n * @param paint\n * @param font\n */\n drawText(\n str: string,\n x: number,\n y: number,\n paint: SkPaint,\n font: SkFont\n ): void;\n\n /**\n * Draws the given TextBlob at (x, y) using the current clip, current matrix, and the\n * provided paint. Reminder that the fonts used to draw TextBlob are part of the blob.\n * @param blob\n * @param x\n * @param y\n * @param paint\n */\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;\n\n /**\n * Draws a run of glyphs, at corresponding positions, in a given font.\n * @param glyphs the array of glyph IDs (Uint16TypedArray)\n * @param positions the array of x,y floats to position each glyph\n * @param x x-coordinate of the origin of the entire run\n * @param y y-coordinate of the origin of the entire run\n * @param font the font that contains the glyphs\n * @param paint\n */\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ): void;\n\n /**\n * Renders the SVG Dom object to the canvas. If width/height are omitted,\n * the SVG will be rendered to fit the canvas.\n */\n drawSvg: (svgDom: SkSVG, width?: number, height?: number) => void;\n /** Saves SkMatrix and clip.\n Calling restore() discards changes to SkMatrix and clip,\n restoring the SkMatrix and clip to their state when save() was called.\n\n SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(),\n and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().\n\n Saved SkCanvas state is put on a stack; multiple calls to save() should be balance\n by an equal number of calls to restore().\n\n Call restoreToCount() with result to restore this and subsequent saves.\n\n @return depth of saved stack\n\n example: https://fiddle.skia.org/c/@Canvas_save\n */\n save: () => number;\n\n /**\n * Saves Matrix and clip, and allocates a SkBitmap for subsequent drawing.\n * Calling restore() discards changes to Matrix and clip, and draws the SkBitmap.\n * It returns the height of the stack.\n * See Canvas.h for more.\n * @param paint\n * @param bounds\n * @param backdrop\n * @param flags\n */\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ): number;\n\n /** Removes changes to SkMatrix and clip since SkCanvas state was\n last saved. The state is removed from the stack.\n\n Does nothing if the stack is empty.\n\n example: https://fiddle.skia.org/c/@AutoCanvasRestore_restore\n\n example: https://fiddle.skia.org/c/@Canvas_restore\n */\n restore: () => void;\n\n /**\n * Rotates the current matrix by the number of degrees.\n * @param rot - angle of rotation in degrees.\n * @param rx\n * @param ry\n */\n rotate(rotationInDegrees: number, rx: number, ry: number): void;\n\n /**\n * Scales the current matrix by sx on the x-axis and sy on the y-axis.\n * @param sx\n * @param sy\n */\n scale(sx: number, sy: number): void;\n\n /**\n * Skews Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx\n * skews the drawing right as y-axis values increase; a positive value of sy skews\n * the drawing down as x-axis values increase.\n * @param sx\n * @param sy\n */\n skew(sx: number, sy: number): void;\n\n /**\n * Translates Matrix by dx along the x-axis and dy along the y-axis.\n * @param dx\n * @param dy\n */\n translate(dx: number, dy: number): void;\n\n /**\n * Fills clip with the given color.\n * @param color\n * @param blendMode - defaults to SrcOver.\n */\n drawColor(color: SkColor, blendMode?: BlendMode): void;\n\n /**\n * Fills the current clip with the given color using Src BlendMode.\n * This has the effect of replacing all pixels contained by clip with color.\n * @param color\n */\n clear(color: SkColor): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and path,\n * with an aliased or anti-aliased clip edge.\n * @param path\n * @param op\n * @param doAntiAlias\n */\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rect,\n * with an aliased or anti-aliased clip edge.\n * @param rect\n * @param op\n * @param doAntiAlias\n */\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rrect,\n * with an aliased or anti-aliased clip edge.\n * @param rrect\n * @param op\n * @param doAntiAlias\n */\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces current matrix with m premultiplied with the existing matrix.\n * @param m\n */\n concat(m: SkMatrix): void;\n\n /**\n * Draws the given picture using the current clip, current matrix, and the provided paint.\n * @param skp\n */\n drawPicture(skp: SkPicture): void;\n}\n"],"mappings":";;;;;;IAgBYA,M;;;WAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;GAAAA,M,sBAAAA,M;;IAKAC,a;;;WAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;GAAAA,a,6BAAAA,a"}
|
1
|
+
{"version":3,"names":["ClipOp","SaveLayerFlag"],"sources":["Canvas.ts"],"sourcesContent":["import type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkFont } from \"./Font\";\nimport type { SkPath } from \"./Path\";\nimport type { SkImage, MipmapMode, FilterMode, ImageInfo } from \"./Image\";\nimport type { SkSVG } from \"./SVG\";\nimport type { SkColor } from \"./Color\";\nimport type { SkRRect } from \"./RRect\";\nimport type { BlendMode } from \"./Paint/BlendMode\";\nimport type { SkPoint, PointMode } from \"./Point\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { SkImageFilter } from \"./ImageFilter\";\nimport type { SkVertices } from \"./Vertices\";\nimport type { SkTextBlob } from \"./TextBlob\";\nimport type { SkPicture } from \"./Picture\";\n\nexport enum ClipOp {\n Difference,\n Intersect,\n}\n\nexport enum SaveLayerFlag {\n SaveLayerInitWithPrevious = 1 << 2,\n SaveLayerF16ColorType = 1 << 4,\n}\n\nexport interface SkCanvas {\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix, and optionally-provided paint.\n * @param img\n * @param left\n * @param top\n * @param paint\n */\n drawImage: (image: SkImage, x: number, y: number, paint?: SkPaint) => void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * @param img\n * @param src\n * @param dest\n * @param paint\n * @param fastSample - if false, will filter strictly within src.\n */\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param left\n * @param top\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the provided sampling options if necessary.\n * @param img\n * @param left\n * @param top\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the provided image stretched proportionally to fit into dst rectangle.\n * The center rectangle divides the image into nine sections: four sides, four corners, and\n * the center.\n * @param img\n * @param center\n * @param dest\n * @param filter - what technique to use when sampling the image\n * @param paint\n */\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param src\n * @param dest\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the provided sampling options if necessary.\n * @param img\n * @param src\n * @param dest\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /** Fills clip with SkPaint paint. SkPaint components, SkShader,\n SkColorFilter, SkImageFilter, and SkBlendMode affect drawing;\n SkMaskFilter and SkPathEffect in paint are ignored.\n\n @param paint graphics state used to fill SkCanvas\n\n example: https://fiddle.skia.org/c/@Canvas_drawPaint\n */\n drawPaint: (paint: SkPaint) => void;\n\n /** Draws line segment from (x0, y0) to (x1, y1) using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint stroke width describes the line thickness;\n SkPaint::Cap draws the end rounded or square;\n SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.\n\n @param x0 start of line segment on x-axis\n @param y0 start of line segment on y-axis\n @param x1 end of line segment on x-axis\n @param y1 end of line segment on y-axis\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawLine\n */\n drawLine: (\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n paint: SkPaint\n ) => void;\n /** Draws SkRect rect using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint::Style determines if rectangle is stroked or filled;\n if stroked, SkPaint stroke width describes the line thickness, and\n SkPaint::Join draws the corners rounded or square.\n\n @param rect rectangle to draw\n @param paint stroke or fill, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawRect\n */\n drawRect: (rect: SkRect, paint: SkPaint) => void;\n\n /**\n * Draws a circle at (cx, cy) with the given radius.\n * @param cx\n * @param cy\n * @param radius\n * @param paint\n */\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint): void;\n\n /**\n * Draws the given vertices (a triangle mesh) using the current clip, current matrix, and the\n * provided paint.\n * If paint contains an Shader and vertices does not contain texCoords, the shader\n * is mapped using the vertices' positions.\n * If vertices colors are defined in vertices, and Paint paint contains Shader,\n * BlendMode mode combines vertices colors with Shader.\n * @param verts\n * @param mode\n * @param paint\n */\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint): void;\n\n /**\n * Draws a cubic patch defined by 12 control points [top, right, bottom, left] with optional\n * colors and shader-coordinates [4] specifed for each corner [top-left, top-right, bottom-right, bottom-left]\n * @param cubics 12 points : 4 connected cubics specifying the boundary of the patch\n * @param colors optional colors interpolated across the patch\n * @param texs optional shader coordinates interpolated across the patch\n * @param mode Specifies how shader and colors blend (if both are specified)\n * @param paint\n */\n drawPatch(\n cubics: readonly SkPoint[],\n colors?: readonly SkColor[] | null,\n texs?: readonly SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ): void;\n\n /**\n * Restores state to a previous stack value.\n * @param saveCount\n */\n restoreToCount(saveCount: number): void;\n\n /**\n * Draws the given points using the current clip, current matrix, and the provided paint.\n *\n * See Canvas.h for more on the mode and its interaction with paint.\n * @param mode\n * @param points\n * @param paint\n */\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint): void;\n\n /** Draws arc using clip, SkMatrix, and SkPaint paint.\n\n Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus\n sweepAngle. startAngle and sweepAngle are in degrees.\n\n startAngle of zero places start point at the right middle edge of oval.\n A positive sweepAngle places arc end point clockwise from start point;\n a negative sweepAngle places arc end point counterclockwise from start point.\n sweepAngle may exceed 360 degrees, a full circle.\n If useCenter is true, draw a wedge that includes lines from oval\n center to arc end points. If useCenter is false, draw arc between end points.\n\n If SkRect oval is empty or sweepAngle is zero, nothing is drawn.\n\n @param oval SkRect bounds of oval containing arc to draw\n @param startAngle angle in degrees where arc begins\n @param sweepAngle sweep angle in degrees; positive is clockwise\n @param useCenter if true, include the center of the oval\n @param paint SkPaint stroke or fill, blend, color, and so on, used to draw\n */\n drawArc: (\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) => void;\n\n /**\n * Draws the given rectangle with rounded corners using the current clip, current matrix,\n * and the provided paint.\n * @param rrect\n * @param paint\n */\n drawRRect(rrect: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws RRect outer and inner using clip, Matrix, and Paint paint.\n * outer must contain inner or the drawing is undefined.\n * @param outer\n * @param inner\n * @param paint\n */\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws an oval bounded by the given rectangle using the current clip, current matrix,\n * and the provided paint.\n * @param oval\n * @param paint\n */\n drawOval(oval: SkRect, paint: SkPaint): void;\n\n /** Draws SkPath path using clip, SkMatrix, and SkPaint paint.\n SkPath contains an array of path contour, each of which may be open or closed.\n\n In paint: SkPaint::Style determines if SkRRect is stroked or filled:\n if filled, SkPath::FillType determines whether path contour describes inside or\n outside of fill; if stroked, SkPaint stroke width describes the line thickness,\n SkPaint::Cap describes line ends, and SkPaint::Join describes how\n corners are drawn.\n\n @param path SkPath to draw\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawPath\n */\n drawPath: (path: SkPath, paint: SkPaint) => void;\n\n /**\n * Draw the given text at the location (x, y) using the provided paint and font. The text will\n * be drawn as is; no shaping, left-to-right, etc.\n * @param str\n * @param x\n * @param y\n * @param paint\n * @param font\n */\n drawText(\n str: string,\n x: number,\n y: number,\n paint: SkPaint,\n font: SkFont\n ): void;\n\n /**\n * Draws the given TextBlob at (x, y) using the current clip, current matrix, and the\n * provided paint. Reminder that the fonts used to draw TextBlob are part of the blob.\n * @param blob\n * @param x\n * @param y\n * @param paint\n */\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;\n\n /**\n * Draws a run of glyphs, at corresponding positions, in a given font.\n * @param glyphs the array of glyph IDs (Uint16TypedArray)\n * @param positions the array of x,y floats to position each glyph\n * @param x x-coordinate of the origin of the entire run\n * @param y y-coordinate of the origin of the entire run\n * @param font the font that contains the glyphs\n * @param paint\n */\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ): void;\n\n /**\n * Renders the SVG Dom object to the canvas. If width/height are omitted,\n * the SVG will be rendered to fit the canvas.\n */\n drawSvg: (svgDom: SkSVG, width?: number, height?: number) => void;\n /** Saves SkMatrix and clip.\n Calling restore() discards changes to SkMatrix and clip,\n restoring the SkMatrix and clip to their state when save() was called.\n\n SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(),\n and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().\n\n Saved SkCanvas state is put on a stack; multiple calls to save() should be balance\n by an equal number of calls to restore().\n\n Call restoreToCount() with result to restore this and subsequent saves.\n\n @return depth of saved stack\n\n example: https://fiddle.skia.org/c/@Canvas_save\n */\n save: () => number;\n\n /**\n * Saves Matrix and clip, and allocates a SkBitmap for subsequent drawing.\n * Calling restore() discards changes to Matrix and clip, and draws the SkBitmap.\n * It returns the height of the stack.\n * See Canvas.h for more.\n * @param paint\n * @param bounds\n * @param backdrop\n * @param flags\n */\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ): number;\n\n /** Removes changes to SkMatrix and clip since SkCanvas state was\n last saved. The state is removed from the stack.\n\n Does nothing if the stack is empty.\n\n example: https://fiddle.skia.org/c/@AutoCanvasRestore_restore\n\n example: https://fiddle.skia.org/c/@Canvas_restore\n */\n restore: () => void;\n\n /**\n * Rotates the current matrix by the number of degrees.\n * @param rot - angle of rotation in degrees.\n * @param rx\n * @param ry\n */\n rotate(rotationInDegrees: number, rx: number, ry: number): void;\n\n /**\n * Scales the current matrix by sx on the x-axis and sy on the y-axis.\n * @param sx\n * @param sy\n */\n scale(sx: number, sy: number): void;\n\n /**\n * Skews Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx\n * skews the drawing right as y-axis values increase; a positive value of sy skews\n * the drawing down as x-axis values increase.\n * @param sx\n * @param sy\n */\n skew(sx: number, sy: number): void;\n\n /**\n * Translates Matrix by dx along the x-axis and dy along the y-axis.\n * @param dx\n * @param dy\n */\n translate(dx: number, dy: number): void;\n\n /**\n * Fills clip with the given color.\n * @param color\n * @param blendMode - defaults to SrcOver.\n */\n drawColor(color: SkColor, blendMode?: BlendMode): void;\n\n /**\n * Fills the current clip with the given color using Src BlendMode.\n * This has the effect of replacing all pixels contained by clip with color.\n * @param color\n */\n clear(color: SkColor): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and path,\n * with an aliased or anti-aliased clip edge.\n * @param path\n * @param op\n * @param doAntiAlias\n */\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rect,\n * with an aliased or anti-aliased clip edge.\n * @param rect\n * @param op\n * @param doAntiAlias\n */\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rrect,\n * with an aliased or anti-aliased clip edge.\n * @param rrect\n * @param op\n * @param doAntiAlias\n */\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces current matrix with m premultiplied with the existing matrix.\n * @param m\n */\n concat(m: SkMatrix): void;\n\n /**\n * Draws the given picture using the current clip, current matrix, and the provided paint.\n * @param skp\n */\n drawPicture(skp: SkPicture): void;\n\n /** Read Image pixels\n *\n * @param srcX - x-axis upper left corner of the rectangle to read from\n * @param srcY - y-axis upper left corner of the rectangle to read from\n * @param imageInfo - describes the pixel format and dimensions of the data to read into\n * @return Float32Array or Uint8Array with data or null if the read failed.\n */\n readPixels(\n srcX: number,\n srcY: number,\n imageInfo: ImageInfo\n ): Float32Array | Uint8Array | null;\n}\n"],"mappings":";;;;;;IAgBYA,M;;;WAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;GAAAA,M,sBAAAA,M;;IAKAC,a;;;WAAAA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;GAAAA,a,6BAAAA,a"}
|
@@ -2,6 +2,7 @@ import type { SkMatrix } from "../Matrix";
|
|
2
2
|
import type { SkJSIInstance } from "../JsiInstance";
|
3
3
|
import type { TileMode } from "../ImageFilter";
|
4
4
|
import type { SkShader } from "../Shader";
|
5
|
+
import type { ImageInfo } from "./ImageFactory";
|
5
6
|
export declare enum FilterMode {
|
6
7
|
Nearest = 0,
|
7
8
|
Linear = 1
|
@@ -25,6 +26,10 @@ export interface SkImage extends SkJSIInstance<"Image"> {
|
|
25
26
|
* Returns the possibly scaled width of the image.
|
26
27
|
*/
|
27
28
|
width(): number;
|
29
|
+
/**
|
30
|
+
* Returns the ImageInfo describing the image.
|
31
|
+
*/
|
32
|
+
getImageInfo(): ImageInfo;
|
28
33
|
/**
|
29
34
|
* Returns this image as a shader with the specified tiling. It will use cubic sampling.
|
30
35
|
* @param tx - tile mode in the x direction.
|
@@ -72,6 +77,14 @@ export interface SkImage extends SkJSIInstance<"Image"> {
|
|
72
77
|
@return base64 encoded string of data
|
73
78
|
*/
|
74
79
|
encodeToBase64(fmt?: ImageFormat, quality?: number): string;
|
80
|
+
/** Read Image pixels
|
81
|
+
*
|
82
|
+
* @param srcX - optional x-axis upper left corner of the rectangle to read from
|
83
|
+
* @param srcY - optional y-axis upper left corner of the rectangle to read from
|
84
|
+
* @param imageInfo - optional describes the pixel format and dimensions of the data to read into
|
85
|
+
* @return Float32Array or Uint8Array with data or null if the read failed.
|
86
|
+
*/
|
87
|
+
readPixels(srcX?: number, srcY?: number, imageInfo?: ImageInfo): Float32Array | Uint8Array | null;
|
75
88
|
/**
|
76
89
|
* Returns raster image or lazy image. Copies SkImage backed by GPU texture
|
77
90
|
* into CPU memory if needed. Returns original SkImage if decoded in raster
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["FilterMode","MipmapMode","ImageFormat"],"sources":["Image.ts"],"sourcesContent":["import type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { TileMode } from \"../ImageFilter\";\nimport type { SkShader } from \"../Shader\";\n\nexport enum FilterMode {\n Nearest,\n Linear,\n}\n\nexport enum MipmapMode {\n None,\n Nearest,\n Linear,\n}\n\nexport enum ImageFormat {\n JPEG = 3,\n PNG = 4,\n WEBP = 6,\n}\n\nexport interface SkImage extends SkJSIInstance<\"Image\"> {\n /**\n * Returns the possibly scaled height of the image.\n */\n height(): number;\n\n /**\n * Returns the possibly scaled width of the image.\n */\n width(): number;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param fm - The filter mode. (default nearest)\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps (default none)\n * calculated with makeCopyWithDefaultMipmaps;\n * @param localMatrix\n */\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param localMatrix\n */\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /** Encodes Image pixels, returning result as UInt8Array. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return Uint8Array with data\n */\n encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;\n\n /** Encodes Image pixels, returning result as a base64 encoded string. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return base64 encoded string of data\n */\n encodeToBase64(fmt?: ImageFormat, quality?: number): string;\n\n /**\n * Returns raster image or lazy image. Copies SkImage backed by GPU texture\n * into CPU memory if needed. Returns original SkImage if decoded in raster\n * bitmap, or if encoded in a stream.\n */\n makeNonTextureImage(): SkImage;\n}\n"],"mappings":";;;;;;
|
1
|
+
{"version":3,"names":["FilterMode","MipmapMode","ImageFormat"],"sources":["Image.ts"],"sourcesContent":["import type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { TileMode } from \"../ImageFilter\";\nimport type { SkShader } from \"../Shader\";\n\nimport type { ImageInfo } from \"./ImageFactory\";\n\nexport enum FilterMode {\n Nearest,\n Linear,\n}\n\nexport enum MipmapMode {\n None,\n Nearest,\n Linear,\n}\n\nexport enum ImageFormat {\n JPEG = 3,\n PNG = 4,\n WEBP = 6,\n}\n\nexport interface SkImage extends SkJSIInstance<\"Image\"> {\n /**\n * Returns the possibly scaled height of the image.\n */\n height(): number;\n\n /**\n * Returns the possibly scaled width of the image.\n */\n width(): number;\n\n /**\n * Returns the ImageInfo describing the image.\n */\n getImageInfo(): ImageInfo;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param fm - The filter mode. (default nearest)\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps (default none)\n * calculated with makeCopyWithDefaultMipmaps;\n * @param localMatrix\n */\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param localMatrix\n */\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /** Encodes Image pixels, returning result as UInt8Array. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return Uint8Array with data\n */\n encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;\n\n /** Encodes Image pixels, returning result as a base64 encoded string. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return base64 encoded string of data\n */\n encodeToBase64(fmt?: ImageFormat, quality?: number): string;\n\n /** Read Image pixels\n *\n * @param srcX - optional x-axis upper left corner of the rectangle to read from\n * @param srcY - optional y-axis upper left corner of the rectangle to read from\n * @param imageInfo - optional describes the pixel format and dimensions of the data to read into\n * @return Float32Array or Uint8Array with data or null if the read failed.\n */\n readPixels(\n srcX?: number,\n srcY?: number,\n imageInfo?: ImageInfo\n ): Float32Array | Uint8Array | null;\n\n /**\n * Returns raster image or lazy image. Copies SkImage backed by GPU texture\n * into CPU memory if needed. Returns original SkImage if decoded in raster\n * bitmap, or if encoded in a stream.\n */\n makeNonTextureImage(): SkImage;\n}\n"],"mappings":";;;;;;IAOYA,U;;;WAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAKAC,U;;;WAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAMAC,W;;;WAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W"}
|
@@ -19,17 +19,20 @@ export declare enum ColorType {
|
|
19
19
|
RGB_101010x = 9,
|
20
20
|
BGR_101010x = 10,
|
21
21
|
BGR_101010x_XR = 11,
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
RGBA_10x6 = 12,
|
23
|
+
Gray_8 = 13,
|
24
|
+
RGBA_F16Norm = 14,
|
25
|
+
RGBA_F16 = 15,
|
26
|
+
RGBA_F32 = 16,
|
27
|
+
R8G8_unorm = 17,
|
28
|
+
A16_float = 18,
|
29
|
+
R16G16_float = 19,
|
30
|
+
A16_unorm = 20,
|
31
|
+
R16G16_unorm = 21,
|
32
|
+
R16G16B16A16_unorm = 22,
|
33
|
+
SRGBA_8888 = 23,
|
34
|
+
R8_unorm = 24,
|
35
|
+
N32_SkColorType = 25
|
33
36
|
}
|
34
37
|
export interface ImageInfo {
|
35
38
|
alphaType: AlphaType;
|
@@ -30,16 +30,19 @@ exports.ColorType = ColorType;
|
|
30
30
|
ColorType[ColorType["RGB_101010x"] = 9] = "RGB_101010x";
|
31
31
|
ColorType[ColorType["BGR_101010x"] = 10] = "BGR_101010x";
|
32
32
|
ColorType[ColorType["BGR_101010x_XR"] = 11] = "BGR_101010x_XR";
|
33
|
-
ColorType[ColorType["
|
34
|
-
ColorType[ColorType["
|
35
|
-
ColorType[ColorType["
|
36
|
-
ColorType[ColorType["
|
37
|
-
ColorType[ColorType["
|
38
|
-
ColorType[ColorType["
|
39
|
-
ColorType[ColorType["
|
40
|
-
ColorType[ColorType["
|
41
|
-
ColorType[ColorType["
|
42
|
-
ColorType[ColorType["
|
43
|
-
ColorType[ColorType["
|
33
|
+
ColorType[ColorType["RGBA_10x6"] = 12] = "RGBA_10x6";
|
34
|
+
ColorType[ColorType["Gray_8"] = 13] = "Gray_8";
|
35
|
+
ColorType[ColorType["RGBA_F16Norm"] = 14] = "RGBA_F16Norm";
|
36
|
+
ColorType[ColorType["RGBA_F16"] = 15] = "RGBA_F16";
|
37
|
+
ColorType[ColorType["RGBA_F32"] = 16] = "RGBA_F32";
|
38
|
+
ColorType[ColorType["R8G8_unorm"] = 17] = "R8G8_unorm";
|
39
|
+
ColorType[ColorType["A16_float"] = 18] = "A16_float";
|
40
|
+
ColorType[ColorType["R16G16_float"] = 19] = "R16G16_float";
|
41
|
+
ColorType[ColorType["A16_unorm"] = 20] = "A16_unorm";
|
42
|
+
ColorType[ColorType["R16G16_unorm"] = 21] = "R16G16_unorm";
|
43
|
+
ColorType[ColorType["R16G16B16A16_unorm"] = 22] = "R16G16B16A16_unorm";
|
44
|
+
ColorType[ColorType["SRGBA_8888"] = 23] = "SRGBA_8888";
|
45
|
+
ColorType[ColorType["R8_unorm"] = 24] = "R8_unorm";
|
46
|
+
ColorType[ColorType["N32_SkColorType"] = 25] = "N32_SkColorType";
|
44
47
|
})(ColorType || (exports.ColorType = ColorType = {}));
|
45
48
|
//# sourceMappingURL=ImageFactory.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AlphaType","ColorType"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\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,
|
1
|
+
{"version":3,"names":["AlphaType","ColorType"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\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 // The following 6 colortypes are just for reading from - not for rendering to\n R8G8_unorm, // pixel with a uint8_t for red and green\n\n A16_float, // pixel with a half float for alpha\n R16G16_float, // pixel with a half float for red and green\n\n A16_unorm, // pixel with a little endian uint16_t for alpha\n R16G16_unorm, // pixel with a little endian uint16_t for red and green\n R16G16B16A16_unorm, // pixel with a little endian uint16_t for red, green, blue, and alpha\n\n SRGBA_8888,\n R8_unorm,\n\n // The `kN32_SkColorType` is platform dependent in the original enum,\n // and TypeScript doesn't support conditional compilation natively.\n // You might need to handle it differently based on your use case.\n N32_SkColorType, // either BGRA_8888 or RGBA_8888 based on the platform\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 * 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":";;;;;;IAIYA,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;;IAOAC,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { CanvasKit, EmbindEnumEntity } from "canvaskit-wasm";
|
1
|
+
import type { CanvasKit, EmbindEnumEntity, EmbindEnum } from "canvaskit-wasm";
|
2
2
|
import type { SkJSIInstance } from "../types";
|
3
3
|
export declare class NotImplementedOnRNWeb extends Error {
|
4
4
|
constructor(msg?: string);
|
@@ -16,5 +16,6 @@ export declare abstract class BaseHostObject<T, N extends string> extends Host i
|
|
16
16
|
export declare abstract class HostObject<T, N extends string> extends BaseHostObject<T, N> {
|
17
17
|
static fromValue<T>(value: SkJSIInstance<string>): T;
|
18
18
|
}
|
19
|
+
export declare const getCkEnum: (e: EmbindEnum, v: number) => EmbindEnumEntity;
|
19
20
|
export declare const ckEnum: (value: number) => EmbindEnumEntity;
|
20
21
|
export declare const optEnum: (value: number | undefined) => EmbindEnumEntity | undefined;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.optEnum = exports.ckEnum = exports.NotImplementedOnRNWeb = exports.HostObject = exports.Host = exports.BaseHostObject = void 0;
|
6
|
+
exports.optEnum = exports.getCkEnum = exports.ckEnum = exports.NotImplementedOnRNWeb = exports.HostObject = exports.Host = exports.BaseHostObject = void 0;
|
7
7
|
|
8
8
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
9
9
|
|
@@ -52,6 +52,15 @@ class HostObject extends BaseHostObject {
|
|
52
52
|
|
53
53
|
exports.HostObject = HostObject;
|
54
54
|
|
55
|
+
const getCkEnum = (e, v) => Object.values(e).find(_ref => {
|
56
|
+
let {
|
57
|
+
value
|
58
|
+
} = _ref;
|
59
|
+
return value === v;
|
60
|
+
});
|
61
|
+
|
62
|
+
exports.getCkEnum = getCkEnum;
|
63
|
+
|
55
64
|
const ckEnum = value => ({
|
56
65
|
value
|
57
66
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NotImplementedOnRNWeb","Error","constructor","msg","Host","CanvasKit","BaseHostObject","ref","typename","__typename__","HostObject","fromValue","value","ckEnum","optEnum","undefined"],"sources":["Host.ts"],"sourcesContent":["import type { CanvasKit, EmbindEnumEntity } from \"canvaskit-wasm\";\n\nimport type { SkJSIInstance } from \"../types\";\n\nexport class NotImplementedOnRNWeb extends Error {\n constructor(msg?: string) {\n super(msg ?? \"Not implemented on React Native Web\");\n }\n}\n\nexport abstract class Host {\n readonly CanvasKit: CanvasKit;\n\n constructor(CanvasKit: CanvasKit) {\n this.CanvasKit = CanvasKit;\n }\n}\n\nexport abstract class BaseHostObject<T, N extends string>\n extends Host\n implements SkJSIInstance<N>\n{\n readonly __typename__: N;\n ref: T;\n\n constructor(CanvasKit: CanvasKit, ref: T, typename: N) {\n super(CanvasKit);\n this.ref = ref;\n this.__typename__ = typename;\n }\n\n abstract dispose(): void;\n}\n\nexport abstract class HostObject<T, N extends string> extends BaseHostObject<\n T,\n N\n> {\n static fromValue<T>(value: SkJSIInstance<string>) {\n return (value as HostObject<T, string>).ref;\n }\n}\n\nexport const ckEnum = (value: number): EmbindEnumEntity => ({ value });\nexport const optEnum = (\n value: number | undefined\n): EmbindEnumEntity | undefined =>\n value === undefined ? undefined : { value };\n"],"mappings":";;;;;;;;;AAIO,MAAMA,qBAAN,SAAoCC,KAApC,CAA0C;EAC/CC,WAAW,CAACC,GAAD,EAAe;IACxB,MAAMA,GAAG,IAAI,qCAAb;EACD;;AAH8C;;;;AAM1C,MAAeC,IAAf,CAAoB;EAGzBF,WAAW,CAACG,SAAD,EAAuB;IAAA;;IAChC,KAAKA,SAAL,GAAiBA,SAAjB;EACD;;AALwB;;;;AAQpB,MAAeC,cAAf,SACGF,IADH,CAGP;EAIEF,WAAW,CAACG,SAAD,EAAuBE,GAAvB,EAA+BC,QAA/B,EAA4C;IACrD,MAAMH,SAAN;;IADqD;;IAAA;;IAErD,KAAKE,GAAL,GAAWA,GAAX;IACA,KAAKE,YAAL,GAAoBD,QAApB;EACD;;AARH;;;;AAaO,MAAeE,UAAf,SAAuDJ,cAAvD,CAGL;EACgB,OAATK,SAAS,CAAIC,KAAJ,EAAkC;IAChD,OAAQA,KAAD,CAAiCL,GAAxC;EACD;;AAHD;;;;AAMK,MAAMM,MAAM,
|
1
|
+
{"version":3,"names":["NotImplementedOnRNWeb","Error","constructor","msg","Host","CanvasKit","BaseHostObject","ref","typename","__typename__","HostObject","fromValue","value","getCkEnum","e","v","Object","values","find","ckEnum","optEnum","undefined"],"sources":["Host.ts"],"sourcesContent":["import type { CanvasKit, EmbindEnumEntity, EmbindEnum } from \"canvaskit-wasm\";\n\nimport type { SkJSIInstance } from \"../types\";\n\nexport class NotImplementedOnRNWeb extends Error {\n constructor(msg?: string) {\n super(msg ?? \"Not implemented on React Native Web\");\n }\n}\n\nexport abstract class Host {\n readonly CanvasKit: CanvasKit;\n\n constructor(CanvasKit: CanvasKit) {\n this.CanvasKit = CanvasKit;\n }\n}\n\nexport abstract class BaseHostObject<T, N extends string>\n extends Host\n implements SkJSIInstance<N>\n{\n readonly __typename__: N;\n ref: T;\n\n constructor(CanvasKit: CanvasKit, ref: T, typename: N) {\n super(CanvasKit);\n this.ref = ref;\n this.__typename__ = typename;\n }\n\n abstract dispose(): void;\n}\n\nexport abstract class HostObject<T, N extends string> extends BaseHostObject<\n T,\n N\n> {\n static fromValue<T>(value: SkJSIInstance<string>) {\n return (value as HostObject<T, string>).ref;\n }\n}\n\nexport const getCkEnum = (e: EmbindEnum, v: number): EmbindEnumEntity =>\n Object.values(e).find(({ value }) => value === v);\nexport const ckEnum = (value: number): EmbindEnumEntity => ({ value });\nexport const optEnum = (\n value: number | undefined\n): EmbindEnumEntity | undefined =>\n value === undefined ? undefined : { value };\n"],"mappings":";;;;;;;;;AAIO,MAAMA,qBAAN,SAAoCC,KAApC,CAA0C;EAC/CC,WAAW,CAACC,GAAD,EAAe;IACxB,MAAMA,GAAG,IAAI,qCAAb;EACD;;AAH8C;;;;AAM1C,MAAeC,IAAf,CAAoB;EAGzBF,WAAW,CAACG,SAAD,EAAuB;IAAA;;IAChC,KAAKA,SAAL,GAAiBA,SAAjB;EACD;;AALwB;;;;AAQpB,MAAeC,cAAf,SACGF,IADH,CAGP;EAIEF,WAAW,CAACG,SAAD,EAAuBE,GAAvB,EAA+BC,QAA/B,EAA4C;IACrD,MAAMH,SAAN;;IADqD;;IAAA;;IAErD,KAAKE,GAAL,GAAWA,GAAX;IACA,KAAKE,YAAL,GAAoBD,QAApB;EACD;;AARH;;;;AAaO,MAAeE,UAAf,SAAuDJ,cAAvD,CAGL;EACgB,OAATK,SAAS,CAAIC,KAAJ,EAAkC;IAChD,OAAQA,KAAD,CAAiCL,GAAxC;EACD;;AAHD;;;;AAMK,MAAMM,SAAS,GAAG,CAACC,CAAD,EAAgBC,CAAhB,KACvBC,MAAM,CAACC,MAAP,CAAcH,CAAd,EAAiBI,IAAjB,CAAsB;EAAA,IAAC;IAAEN;EAAF,CAAD;EAAA,OAAeA,KAAK,KAAKG,CAAzB;AAAA,CAAtB,CADK;;;;AAEA,MAAMI,MAAM,GAAIP,KAAD,KAAsC;EAAEA;AAAF,CAAtC,CAAf;;;;AACA,MAAMQ,OAAO,GAClBR,KADqB,IAGrBA,KAAK,KAAKS,SAAV,GAAsBA,SAAtB,GAAkC;EAAET;AAAF,CAH7B"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Canvas, CanvasKit } from "canvaskit-wasm";
|
2
|
-
import type { BlendMode, ClipOp, FilterMode, MipmapMode, PointMode, SaveLayerFlag, SkCanvas, SkColor, SkFont, SkImage, SkImageFilter, SkMatrix, SkPaint, SkPath, SkPicture, SkPoint, SkRect, SkRRect, SkSVG, SkTextBlob, SkVertices } from "../types";
|
2
|
+
import type { BlendMode, ClipOp, FilterMode, MipmapMode, PointMode, SaveLayerFlag, ImageInfo, SkCanvas, SkColor, SkFont, SkImage, SkImageFilter, SkMatrix, SkPaint, SkPath, SkPicture, SkPoint, SkRect, SkRRect, SkSVG, SkTextBlob, SkVertices } from "../types";
|
3
3
|
import { HostObject } from "./Host";
|
4
4
|
export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements SkCanvas {
|
5
5
|
constructor(CanvasKit: CanvasKit, ref: Canvas);
|
@@ -42,4 +42,5 @@ export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements
|
|
42
42
|
clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean): void;
|
43
43
|
concat(m: SkMatrix): void;
|
44
44
|
drawPicture(skp: SkPicture): void;
|
45
|
+
readPixels(srcX: number, srcY: number, imageInfo: ImageInfo): Float32Array | Uint8Array | null;
|
45
46
|
}
|
@@ -206,6 +206,17 @@ class JsiSkCanvas extends _Host.HostObject {
|
|
206
206
|
this.ref.drawPicture(_JsiSkPicture.JsiSkPicture.fromValue(skp));
|
207
207
|
}
|
208
208
|
|
209
|
+
readPixels(srcX, srcY, imageInfo) {
|
210
|
+
const pxInfo = {
|
211
|
+
width: imageInfo.width,
|
212
|
+
height: imageInfo.height,
|
213
|
+
colorSpace: this.CanvasKit.ColorSpace.SRGB,
|
214
|
+
alphaType: (0, _Host.getCkEnum)(this.CanvasKit.AlphaType, imageInfo.alphaType),
|
215
|
+
colorType: (0, _Host.getCkEnum)(this.CanvasKit.ColorType, imageInfo.colorType)
|
216
|
+
};
|
217
|
+
return this.ref.readPixels(srcX, srcY, pxInfo);
|
218
|
+
}
|
219
|
+
|
209
220
|
}
|
210
221
|
|
211
222
|
exports.JsiSkCanvas = JsiSkCanvas;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JsiSkCanvas","HostObject","constructor","CanvasKit","ref","delete","drawRect","rect","paint","JsiSkRect","fromValue","JsiSkPaint","drawImage","image","x","y","JsiSkImage","drawImageRect","img","src","dest","fastSample","drawImageCubic","left","top","B","C","drawImageOptions","fm","mm","ckEnum","drawImageNine","center","filter","Array","from","drawImageRectCubic","drawImageRectOptions","drawPaint","drawLine","x0","y0","x1","y1","drawCircle","cx","cy","radius","drawVertices","verts","mode","JsiSkVertices","drawPatch","cubics","colors","texs","map","flat","flatMap","p","JsiSkPoint","undefined","restoreToCount","saveCount","drawPoints","points","drawArc","oval","startAngle","sweepAngle","useCenter","drawRRect","rrect","JsiSkRRect","drawDRRect","outer","inner","drawOval","drawPath","path","JsiSkPath","drawText","str","font","JsiSkFont","drawTextBlob","blob","JsiSkTextBlob","drawGlyphs","glyphs","positions","drawSvg","_svgDom","_width","_height","Error","save","saveLayer","bounds","backdrop","flags","JsiSkImageFilter","restore","rotate","rotationInDegrees","rx","ry","scale","sx","sy","skew","translate","dx","dy","drawColor","color","blendMode","clear","clipPath","op","doAntiAlias","clipRect","clipRRect","concat","m","JsiSkMatrix","drawPicture","skp","JsiSkPicture"],"sources":["JsiSkCanvas.ts"],"sourcesContent":["import type { Canvas, CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n BlendMode,\n ClipOp,\n FilterMode,\n MipmapMode,\n PointMode,\n SaveLayerFlag,\n SkCanvas,\n SkColor,\n SkFont,\n SkImage,\n SkImageFilter,\n SkMatrix,\n SkPaint,\n SkPath,\n SkPicture,\n SkPoint,\n SkRect,\n SkRRect,\n SkSVG,\n SkTextBlob,\n SkVertices,\n} from \"../types\";\n\nimport { ckEnum, HostObject } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkVertices } from \"./JsiSkVertices\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { JsiSkTextBlob } from \"./JsiSkTextBlob\";\nimport { JsiSkPicture } from \"./JsiSkPicture\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\n\nexport class JsiSkCanvas\n extends HostObject<Canvas, \"Canvas\">\n implements SkCanvas\n{\n constructor(CanvasKit: CanvasKit, ref: Canvas) {\n super(CanvasKit, ref, \"Canvas\");\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n drawRect(rect: SkRect, paint: SkPaint) {\n this.ref.drawRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {\n this.ref.drawImage(\n JsiSkImage.fromValue(image),\n x,\n y,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ) {\n this.ref.drawImageRect(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n JsiSkPaint.fromValue(paint),\n fastSample\n );\n }\n\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageCubic(\n JsiSkImage.fromValue(img),\n left,\n top,\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageOptions(\n JsiSkImage.fromValue(img),\n left,\n top,\n ckEnum(fm),\n ckEnum(mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageNine(\n JsiSkImage.fromValue(img),\n Array.from(JsiSkRect.fromValue(this.CanvasKit, center)),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n ckEnum(filter),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectCubic(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectOptions(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n ckEnum(fm),\n ckEnum(mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawPaint(paint: SkPaint) {\n this.ref.drawPaint(JsiSkPaint.fromValue(paint));\n }\n\n drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {\n this.ref.drawLine(x0, y0, x1, y1, JsiSkPaint.fromValue(paint));\n }\n\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {\n this.ref.drawCircle(cx, cy, radius, JsiSkPaint.fromValue(paint));\n }\n\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {\n this.ref.drawVertices(\n JsiSkVertices.fromValue(verts),\n ckEnum(mode),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPatch(\n cubics: SkPoint[],\n colors?: SkColor[] | null,\n texs?: SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ) {\n this.ref.drawPatch(\n cubics.map(({ x, y }) => [x, y]).flat(),\n colors,\n texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,\n mode ? ckEnum(mode) : null,\n paint ? JsiSkPaint.fromValue(paint) : undefined\n );\n }\n\n restoreToCount(saveCount: number) {\n this.ref.restoreToCount(saveCount);\n }\n\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {\n this.ref.drawPoints(\n ckEnum(mode),\n points.map(({ x, y }) => [x, y]).flat(),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawArc(\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) {\n this.ref.drawArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngle,\n sweepAngle,\n useCenter,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawRRect(rrect: SkRRect, paint: SkPaint) {\n this.ref.drawRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint) {\n this.ref.drawDRRect(\n JsiSkRRect.fromValue(this.CanvasKit, outer),\n JsiSkRRect.fromValue(this.CanvasKit, inner),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawOval(oval: SkRect, paint: SkPaint) {\n this.ref.drawOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPath(path: SkPath, paint: SkPaint) {\n this.ref.drawPath(JsiSkPath.fromValue(path), JsiSkPaint.fromValue(paint));\n }\n\n drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {\n this.ref.drawText(\n str,\n x,\n y,\n JsiSkPaint.fromValue(paint),\n JsiSkFont.fromValue(font)\n );\n }\n\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {\n this.ref.drawTextBlob(\n JsiSkTextBlob.fromValue(blob),\n x,\n y,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ) {\n this.ref.drawGlyphs(\n glyphs,\n positions.map((p) => [p.x, p.y]).flat(),\n x,\n y,\n JsiSkFont.fromValue(font),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawSvg(_svgDom: SkSVG, _width?: number, _height?: number) {\n throw new Error(\"drawSvg is not implemented on React Native Web\");\n }\n\n save() {\n return this.ref.save();\n }\n\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ) {\n return this.ref.saveLayer(\n paint ? JsiSkPaint.fromValue(paint) : undefined,\n bounds ? JsiSkRect.fromValue(this.CanvasKit, bounds) : bounds,\n backdrop ? JsiSkImageFilter.fromValue(backdrop) : backdrop,\n flags\n );\n }\n\n restore() {\n this.ref.restore();\n }\n\n rotate(rotationInDegrees: number, rx: number, ry: number) {\n this.ref.rotate(rotationInDegrees, rx, ry);\n }\n\n scale(sx: number, sy: number) {\n this.ref.scale(sx, sy);\n }\n\n skew(sx: number, sy: number) {\n this.ref.skew(sx, sy);\n }\n\n translate(dx: number, dy: number) {\n this.ref.translate(dx, dy);\n }\n\n drawColor(color: SkColor, blendMode?: BlendMode) {\n this.ref.drawColor(color, blendMode ? ckEnum(blendMode) : undefined);\n }\n\n clear(color: SkColor) {\n this.ref.clear(color);\n }\n\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipPath(JsiSkPath.fromValue(path), ckEnum(op), doAntiAlias);\n }\n\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n ckEnum(op),\n doAntiAlias\n );\n }\n\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n ckEnum(op),\n doAntiAlias\n );\n }\n\n concat(m: SkMatrix) {\n this.ref.concat(JsiSkMatrix.fromValue(m));\n }\n\n drawPicture(skp: SkPicture) {\n this.ref.drawPicture(JsiSkPicture.fromValue(skp));\n }\n}\n"],"mappings":";;;;;;;AA0BA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEO,MAAMA,WAAN,SACGC,gBADH,CAGP;EACEC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAoC;IAC7C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,QAAtB;;IAD6C,iCAIrC,MAAM;MACd,KAAKA,GAAL,CAASC,MAAT;IACD,CAN8C;EAE9C;;EAMDC,QAAQ,CAACC,IAAD,EAAeC,KAAf,EAA+B;IACrC,KAAKJ,GAAL,CAASE,QAAT,CACEG,oBAAA,CAAUC,SAAV,CAAoB,KAAKP,SAAzB,EAAoCI,IAApC,CADF,EAEEI,sBAAA,CAAWD,SAAX,CAAqBF,KAArB,CAFF;EAID;;EAEDI,SAAS,CAACC,KAAD,EAAiBC,CAAjB,EAA4BC,CAA5B,EAAuCP,KAAvC,EAAwD;IAC/D,KAAKJ,GAAL,CAASQ,SAAT,CACEI,sBAAA,CAAWN,SAAX,CAAqBG,KAArB,CADF,EAEEC,CAFF,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,MAAM,CAACC,CAAD,EAAc;IAClB,KAAKxH,GAAL,CAASuH,MAAT,CAAgBE,wBAAA,CAAYnH,SAAZ,CAAsBkH,CAAtB,CAAhB;EACD;;EAEDE,WAAW,CAACC,GAAD,EAAiB;IAC1B,KAAK3H,GAAL,CAAS0H,WAAT,CAAqBE,0BAAA,CAAatH,SAAb,CAAuBqH,GAAvB,CAArB;EACD;;AA5UH"}
|
1
|
+
{"version":3,"names":["JsiSkCanvas","HostObject","constructor","CanvasKit","ref","delete","drawRect","rect","paint","JsiSkRect","fromValue","JsiSkPaint","drawImage","image","x","y","JsiSkImage","drawImageRect","img","src","dest","fastSample","drawImageCubic","left","top","B","C","drawImageOptions","fm","mm","ckEnum","drawImageNine","center","filter","Array","from","drawImageRectCubic","drawImageRectOptions","drawPaint","drawLine","x0","y0","x1","y1","drawCircle","cx","cy","radius","drawVertices","verts","mode","JsiSkVertices","drawPatch","cubics","colors","texs","map","flat","flatMap","p","JsiSkPoint","undefined","restoreToCount","saveCount","drawPoints","points","drawArc","oval","startAngle","sweepAngle","useCenter","drawRRect","rrect","JsiSkRRect","drawDRRect","outer","inner","drawOval","drawPath","path","JsiSkPath","drawText","str","font","JsiSkFont","drawTextBlob","blob","JsiSkTextBlob","drawGlyphs","glyphs","positions","drawSvg","_svgDom","_width","_height","Error","save","saveLayer","bounds","backdrop","flags","JsiSkImageFilter","restore","rotate","rotationInDegrees","rx","ry","scale","sx","sy","skew","translate","dx","dy","drawColor","color","blendMode","clear","clipPath","op","doAntiAlias","clipRect","clipRRect","concat","m","JsiSkMatrix","drawPicture","skp","JsiSkPicture","readPixels","srcX","srcY","imageInfo","pxInfo","width","height","colorSpace","ColorSpace","SRGB","alphaType","getCkEnum","AlphaType","colorType","ColorType"],"sources":["JsiSkCanvas.ts"],"sourcesContent":["import type { Canvas, CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n BlendMode,\n ClipOp,\n FilterMode,\n MipmapMode,\n PointMode,\n SaveLayerFlag,\n ImageInfo,\n SkCanvas,\n SkColor,\n SkFont,\n SkImage,\n SkImageFilter,\n SkMatrix,\n SkPaint,\n SkPath,\n SkPicture,\n SkPoint,\n SkRect,\n SkRRect,\n SkSVG,\n SkTextBlob,\n SkVertices,\n} from \"../types\";\n\nimport { ckEnum, getCkEnum, HostObject } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkVertices } from \"./JsiSkVertices\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { JsiSkTextBlob } from \"./JsiSkTextBlob\";\nimport { JsiSkPicture } from \"./JsiSkPicture\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\n\nexport class JsiSkCanvas\n extends HostObject<Canvas, \"Canvas\">\n implements SkCanvas\n{\n constructor(CanvasKit: CanvasKit, ref: Canvas) {\n super(CanvasKit, ref, \"Canvas\");\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n drawRect(rect: SkRect, paint: SkPaint) {\n this.ref.drawRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {\n this.ref.drawImage(\n JsiSkImage.fromValue(image),\n x,\n y,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ) {\n this.ref.drawImageRect(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n JsiSkPaint.fromValue(paint),\n fastSample\n );\n }\n\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageCubic(\n JsiSkImage.fromValue(img),\n left,\n top,\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageOptions(\n JsiSkImage.fromValue(img),\n left,\n top,\n ckEnum(fm),\n ckEnum(mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageNine(\n JsiSkImage.fromValue(img),\n Array.from(JsiSkRect.fromValue(this.CanvasKit, center)),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n ckEnum(filter),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectCubic(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectOptions(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n ckEnum(fm),\n ckEnum(mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawPaint(paint: SkPaint) {\n this.ref.drawPaint(JsiSkPaint.fromValue(paint));\n }\n\n drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {\n this.ref.drawLine(x0, y0, x1, y1, JsiSkPaint.fromValue(paint));\n }\n\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {\n this.ref.drawCircle(cx, cy, radius, JsiSkPaint.fromValue(paint));\n }\n\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {\n this.ref.drawVertices(\n JsiSkVertices.fromValue(verts),\n ckEnum(mode),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPatch(\n cubics: SkPoint[],\n colors?: SkColor[] | null,\n texs?: SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ) {\n this.ref.drawPatch(\n cubics.map(({ x, y }) => [x, y]).flat(),\n colors,\n texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,\n mode ? ckEnum(mode) : null,\n paint ? JsiSkPaint.fromValue(paint) : undefined\n );\n }\n\n restoreToCount(saveCount: number) {\n this.ref.restoreToCount(saveCount);\n }\n\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {\n this.ref.drawPoints(\n ckEnum(mode),\n points.map(({ x, y }) => [x, y]).flat(),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawArc(\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) {\n this.ref.drawArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngle,\n sweepAngle,\n useCenter,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawRRect(rrect: SkRRect, paint: SkPaint) {\n this.ref.drawRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint) {\n this.ref.drawDRRect(\n JsiSkRRect.fromValue(this.CanvasKit, outer),\n JsiSkRRect.fromValue(this.CanvasKit, inner),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawOval(oval: SkRect, paint: SkPaint) {\n this.ref.drawOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPath(path: SkPath, paint: SkPaint) {\n this.ref.drawPath(JsiSkPath.fromValue(path), JsiSkPaint.fromValue(paint));\n }\n\n drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {\n this.ref.drawText(\n str,\n x,\n y,\n JsiSkPaint.fromValue(paint),\n JsiSkFont.fromValue(font)\n );\n }\n\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {\n this.ref.drawTextBlob(\n JsiSkTextBlob.fromValue(blob),\n x,\n y,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ) {\n this.ref.drawGlyphs(\n glyphs,\n positions.map((p) => [p.x, p.y]).flat(),\n x,\n y,\n JsiSkFont.fromValue(font),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawSvg(_svgDom: SkSVG, _width?: number, _height?: number) {\n throw new Error(\"drawSvg is not implemented on React Native Web\");\n }\n\n save() {\n return this.ref.save();\n }\n\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ) {\n return this.ref.saveLayer(\n paint ? JsiSkPaint.fromValue(paint) : undefined,\n bounds ? JsiSkRect.fromValue(this.CanvasKit, bounds) : bounds,\n backdrop ? JsiSkImageFilter.fromValue(backdrop) : backdrop,\n flags\n );\n }\n\n restore() {\n this.ref.restore();\n }\n\n rotate(rotationInDegrees: number, rx: number, ry: number) {\n this.ref.rotate(rotationInDegrees, rx, ry);\n }\n\n scale(sx: number, sy: number) {\n this.ref.scale(sx, sy);\n }\n\n skew(sx: number, sy: number) {\n this.ref.skew(sx, sy);\n }\n\n translate(dx: number, dy: number) {\n this.ref.translate(dx, dy);\n }\n\n drawColor(color: SkColor, blendMode?: BlendMode) {\n this.ref.drawColor(color, blendMode ? ckEnum(blendMode) : undefined);\n }\n\n clear(color: SkColor) {\n this.ref.clear(color);\n }\n\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipPath(JsiSkPath.fromValue(path), ckEnum(op), doAntiAlias);\n }\n\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n ckEnum(op),\n doAntiAlias\n );\n }\n\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n ckEnum(op),\n doAntiAlias\n );\n }\n\n concat(m: SkMatrix) {\n this.ref.concat(JsiSkMatrix.fromValue(m));\n }\n\n drawPicture(skp: SkPicture) {\n this.ref.drawPicture(JsiSkPicture.fromValue(skp));\n }\n\n readPixels(srcX: number, srcY: number, imageInfo: ImageInfo) {\n const pxInfo = {\n width: imageInfo.width,\n height: imageInfo.height,\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n alphaType: getCkEnum(this.CanvasKit.AlphaType, imageInfo.alphaType),\n colorType: getCkEnum(this.CanvasKit.ColorType, imageInfo.colorType),\n };\n return this.ref.readPixels(srcX, srcY, pxInfo);\n }\n}\n"],"mappings":";;;;;;;AA2BA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEO,MAAMA,WAAN,SACGC,gBADH,CAGP;EACEC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAoC;IAC7C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,QAAtB;;IAD6C,iCAIrC,MAAM;MACd,KAAKA,GAAL,CAASC,MAAT;IACD,CAN8C;EAE9C;;EAMDC,QAAQ,CAACC,IAAD,EAAeC,KAAf,EAA+B;IACrC,KAAKJ,GAAL,CAASE,QAAT,CACEG,oBAAA,CAAUC,SAAV,CAAoB,KAAKP,SAAzB,EAAoCI,IAApC,CADF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S,CAAClD,KAAD,EAAiB+C,EAAjB,EAA6BC,WAA7B,EAAmD;IAC1D,KAAKpH,GAAL,CAASsH,SAAT,CACEjD,sBAAA,CAAW/D,SAAX,CAAqB,KAAKP,SAA1B,EAAqCqE,KAArC,CADF,EAEE,IAAA1C,YAAA,EAAOyF,EAAP,CAFF,EAGEC,WAHF;EAKD;;EAEDG,MAAM,CAACC,CAAD,EAAc;IAClB,KAAKxH,GAAL,CAASuH,MAAT,CAAgBE,wBAAA,CAAYnH,SAAZ,CAAsBkH,CAAtB,CAAhB;EACD;;EAEDE,WAAW,CAACC,GAAD,EAAiB;IAC1B,KAAK3H,GAAL,CAAS0H,WAAT,CAAqBE,0BAAA,CAAatH,SAAb,CAAuBqH,GAAvB,CAArB;EACD;;EAEDE,UAAU,CAACC,IAAD,EAAeC,IAAf,EAA6BC,SAA7B,EAAmD;IAC3D,MAAMC,MAAM,GAAG;MACbC,KAAK,EAAEF,SAAS,CAACE,KADJ;MAEbC,MAAM,EAAEH,SAAS,CAACG,MAFL;MAGbC,UAAU,EAAE,KAAKrI,SAAL,CAAesI,UAAf,CAA0BC,IAHzB;MAIbC,SAAS,EAAE,IAAAC,eAAA,EAAU,KAAKzI,SAAL,CAAe0I,SAAzB,EAAoCT,SAAS,CAACO,SAA9C,CAJE;MAKbG,SAAS,EAAE,IAAAF,eAAA,EAAU,KAAKzI,SAAL,CAAe4I,SAAzB,EAAoCX,SAAS,CAACU,SAA9C;IALE,CAAf;IAOA,OAAO,KAAK1I,GAAL,CAAS6H,UAAT,CAAoBC,IAApB,EAA0BC,IAA1B,EAAgCE,MAAhC,CAAP;EACD;;AAvVH"}
|
@@ -19,9 +19,7 @@ class JsiSkFontMgrFactory extends _Host.Host {
|
|
19
19
|
|
20
20
|
if (!fontMgr) {
|
21
21
|
throw new Error("Couldn't create system font manager");
|
22
|
-
}
|
23
|
-
// @ts-expect-error
|
24
|
-
|
22
|
+
}
|
25
23
|
|
26
24
|
return new _JsiSkFontMgr.JsiSkFontMgr(this.CanvasKit, fontMgr);
|
27
25
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JsiSkFontMgrFactory","Host","constructor","CanvasKit","System","fontMgr","TypefaceFontProvider","Make","Error","JsiSkFontMgr"],"sources":["JsiSkFontMgrFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { FontMgrFactory } from \"../types\";\n\nimport { Host } from \"./Host\";\nimport { JsiSkFontMgr } from \"./JsiSkFontMgr\";\n\nexport class JsiSkFontMgrFactory extends Host implements FontMgrFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n System() {\n const fontMgr = this.CanvasKit.TypefaceFontProvider.Make();\n if (!fontMgr) {\n throw new Error(\"Couldn't create system font manager\");\n }\n
|
1
|
+
{"version":3,"names":["JsiSkFontMgrFactory","Host","constructor","CanvasKit","System","fontMgr","TypefaceFontProvider","Make","Error","JsiSkFontMgr"],"sources":["JsiSkFontMgrFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { FontMgrFactory } from \"../types\";\n\nimport { Host } from \"./Host\";\nimport { JsiSkFontMgr } from \"./JsiSkFontMgr\";\n\nexport class JsiSkFontMgrFactory extends Host implements FontMgrFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n System() {\n const fontMgr = this.CanvasKit.TypefaceFontProvider.Make();\n if (!fontMgr) {\n throw new Error(\"Couldn't create system font manager\");\n }\n return new JsiSkFontMgr(this.CanvasKit, fontMgr);\n }\n}\n"],"mappings":";;;;;;;AAIA;;AACA;;AAEO,MAAMA,mBAAN,SAAkCC,UAAlC,CAAiE;EACtEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,MAAM,GAAG;IACP,MAAMC,OAAO,GAAG,KAAKF,SAAL,CAAeG,oBAAf,CAAoCC,IAApC,EAAhB;;IACA,IAAI,CAACF,OAAL,EAAc;MACZ,MAAM,IAAIG,KAAJ,CAAU,qCAAV,CAAN;IACD;;IACD,OAAO,IAAIC,0BAAJ,CAAiB,KAAKN,SAAtB,EAAiCE,OAAjC,CAAP;EACD;;AAXqE"}
|
@@ -1,15 +1,17 @@
|
|
1
1
|
import type { CanvasKit, Image } from "canvaskit-wasm";
|
2
|
-
import type {
|
2
|
+
import type { FilterMode, MipmapMode, SkImage, SkMatrix, SkShader, TileMode, ImageFormat, ImageInfo } from "../types";
|
3
3
|
import { HostObject } from "./Host";
|
4
4
|
export declare const toBase64String: (bytes: Uint8Array) => string;
|
5
5
|
export declare class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
6
6
|
constructor(CanvasKit: CanvasKit, ref: Image);
|
7
7
|
height(): number;
|
8
8
|
width(): number;
|
9
|
+
getImageInfo(): ImageInfo;
|
9
10
|
makeShaderOptions(tx: TileMode, ty: TileMode, fm: FilterMode, mm: MipmapMode, localMatrix?: SkMatrix): SkShader;
|
10
11
|
makeShaderCubic(tx: TileMode, ty: TileMode, B: number, C: number, localMatrix?: SkMatrix): SkShader;
|
11
12
|
encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;
|
12
13
|
encodeToBase64(fmt?: ImageFormat, quality?: number): string;
|
14
|
+
readPixels(srcX?: number, srcY?: number, imageInfo?: ImageInfo): Float32Array | Uint8Array | null;
|
13
15
|
dispose: () => void;
|
14
16
|
makeNonTextureImage(): SkImage;
|
15
17
|
}
|
@@ -62,6 +62,16 @@ class JsiSkImage extends _Host.HostObject {
|
|
62
62
|
return this.ref.width();
|
63
63
|
}
|
64
64
|
|
65
|
+
getImageInfo() {
|
66
|
+
const info = this.ref.getImageInfo();
|
67
|
+
return {
|
68
|
+
width: info.width,
|
69
|
+
height: info.height,
|
70
|
+
colorType: info.colorType.value,
|
71
|
+
alphaType: info.alphaType.value
|
72
|
+
};
|
73
|
+
}
|
74
|
+
|
65
75
|
makeShaderOptions(tx, ty, fm, mm, localMatrix) {
|
66
76
|
return new _JsiSkShader.JsiSkShader(this.CanvasKit, this.ref.makeShaderOptions((0, _Host.ckEnum)(tx), (0, _Host.ckEnum)(ty), (0, _Host.ckEnum)(fm), (0, _Host.ckEnum)(mm), localMatrix ? _JsiSkMatrix.JsiSkMatrix.fromValue(localMatrix) : undefined));
|
67
77
|
}
|
@@ -93,6 +103,18 @@ class JsiSkImage extends _Host.HostObject {
|
|
93
103
|
return toBase64String(bytes);
|
94
104
|
}
|
95
105
|
|
106
|
+
readPixels(srcX, srcY, imageInfo) {
|
107
|
+
const info = this.getImageInfo();
|
108
|
+
const pxInfo = {
|
109
|
+
colorSpace: this.CanvasKit.ColorSpace.SRGB,
|
110
|
+
width: (imageInfo === null || imageInfo === void 0 ? void 0 : imageInfo.width) ?? info.width,
|
111
|
+
height: (imageInfo === null || imageInfo === void 0 ? void 0 : imageInfo.height) ?? info.height,
|
112
|
+
alphaType: (0, _Host.getCkEnum)(this.CanvasKit.AlphaType, (imageInfo ?? info).alphaType),
|
113
|
+
colorType: (0, _Host.getCkEnum)(this.CanvasKit.ColorType, (imageInfo ?? info).colorType)
|
114
|
+
};
|
115
|
+
return this.ref.readPixels(srcX ?? 0, srcY ?? 0, pxInfo);
|
116
|
+
}
|
117
|
+
|
96
118
|
makeNonTextureImage() {
|
97
119
|
return new JsiSkImage(this.CanvasKit, this.CanvasKit.MakeImageFromEncoded(this.encodeToBytes()));
|
98
120
|
}
|