@shopify/react-native-skia 1.10.2 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cpp/api/JsiSkApi.h +3 -0
- package/cpp/api/recorder/ColorFilters.h +133 -0
- package/cpp/api/recorder/Command.h +58 -0
- package/cpp/api/recorder/Convertor.h +1213 -0
- package/cpp/api/recorder/DataTypes.h +232 -0
- package/cpp/api/recorder/DrawingCtx.h +187 -0
- package/cpp/api/recorder/Drawings.h +950 -0
- package/cpp/api/recorder/ImageFilters.h +292 -0
- package/cpp/api/recorder/ImageFit.h +108 -0
- package/cpp/api/recorder/JsiRecorder.h +314 -0
- package/cpp/api/recorder/Paint.h +191 -0
- package/cpp/api/recorder/PathEffects.h +194 -0
- package/cpp/api/recorder/RNRecorder.h +637 -0
- package/cpp/api/recorder/Shaders.h +406 -0
- package/cpp/rnskia/dom/nodes/JsiAtlasNode.h +3 -2
- package/cpp/rnskia/dom/nodes/JsiImageNode.h +3 -2
- package/jestSetup.js +8 -0
- package/jestSetup.mjs +8 -0
- package/lib/commonjs/renderer/components/image/Image.d.ts +1 -1
- package/lib/commonjs/renderer/components/image/Image.js +8 -2
- package/lib/commonjs/renderer/components/image/Image.js.map +1 -1
- package/lib/commonjs/skia/types/Recorder.d.ts +52 -0
- package/lib/commonjs/skia/types/Recorder.js +6 -0
- package/lib/commonjs/skia/types/Recorder.js.map +1 -0
- package/lib/commonjs/skia/types/Skia.d.ts +2 -0
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/index.d.ts +1 -0
- package/lib/commonjs/skia/types/index.js +11 -0
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +3 -0
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/sksg/Container.d.ts +6 -1
- package/lib/commonjs/sksg/Container.js +59 -2
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/DrawingContext.js +1 -0
- package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +53 -0
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +189 -0
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +2 -2
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Visitor.d.ts +2 -2
- package/lib/commonjs/sksg/Recorder/Visitor.js +2 -2
- package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/module/renderer/components/image/Image.d.ts +1 -1
- package/lib/module/renderer/components/image/Image.js +8 -2
- package/lib/module/renderer/components/image/Image.js.map +1 -1
- package/lib/module/skia/types/Recorder.d.ts +52 -0
- package/lib/module/skia/types/Recorder.js +2 -0
- package/lib/module/skia/types/Recorder.js.map +1 -0
- package/lib/module/skia/types/Skia.d.ts +2 -0
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/index.d.ts +1 -0
- package/lib/module/skia/types/index.js +1 -0
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +3 -0
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/sksg/Container.d.ts +6 -1
- package/lib/module/sksg/Container.js +59 -2
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/Recorder/DrawingContext.js +1 -0
- package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +53 -0
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js +182 -0
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -0
- package/lib/module/sksg/Recorder/Recorder.d.ts +2 -2
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Visitor.d.ts +2 -2
- package/lib/module/sksg/Recorder/Visitor.js +2 -2
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/typescript/lib/commonjs/renderer/components/image/Image.d.ts +4 -1
- package/lib/typescript/lib/commonjs/skia/types/Recorder.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Container.d.ts +5 -1
- package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +6 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +47 -0
- package/lib/typescript/lib/module/mock/index.d.ts +4 -1
- package/lib/typescript/lib/module/renderer/components/image/Image.d.ts +4 -1
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Recorder.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Container.d.ts +5 -1
- package/lib/typescript/lib/module/sksg/Reconciler.d.ts +6 -0
- package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +46 -0
- package/lib/typescript/src/renderer/components/image/Image.d.ts +1 -1
- package/lib/typescript/src/skia/types/Recorder.d.ts +52 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
- package/lib/typescript/src/skia/types/index.d.ts +1 -0
- package/lib/typescript/src/sksg/Container.d.ts +6 -1
- package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +53 -0
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +2 -2
- package/lib/typescript/src/sksg/Recorder/Visitor.d.ts +2 -2
- package/package.json +3 -2
- package/src/renderer/components/image/Image.tsx +2 -2
- package/src/skia/types/Recorder.ts +91 -0
- package/src/skia/types/Skia.ts +2 -0
- package/src/skia/types/index.ts +1 -0
- package/src/skia/web/JsiSkia.ts +3 -0
- package/src/sksg/Container.ts +63 -4
- package/src/sksg/Recorder/DrawingContext.ts +1 -0
- package/src/sksg/Recorder/ReanimatedRecorder.ts +271 -0
- package/src/sksg/Recorder/Recorder.ts +2 -2
- package/src/sksg/Recorder/Visitor.ts +17 -12
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <optional>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <variant>
|
|
6
|
+
|
|
7
|
+
#include <include/core/SkSamplingOptions.h>
|
|
8
|
+
|
|
9
|
+
#include "Command.h"
|
|
10
|
+
#include "Convertor.h"
|
|
11
|
+
#include "DrawingCtx.h"
|
|
12
|
+
#include "ImageFit.h"
|
|
13
|
+
|
|
14
|
+
namespace RNSkia {
|
|
15
|
+
|
|
16
|
+
struct PushShaderProps : TransformProps {
|
|
17
|
+
sk_sp<SkRuntimeEffect> source;
|
|
18
|
+
Uniforms uniforms;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
class PushShaderCmd : public Command {
|
|
22
|
+
private:
|
|
23
|
+
PushShaderProps props;
|
|
24
|
+
|
|
25
|
+
public:
|
|
26
|
+
PushShaderCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
|
27
|
+
Variables &variables)
|
|
28
|
+
: Command(CommandType::PushShader, "skShader") {
|
|
29
|
+
convertProperty(runtime, object, "transform", props.transform, variables);
|
|
30
|
+
convertProperty(runtime, object, "origin", props.origin, variables);
|
|
31
|
+
convertProperty(runtime, object, "matrix", props.matrix, variables);
|
|
32
|
+
convertProperty(runtime, object, "source", props.source, variables);
|
|
33
|
+
convertProperty(runtime, object, "uniforms", props.uniforms, variables);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void pushShader(DrawingCtx *ctx) {
|
|
37
|
+
auto source = props.source;
|
|
38
|
+
auto uniforms = props.uniforms;
|
|
39
|
+
auto m3 = processTransform(props.matrix, props.transform, props.origin);
|
|
40
|
+
auto uniformsData = processUniforms(source, props.uniforms);
|
|
41
|
+
|
|
42
|
+
std::vector<sk_sp<SkShader>> children = ctx->popAllShaders();
|
|
43
|
+
auto shader = source->makeShader(std::move(uniformsData), children.data(),
|
|
44
|
+
children.size(), &m3);
|
|
45
|
+
|
|
46
|
+
ctx->shaders.push_back(shader);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
struct PushImageShaderProps : TransformProps {
|
|
51
|
+
SkTileMode tx;
|
|
52
|
+
SkTileMode ty;
|
|
53
|
+
float x = 0;
|
|
54
|
+
float y = 0;
|
|
55
|
+
std::optional<float> width;
|
|
56
|
+
std::optional<float> height;
|
|
57
|
+
std::optional<SkRect> rect;
|
|
58
|
+
std::string fit;
|
|
59
|
+
std::optional<sk_sp<SkImage>> image;
|
|
60
|
+
std::optional<SkSamplingOptions> sampling;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
class PushImageShaderCmd : public Command {
|
|
64
|
+
private:
|
|
65
|
+
PushImageShaderProps props;
|
|
66
|
+
|
|
67
|
+
public:
|
|
68
|
+
PushImageShaderCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
|
69
|
+
Variables &variables)
|
|
70
|
+
: Command(CommandType::PushShader, "skImageShader") {
|
|
71
|
+
convertProperty(runtime, object, "tx", props.tx, variables);
|
|
72
|
+
convertProperty(runtime, object, "ty", props.ty, variables);
|
|
73
|
+
convertProperty(runtime, object, "rect", props.rect, variables);
|
|
74
|
+
convertProperty(runtime, object, "image", props.image, variables);
|
|
75
|
+
convertProperty(runtime, object, "sampling", props.sampling, variables);
|
|
76
|
+
|
|
77
|
+
convertProperty(runtime, object, "transform", props.transform, variables);
|
|
78
|
+
convertProperty(runtime, object, "origin", props.origin, variables);
|
|
79
|
+
convertProperty(runtime, object, "matrix", props.matrix, variables);
|
|
80
|
+
|
|
81
|
+
convertProperty(runtime, object, "fit", props.fit, variables);
|
|
82
|
+
convertProperty(runtime, object, "x", props.x, variables);
|
|
83
|
+
convertProperty(runtime, object, "y", props.y, variables);
|
|
84
|
+
convertProperty(runtime, object, "width", props.width, variables);
|
|
85
|
+
convertProperty(runtime, object, "height", props.height, variables);
|
|
86
|
+
convertProperty(runtime, object, "rect", props.rect, variables);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
void pushShader(DrawingCtx *ctx) {
|
|
90
|
+
auto x = props.x;
|
|
91
|
+
auto y = props.y;
|
|
92
|
+
auto width = props.width;
|
|
93
|
+
auto height = props.height;
|
|
94
|
+
auto rect = props.rect;
|
|
95
|
+
if (props.image.has_value()) {
|
|
96
|
+
auto img = props.image.value();
|
|
97
|
+
SkMatrix m33;
|
|
98
|
+
auto hasRect =
|
|
99
|
+
rect.has_value() || (width.has_value() && height.has_value());
|
|
100
|
+
if (hasRect) {
|
|
101
|
+
auto src = SkRect::MakeXYWH(0, 0, img->width(), img->height());
|
|
102
|
+
auto dst = rect.has_value()
|
|
103
|
+
? rect.value()
|
|
104
|
+
: SkRect::MakeXYWH(x, y, width.value(), height.value());
|
|
105
|
+
auto rects = RNSkiaImage::fitRects(props.fit, src, dst);
|
|
106
|
+
auto m = RNSkiaImage::rect2rect(rects.src, rects.dst);
|
|
107
|
+
m33.preConcat(m);
|
|
108
|
+
}
|
|
109
|
+
SkMatrix lm;
|
|
110
|
+
lm.preConcat(m33);
|
|
111
|
+
auto m3 = processTransform(props.matrix, props.transform, props.origin);
|
|
112
|
+
lm.preConcat(m3);
|
|
113
|
+
auto shader = img->makeShader(
|
|
114
|
+
props.tx, props.ty,
|
|
115
|
+
props.sampling.value_or(SkSamplingOptions(SkFilterMode::kLinear)),
|
|
116
|
+
&lm);
|
|
117
|
+
ctx->shaders.push_back(shader);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
struct GradientProps : TransformProps {
|
|
123
|
+
std::vector<SkColor> colors;
|
|
124
|
+
std::optional<std::vector<float>> positions;
|
|
125
|
+
std::optional<SkTileMode> mode;
|
|
126
|
+
std::optional<uint32_t> flags;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
struct ColorShaderProps {
|
|
130
|
+
SkColor color;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
class ColorShaderCmd : public Command {
|
|
134
|
+
private:
|
|
135
|
+
ColorShaderProps props;
|
|
136
|
+
|
|
137
|
+
public:
|
|
138
|
+
ColorShaderCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
|
139
|
+
Variables &variables)
|
|
140
|
+
: Command(CommandType::PushShader, "skColorShader") {
|
|
141
|
+
convertProperty(runtime, object, "color", props.color, variables);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
void pushShader(DrawingCtx *ctx) {
|
|
145
|
+
auto shader = SkShaders::Color(props.color);
|
|
146
|
+
ctx->shaders.push_back(shader);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
struct TurbulenceProps {
|
|
151
|
+
float freqX;
|
|
152
|
+
float freqY;
|
|
153
|
+
int octaves;
|
|
154
|
+
float seed;
|
|
155
|
+
float tileWidth;
|
|
156
|
+
float tileHeight;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
class TurbulenceCmd : public Command {
|
|
160
|
+
private:
|
|
161
|
+
TurbulenceProps props;
|
|
162
|
+
|
|
163
|
+
public:
|
|
164
|
+
TurbulenceCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
|
165
|
+
Variables &variables)
|
|
166
|
+
: Command(CommandType::PushShader, "skTurbulence") {
|
|
167
|
+
convertProperty(runtime, object, "freqX", props.freqX, variables);
|
|
168
|
+
convertProperty(runtime, object, "freqY", props.freqY, variables);
|
|
169
|
+
convertProperty(runtime, object, "octaves", props.octaves, variables);
|
|
170
|
+
convertProperty(runtime, object, "seed", props.seed, variables);
|
|
171
|
+
convertProperty(runtime, object, "tileWidth", props.tileWidth, variables);
|
|
172
|
+
convertProperty(runtime, object, "tileHeight", props.tileHeight, variables);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
void pushShader(DrawingCtx *ctx) {
|
|
176
|
+
auto size = SkISize::Make(props.tileWidth, props.tileHeight);
|
|
177
|
+
auto shader = SkShaders::MakeTurbulence(props.freqX, props.freqY,
|
|
178
|
+
props.octaves, props.seed, &size);
|
|
179
|
+
ctx->shaders.push_back(shader);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
struct FractalNoiseProps {
|
|
184
|
+
float freqX;
|
|
185
|
+
float freqY;
|
|
186
|
+
int octaves;
|
|
187
|
+
float seed;
|
|
188
|
+
float tileWidth;
|
|
189
|
+
float tileHeight;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
class FractalNoiseCmd : public Command {
|
|
193
|
+
private:
|
|
194
|
+
FractalNoiseProps props;
|
|
195
|
+
|
|
196
|
+
public:
|
|
197
|
+
FractalNoiseCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
|
198
|
+
Variables &variables)
|
|
199
|
+
: Command(CommandType::PushShader, "skFractalNoise") {
|
|
200
|
+
convertProperty(runtime, object, "freqX", props.freqX, variables);
|
|
201
|
+
convertProperty(runtime, object, "freqY", props.freqY, variables);
|
|
202
|
+
convertProperty(runtime, object, "octaves", props.octaves, variables);
|
|
203
|
+
convertProperty(runtime, object, "seed", props.seed, variables);
|
|
204
|
+
convertProperty(runtime, object, "tileWidth", props.tileWidth, variables);
|
|
205
|
+
convertProperty(runtime, object, "tileHeight", props.tileHeight, variables);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
void pushShader(DrawingCtx *ctx) {
|
|
209
|
+
auto size = SkISize::Make(props.tileWidth, props.tileHeight);
|
|
210
|
+
auto shader = SkShaders::MakeFractalNoise(props.freqX, props.freqY,
|
|
211
|
+
props.octaves, props.seed, &size);
|
|
212
|
+
ctx->shaders.push_back(shader);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
struct LinearGradientProps : GradientProps {
|
|
217
|
+
SkPoint start;
|
|
218
|
+
SkPoint end;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
class LinearGradientCmd : public Command {
|
|
222
|
+
private:
|
|
223
|
+
LinearGradientProps props;
|
|
224
|
+
|
|
225
|
+
public:
|
|
226
|
+
LinearGradientCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
|
227
|
+
Variables &variables)
|
|
228
|
+
: Command(CommandType::PushShader, "skLinearGradient") {
|
|
229
|
+
convertProperty(runtime, object, "start", props.start, variables);
|
|
230
|
+
convertProperty(runtime, object, "end", props.end, variables);
|
|
231
|
+
convertProperty(runtime, object, "colors", props.colors, variables);
|
|
232
|
+
convertProperty(runtime, object, "positions", props.positions, variables);
|
|
233
|
+
convertProperty(runtime, object, "mode", props.mode, variables);
|
|
234
|
+
convertProperty(runtime, object, "flags", props.flags, variables);
|
|
235
|
+
|
|
236
|
+
convertProperty(runtime, object, "transform", props.transform, variables);
|
|
237
|
+
convertProperty(runtime, object, "origin", props.origin, variables);
|
|
238
|
+
convertProperty(runtime, object, "matrix", props.matrix, variables);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
void pushShader(DrawingCtx *ctx) {
|
|
242
|
+
SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
|
|
243
|
+
const SkPoint pts[2] = {props.start, props.end};
|
|
244
|
+
auto shader = SkGradientShader::MakeLinear(
|
|
245
|
+
pts, props.colors.data(),
|
|
246
|
+
props.positions ? props.positions->data() : nullptr,
|
|
247
|
+
props.colors.size(), props.mode.value_or(SkTileMode::kClamp),
|
|
248
|
+
props.flags.value_or(0), &m3);
|
|
249
|
+
ctx->shaders.push_back(shader);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
struct RadialGradientProps : GradientProps {
|
|
254
|
+
SkPoint center;
|
|
255
|
+
float radius;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
class RadialGradientCmd : public Command {
|
|
259
|
+
private:
|
|
260
|
+
RadialGradientProps props;
|
|
261
|
+
|
|
262
|
+
public:
|
|
263
|
+
RadialGradientCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
|
264
|
+
Variables &variables)
|
|
265
|
+
: Command(CommandType::PushShader, "skRadialGradient") {
|
|
266
|
+
convertProperty(runtime, object, "c", props.center, variables);
|
|
267
|
+
convertProperty(runtime, object, "r", props.radius, variables);
|
|
268
|
+
convertProperty(runtime, object, "colors", props.colors, variables);
|
|
269
|
+
convertProperty(runtime, object, "positions", props.positions, variables);
|
|
270
|
+
convertProperty(runtime, object, "mode", props.mode, variables);
|
|
271
|
+
convertProperty(runtime, object, "flags", props.flags, variables);
|
|
272
|
+
|
|
273
|
+
convertProperty(runtime, object, "transform", props.transform, variables);
|
|
274
|
+
convertProperty(runtime, object, "origin", props.origin, variables);
|
|
275
|
+
convertProperty(runtime, object, "matrix", props.matrix, variables);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
void pushShader(DrawingCtx *ctx) {
|
|
279
|
+
SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
|
|
280
|
+
auto shader = SkGradientShader::MakeRadial(
|
|
281
|
+
props.center, props.radius, props.colors.data(),
|
|
282
|
+
props.positions ? props.positions->data() : nullptr,
|
|
283
|
+
props.colors.size(), props.mode.value_or(SkTileMode::kClamp),
|
|
284
|
+
props.flags.value_or(0), &m3);
|
|
285
|
+
ctx->shaders.push_back(shader);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
struct SweepGradientProps : GradientProps {
|
|
290
|
+
SkPoint center;
|
|
291
|
+
std::optional<float> start;
|
|
292
|
+
std::optional<float> end;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
class SweepGradientCmd : public Command {
|
|
296
|
+
private:
|
|
297
|
+
SweepGradientProps props;
|
|
298
|
+
|
|
299
|
+
public:
|
|
300
|
+
SweepGradientCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
|
301
|
+
Variables &variables)
|
|
302
|
+
: Command(CommandType::PushShader, "skSweepGradient") {
|
|
303
|
+
convertProperty(runtime, object, "c", props.center, variables);
|
|
304
|
+
convertProperty(runtime, object, "start", props.start, variables);
|
|
305
|
+
convertProperty(runtime, object, "end", props.end, variables);
|
|
306
|
+
convertProperty(runtime, object, "colors", props.colors, variables);
|
|
307
|
+
convertProperty(runtime, object, "positions", props.positions, variables);
|
|
308
|
+
convertProperty(runtime, object, "mode", props.mode, variables);
|
|
309
|
+
convertProperty(runtime, object, "flags", props.flags, variables);
|
|
310
|
+
|
|
311
|
+
convertProperty(runtime, object, "transform", props.transform, variables);
|
|
312
|
+
convertProperty(runtime, object, "origin", props.origin, variables);
|
|
313
|
+
convertProperty(runtime, object, "matrix", props.matrix, variables);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
void pushShader(DrawingCtx *ctx) {
|
|
317
|
+
SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
|
|
318
|
+
auto shader = SkGradientShader::MakeSweep(
|
|
319
|
+
props.center.x(), props.center.y(), props.colors.data(),
|
|
320
|
+
props.positions ? props.positions->data() : nullptr,
|
|
321
|
+
props.colors.size(), props.mode.value_or(SkTileMode::kClamp),
|
|
322
|
+
props.start.value_or(0), props.end.value_or(360),
|
|
323
|
+
props.flags.value_or(0), &m3);
|
|
324
|
+
ctx->shaders.push_back(shader);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
struct TwoPointConicalGradientProps : GradientProps {
|
|
329
|
+
SkPoint start;
|
|
330
|
+
float startRadius;
|
|
331
|
+
SkPoint end;
|
|
332
|
+
float endRadius;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
class TwoPointConicalGradientCmd : public Command {
|
|
336
|
+
private:
|
|
337
|
+
TwoPointConicalGradientProps props;
|
|
338
|
+
|
|
339
|
+
public:
|
|
340
|
+
TwoPointConicalGradientCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
|
341
|
+
Variables &variables)
|
|
342
|
+
: Command(CommandType::PushShader, "skTwoPointConicalGradient") {
|
|
343
|
+
convertProperty(runtime, object, "start", props.start, variables);
|
|
344
|
+
convertProperty(runtime, object, "startR", props.startRadius, variables);
|
|
345
|
+
convertProperty(runtime, object, "end", props.end, variables);
|
|
346
|
+
convertProperty(runtime, object, "endR", props.endRadius, variables);
|
|
347
|
+
convertProperty(runtime, object, "colors", props.colors, variables);
|
|
348
|
+
convertProperty(runtime, object, "positions", props.positions, variables);
|
|
349
|
+
convertProperty(runtime, object, "mode", props.mode, variables);
|
|
350
|
+
convertProperty(runtime, object, "flags", props.flags, variables);
|
|
351
|
+
|
|
352
|
+
convertProperty(runtime, object, "transform", props.transform, variables);
|
|
353
|
+
convertProperty(runtime, object, "origin", props.origin, variables);
|
|
354
|
+
convertProperty(runtime, object, "matrix", props.matrix, variables);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
void pushShader(DrawingCtx *ctx) {
|
|
358
|
+
SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
|
|
359
|
+
auto shader = SkGradientShader::MakeTwoPointConical(
|
|
360
|
+
props.start, props.startRadius, props.end, props.endRadius,
|
|
361
|
+
props.colors.data(),
|
|
362
|
+
props.positions ? props.positions->data() : nullptr,
|
|
363
|
+
props.colors.size(), props.mode.value_or(SkTileMode::kClamp),
|
|
364
|
+
props.flags.value_or(0), &m3);
|
|
365
|
+
ctx->shaders.push_back(shader);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
struct BlendShaderProps {
|
|
370
|
+
SkBlendMode mode;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
class BlendShaderCmd : public Command {
|
|
374
|
+
private:
|
|
375
|
+
BlendShaderProps props;
|
|
376
|
+
|
|
377
|
+
public:
|
|
378
|
+
BlendShaderCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
|
379
|
+
Variables &variables)
|
|
380
|
+
: Command(CommandType::PushShader, "skBlendShader") {
|
|
381
|
+
convertProperty(runtime, object, "mode", props.mode, variables);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
void pushShader(DrawingCtx *ctx) {
|
|
385
|
+
// Get all existing shaders from the context
|
|
386
|
+
std::vector<sk_sp<SkShader>> shaders = ctx->popAllShaders();
|
|
387
|
+
|
|
388
|
+
// We need at least 2 shaders to blend
|
|
389
|
+
if (shaders.size() >= 2) {
|
|
390
|
+
// Start from the last shader and blend backwards
|
|
391
|
+
sk_sp<SkShader> blendedShader = shaders.back();
|
|
392
|
+
|
|
393
|
+
// Iterate from second-to-last to first shader
|
|
394
|
+
for (int i = shaders.size() - 2; i >= 0; i--) {
|
|
395
|
+
blendedShader = SkShaders::Blend(props.mode, shaders[i], blendedShader);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
ctx->shaders.push_back(blendedShader);
|
|
399
|
+
} else if (shaders.size() == 1) {
|
|
400
|
+
// If only one shader, just push it back
|
|
401
|
+
ctx->shaders.push_back(shaders[0]);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
} // namespace RNSkia
|
|
@@ -29,8 +29,9 @@ protected:
|
|
|
29
29
|
? *_blendModeProp->getDerivedValue()
|
|
30
30
|
: SkBlendMode::kDstOver;
|
|
31
31
|
auto paint = *context->getPaint();
|
|
32
|
-
auto sampling = _samplingProp->isSet()
|
|
33
|
-
|
|
32
|
+
auto sampling = _samplingProp->isSet()
|
|
33
|
+
? *_samplingProp->getDerivedValue()
|
|
34
|
+
: SkSamplingOptions(SkFilterMode::kLinear);
|
|
34
35
|
context->getCanvas()->drawAtlas(
|
|
35
36
|
image.get(), transforms->data(), sprites->data(),
|
|
36
37
|
colors == nullptr ? nullptr : colors->data(), sprites->size(),
|
|
@@ -21,8 +21,9 @@ protected:
|
|
|
21
21
|
if (image == nullptr) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
auto sampling = _samplingProp->isSet()
|
|
25
|
-
|
|
24
|
+
auto sampling = _samplingProp->isSet()
|
|
25
|
+
? *_samplingProp->getDerivedValue()
|
|
26
|
+
: SkSamplingOptions(SkFilterMode::kLinear);
|
|
26
27
|
context->getCanvas()->drawImageRect(image, rects->src, rects->dst, sampling,
|
|
27
28
|
context->getPaint().get(),
|
|
28
29
|
SkCanvas::kStrict_SrcRectConstraint);
|
package/jestSetup.js
CHANGED
|
@@ -12,6 +12,14 @@ jest.mock("@shopify/react-native-skia", () => {
|
|
|
12
12
|
View: Noop,
|
|
13
13
|
};
|
|
14
14
|
});
|
|
15
|
+
jest.mock("@shopify/react-native-skia/lib/commonjs/skia/core/Font", () => {
|
|
16
|
+
return {
|
|
17
|
+
useFont: () => null,
|
|
18
|
+
matchFont: () => null,
|
|
19
|
+
listFontFamilies: () => [],
|
|
20
|
+
useFonts: () => null,
|
|
21
|
+
}
|
|
22
|
+
});
|
|
15
23
|
return require("@shopify/react-native-skia/lib/commonjs/mock").Mock(
|
|
16
24
|
global.CanvasKit
|
|
17
25
|
);
|
package/jestSetup.mjs
CHANGED
|
@@ -18,5 +18,13 @@ jest.mock("@shopify/react-native-skia", () => {
|
|
|
18
18
|
View: Noop,
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
|
+
jest.mock("@shopify/react-native-skia/lib/commonjs/skia/core/Font", () => {
|
|
22
|
+
return {
|
|
23
|
+
useFont: () => null,
|
|
24
|
+
matchFont: () => null,
|
|
25
|
+
listFontFamilies: () => [],
|
|
26
|
+
useFonts: () => null,
|
|
27
|
+
}
|
|
28
|
+
});
|
|
21
29
|
return Mock(global.CanvasKit);
|
|
22
30
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { SkiaProps } from "../../processors";
|
|
3
3
|
import type { ImageProps } from "../../../dom/types";
|
|
4
|
-
export declare const Image: (props: SkiaProps<ImageProps>) => React.JSX.Element;
|
|
4
|
+
export declare const Image: ({ fit, ...props }: SkiaProps<ImageProps>) => React.JSX.Element;
|
|
@@ -6,8 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Image = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
10
|
+
const Image = ({
|
|
11
|
+
fit = "contain",
|
|
12
|
+
...props
|
|
13
|
+
}) => {
|
|
14
|
+
return /*#__PURE__*/_react.default.createElement("skImage", _extends({
|
|
15
|
+
fit: fit
|
|
16
|
+
}, props));
|
|
11
17
|
};
|
|
12
18
|
exports.Image = Image;
|
|
13
19
|
//# sourceMappingURL=Image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","e","__esModule","default","Image","props","createElement","exports"],"sources":["Image.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { SkiaProps } from \"../../processors\";\nimport type { ImageProps } from \"../../../dom/types\";\n\nexport const Image = (props: SkiaProps<ImageProps>) => {\n return <skImage {...props} />;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAKnB,
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","Image","fit","props","createElement","exports"],"sources":["Image.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { SkiaProps } from \"../../processors\";\nimport type { ImageProps } from \"../../../dom/types\";\n\nexport const Image = ({ fit = \"contain\", ...props }: SkiaProps<ImageProps>) => {\n return <skImage fit={fit} {...props} />;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,CAAA,aAAAP,CAAA,MAAAA,CAAA,GAAAQ,SAAA,CAAAC,MAAA,EAAAT,CAAA,UAAAU,CAAA,GAAAF,SAAA,CAAAR,CAAA,YAAAW,CAAA,IAAAD,CAAA,OAAAE,cAAA,CAAAC,IAAA,CAAAH,CAAA,EAAAC,CAAA,MAAAJ,CAAA,CAAAI,CAAA,IAAAD,CAAA,CAAAC,CAAA,aAAAJ,CAAA,KAAAJ,QAAA,CAAAW,KAAA,OAAAN,SAAA;AAKnB,MAAMO,KAAK,GAAGA,CAAC;EAAEC,GAAG,GAAG,SAAS;EAAE,GAAGC;AAA6B,CAAC,KAAK;EAC7E,oBAAOpB,MAAA,CAAAK,OAAA,CAAAgB,aAAA,YAAAf,QAAA;IAASa,GAAG,EAAEA;EAAI,GAAKC,KAAK,CAAG,CAAC;AACzC,CAAC;AAACE,OAAA,CAAAJ,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SharedValue } from "react-native-reanimated";
|
|
2
|
+
import type { TextProps, AtlasProps, BlurMaskFilterProps, BoxProps, BoxShadowProps, CircleProps, CTMProps, DiffRectProps, GlyphsProps, ImageProps, ImageSVGProps, LineProps, NodeType, OvalProps, PaintProps, ParagraphProps, PatchProps, PathProps, PictureProps, PointsProps, RectProps, RoundedRectProps, TextBlobProps, TextPathProps, VerticesProps } from "../../dom/types";
|
|
3
|
+
import type { AnimatedProps } from "../../renderer/processors/Animations/Animations";
|
|
4
|
+
import type { SkCanvas } from "./Canvas";
|
|
5
|
+
export interface BaseRecorder {
|
|
6
|
+
saveGroup(): void;
|
|
7
|
+
restoreGroup(): void;
|
|
8
|
+
savePaint(props: AnimatedProps<PaintProps>): void;
|
|
9
|
+
restorePaint(): void;
|
|
10
|
+
restorePaintDeclaration(): void;
|
|
11
|
+
materializePaint(): void;
|
|
12
|
+
pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;
|
|
13
|
+
pushImageFilter(imageFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
|
14
|
+
pushColorFilter(colorFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
|
15
|
+
pushShader(shaderType: NodeType, props: AnimatedProps<unknown>): void;
|
|
16
|
+
pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;
|
|
17
|
+
composePathEffect(): void;
|
|
18
|
+
composeColorFilter(): void;
|
|
19
|
+
composeImageFilter(): void;
|
|
20
|
+
saveCTM(props: AnimatedProps<CTMProps>): void;
|
|
21
|
+
restoreCTM(): void;
|
|
22
|
+
drawPaint(): void;
|
|
23
|
+
saveLayer(): void;
|
|
24
|
+
saveBackdropFilter(): void;
|
|
25
|
+
drawBox(boxProps: AnimatedProps<BoxProps>, shadows: {
|
|
26
|
+
props: BoxShadowProps;
|
|
27
|
+
animatedProps?: Record<string, SharedValue<unknown>>;
|
|
28
|
+
}[]): void;
|
|
29
|
+
drawImage(props: AnimatedProps<ImageProps>): void;
|
|
30
|
+
drawCircle(props: AnimatedProps<CircleProps>): void;
|
|
31
|
+
drawPoints(props: AnimatedProps<PointsProps>): void;
|
|
32
|
+
drawPath(props: AnimatedProps<PathProps>): void;
|
|
33
|
+
drawRect(props: AnimatedProps<RectProps>): void;
|
|
34
|
+
drawRRect(props: AnimatedProps<RoundedRectProps>): void;
|
|
35
|
+
drawOval(props: AnimatedProps<OvalProps>): void;
|
|
36
|
+
drawLine(props: AnimatedProps<LineProps>): void;
|
|
37
|
+
drawPatch(props: AnimatedProps<PatchProps>): void;
|
|
38
|
+
drawVertices(props: AnimatedProps<VerticesProps>): void;
|
|
39
|
+
drawDiffRect(props: AnimatedProps<DiffRectProps>): void;
|
|
40
|
+
drawText(props: AnimatedProps<TextProps>): void;
|
|
41
|
+
drawTextPath(props: AnimatedProps<TextPathProps>): void;
|
|
42
|
+
drawTextBlob(props: AnimatedProps<TextBlobProps>): void;
|
|
43
|
+
drawGlyphs(props: AnimatedProps<GlyphsProps>): void;
|
|
44
|
+
drawPicture(props: AnimatedProps<PictureProps>): void;
|
|
45
|
+
drawImageSVG(props: AnimatedProps<ImageSVGProps>): void;
|
|
46
|
+
drawParagraph(props: AnimatedProps<ParagraphProps>): void;
|
|
47
|
+
drawAtlas(props: AnimatedProps<AtlasProps>): void;
|
|
48
|
+
}
|
|
49
|
+
export interface JsiRecorder extends BaseRecorder {
|
|
50
|
+
play(canvas: SkCanvas): void;
|
|
51
|
+
applyUpdates(variables: SharedValue<unknown>[]): void;
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["Recorder.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n TextProps,\n AtlasProps,\n BlurMaskFilterProps,\n BoxProps,\n BoxShadowProps,\n CircleProps,\n CTMProps,\n DiffRectProps,\n GlyphsProps,\n ImageProps,\n ImageSVGProps,\n LineProps,\n NodeType,\n OvalProps,\n PaintProps,\n ParagraphProps,\n PatchProps,\n PathProps,\n PictureProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextBlobProps,\n TextPathProps,\n VerticesProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer/processors/Animations/Animations\";\n\nimport type { SkCanvas } from \"./Canvas\";\n\nexport interface BaseRecorder {\n saveGroup(): void;\n restoreGroup(): void;\n savePaint(props: AnimatedProps<PaintProps>): void;\n restorePaint(): void;\n restorePaintDeclaration(): void;\n materializePaint(): void;\n pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;\n pushImageFilter(\n imageFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void;\n pushColorFilter(\n colorFilterType: NodeType,\n props: AnimatedProps<unknown>\n ): void;\n pushShader(shaderType: NodeType, props: AnimatedProps<unknown>): void;\n pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;\n composePathEffect(): void;\n composeColorFilter(): void;\n composeImageFilter(): void;\n saveCTM(props: AnimatedProps<CTMProps>): void;\n restoreCTM(): void;\n drawPaint(): void;\n saveLayer(): void;\n saveBackdropFilter(): void;\n drawBox(\n boxProps: AnimatedProps<BoxProps>,\n shadows: {\n props: BoxShadowProps;\n animatedProps?: Record<string, SharedValue<unknown>>;\n }[]\n ): void;\n drawImage(props: AnimatedProps<ImageProps>): void;\n drawCircle(props: AnimatedProps<CircleProps>): void;\n drawPoints(props: AnimatedProps<PointsProps>): void;\n drawPath(props: AnimatedProps<PathProps>): void;\n drawRect(props: AnimatedProps<RectProps>): void;\n drawRRect(props: AnimatedProps<RoundedRectProps>): void;\n drawOval(props: AnimatedProps<OvalProps>): void;\n drawLine(props: AnimatedProps<LineProps>): void;\n drawPatch(props: AnimatedProps<PatchProps>): void;\n drawVertices(props: AnimatedProps<VerticesProps>): void;\n drawDiffRect(props: AnimatedProps<DiffRectProps>): void;\n drawText(props: AnimatedProps<TextProps>): void;\n drawTextPath(props: AnimatedProps<TextPathProps>): void;\n drawTextBlob(props: AnimatedProps<TextBlobProps>): void;\n drawGlyphs(props: AnimatedProps<GlyphsProps>): void;\n drawPicture(props: AnimatedProps<PictureProps>): void;\n drawImageSVG(props: AnimatedProps<ImageSVGProps>): void;\n drawParagraph(props: AnimatedProps<ParagraphProps>): void;\n drawAtlas(props: AnimatedProps<AtlasProps>): void;\n}\n\nexport interface JsiRecorder extends BaseRecorder {\n play(canvas: SkCanvas): void;\n applyUpdates(variables: SharedValue<unknown>[]): void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -28,6 +28,7 @@ import type { AnimatedImageFactory } from "./AnimatedImage";
|
|
|
28
28
|
import type { ParagraphBuilderFactory } from "./Paragraph/ParagraphBuilder";
|
|
29
29
|
import type { Video } from "./Video";
|
|
30
30
|
import type { NativeBufferFactory } from "./NativeBuffer";
|
|
31
|
+
import type { JsiRecorder } from "./Recorder";
|
|
31
32
|
export interface SkiaContext {
|
|
32
33
|
getSurface(): SkSurface;
|
|
33
34
|
present(): void;
|
|
@@ -80,4 +81,5 @@ export interface Skia {
|
|
|
80
81
|
Video: (url: string) => Promise<Video> | Video;
|
|
81
82
|
Context(surface: bigint, width: number, height: number): SkiaContext;
|
|
82
83
|
NativeBuffer: NativeBufferFactory;
|
|
84
|
+
Recorder(): JsiRecorder;
|
|
83
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkHostRect, SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SkSurface, SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\nimport type { ParagraphBuilderFactory } from \"./Paragraph/ParagraphBuilder\";\nimport type { Video } from \"./Video\";\nimport type { NativeBufferFactory } from \"./NativeBuffer\";\n\nexport interface SkiaContext {\n getSurface(): SkSurface;\n present(): void;\n}\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkHostRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n RSXformFromRadians: (\n scale: number,\n radians: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n ParagraphBuilder: ParagraphBuilderFactory;\n Video: (url: string) => Promise<Video> | Video;\n Context(surface: bigint, width: number, height: number): SkiaContext;\n NativeBuffer: NativeBufferFactory;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkHostRect, SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SkSurface, SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\nimport type { ParagraphBuilderFactory } from \"./Paragraph/ParagraphBuilder\";\nimport type { Video } from \"./Video\";\nimport type { NativeBufferFactory } from \"./NativeBuffer\";\nimport type { JsiRecorder } from \"./Recorder\";\n\nexport interface SkiaContext {\n getSurface(): SkSurface;\n present(): void;\n}\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkHostRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n RSXformFromRadians: (\n scale: number,\n radians: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n ParagraphBuilder: ParagraphBuilderFactory;\n Video: (url: string) => Promise<Video> | Video;\n Context(surface: bigint, width: number, height: number): SkiaContext;\n NativeBuffer: NativeBufferFactory;\n Recorder(): JsiRecorder;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -355,6 +355,17 @@ Object.keys(_NativeBuffer).forEach(function (key) {
|
|
|
355
355
|
}
|
|
356
356
|
});
|
|
357
357
|
});
|
|
358
|
+
var _Recorder = require("./Recorder");
|
|
359
|
+
Object.keys(_Recorder).forEach(function (key) {
|
|
360
|
+
if (key === "default" || key === "__esModule") return;
|
|
361
|
+
if (key in exports && exports[key] === _Recorder[key]) return;
|
|
362
|
+
Object.defineProperty(exports, key, {
|
|
363
|
+
enumerable: true,
|
|
364
|
+
get: function () {
|
|
365
|
+
return _Recorder[key];
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
});
|
|
358
369
|
var _Video = require("./Video");
|
|
359
370
|
Object.keys(_Video).forEach(function (key) {
|
|
360
371
|
if (key === "default" || key === "__esModule") return;
|