@shopify/react-native-skia 2.2.7 → 2.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +0 -11
- package/cpp/api/JsiSkParagraph.h +40 -8
- package/cpp/api/recorder/DrawingCtx.h +15 -0
- package/cpp/api/recorder/JsiRecorder.h +2 -1
- package/cpp/api/recorder/RNRecorder.h +2 -2
- package/cpp/api/recorder/Shaders.h +6 -5
- package/lib/commonjs/renderer/__tests__/e2e/ParagraphMethods.spec.d.ts +1 -0
- package/lib/commonjs/renderer/__tests__/e2e/setup/Paragraph.d.ts +1 -1
- package/lib/commonjs/skia/types/Paragraph/Paragraph.d.ts +31 -1
- package/lib/commonjs/skia/types/Paragraph/Paragraph.js.map +1 -1
- package/lib/commonjs/skia/types/Recorder.d.ts +1 -1
- package/lib/commonjs/skia/types/Recorder.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraph.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkParagraph.js +4 -18
- package/lib/commonjs/skia/web/JsiSkParagraph.js.map +1 -1
- package/lib/commonjs/sksg/Container.d.ts +2 -10
- package/lib/commonjs/sksg/Container.js +1 -78
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/Container.web.d.ts +14 -0
- package/lib/commonjs/sksg/Container.web.js +91 -0
- package/lib/commonjs/sksg/Container.web.js.map +1 -0
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +2 -2
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.js +3 -2
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Visitor.js +2 -2
- package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js +3 -3
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/module/renderer/__tests__/e2e/ParagraphMethods.spec.d.ts +1 -0
- package/lib/module/renderer/__tests__/e2e/setup/Paragraph.d.ts +1 -1
- package/lib/module/skia/types/Paragraph/Paragraph.d.ts +31 -1
- package/lib/module/skia/types/Paragraph/Paragraph.js.map +1 -1
- package/lib/module/skia/types/Recorder.d.ts +1 -1
- package/lib/module/skia/types/Recorder.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraph.d.ts +2 -2
- package/lib/module/skia/web/JsiSkParagraph.js +4 -18
- package/lib/module/skia/web/JsiSkParagraph.js.map +1 -1
- package/lib/module/sksg/Container.d.ts +2 -10
- package/lib/module/sksg/Container.js +2 -78
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/Container.web.d.ts +14 -0
- package/lib/module/sksg/Container.web.js +83 -0
- package/lib/module/sksg/Container.web.js.map +1 -0
- package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js +2 -2
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/module/sksg/Recorder/Recorder.js +3 -2
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Visitor.js +2 -2
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js +3 -3
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/typescript/lib/commonjs/sksg/Container.d.ts +1 -13
- package/lib/typescript/lib/commonjs/sksg/Container.web.d.ts +15 -0
- package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +1 -17
- package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Container.d.ts +1 -14
- package/lib/typescript/lib/module/sksg/Container.web.d.ts +15 -0
- package/lib/typescript/lib/module/sksg/Reconciler.d.ts +1 -17
- package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
- package/lib/typescript/src/renderer/__tests__/e2e/ParagraphMethods.spec.d.ts +1 -0
- package/lib/typescript/src/renderer/__tests__/e2e/setup/Paragraph.d.ts +1 -1
- package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +31 -1
- package/lib/typescript/src/skia/types/Recorder.d.ts +1 -1
- package/lib/typescript/src/skia/web/JsiSkParagraph.d.ts +2 -2
- package/lib/typescript/src/sksg/Container.d.ts +2 -10
- package/lib/typescript/src/sksg/Container.web.d.ts +14 -0
- package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +1 -1
- package/package.json +1 -1
- package/src/renderer/__tests__/e2e/ParagraphMethods.spec.tsx +383 -0
- package/src/renderer/__tests__/e2e/Shader.spec.tsx +93 -0
- package/src/skia/types/Paragraph/Paragraph.ts +32 -1
- package/src/skia/types/Recorder.ts +5 -1
- package/src/skia/web/JsiSkParagraph.ts +19 -28
- package/src/sksg/Container.ts +2 -81
- package/src/sksg/Container.web.ts +95 -0
- package/src/sksg/Recorder/ReanimatedRecorder.ts +6 -2
- package/src/sksg/Recorder/Recorder.ts +6 -2
- package/src/sksg/Recorder/Visitor.ts +2 -2
- package/src/sksg/Recorder/commands/Shaders.ts +8 -3
package/android/build.gradle
CHANGED
@@ -286,17 +286,6 @@ dependencies {
|
|
286
286
|
}
|
287
287
|
}
|
288
288
|
|
289
|
-
afterEvaluate { project ->
|
290
|
-
android.libraryVariants.all { variant ->
|
291
|
-
def name = variant.name.capitalize()
|
292
|
-
def javaCompileTask = variant.javaCompileProvider.get()
|
293
|
-
|
294
|
-
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
|
295
|
-
from javaCompileTask.destinationDir
|
296
|
-
}
|
297
|
-
}
|
298
|
-
}
|
299
|
-
|
300
289
|
def localBuildDir = buildDir
|
301
290
|
def headersConfiguration = configurations.extractHeaders
|
302
291
|
def jniConfiguration = configurations.extractJNI
|
package/cpp/api/JsiSkParagraph.h
CHANGED
@@ -95,15 +95,47 @@ public:
|
|
95
95
|
std::vector<para::LineMetrics> metrics;
|
96
96
|
getObject()->getLineMetrics(metrics);
|
97
97
|
auto returnValue = jsi::Array(runtime, metrics.size());
|
98
|
-
|
98
|
+
|
99
99
|
for (size_t i = 0; i < metrics.size(); ++i) {
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
100
|
+
auto lineMetrics = jsi::Object(runtime);
|
101
|
+
|
102
|
+
// Text indices
|
103
|
+
lineMetrics.setProperty(runtime, "startIndex",
|
104
|
+
static_cast<double>(metrics[i].fStartIndex));
|
105
|
+
lineMetrics.setProperty(runtime, "endIndex",
|
106
|
+
static_cast<double>(metrics[i].fEndIndex));
|
107
|
+
lineMetrics.setProperty(runtime, "endExcludingWhitespaces",
|
108
|
+
static_cast<double>(metrics[i].fEndExcludingWhitespaces));
|
109
|
+
lineMetrics.setProperty(runtime, "endIncludingNewline",
|
110
|
+
static_cast<double>(metrics[i].fEndIncludingNewline));
|
111
|
+
|
112
|
+
// Line break info
|
113
|
+
lineMetrics.setProperty(runtime, "isHardBreak",
|
114
|
+
metrics[i].fHardBreak);
|
115
|
+
|
116
|
+
// Vertical metrics
|
117
|
+
lineMetrics.setProperty(runtime, "ascent",
|
118
|
+
static_cast<double>(metrics[i].fAscent));
|
119
|
+
lineMetrics.setProperty(runtime, "descent",
|
120
|
+
static_cast<double>(metrics[i].fDescent));
|
121
|
+
lineMetrics.setProperty(runtime, "height",
|
122
|
+
static_cast<double>(metrics[i].fHeight));
|
123
|
+
|
124
|
+
// Horizontal metrics
|
125
|
+
lineMetrics.setProperty(runtime, "width",
|
126
|
+
static_cast<double>(metrics[i].fWidth));
|
127
|
+
lineMetrics.setProperty(runtime, "left",
|
128
|
+
static_cast<double>(metrics[i].fLeft));
|
129
|
+
|
130
|
+
// Position
|
131
|
+
lineMetrics.setProperty(runtime, "baseline",
|
132
|
+
static_cast<double>(metrics[i].fBaseline));
|
133
|
+
|
134
|
+
// Line number
|
135
|
+
lineMetrics.setProperty(runtime, "lineNumber",
|
136
|
+
static_cast<double>(metrics[i].fLineNumber));
|
137
|
+
|
138
|
+
returnValue.setValueAtIndex(runtime, i, lineMetrics);
|
107
139
|
}
|
108
140
|
return returnValue;
|
109
141
|
}
|
@@ -119,6 +119,21 @@ public:
|
|
119
119
|
return result;
|
120
120
|
}
|
121
121
|
|
122
|
+
std::vector<sk_sp<SkShader>> popShaders(int count) {
|
123
|
+
std::vector<sk_sp<SkShader>> result;
|
124
|
+
int actualCount = std::min(count, static_cast<int>(shaders.size()));
|
125
|
+
|
126
|
+
if (actualCount > 0) {
|
127
|
+
// Get the last 'actualCount' shaders
|
128
|
+
auto start = shaders.end() - actualCount;
|
129
|
+
result.assign(start, shaders.end());
|
130
|
+
// Remove them from the original vector
|
131
|
+
shaders.erase(start, shaders.end());
|
132
|
+
}
|
133
|
+
|
134
|
+
return result;
|
135
|
+
}
|
136
|
+
|
122
137
|
void composeImageFilter() {
|
123
138
|
if (imageFilters.size() >= 2) {
|
124
139
|
auto outer = imageFilters.back();
|
@@ -121,7 +121,8 @@ public:
|
|
121
121
|
JSI_HOST_FUNCTION(pushShader) {
|
122
122
|
getObject()->pushShader(runtime,
|
123
123
|
arguments[0].asString(runtime).utf8(runtime),
|
124
|
-
arguments[1].asObject(runtime)
|
124
|
+
arguments[1].asObject(runtime),
|
125
|
+
arguments[2].asNumber());
|
125
126
|
return jsi::Value::undefined();
|
126
127
|
}
|
127
128
|
|
@@ -35,10 +35,10 @@ public:
|
|
35
35
|
}
|
36
36
|
|
37
37
|
void pushShader(jsi::Runtime &runtime, const std::string &nodeType,
|
38
|
-
const jsi::Object &props) {
|
38
|
+
const jsi::Object &props, int children) {
|
39
39
|
if (nodeType == "skShader") {
|
40
40
|
commands.push_back(
|
41
|
-
std::make_unique<PushShaderCmd>(runtime, props, variables));
|
41
|
+
std::make_unique<PushShaderCmd>(runtime, props, variables, children));
|
42
42
|
} else if (nodeType == "skImageShader") {
|
43
43
|
commands.push_back(
|
44
44
|
std::make_unique<PushImageShaderCmd>(runtime, props, variables));
|
@@ -21,11 +21,12 @@ struct PushShaderProps : TransformProps {
|
|
21
21
|
class PushShaderCmd : public Command {
|
22
22
|
private:
|
23
23
|
PushShaderProps props;
|
24
|
+
int children;
|
24
25
|
|
25
26
|
public:
|
26
27
|
PushShaderCmd(jsi::Runtime &runtime, const jsi::Object &object,
|
27
|
-
Variables &variables)
|
28
|
-
: Command(CommandType::PushShader, "skShader") {
|
28
|
+
Variables &variables, int children)
|
29
|
+
: Command(CommandType::PushShader, "skShader"), children(children) {
|
29
30
|
convertProperty(runtime, object, "transform", props.transform, variables);
|
30
31
|
convertProperty(runtime, object, "origin", props.origin, variables);
|
31
32
|
convertProperty(runtime, object, "matrix", props.matrix, variables);
|
@@ -39,9 +40,9 @@ public:
|
|
39
40
|
auto m3 = processTransform(props.matrix, props.transform, props.origin);
|
40
41
|
auto uniformsData = processUniforms(source, props.uniforms);
|
41
42
|
|
42
|
-
std::vector<sk_sp<SkShader>>
|
43
|
-
auto shader = source->makeShader(std::move(uniformsData),
|
44
|
-
|
43
|
+
std::vector<sk_sp<SkShader>> childrenShaders = ctx->popShaders(children);
|
44
|
+
auto shader = source->makeShader(std::move(uniformsData), childrenShaders.data(),
|
45
|
+
childrenShaders.size(), &m3);
|
45
46
|
|
46
47
|
ctx->shaders.push_back(shader);
|
47
48
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -12,7 +12,7 @@ export declare class ParagraphAsset<Ctx extends EvalContext> extends SkiaObject<
|
|
12
12
|
getLongestLine(): number;
|
13
13
|
getGlyphPositionAtCoordinate(x: number, y: number): number;
|
14
14
|
getRectsForRange(start: number, end: number): import("../../../../skia/types").SkRect[];
|
15
|
-
getLineMetrics(): import("../../../../skia/types").
|
15
|
+
getLineMetrics(): import("../../../../skia/types").LineMetrics[];
|
16
16
|
getRectsForPlaceholders(): import("../../../../skia/types").SkRectWithDirection[];
|
17
17
|
__typename__: "Paragraph";
|
18
18
|
dispose(): void;
|
@@ -2,6 +2,36 @@ import type { SkCanvas } from "../Canvas";
|
|
2
2
|
import type { SkJSIInstance } from "../JsiInstance";
|
3
3
|
import type { SkRect } from "../Rect";
|
4
4
|
import type { TextDirection } from "./ParagraphStyle";
|
5
|
+
export interface LineMetrics {
|
6
|
+
/** The index in the text buffer the line begins. */
|
7
|
+
startIndex: number;
|
8
|
+
/** The index in the text buffer the line ends. */
|
9
|
+
endIndex: number;
|
10
|
+
endExcludingWhitespaces: number;
|
11
|
+
endIncludingNewline: number;
|
12
|
+
/** True if the line ends in a hard break (e.g. newline) */
|
13
|
+
isHardBreak: boolean;
|
14
|
+
/**
|
15
|
+
* The final computed ascent for the line. This can be impacted by
|
16
|
+
* the strut, height, scaling, as well as outlying runs that are very tall.
|
17
|
+
*/
|
18
|
+
ascent: number;
|
19
|
+
/**
|
20
|
+
* The final computed descent for the line. This can be impacted by
|
21
|
+
* the strut, height, scaling, as well as outlying runs that are very tall.
|
22
|
+
*/
|
23
|
+
descent: number;
|
24
|
+
/** round(ascent + descent) */
|
25
|
+
height: number;
|
26
|
+
/** width of the line */
|
27
|
+
width: number;
|
28
|
+
/** The left edge of the line. The right edge can be obtained with `left + width` */
|
29
|
+
left: number;
|
30
|
+
/** The y position of the baseline for this line from the top of the paragraph. */
|
31
|
+
baseline: number;
|
32
|
+
/** Zero indexed line number. */
|
33
|
+
lineNumber: number;
|
34
|
+
}
|
5
35
|
export interface SkRectWithDirection {
|
6
36
|
rect: SkRect;
|
7
37
|
direction: TextDirection;
|
@@ -70,7 +100,7 @@ export interface SkParagraph extends SkJSIInstance<"Paragraph"> {
|
|
70
100
|
* Returns the bounding boxes for all lines in the paragraph. This method
|
71
101
|
* requires the layout method to have been called first.
|
72
102
|
*/
|
73
|
-
getLineMetrics():
|
103
|
+
getLineMetrics(): LineMetrics[];
|
74
104
|
/**
|
75
105
|
* Returns a list of rects with direction info for the placeholders added
|
76
106
|
* to the paragraph.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["Paragraph.ts"],"sourcesContent":["import type { SkCanvas } from \"../Canvas\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkRect } from \"../Rect\";\n\nimport type { TextDirection } from \"./ParagraphStyle\";\n\nexport interface SkRectWithDirection {\n rect: SkRect;\n direction: TextDirection;\n}\n\nexport interface SkParagraph extends SkJSIInstance<\"Paragraph\"> {\n /**\n * Calculates the position of the the glyphs in the paragraph\n * @param width Max width of the paragraph\n */\n layout(width: number): void;\n /**\n * Paints the paragraph to the provded canvas\n * @param canvas Canvas to paint into\n * @param x X coordinate to paint at\n * @param y Y coordinate to paint at\n */\n paint(canvas: SkCanvas, x: number, y: number): void;\n /**\n * Returns the height of the paragraph. This method requires the layout\n * method to have been called first.\n */\n getHeight(): number;\n /**\n * Returns the max width of the paragraph. This method requires the layout\n * method to have been called first.\n */\n getMaxWidth(): number;\n /**\n * Returns the minimum intrinsic width of the paragraph.\n * The minimum intrinsic width is the width beyond which increasing the width of the paragraph\n * does not decrease the height. This is effectively the width at which the paragraph\n * can no longer wrap lines and is forced to overflow.\n * This method requires the layout method to have been called first.\n * @returns {number} The minimum intrinsic width of the paragraph.\n */\n getMinIntrinsicWidth(): number;\n /**\n * Returns the maximum intrinsic width of the paragraph.\n * The maximum intrinsic width is the width at which the paragraph can layout its content without line breaks,\n * meaning it's the width of the widest line or the widest word if the widest line is shorter than that.\n * This width represents the ideal width for the paragraph to display all content in a single line without overflow.\n * This method requires the layout method to have been called first.\n * @returns {number} The maximum intrinsic width of the paragraph.\n */\n getMaxIntrinsicWidth(): number;\n\n /**\n * Returns the width of the longest line in the paragraph.\n * This method requires the layout method to have been called first.\n */\n getLongestLine(): number;\n\n /**\n * Returns the index of the glyph at the given position. This method requires\n * the layout method to have been called first.\n * @param x X coordinate of the position\n * @param y Y coordinate of the position\n */\n getGlyphPositionAtCoordinate(x: number, y: number): number;\n /**\n * Returns the bounding boxes of the glyphs in the given range. This method\n * requires the layout method to have been called first.\n * @param start Start index of the range\n * @param end End index of the range\n */\n getRectsForRange(start: number, end: number): SkRect[];\n /**\n * Returns the bounding boxes for all lines in the paragraph. This method\n * requires the layout method to have been called first.\n */\n getLineMetrics():
|
1
|
+
{"version":3,"names":[],"sources":["Paragraph.ts"],"sourcesContent":["import type { SkCanvas } from \"../Canvas\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkRect } from \"../Rect\";\n\nimport type { TextDirection } from \"./ParagraphStyle\";\n\nexport interface LineMetrics {\n /** The index in the text buffer the line begins. */\n startIndex: number;\n /** The index in the text buffer the line ends. */\n endIndex: number;\n endExcludingWhitespaces: number;\n endIncludingNewline: number;\n /** True if the line ends in a hard break (e.g. newline) */\n isHardBreak: boolean;\n /**\n * The final computed ascent for the line. This can be impacted by\n * the strut, height, scaling, as well as outlying runs that are very tall.\n */\n ascent: number;\n /**\n * The final computed descent for the line. This can be impacted by\n * the strut, height, scaling, as well as outlying runs that are very tall.\n */\n descent: number;\n /** round(ascent + descent) */\n height: number;\n /** width of the line */\n width: number;\n /** The left edge of the line. The right edge can be obtained with `left + width` */\n left: number;\n /** The y position of the baseline for this line from the top of the paragraph. */\n baseline: number;\n /** Zero indexed line number. */\n lineNumber: number;\n}\n\nexport interface SkRectWithDirection {\n rect: SkRect;\n direction: TextDirection;\n}\n\nexport interface SkParagraph extends SkJSIInstance<\"Paragraph\"> {\n /**\n * Calculates the position of the the glyphs in the paragraph\n * @param width Max width of the paragraph\n */\n layout(width: number): void;\n /**\n * Paints the paragraph to the provded canvas\n * @param canvas Canvas to paint into\n * @param x X coordinate to paint at\n * @param y Y coordinate to paint at\n */\n paint(canvas: SkCanvas, x: number, y: number): void;\n /**\n * Returns the height of the paragraph. This method requires the layout\n * method to have been called first.\n */\n getHeight(): number;\n /**\n * Returns the max width of the paragraph. This method requires the layout\n * method to have been called first.\n */\n getMaxWidth(): number;\n /**\n * Returns the minimum intrinsic width of the paragraph.\n * The minimum intrinsic width is the width beyond which increasing the width of the paragraph\n * does not decrease the height. This is effectively the width at which the paragraph\n * can no longer wrap lines and is forced to overflow.\n * This method requires the layout method to have been called first.\n * @returns {number} The minimum intrinsic width of the paragraph.\n */\n getMinIntrinsicWidth(): number;\n /**\n * Returns the maximum intrinsic width of the paragraph.\n * The maximum intrinsic width is the width at which the paragraph can layout its content without line breaks,\n * meaning it's the width of the widest line or the widest word if the widest line is shorter than that.\n * This width represents the ideal width for the paragraph to display all content in a single line without overflow.\n * This method requires the layout method to have been called first.\n * @returns {number} The maximum intrinsic width of the paragraph.\n */\n getMaxIntrinsicWidth(): number;\n\n /**\n * Returns the width of the longest line in the paragraph.\n * This method requires the layout method to have been called first.\n */\n getLongestLine(): number;\n\n /**\n * Returns the index of the glyph at the given position. This method requires\n * the layout method to have been called first.\n * @param x X coordinate of the position\n * @param y Y coordinate of the position\n */\n getGlyphPositionAtCoordinate(x: number, y: number): number;\n /**\n * Returns the bounding boxes of the glyphs in the given range. This method\n * requires the layout method to have been called first.\n * @param start Start index of the range\n * @param end End index of the range\n */\n getRectsForRange(start: number, end: number): SkRect[];\n /**\n * Returns the bounding boxes for all lines in the paragraph. This method\n * requires the layout method to have been called first.\n */\n getLineMetrics(): LineMetrics[];\n /**\n * Returns a list of rects with direction info for the placeholders added\n * to the paragraph.\n */\n getRectsForPlaceholders(): SkRectWithDirection[];\n}\n"],"mappings":"","ignoreList":[]}
|
@@ -12,7 +12,7 @@ export interface BaseRecorder {
|
|
12
12
|
pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;
|
13
13
|
pushImageFilter(imageFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
14
14
|
pushColorFilter(colorFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
15
|
-
pushShader(shaderType: NodeType, props: AnimatedProps<unknown
|
15
|
+
pushShader(shaderType: NodeType, props: AnimatedProps<unknown>, children: number): void;
|
16
16
|
pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;
|
17
17
|
composePathEffect(): void;
|
18
18
|
composeColorFilter(): void;
|
@@ -1 +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 SkottieProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer/processors/Animations/Animations\";\n\nimport type { SkPicture } from \"./Picture\";\n\nexport interface BaseRecorder {\n saveGroup(): void;\n restoreGroup(): void;\n savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): 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
|
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 SkottieProps,\n} from \"../../dom/types\";\nimport type { AnimatedProps } from \"../../renderer/processors/Animations/Animations\";\n\nimport type { SkPicture } from \"./Picture\";\n\nexport interface BaseRecorder {\n saveGroup(): void;\n restoreGroup(): void;\n savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): 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(\n shaderType: NodeType,\n props: AnimatedProps<unknown>,\n children: number\n ): 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 drawSkottie(props: AnimatedProps<SkottieProps>): void;\n drawAtlas(props: AnimatedProps<AtlasProps>): void;\n}\n\nexport interface JsiRecorder extends BaseRecorder {\n play(): SkPicture;\n applyUpdates(variables: SharedValue<unknown>[]): void;\n}\n"],"mappings":"","ignoreList":[]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { CanvasKit, Paragraph } from "canvaskit-wasm";
|
2
|
-
import type { SkRect, SkRectWithDirection, SkParagraph } from "../types";
|
2
|
+
import type { SkRect, SkRectWithDirection, SkParagraph, LineMetrics } from "../types";
|
3
3
|
import { HostObject } from "./Host";
|
4
4
|
import type { JsiSkCanvas } from "./JsiSkCanvas";
|
5
5
|
export declare class JsiSkParagraph extends HostObject<Paragraph, "Paragraph"> implements SkParagraph {
|
@@ -14,6 +14,6 @@ export declare class JsiSkParagraph extends HostObject<Paragraph, "Paragraph"> i
|
|
14
14
|
getGlyphPositionAtCoordinate(x: number, y: number): number;
|
15
15
|
getRectsForPlaceholders(): SkRectWithDirection[];
|
16
16
|
getRectsForRange(start: number, end: number): SkRect[];
|
17
|
-
getLineMetrics():
|
17
|
+
getLineMetrics(): LineMetrics[];
|
18
18
|
dispose(): void;
|
19
19
|
}
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.JsiSkParagraph = void 0;
|
7
7
|
var _Host = require("./Host");
|
8
|
+
var _JsiSkRect = require("./JsiSkRect");
|
8
9
|
class JsiSkParagraph extends _Host.HostObject {
|
9
10
|
constructor(CanvasKit, ref) {
|
10
11
|
super(CanvasKit, ref, "Paragraph");
|
@@ -38,12 +39,7 @@ class JsiSkParagraph extends _Host.HostObject {
|
|
38
39
|
rect,
|
39
40
|
dir
|
40
41
|
}) => ({
|
41
|
-
rect:
|
42
|
-
x: rect.at(0),
|
43
|
-
y: rect.at(1),
|
44
|
-
width: rect.at(2),
|
45
|
-
height: rect.at(3)
|
46
|
-
},
|
42
|
+
rect: new _JsiSkRect.JsiSkRect(this.CanvasKit, rect),
|
47
43
|
direction: dir.value
|
48
44
|
}));
|
49
45
|
}
|
@@ -54,20 +50,10 @@ class JsiSkParagraph extends _Host.HostObject {
|
|
54
50
|
value: 0
|
55
51
|
} /** kTight */).map(({
|
56
52
|
rect
|
57
|
-
}) => (
|
58
|
-
x: rect[0],
|
59
|
-
y: rect[1],
|
60
|
-
width: rect[2],
|
61
|
-
height: rect[3]
|
62
|
-
}));
|
53
|
+
}) => new _JsiSkRect.JsiSkRect(this.CanvasKit, rect));
|
63
54
|
}
|
64
55
|
getLineMetrics() {
|
65
|
-
return this.ref.getLineMetrics()
|
66
|
-
x: r.left,
|
67
|
-
y: index * r.height,
|
68
|
-
width: r.width,
|
69
|
-
height: r.height
|
70
|
-
}));
|
56
|
+
return this.ref.getLineMetrics();
|
71
57
|
}
|
72
58
|
dispose() {
|
73
59
|
this.ref.delete();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_Host","require","JsiSkParagraph","HostObject","constructor","CanvasKit","ref","getMinIntrinsicWidth","getMaxIntrinsicWidth","getLongestLine","layout","width","paint","canvas","x","y","drawParagraph","getHeight","getMaxWidth","getGlyphPositionAtCoordinate","pos","getRectsForPlaceholders","map","rect","dir","
|
1
|
+
{"version":3,"names":["_Host","require","_JsiSkRect","JsiSkParagraph","HostObject","constructor","CanvasKit","ref","getMinIntrinsicWidth","getMaxIntrinsicWidth","getLongestLine","layout","width","paint","canvas","x","y","drawParagraph","getHeight","getMaxWidth","getGlyphPositionAtCoordinate","pos","getRectsForPlaceholders","map","rect","dir","JsiSkRect","direction","value","getRectsForRange","start","end","getLineMetrics","dispose","delete","exports"],"sources":["JsiSkParagraph.ts"],"sourcesContent":["import type { CanvasKit, Paragraph } from \"canvaskit-wasm\";\n\nimport type {\n SkRect,\n SkRectWithDirection,\n SkParagraph,\n LineMetrics,\n} from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport type { JsiSkCanvas } from \"./JsiSkCanvas\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkParagraph\n extends HostObject<Paragraph, \"Paragraph\">\n implements SkParagraph\n{\n constructor(CanvasKit: CanvasKit, ref: Paragraph) {\n super(CanvasKit, ref, \"Paragraph\");\n }\n getMinIntrinsicWidth() {\n return this.ref.getMinIntrinsicWidth();\n }\n\n getMaxIntrinsicWidth() {\n return this.ref.getMaxIntrinsicWidth();\n }\n\n getLongestLine() {\n return this.ref.getLongestLine();\n }\n\n layout(width: number) {\n this.ref.layout(width);\n }\n paint(canvas: JsiSkCanvas, x: number, y: number) {\n canvas.ref.drawParagraph(this.ref, x, y);\n }\n getHeight() {\n return this.ref.getHeight();\n }\n getMaxWidth() {\n return this.ref.getMaxWidth();\n }\n getGlyphPositionAtCoordinate(x: number, y: number) {\n return this.ref.getGlyphPositionAtCoordinate(x, y).pos;\n }\n getRectsForPlaceholders(): SkRectWithDirection[] {\n return this.ref.getRectsForPlaceholders().map(({ rect, dir }) => ({\n rect: new JsiSkRect(this.CanvasKit, rect),\n direction: dir.value,\n }));\n }\n getRectsForRange(start: number, end: number): SkRect[] {\n return this.ref\n .getRectsForRange(\n start,\n end,\n { value: 0 } /** kTight */,\n { value: 0 } /** kTight */\n )\n .map(({ rect }) => new JsiSkRect(this.CanvasKit, rect));\n }\n getLineMetrics(): LineMetrics[] {\n return this.ref.getLineMetrics();\n }\n\n dispose() {\n this.ref.delete();\n }\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,IAAIE,oBAAS,CAAC,IAAI,CAACpB,SAAS,EAAEkB,IAAI,CAAC;MACzCG,SAAS,EAAEF,GAAG,CAACG;IACjB,CAAC,CAAC,CAAC;EACL;EACAC,gBAAgBA,CAACC,KAAa,EAAEC,GAAW,EAAY;IACrD,OAAO,IAAI,CAACxB,GAAG,CACZsB,gBAAgB,CACfC,KAAK,EACLC,GAAG,EACH;MAAEH,KAAK,EAAE;IAAE,CAAC,CAAC,eACb;MAAEA,KAAK,EAAE;IAAE,CAAC,CAAC,aACf,CAAC,CACAL,GAAG,CAAC,CAAC;MAAEC;IAAK,CAAC,KAAK,IAAIE,oBAAS,CAAC,IAAI,CAACpB,SAAS,EAAEkB,IAAI,CAAC,CAAC;EAC3D;EACAQ,cAAcA,CAAA,EAAkB;IAC9B,OAAO,IAAI,CAACzB,GAAG,CAACyB,cAAc,CAAC,CAAC;EAClC;EAEAC,OAAOA,CAAA,EAAG;IACR,IAAI,CAAC1B,GAAG,CAAC2B,MAAM,CAAC,CAAC;EACnB;AACF;AAACC,OAAA,CAAAhC,cAAA,GAAAA,cAAA","ignoreList":[]}
|
@@ -1,12 +1,4 @@
|
|
1
1
|
import type { SharedValue } from "react-native-reanimated";
|
2
2
|
import type { Skia, SkSize } from "../skia/types";
|
3
|
-
import {
|
4
|
-
declare
|
5
|
-
private nativeId;
|
6
|
-
private onSize?;
|
7
|
-
private mapperId;
|
8
|
-
constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
|
9
|
-
redraw(): void;
|
10
|
-
}
|
11
|
-
export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer | ReanimatedContainer;
|
12
|
-
export {};
|
3
|
+
import { StaticContainer } from "./StaticContainer";
|
4
|
+
export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer;
|
@@ -4,86 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createContainer = void 0;
|
7
|
-
var _ReanimatedProxy = _interopRequireDefault(require("../external/reanimated/ReanimatedProxy"));
|
8
|
-
var _renderHelpers = require("../external/reanimated/renderHelpers");
|
9
|
-
var _Recorder = require("./Recorder/Recorder");
|
10
|
-
var _Visitor = require("./Recorder/Visitor");
|
11
|
-
var _Player = require("./Recorder/Player");
|
12
|
-
var _DrawingContext = require("./Recorder/DrawingContext");
|
13
7
|
var _StaticContainer = require("./StaticContainer");
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
15
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
16
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
17
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
18
|
-
const drawOnscreen = (Skia, nativeId, recording, onSize) => {
|
19
|
-
"worklet";
|
20
|
-
|
21
|
-
if (onSize) {
|
22
|
-
const size = SkiaViewApi.size(nativeId);
|
23
|
-
if (size.width !== onSize.value.width || size.height !== onSize.value.height) {
|
24
|
-
onSize.value = size;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
const rec = Skia.PictureRecorder();
|
28
|
-
const canvas = rec.beginRecording();
|
29
|
-
//const start = performance.now();
|
30
|
-
|
31
|
-
const ctx = (0, _DrawingContext.createDrawingContext)(Skia, recording.paintPool, canvas);
|
32
|
-
(0, _Player.replay)(ctx, recording.commands);
|
33
|
-
const picture = rec.finishRecordingAsPicture();
|
34
|
-
//const end = performance.now();
|
35
|
-
//console.log("Recording time: ", end - start);
|
36
|
-
SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
|
37
|
-
};
|
38
|
-
class ReanimatedContainer extends _StaticContainer.Container {
|
39
|
-
constructor(Skia, nativeId, onSize) {
|
40
|
-
super(Skia);
|
41
|
-
this.nativeId = nativeId;
|
42
|
-
this.onSize = onSize;
|
43
|
-
_defineProperty(this, "mapperId", null);
|
44
|
-
}
|
45
|
-
redraw() {
|
46
|
-
if (this.mapperId !== null) {
|
47
|
-
_ReanimatedProxy.default.stopMapper(this.mapperId);
|
48
|
-
}
|
49
|
-
if (this.unmounted) {
|
50
|
-
return;
|
51
|
-
}
|
52
|
-
const recorder = new _Recorder.Recorder();
|
53
|
-
(0, _Visitor.visit)(recorder, this.root);
|
54
|
-
const record = recorder.getRecording();
|
55
|
-
const {
|
56
|
-
animationValues
|
57
|
-
} = record;
|
58
|
-
this.recording = {
|
59
|
-
commands: record.commands,
|
60
|
-
paintPool: record.paintPool
|
61
|
-
};
|
62
|
-
const {
|
63
|
-
nativeId,
|
64
|
-
Skia,
|
65
|
-
recording
|
66
|
-
} = this;
|
67
|
-
if (animationValues.size > 0) {
|
68
|
-
this.mapperId = _ReanimatedProxy.default.startMapper(() => {
|
69
|
-
"worklet";
|
70
|
-
|
71
|
-
drawOnscreen(Skia, nativeId, recording);
|
72
|
-
}, Array.from(animationValues));
|
73
|
-
}
|
74
|
-
_ReanimatedProxy.default.runOnUI(onSize => {
|
75
|
-
"worklet";
|
76
|
-
|
77
|
-
drawOnscreen(Skia, nativeId, recording, onSize);
|
78
|
-
})(this.onSize);
|
79
|
-
}
|
80
|
-
}
|
81
8
|
const createContainer = (Skia, nativeId, onSize) => {
|
82
|
-
|
83
|
-
return new ReanimatedContainer(Skia, nativeId, onSize);
|
84
|
-
} else {
|
85
|
-
return new _StaticContainer.StaticContainer(Skia, nativeId);
|
86
|
-
}
|
9
|
+
return new _StaticContainer.StaticContainer(Skia, nativeId, onSize);
|
87
10
|
};
|
88
11
|
exports.createContainer = createContainer;
|
89
12
|
//# sourceMappingURL=Container.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_StaticContainer","require","createContainer","Skia","nativeId","onSize","StaticContainer","exports"],"sources":["Container.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport type { Skia, SkSize } from \"../skia/types\";\n\nimport { StaticContainer } from \"./StaticContainer\";\n\nexport const createContainer = (\n Skia: Skia,\n nativeId: number,\n onSize?: SharedValue<SkSize>\n) => {\n return new StaticContainer(Skia, nativeId, onSize);\n};\n"],"mappings":";;;;;;AAIA,IAAAA,gBAAA,GAAAC,OAAA;AAEO,MAAMC,eAAe,GAAGA,CAC7BC,IAAU,EACVC,QAAgB,EAChBC,MAA4B,KACzB;EACH,OAAO,IAAIC,gCAAe,CAACH,IAAI,EAAEC,QAAQ,EAAEC,MAAM,CAAC;AACpD,CAAC;AAACE,OAAA,CAAAL,eAAA,GAAAA,eAAA","ignoreList":[]}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { SharedValue } from "react-native-reanimated";
|
2
|
+
import type { Skia, SkSize } from "../skia/types";
|
3
|
+
import { Container, StaticContainer } from "./StaticContainer";
|
4
|
+
import "../skia/NativeSetup";
|
5
|
+
import "../views/api";
|
6
|
+
declare class ReanimatedContainer extends Container {
|
7
|
+
private nativeId;
|
8
|
+
private onSize?;
|
9
|
+
private mapperId;
|
10
|
+
constructor(Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize> | undefined);
|
11
|
+
redraw(): void;
|
12
|
+
}
|
13
|
+
export declare const createContainer: (Skia: Skia, nativeId: number, onSize?: SharedValue<SkSize>) => StaticContainer | ReanimatedContainer;
|
14
|
+
export {};
|
@@ -0,0 +1,91 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.createContainer = void 0;
|
7
|
+
var _ReanimatedProxy = _interopRequireDefault(require("../external/reanimated/ReanimatedProxy"));
|
8
|
+
var _renderHelpers = require("../external/reanimated/renderHelpers");
|
9
|
+
var _Recorder = require("./Recorder/Recorder");
|
10
|
+
var _Visitor = require("./Recorder/Visitor");
|
11
|
+
var _Player = require("./Recorder/Player");
|
12
|
+
var _DrawingContext = require("./Recorder/DrawingContext");
|
13
|
+
var _StaticContainer = require("./StaticContainer");
|
14
|
+
require("../skia/NativeSetup");
|
15
|
+
require("../views/api");
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
17
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
19
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
20
|
+
const drawOnscreen = (Skia, nativeId, recording, onSize) => {
|
21
|
+
"worklet";
|
22
|
+
|
23
|
+
if (onSize) {
|
24
|
+
const size = SkiaViewApi.size(nativeId);
|
25
|
+
if (size.width !== onSize.value.width || size.height !== onSize.value.height) {
|
26
|
+
onSize.value = size;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
const rec = Skia.PictureRecorder();
|
30
|
+
const canvas = rec.beginRecording();
|
31
|
+
//const start = performance.now();
|
32
|
+
|
33
|
+
const ctx = (0, _DrawingContext.createDrawingContext)(Skia, recording.paintPool, canvas);
|
34
|
+
(0, _Player.replay)(ctx, recording.commands);
|
35
|
+
const picture = rec.finishRecordingAsPicture();
|
36
|
+
//const end = performance.now();
|
37
|
+
//console.log("Recording time: ", end - start);
|
38
|
+
SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
|
39
|
+
};
|
40
|
+
class ReanimatedContainer extends _StaticContainer.Container {
|
41
|
+
constructor(Skia, nativeId, onSize) {
|
42
|
+
super(Skia);
|
43
|
+
this.nativeId = nativeId;
|
44
|
+
this.onSize = onSize;
|
45
|
+
_defineProperty(this, "mapperId", null);
|
46
|
+
}
|
47
|
+
redraw() {
|
48
|
+
if (this.mapperId !== null) {
|
49
|
+
_ReanimatedProxy.default.stopMapper(this.mapperId);
|
50
|
+
}
|
51
|
+
if (this.unmounted) {
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
const recorder = new _Recorder.Recorder();
|
55
|
+
(0, _Visitor.visit)(recorder, this.root);
|
56
|
+
const record = recorder.getRecording();
|
57
|
+
const {
|
58
|
+
animationValues
|
59
|
+
} = record;
|
60
|
+
this.recording = {
|
61
|
+
commands: record.commands,
|
62
|
+
paintPool: record.paintPool
|
63
|
+
};
|
64
|
+
const {
|
65
|
+
nativeId,
|
66
|
+
Skia,
|
67
|
+
recording
|
68
|
+
} = this;
|
69
|
+
if (animationValues.size > 0) {
|
70
|
+
this.mapperId = _ReanimatedProxy.default.startMapper(() => {
|
71
|
+
"worklet";
|
72
|
+
|
73
|
+
drawOnscreen(Skia, nativeId, recording);
|
74
|
+
}, Array.from(animationValues));
|
75
|
+
}
|
76
|
+
_ReanimatedProxy.default.runOnUI(onSize => {
|
77
|
+
"worklet";
|
78
|
+
|
79
|
+
drawOnscreen(Skia, nativeId, recording, onSize);
|
80
|
+
})(this.onSize);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
const createContainer = (Skia, nativeId, onSize) => {
|
84
|
+
if (_renderHelpers.HAS_REANIMATED_3 && nativeId !== -1) {
|
85
|
+
return new ReanimatedContainer(Skia, nativeId, onSize);
|
86
|
+
} else {
|
87
|
+
return new _StaticContainer.StaticContainer(Skia, nativeId);
|
88
|
+
}
|
89
|
+
};
|
90
|
+
exports.createContainer = createContainer;
|
91
|
+
//# sourceMappingURL=Container.web.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_ReanimatedProxy","_interopRequireDefault","require","_renderHelpers","_Recorder","_Visitor","_Player","_DrawingContext","_StaticContainer","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","drawOnscreen","Skia","nativeId","recording","onSize","size","SkiaViewApi","width","height","rec","PictureRecorder","canvas","beginRecording","ctx","createDrawingContext","paintPool","replay","commands","picture","finishRecordingAsPicture","setJsiProperty","ReanimatedContainer","Container","constructor","redraw","mapperId","Rea","stopMapper","unmounted","recorder","Recorder","visit","root","record","getRecording","animationValues","startMapper","Array","from","runOnUI","createContainer","HAS_REANIMATED_3","StaticContainer","exports"],"sources":["Container.web.ts"],"sourcesContent":["import type { SharedValue } from \"react-native-reanimated\";\n\nimport Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkSize } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\n\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\nconst drawOnscreen = (\n Skia: Skia,\n nativeId: number,\n recording: Recording,\n onSize?: SharedValue<SkSize>\n) => {\n \"worklet\";\n if (onSize) {\n const size = SkiaViewApi.size(nativeId);\n if (\n size.width !== onSize.value.width ||\n size.height !== onSize.value.height\n ) {\n onSize.value = size;\n }\n }\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n replay(ctx, recording.commands);\n const picture = rec.finishRecordingAsPicture();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number,\n private onSize?: SharedValue<SkSize>\n ) {\n super(Skia);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI((onSize?: SharedValue<SkSize>) => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!, onSize);\n })(this.onSize);\n }\n}\n\nexport const createContainer = (\n Skia: Skia,\n nativeId: number,\n onSize?: SharedValue<SkSize>\n) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new ReanimatedContainer(Skia, nativeId, onSize);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AAEAA,OAAA;AACAA,OAAA;AAAsB,SAAAD,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAA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AAe,CAAC,CAAC;IACjC;IACAT,wBAAG,CAACa,OAAO,CAAEnC,MAA4B,IAAK;MAC5C,SAAS;;MACTJ,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,EAAGC,MAAM,CAAC;IAClD,CAAC,CAAC,CAAC,IAAI,CAACA,MAAM,CAAC;EACjB;AACF;AAEO,MAAMoC,eAAe,GAAGA,CAC7BvC,IAAU,EACVC,QAAgB,EAChBE,MAA4B,KACzB;EACH,IAAIqC,+BAAgB,IAAIvC,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAImB,mBAAmB,CAACpB,IAAI,EAAEC,QAAQ,EAAEE,MAAM,CAAC;EACxD,CAAC,MAAM;IACL,OAAO,IAAIsC,gCAAe,CAACzC,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC;AAACyC,OAAA,CAAAH,eAAA,GAAAA,eAAA","ignoreList":[]}
|
@@ -18,7 +18,7 @@ export declare class ReanimatedRecorder implements BaseRecorder {
|
|
18
18
|
pushPathEffect(pathEffectType: NodeType, props: AnimatedProps<unknown>): void;
|
19
19
|
pushImageFilter(imageFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
20
20
|
pushColorFilter(colorFilterType: NodeType, props: AnimatedProps<unknown>): void;
|
21
|
-
pushShader(shaderType: NodeType, props: AnimatedProps<unknown
|
21
|
+
pushShader(shaderType: NodeType, props: AnimatedProps<unknown>, children: number): void;
|
22
22
|
pushBlurMaskFilter(props: AnimatedProps<BlurMaskFilterProps>): void;
|
23
23
|
composePathEffect(): void;
|
24
24
|
composeColorFilter(): void;
|
@@ -64,9 +64,9 @@ class ReanimatedRecorder {
|
|
64
64
|
this.processAnimationValues(props);
|
65
65
|
this.recorder.pushColorFilter(colorFilterType, props);
|
66
66
|
}
|
67
|
-
pushShader(shaderType, props) {
|
67
|
+
pushShader(shaderType, props, children) {
|
68
68
|
this.processAnimationValues(props);
|
69
|
-
this.recorder.pushShader(shaderType, props);
|
69
|
+
this.recorder.pushShader(shaderType, props, children);
|
70
70
|
}
|
71
71
|
pushBlurMaskFilter(props) {
|
72
72
|
this.processAnimationValues(props);
|