@shopify/react-native-skia 1.12.3 → 1.12.4
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 +15 -11
- package/cpp/api/JsiSkCanvas.h +45 -2
- package/cpp/api/recorder/Drawings.h +31 -2
- package/cpp/api/recorder/Shaders.h +40 -0
- package/lib/commonjs/renderer/Canvas.d.ts +1 -2
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Player.d.ts +1 -1
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Box.js +2 -2
- package/lib/commonjs/sksg/Recorder/commands/Box.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +1 -3
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +1 -58
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +1 -2
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/sksg/Recorder/Player.d.ts +1 -1
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Box.js +2 -2
- package/lib/module/sksg/Recorder/commands/Box.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.d.ts +1 -3
- package/lib/module/sksg/Recorder/commands/Drawing.js +2 -58
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +0 -1
- package/lib/typescript/lib/module/sksg/Recorder/commands/Drawing.d.ts +0 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +1 -2
- package/lib/typescript/src/sksg/Recorder/Player.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +1 -3
- package/package.json +1 -1
- package/src/__tests__/snapshots/box/box-shadow-opacity.png +0 -0
- package/src/renderer/Canvas.tsx +1 -1
- package/src/renderer/__tests__/e2e/Box.spec.tsx +22 -0
- package/src/sksg/Recorder/Player.ts +1 -1
- package/src/sksg/Recorder/commands/Box.ts +2 -2
- package/src/sksg/Recorder/commands/Drawing.ts +0 -65
package/android/build.gradle
CHANGED
@@ -19,7 +19,7 @@ import java.nio.file.Paths
|
|
19
19
|
// the minimum React Native version supported.
|
20
20
|
def DEFAULT_COMPILE_SDK_VERSION = 28
|
21
21
|
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
|
22
|
-
def DEFAULT_MIN_SDK_VERSION =
|
22
|
+
def DEFAULT_MIN_SDK_VERSION = 21
|
23
23
|
def DEFAULT_TARGET_SDK_VERSION = 28
|
24
24
|
|
25
25
|
def safeExtGet(prop, fallback) {
|
@@ -295,13 +295,17 @@ afterEvaluate { project ->
|
|
295
295
|
}
|
296
296
|
}
|
297
297
|
|
298
|
+
def localBuildDir = buildDir
|
299
|
+
def headersConfiguration = configurations.extractHeaders
|
300
|
+
def jniConfiguration = configurations.extractJNI
|
301
|
+
|
298
302
|
task extractAARHeaders {
|
299
303
|
doLast {
|
300
|
-
|
301
|
-
def
|
302
|
-
copy {
|
303
|
-
from zipTree(
|
304
|
-
into "$
|
304
|
+
headersConfiguration.files.each { file ->
|
305
|
+
def absFile = file.absoluteFile
|
306
|
+
project.copy {
|
307
|
+
from project.zipTree(absFile)
|
308
|
+
into "${localBuildDir}/${absFile.name}"
|
305
309
|
include "**/*.h"
|
306
310
|
}
|
307
311
|
}
|
@@ -310,11 +314,11 @@ task extractAARHeaders {
|
|
310
314
|
|
311
315
|
task extractJNIFiles {
|
312
316
|
doLast {
|
313
|
-
|
314
|
-
def
|
315
|
-
copy {
|
316
|
-
from zipTree(
|
317
|
-
into "$
|
317
|
+
jniConfiguration.files.each { file ->
|
318
|
+
def absFile = file.absoluteFile
|
319
|
+
project.copy {
|
320
|
+
from project.zipTree(absFile)
|
321
|
+
into "${localBuildDir}/${absFile.name}"
|
318
322
|
include "jni/**/*"
|
319
323
|
}
|
320
324
|
}
|
package/cpp/api/JsiSkCanvas.h
CHANGED
@@ -243,6 +243,12 @@ public:
|
|
243
243
|
|
244
244
|
auto jsiPoints = arguments[1].asObject(runtime).asArray(runtime);
|
245
245
|
auto pointsSize = jsiPoints.size(runtime);
|
246
|
+
|
247
|
+
// Check if we have at least one point
|
248
|
+
if (pointsSize == 0) {
|
249
|
+
throw std::invalid_argument("Points array must not be empty");
|
250
|
+
}
|
251
|
+
|
246
252
|
points.reserve(pointsSize);
|
247
253
|
|
248
254
|
for (int i = 0; i < pointsSize; i++) {
|
@@ -274,6 +280,12 @@ public:
|
|
274
280
|
|
275
281
|
auto jsiCubics = arguments[0].asObject(runtime).asArray(runtime);
|
276
282
|
auto cubicsSize = jsiCubics.size(runtime);
|
283
|
+
|
284
|
+
// Validate cubic points - must be exactly 12 points
|
285
|
+
if (cubicsSize != 12) {
|
286
|
+
throw std::invalid_argument("Cubic points array must contain exactly 12 points");
|
287
|
+
}
|
288
|
+
|
277
289
|
cubics.reserve(cubicsSize);
|
278
290
|
for (int i = 0; i < cubicsSize; i++) {
|
279
291
|
std::shared_ptr<SkPoint> point = JsiSkPoint::fromValue(
|
@@ -284,6 +296,12 @@ public:
|
|
284
296
|
if (count >= 2 && !arguments[1].isNull() && !arguments[1].isUndefined()) {
|
285
297
|
auto jsiColors = arguments[1].asObject(runtime).asArray(runtime);
|
286
298
|
auto colorsSize = jsiColors.size(runtime);
|
299
|
+
|
300
|
+
// Validate colors array - must be exactly 4 colors
|
301
|
+
if (colorsSize != 4) {
|
302
|
+
throw std::invalid_argument("Colors array must contain exactly 4 colors");
|
303
|
+
}
|
304
|
+
|
287
305
|
colors.reserve(colorsSize);
|
288
306
|
for (int i = 0; i < colorsSize; i++) {
|
289
307
|
SkColor color = JsiSkColor::fromValue(
|
@@ -295,6 +313,12 @@ public:
|
|
295
313
|
if (count >= 3 && !arguments[2].isNull() && !arguments[2].isUndefined()) {
|
296
314
|
auto jsiTexs = arguments[2].asObject(runtime).asArray(runtime);
|
297
315
|
auto texsSize = jsiTexs.size(runtime);
|
316
|
+
|
317
|
+
// Validate textures array - must be exactly 4 points
|
318
|
+
if (texsSize != 4) {
|
319
|
+
throw std::invalid_argument("Texture coordinates array must contain exactly 4 points");
|
320
|
+
}
|
321
|
+
|
298
322
|
texs.reserve(texsSize);
|
299
323
|
for (int i = 0; i < texsSize; i++) {
|
300
324
|
auto point = JsiSkPoint::fromValue(
|
@@ -306,7 +330,8 @@ public:
|
|
306
330
|
auto paint =
|
307
331
|
count >= 4 ? JsiSkPaint::fromValue(runtime, arguments[4]) : nullptr;
|
308
332
|
auto blendMode = static_cast<SkBlendMode>(arguments[3].asNumber());
|
309
|
-
_canvas->drawPatch(cubics.data(), colors.
|
333
|
+
_canvas->drawPatch(cubics.data(), colors.empty() ? nullptr : colors.data(),
|
334
|
+
texs.empty() ? nullptr : texs.data(), blendMode,
|
310
335
|
*paint);
|
311
336
|
return jsi::Value::undefined();
|
312
337
|
}
|
@@ -364,6 +389,12 @@ public:
|
|
364
389
|
|
365
390
|
std::vector<SkGlyphID> glyphs;
|
366
391
|
int glyphsSize = static_cast<int>(jsiGlyphs.size(runtime));
|
392
|
+
|
393
|
+
// Validate that glyphs and positions arrays have the same size
|
394
|
+
if (glyphsSize != pointsSize) {
|
395
|
+
throw std::invalid_argument("Glyphs and positions arrays must have the same length");
|
396
|
+
}
|
397
|
+
|
367
398
|
glyphs.reserve(glyphsSize);
|
368
399
|
for (int i = 0; i < glyphsSize; i++) {
|
369
400
|
glyphs.push_back(jsiGlyphs.getValueAtIndex(runtime, i).asNumber());
|
@@ -522,11 +553,22 @@ public:
|
|
522
553
|
runtime, rects.getValueAtIndex(runtime, i).asObject(runtime));
|
523
554
|
skRects.push_back(*rect.get());
|
524
555
|
}
|
556
|
+
|
557
|
+
// Validate transforms and rects have the same size
|
558
|
+
if (xformsSize != rectsSize) {
|
559
|
+
throw std::invalid_argument("Transforms and rects arrays must have the same length");
|
560
|
+
}
|
525
561
|
|
526
562
|
std::vector<SkColor> colors;
|
527
563
|
if (count > 5 && !arguments[5].isUndefined()) {
|
528
564
|
auto colorsArray = arguments[5].asObject(runtime).asArray(runtime);
|
529
565
|
int colorsSize = static_cast<int>(colorsArray.size(runtime));
|
566
|
+
|
567
|
+
// Validate colors array matches the size of sprites and transforms
|
568
|
+
if (colorsSize != rectsSize) {
|
569
|
+
throw std::invalid_argument("Colors array must have the same length as rects/transforms");
|
570
|
+
}
|
571
|
+
|
530
572
|
colors.reserve(colorsSize);
|
531
573
|
for (int i = 0; i < colorsSize; i++) {
|
532
574
|
// Convert from [r,g,b,a] in [0,1] to SkColor
|
@@ -551,7 +593,8 @@ public:
|
|
551
593
|
sampling = SamplingOptionsFromValue(runtime, arguments[6]);
|
552
594
|
}
|
553
595
|
_canvas->drawAtlas(atlas.get(), xforms.data(), skRects.data(),
|
554
|
-
colors.
|
596
|
+
colors.empty() ? nullptr : colors.data(),
|
597
|
+
skRects.size(), blendMode, sampling,
|
555
598
|
nullptr, paint.get());
|
556
599
|
|
557
600
|
return jsi::Value::undefined();
|
@@ -418,7 +418,7 @@ public:
|
|
418
418
|
SkPaint shadowPaint;
|
419
419
|
shadowPaint.setAntiAlias(true);
|
420
420
|
shadowPaint.setColor(shadow.color.value_or(SK_ColorBLACK));
|
421
|
-
shadowPaint.setAlphaf(opacity);
|
421
|
+
shadowPaint.setAlphaf(opacity * shadowPaint.getAlphaf());
|
422
422
|
shadowPaint.setMaskFilter(SkMaskFilter::MakeBlur(
|
423
423
|
SkBlurStyle::kNormal_SkBlurStyle, shadow.blur, true));
|
424
424
|
|
@@ -442,7 +442,7 @@ public:
|
|
442
442
|
SkPaint shadowPaint;
|
443
443
|
shadowPaint.setAntiAlias(true);
|
444
444
|
shadowPaint.setColor(shadow.color.value_or(SK_ColorBLACK));
|
445
|
-
shadowPaint.setAlphaf(opacity);
|
445
|
+
shadowPaint.setAlphaf(opacity * shadowPaint.getAlphaf());
|
446
446
|
shadowPaint.setMaskFilter(SkMaskFilter::MakeBlur(
|
447
447
|
SkBlurStyle::kNormal_SkBlurStyle, shadow.blur, true));
|
448
448
|
|
@@ -637,6 +637,16 @@ public:
|
|
637
637
|
}
|
638
638
|
|
639
639
|
void draw(DrawingCtx *ctx) {
|
640
|
+
// Validate colors array has exactly 4 colors if provided
|
641
|
+
if (props.colors.has_value() && props.colors.value().size() != 4) {
|
642
|
+
throw std::invalid_argument("Colors array for patch must have exactly 4 colors");
|
643
|
+
}
|
644
|
+
|
645
|
+
// Validate texture array has exactly 4 points if provided
|
646
|
+
if (props.texture.has_value() && props.texture.value().size() != 4) {
|
647
|
+
throw std::invalid_argument("Texture coordinates array for patch must have exactly 4 points");
|
648
|
+
}
|
649
|
+
|
640
650
|
// Determine default blend mode based on presence of colors
|
641
651
|
SkBlendMode defaultBlendMode = props.colors.has_value()
|
642
652
|
? SkBlendMode::kDstOver
|
@@ -676,6 +686,15 @@ public:
|
|
676
686
|
}
|
677
687
|
|
678
688
|
void draw(DrawingCtx *ctx) {
|
689
|
+
// Validate array sizes
|
690
|
+
if (props.colors.has_value() && props.colors.value().size() != props.vertices.size()) {
|
691
|
+
throw std::invalid_argument("Colors array must have the same size as vertices array");
|
692
|
+
}
|
693
|
+
|
694
|
+
if (props.textures.has_value() && props.textures.value().size() != props.vertices.size()) {
|
695
|
+
throw std::invalid_argument("Textures array must have the same size as vertices array");
|
696
|
+
}
|
697
|
+
|
679
698
|
// Create vertices using MakeCopy
|
680
699
|
auto vertices = SkVertices::MakeCopy(
|
681
700
|
props.mode, static_cast<int>(props.vertices.size()),
|
@@ -909,6 +928,16 @@ public:
|
|
909
928
|
|
910
929
|
void draw(DrawingCtx *ctx) {
|
911
930
|
if (props.image) {
|
931
|
+
// Validate transforms and sprites have the same size
|
932
|
+
if (props.transforms.size() != props.sprites.size()) {
|
933
|
+
throw std::invalid_argument("transforms and sprites arrays must have the same length");
|
934
|
+
}
|
935
|
+
|
936
|
+
// Validate colors array matches if provided
|
937
|
+
if (props.colors.has_value() && props.colors.value().size() != props.transforms.size()) {
|
938
|
+
throw std::invalid_argument("colors array must have the same length as transforms/sprites");
|
939
|
+
}
|
940
|
+
|
912
941
|
auto colors =
|
913
942
|
props.colors.has_value() ? props.colors.value().data() : nullptr;
|
914
943
|
auto blendMode = props.blendMode.value_or(SkBlendMode::kDstOver);
|
@@ -239,6 +239,16 @@ public:
|
|
239
239
|
}
|
240
240
|
|
241
241
|
void pushShader(DrawingCtx *ctx) {
|
242
|
+
// Validate colors array has at least 2 colors
|
243
|
+
if (props.colors.size() < 2) {
|
244
|
+
throw std::invalid_argument("Colors array must have at least 2 colors");
|
245
|
+
}
|
246
|
+
|
247
|
+
// Validate positions array matches colors array in size
|
248
|
+
if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
|
249
|
+
throw std::invalid_argument("Positions array must have the same size as colors array");
|
250
|
+
}
|
251
|
+
|
242
252
|
SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
|
243
253
|
const SkPoint pts[2] = {props.start, props.end};
|
244
254
|
auto shader = SkGradientShader::MakeLinear(
|
@@ -276,6 +286,16 @@ public:
|
|
276
286
|
}
|
277
287
|
|
278
288
|
void pushShader(DrawingCtx *ctx) {
|
289
|
+
// Validate colors array has at least 2 colors
|
290
|
+
if (props.colors.size() < 2) {
|
291
|
+
throw std::invalid_argument("Colors array must have at least 2 colors");
|
292
|
+
}
|
293
|
+
|
294
|
+
// Validate positions array matches colors array in size
|
295
|
+
if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
|
296
|
+
throw std::invalid_argument("Positions array must have the same size as colors array");
|
297
|
+
}
|
298
|
+
|
279
299
|
SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
|
280
300
|
auto shader = SkGradientShader::MakeRadial(
|
281
301
|
props.center, props.radius, props.colors.data(),
|
@@ -314,6 +334,16 @@ public:
|
|
314
334
|
}
|
315
335
|
|
316
336
|
void pushShader(DrawingCtx *ctx) {
|
337
|
+
// Validate colors array has at least 2 colors
|
338
|
+
if (props.colors.size() < 2) {
|
339
|
+
throw std::invalid_argument("Colors array must have at least 2 colors");
|
340
|
+
}
|
341
|
+
|
342
|
+
// Validate positions array matches colors array in size
|
343
|
+
if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
|
344
|
+
throw std::invalid_argument("Positions array must have the same size as colors array");
|
345
|
+
}
|
346
|
+
|
317
347
|
SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
|
318
348
|
auto shader = SkGradientShader::MakeSweep(
|
319
349
|
props.center.x(), props.center.y(), props.colors.data(),
|
@@ -355,6 +385,16 @@ public:
|
|
355
385
|
}
|
356
386
|
|
357
387
|
void pushShader(DrawingCtx *ctx) {
|
388
|
+
// Validate colors array has at least 2 colors
|
389
|
+
if (props.colors.size() < 2) {
|
390
|
+
throw std::invalid_argument("Colors array must have at least 2 colors");
|
391
|
+
}
|
392
|
+
|
393
|
+
// Validate positions array matches colors array in size
|
394
|
+
if (props.positions.has_value() && props.positions.value().size() != props.colors.size()) {
|
395
|
+
throw std::invalid_argument("Positions array must have the same size as colors array");
|
396
|
+
}
|
397
|
+
|
358
398
|
SkMatrix m3 = processTransform(props.matrix, props.transform, props.origin);
|
359
399
|
auto shader = SkGradientShader::MakeTwoPointConical(
|
360
400
|
props.start, props.startRadius, props.end, props.endRadius,
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
3
3
|
import type { ViewProps } from "react-native";
|
4
4
|
import type { SharedValue } from "react-native-reanimated";
|
5
5
|
import type { SkImage, SkRect, SkSize } from "../skia/types";
|
6
|
-
interface CanvasRef extends FC<CanvasProps> {
|
6
|
+
export interface CanvasRef extends FC<CanvasProps> {
|
7
7
|
makeImageSnapshot(rect?: SkRect): SkImage;
|
8
8
|
makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;
|
9
9
|
redraw(): void;
|
@@ -17,4 +17,3 @@ export interface CanvasProps extends ViewProps {
|
|
17
17
|
mode?: "continuous" | "default";
|
18
18
|
}
|
19
19
|
export declare const Canvas: React.ForwardRefExoticComponent<CanvasProps & React.RefAttributes<unknown>>;
|
20
|
-
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","NativeSkiaPictureView","SkiaPictureViewNativeComponent","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","forwardRef","mode","debug","opaque","children","onSize","_onLayout","viewProps","ref","rafId","nativeId","useMemo","SkiaViewNativeId","current","root","SkiaSGRoot","Skia","useLayoutEffect","render","useEffect","unmount","requestRedraw","requestAnimationFrame","console","warn","cancelAnimationFrame","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","getNativeId","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\n\
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_SkiaViewNativeId","_SkiaPictureViewNativeComponent","_interopRequireDefault","_Reconciler","_skia","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","useCanvasRef","useRef","exports","NativeSkiaPictureView","SkiaPictureViewNativeComponent","useOnSizeEvent","resultValue","onLayout","useCallback","event","width","height","nativeEvent","layout","value","Canvas","forwardRef","mode","debug","opaque","children","onSize","_onLayout","viewProps","ref","rafId","nativeId","useMemo","SkiaViewNativeId","current","root","SkiaSGRoot","Skia","useLayoutEffect","render","useEffect","unmount","requestRedraw","requestAnimationFrame","console","warn","cancelAnimationFrame","useImperativeHandle","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","getNativeId","createElement","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\n\nexport interface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n mode?: \"continuous\" | \"default\";\n}\n\nexport const Canvas = forwardRef(\n (\n {\n mode,\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n ...viewProps\n }: CanvasProps,\n ref\n ) => {\n const rafId = useRef<number | null>(null);\n const onLayout = useOnSizeEvent(onSize, _onLayout);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n // Render effects\n useLayoutEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n const requestRedraw = useCallback(() => {\n rafId.current = requestAnimationFrame(() => {\n root.render(children);\n if (mode === \"continuous\") {\n requestRedraw();\n }\n });\n }, [children, mode, root]);\n\n useEffect(() => {\n if (mode === \"continuous\") {\n console.warn(\"The `mode` property in `Canvas` is deprecated.\");\n requestRedraw();\n }\n return () => {\n if (rafId.current !== null) {\n cancelAnimationFrame(rafId.current);\n }\n };\n }, [mode, requestRedraw]);\n // Component methods\n useImperativeHandle(ref, () => ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n }));\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n }\n);\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBA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AAO,KAAK,IAAI,EAAE;QAC1BY,oBAAoB,CAAChB,KAAK,CAACI,OAAO,CAAC;MACrC;IACF,CAAC;EACH,CAAC,EAAE,CAACZ,IAAI,EAAEoB,aAAa,CAAC,CAAC;EACzB;EACA,IAAAK,0BAAmB,EAAClB,GAAG,EAAE,OAAO;IAC9BmB,iBAAiB,EAAGC,IAAa,IAAK;MACpC,OAAOC,WAAW,CAACF,iBAAiB,CAACjB,QAAQ,EAAEkB,IAAI,CAAC;IACtD,CAAC;IACDE,sBAAsB,EAAGF,IAAa,IAAK;MACzC,OAAOC,WAAW,CAACC,sBAAsB,CAACpB,QAAQ,EAAEkB,IAAI,CAAC;IAC3D,CAAC;IACDG,MAAM,EAAEA,CAAA,KAAM;MACZF,WAAW,CAACR,aAAa,CAACX,QAAQ,CAAC;IACrC,CAAC;IACDsB,WAAW,EAAEA,CAAA,KAAM;MACjB,OAAOtB,QAAQ;IACjB;EACF,CAAC,CAAC,CAAC;EACH,oBACE5D,MAAA,CAAAU,OAAA,CAAAyE,aAAA,CAAC9C,qBAAqB,EAAAT,QAAA;IACpBwD,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGzB,QAAQ,EAAG;IACxBR,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfZ,QAAQ,EAAEA;EAAS,GACfgB,SAAS,CACd,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_Drawing","require","_Box","_ColorFilters","_CTM","_ImageFilters","_Paint","_PathEffects","_Shaders","_Core","play","ctx","_command","isGroup","children","forEach","child","command","materializeCommand","isCommand","CommandType","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","isDrawCommand","SavePaint","props","paints","push","savePaint","setPaintProperties","Skia","RestorePaint","restorePaint","ComposeColorFilter","composeColorFilters","RestorePaintDeclaration","Error","MaterializePaint","isPushColorFilter","pushColorFilter","isPushShader","pushShader","isPushImageFilter","pushImageFilter","isPushPathEffect","pushPathEffect","ComposePathEffect","composePathEffects","ComposeImageFilter","composeImageFilters","PushBlurMaskFilter","setBlurMaskFilter","SaveCTM","saveCTM","RestoreCTM","restore","p","isBoxCommand","drawBox","DrawPaint","drawPaint","DrawImage","drawImage","DrawCircle","drawCircle","DrawPoints","drawPoints","DrawPath","drawPath","DrawRect","drawRect","DrawRRect","drawRRect","DrawOval","drawOval","DrawLine","drawLine","DrawPatch","drawPatch","DrawVertices","drawVertices","DrawDiffRect","drawDiffRect","DrawText","drawText","DrawTextPath","drawTextPath","DrawTextBlob","drawTextBlob","DrawGlyphs","drawGlyphs","DrawPicture","drawPicture","DrawImageSVG","drawImageSVG","DrawParagraph","drawParagraph","DrawAtlas","drawAtlas","console","warn","type","replay","commands","exports"],"sources":["Player.ts"],"sourcesContent":["import {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n isGroup,\n materializeCommand,\n type Command,\n} from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nfunction play(ctx: DrawingContext, _command: Command) {\n \"worklet\";\n if (isGroup(_command)) {\n _command.children.forEach((child) => play(ctx, child));\n return;\n }\n const command = materializeCommand(_command);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n ctx.savePaint();\n setPaintProperties(ctx.Skia, ctx.paint, command.props);\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n const paints = [ctx.paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n}\n\nexport const replay = (ctx: DrawingContext, commands: Command[]) => {\n \"worklet\";\n commands.forEach((command) => {\n play(ctx, command);\n });\n};\n"],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,GAAG,EAAEM,OAAO,CAACe,KAAK,CAAC;MAChC,CAAC,MAAM,IAAI,IAAAF,mBAAa,EAACb,OAAO,EAAEG,iBAAW,CAAC8E,WAAW,CAAC,EAAE;QAC1D,IAAAC,oBAAW,EAACxF,GAAG,EAAEM,OAAO,CAACe,KAAK,CAAC;MACjC,CAAC,MAAM,IAAI,IAAAF,mBAAa,EAACb,OAAO,EAAEG,iBAAW,CAACgF,YAAY,CAAC,EAAE;QAC3D,IAAAC,qBAAY,EAAC1F,GAAG,EAAEM,OAAO,CAACe,KAAK,CAAC;MAClC,CAAC,MAAM,IAAI,IAAAF,mBAAa,EAACb,OAAO,EAAEG,iBAAW,CAACkF,aAAa,CAAC,EAAE;QAC5D,IAAAC,sBAAa,EAAC5F,GAAG,EAAEM,OAAO,CAACe,KAAK,CAAC;MACnC,CAAC,MAAM,IAAI,IAAAF,mBAAa,EAACb,OAAO,EAAEG,iBAAW,CAACoF,SAAS,CAAC,EAAE;QACxD,IAAAC,kBAAS,EAAC9F,GAAG,EAAEM,OAAO,CAACe,KAAK,CAAC;MAC/B,CAAC,MAAM;QACL0E,OAAO,CAACC,IAAI,CAAC,oBAAoB1F,OAAO,CAAC2F,IAAI,EAAE,CAAC;MAClD;MACAjG,GAAG,CAACsB,MAAM,CAACN,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC;EACJ;AACF;AAEO,MAAMkF,MAAM,GAAGA,CAAClG,GAAmB,EAAEmG,QAAmB,KAAK;EAClE,SAAS;;EACTA,QAAQ,CAAC/F,OAAO,CAAEE,OAAO,IAAK;IAC5BP,IAAI,CAACC,GAAG,EAAEM,OAAO,CAAC;EACpB,CAAC,CAAC;AACJ,CAAC;AAAC8F,OAAA,CAAAF,MAAA,GAAAA,MAAA","ignoreList":[]}
|
1
|
+
{"version":3,"names":["_Drawing","require","_Box","_ColorFilters","_CTM","_ImageFilters","_Paint","_PathEffects","_Shaders","_Core","play","ctx","_command","isGroup","children","forEach","child","command","materializeCommand","isCommand","CommandType","SaveBackdropFilter","saveBackdropFilter","SaveLayer","materializePaint","paint","paintDeclarations","pop","canvas","saveLayer","isDrawCommand","SavePaint","props","paints","push","savePaint","setPaintProperties","Skia","RestorePaint","restorePaint","ComposeColorFilter","composeColorFilters","RestorePaintDeclaration","Error","MaterializePaint","isPushColorFilter","pushColorFilter","isPushShader","pushShader","isPushImageFilter","pushImageFilter","isPushPathEffect","pushPathEffect","ComposePathEffect","composePathEffects","ComposeImageFilter","composeImageFilters","PushBlurMaskFilter","setBlurMaskFilter","SaveCTM","saveCTM","RestoreCTM","restore","p","isBoxCommand","drawBox","DrawPaint","drawPaint","DrawImage","drawImage","DrawCircle","drawCircle","DrawPoints","drawPoints","DrawPath","drawPath","DrawRect","drawRect","DrawRRect","drawRRect","DrawOval","drawOval","DrawLine","drawLine","DrawPatch","drawPatch","DrawVertices","drawVertices","DrawDiffRect","drawDiffRect","DrawText","drawText","DrawTextPath","drawTextPath","DrawTextBlob","drawTextBlob","DrawGlyphs","drawGlyphs","DrawPicture","drawPicture","DrawImageSVG","drawImageSVG","DrawParagraph","drawParagraph","DrawAtlas","drawAtlas","console","warn","type","replay","commands","exports"],"sources":["Player.ts"],"sourcesContent":["import {\n drawCircle,\n drawImage,\n drawOval,\n drawPath,\n drawPoints,\n drawRect,\n drawRRect,\n drawLine,\n drawAtlas,\n drawParagraph,\n drawImageSVG,\n drawPicture,\n drawGlyphs,\n drawTextBlob,\n drawTextPath,\n drawText,\n drawDiffRect,\n drawVertices,\n drawPatch,\n} from \"./commands/Drawing\";\nimport { drawBox, isBoxCommand } from \"./commands/Box\";\nimport {\n composeColorFilters,\n isPushColorFilter,\n pushColorFilter,\n} from \"./commands/ColorFilters\";\nimport { saveCTM } from \"./commands/CTM\";\nimport {\n setBlurMaskFilter,\n isPushImageFilter,\n pushImageFilter,\n composeImageFilters,\n} from \"./commands/ImageFilters\";\nimport { setPaintProperties } from \"./commands/Paint\";\nimport {\n composePathEffects,\n isPushPathEffect,\n pushPathEffect,\n} from \"./commands/PathEffects\";\nimport { isPushShader, pushShader } from \"./commands/Shaders\";\nimport {\n CommandType,\n isCommand,\n isDrawCommand,\n isGroup,\n materializeCommand,\n} from \"./Core\";\nimport type { Command } from \"./Core\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nfunction play(ctx: DrawingContext, _command: Command) {\n \"worklet\";\n if (isGroup(_command)) {\n _command.children.forEach((child) => play(ctx, child));\n return;\n }\n const command = materializeCommand(_command);\n if (isCommand(command, CommandType.SaveBackdropFilter)) {\n ctx.saveBackdropFilter();\n } else if (isCommand(command, CommandType.SaveLayer)) {\n ctx.materializePaint();\n const paint = ctx.paintDeclarations.pop();\n ctx.canvas.saveLayer(paint);\n } else if (isDrawCommand(command, CommandType.SavePaint)) {\n if (command.props.paint) {\n ctx.paints.push(command.props.paint);\n } else {\n ctx.savePaint();\n setPaintProperties(ctx.Skia, ctx.paint, command.props);\n }\n } else if (isCommand(command, CommandType.RestorePaint)) {\n ctx.restorePaint();\n } else if (isCommand(command, CommandType.ComposeColorFilter)) {\n composeColorFilters(ctx);\n } else if (isCommand(command, CommandType.RestorePaintDeclaration)) {\n ctx.materializePaint();\n const paint = ctx.restorePaint();\n if (!paint) {\n throw new Error(\"No paint declaration to push\");\n }\n ctx.paintDeclarations.push(paint);\n } else if (isCommand(command, CommandType.MaterializePaint)) {\n ctx.materializePaint();\n } else if (isPushColorFilter(command)) {\n pushColorFilter(ctx, command);\n } else if (isPushShader(command)) {\n pushShader(ctx, command);\n } else if (isPushImageFilter(command)) {\n pushImageFilter(ctx, command);\n } else if (isPushPathEffect(command)) {\n pushPathEffect(ctx, command);\n } else if (isCommand(command, CommandType.ComposePathEffect)) {\n composePathEffects(ctx);\n } else if (isCommand(command, CommandType.ComposeImageFilter)) {\n composeImageFilters(ctx);\n } else if (isDrawCommand(command, CommandType.PushBlurMaskFilter)) {\n setBlurMaskFilter(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.SaveCTM)) {\n saveCTM(ctx, command.props);\n } else if (isCommand(command, CommandType.RestoreCTM)) {\n ctx.canvas.restore();\n } else {\n const paints = [ctx.paint, ...ctx.paintDeclarations];\n ctx.paintDeclarations = [];\n paints.forEach((p) => {\n ctx.paints.push(p);\n if (isBoxCommand(command)) {\n drawBox(ctx, command);\n } else if (isCommand(command, CommandType.DrawPaint)) {\n ctx.canvas.drawPaint(ctx.paint);\n } else if (isDrawCommand(command, CommandType.DrawImage)) {\n drawImage(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawCircle)) {\n drawCircle(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPoints)) {\n drawPoints(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPath)) {\n drawPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRect)) {\n drawRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawRRect)) {\n drawRRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawOval)) {\n drawOval(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawLine)) {\n drawLine(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPatch)) {\n drawPatch(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawVertices)) {\n drawVertices(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawDiffRect)) {\n drawDiffRect(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawText)) {\n drawText(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextPath)) {\n drawTextPath(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawTextBlob)) {\n drawTextBlob(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawGlyphs)) {\n drawGlyphs(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawPicture)) {\n drawPicture(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawImageSVG)) {\n drawImageSVG(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawParagraph)) {\n drawParagraph(ctx, command.props);\n } else if (isDrawCommand(command, CommandType.DrawAtlas)) {\n drawAtlas(ctx, command.props);\n } else {\n console.warn(`Unknown command: ${command.type}`);\n }\n ctx.paints.pop();\n });\n }\n}\n\nexport const replay = (ctx: DrawingContext, commands: Command[]) => {\n \"worklet\";\n commands.forEach((command) => {\n play(ctx, command);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAqBA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAKA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAUA,SAASS,IAAIA,CAACC,GAAmB,EAAEC,QAAiB,EAAE;EACpD,SAAS;;EACT,IAAI,IAAAC,aAAO,EAACD,QAAQ,CAAC,EAAE;IACrBA,QAAQ,CAACE,QAAQ,CAACC,OAAO,CAAEC,KAAK,IAAKN,IAAI,CAACC,GAAG,EAAEK,KAAK,CAAC,CAAC;IACtD;EACF;EACA,MAAMC,OAAO,GAAG,IAAAC,wBAAkB,EAACN,QAAQ,CAAC;EAC5C,IAAI,IAAAO,eAAS,EAACF,OAAO,EAAEG,iBAAW,CAACC,kBAAkB,CAAC,EAAE;IACtDV,GAAG,CAACW,kBAAkB,CAAC,CAAC;EAC1B,CAAC,MAAM,IAAI,IAAAH,eAAS,EAACF,OAAO,EAAEG,iBAAW,CAACG,SAAS,CAAC,EAAE;IACpDZ,GAAG,CAACa,gBAAgB,CAAC,CAAC;IACtB,MAAMC,KAAK,GAAGd,GAAG,CAACe,iBAAiB,CAACC,GAAG,CAAC,CAAC;IACzChB,GAAG,CAACiB,MAAM,CAACC,SAAS,CAACJ,KAAK,CAAC;EAC7B,CAAC,MAAM,IAAI,IAAAK,mBAAa,EAACb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;EACpB,CAAC,CAAC;AACJ,CAAC;AAAC8F,OAAA,CAAAF,MAAA,GAAAA,MAAA","ignoreList":[]}
|
@@ -39,7 +39,7 @@ const drawBox = (ctx, command) => {
|
|
39
39
|
} = shadow;
|
40
40
|
const lPaint = Skia.Paint();
|
41
41
|
lPaint.setColor((0, _nodes.processColor)(Skia, color));
|
42
|
-
lPaint.setAlphaf(
|
42
|
+
lPaint.setAlphaf(lPaint.getAlphaf() * opacity);
|
43
43
|
lPaint.setMaskFilter(Skia.MaskFilter.MakeBlur(_types.BlurStyle.Normal, blur, true));
|
44
44
|
canvas.drawRRect((0, _nodes.inflate)(Skia, box, spread, spread, dx, dy), lPaint);
|
45
45
|
});
|
@@ -57,7 +57,7 @@ const drawBox = (ctx, command) => {
|
|
57
57
|
canvas.clipRRect(box, _types.ClipOp.Intersect, false);
|
58
58
|
const lPaint = Skia.Paint();
|
59
59
|
lPaint.setColor(Skia.Color(color));
|
60
|
-
lPaint.setAlphaf(
|
60
|
+
lPaint.setAlphaf(lPaint.getAlphaf() * opacity);
|
61
61
|
lPaint.setMaskFilter(Skia.MaskFilter.MakeBlur(_types.BlurStyle.Normal, blur, true));
|
62
62
|
const inner = (0, _nodes.deflate)(Skia, box, spread, spread, dx, dy);
|
63
63
|
const outer = (0, _nodes.inflate)(Skia, box, delta.x, delta.y);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_nodes","require","_types","_Core","isBoxCommand","command","type","CommandType","DrawBox","exports","drawBox","ctx","shadows","map","shadow","materializeCommand","props","paint","Skia","canvas","box","defaultBox","opacity","getAlphaf","isRRect","RRectXY","filter","inner","color","blur","spread","dx","dy","lPaint","Paint","setColor","processColor","setAlphaf","setMaskFilter","MaskFilter","MakeBlur","BlurStyle","Normal","drawRRect","inflate","delta","Point","Math","abs","save","clipRRect","ClipOp","Intersect","Color","deflate","outer","x","y","drawDRRect","restore"],"sources":["Box.ts"],"sourcesContent":["import { deflate, inflate, processColor } from \"../../../dom/nodes\";\nimport type { BoxProps, BoxShadowProps } from \"../../../dom/types\";\nimport { BlurStyle, ClipOp, isRRect } from \"../../../skia/types\";\nimport type { Command } from \"../Core\";\nimport { CommandType, materializeCommand } from \"../Core\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\ninterface BoxCommand extends Command<CommandType.DrawBox> {\n props: BoxProps;\n shadows: { props: BoxShadowProps }[];\n}\n\nexport const isBoxCommand = (command: Command): command is BoxCommand => {\n \"worklet\";\n return command.type === CommandType.DrawBox;\n};\n\nexport const drawBox = (ctx: DrawingContext, command: BoxCommand) => {\n \"worklet\";\n const shadows = command.shadows.map((shadow) => {\n return materializeCommand(shadow).props;\n });\n const { paint, Skia, canvas } = ctx;\n const { box: defaultBox } = command.props;\n const opacity = paint.getAlphaf();\n const box = isRRect(defaultBox) ? defaultBox : Skia.RRectXY(defaultBox, 0, 0);\n shadows\n .filter((shadow) => !shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const lPaint = Skia.Paint();\n lPaint.setColor(processColor(Skia, color));\n lPaint.setAlphaf(
|
1
|
+
{"version":3,"names":["_nodes","require","_types","_Core","isBoxCommand","command","type","CommandType","DrawBox","exports","drawBox","ctx","shadows","map","shadow","materializeCommand","props","paint","Skia","canvas","box","defaultBox","opacity","getAlphaf","isRRect","RRectXY","filter","inner","color","blur","spread","dx","dy","lPaint","Paint","setColor","processColor","setAlphaf","setMaskFilter","MaskFilter","MakeBlur","BlurStyle","Normal","drawRRect","inflate","delta","Point","Math","abs","save","clipRRect","ClipOp","Intersect","Color","deflate","outer","x","y","drawDRRect","restore"],"sources":["Box.ts"],"sourcesContent":["import { deflate, inflate, processColor } from \"../../../dom/nodes\";\nimport type { BoxProps, BoxShadowProps } from \"../../../dom/types\";\nimport { BlurStyle, ClipOp, isRRect } from \"../../../skia/types\";\nimport type { Command } from \"../Core\";\nimport { CommandType, materializeCommand } from \"../Core\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\ninterface BoxCommand extends Command<CommandType.DrawBox> {\n props: BoxProps;\n shadows: { props: BoxShadowProps }[];\n}\n\nexport const isBoxCommand = (command: Command): command is BoxCommand => {\n \"worklet\";\n return command.type === CommandType.DrawBox;\n};\n\nexport const drawBox = (ctx: DrawingContext, command: BoxCommand) => {\n \"worklet\";\n const shadows = command.shadows.map((shadow) => {\n return materializeCommand(shadow).props;\n });\n const { paint, Skia, canvas } = ctx;\n const { box: defaultBox } = command.props;\n const opacity = paint.getAlphaf();\n const box = isRRect(defaultBox) ? defaultBox : Skia.RRectXY(defaultBox, 0, 0);\n shadows\n .filter((shadow) => !shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const lPaint = Skia.Paint();\n lPaint.setColor(processColor(Skia, color));\n lPaint.setAlphaf(lPaint.getAlphaf() * opacity);\n lPaint.setMaskFilter(\n Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n canvas.drawRRect(inflate(Skia, box, spread, spread, dx, dy), lPaint);\n });\n\n canvas.drawRRect(box, paint);\n\n shadows\n .filter((shadow) => shadow.inner)\n .map((shadow) => {\n const { color = \"black\", blur, spread = 0, dx = 0, dy = 0 } = shadow;\n const delta = Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));\n canvas.save();\n canvas.clipRRect(box, ClipOp.Intersect, false);\n const lPaint = Skia.Paint();\n lPaint.setColor(Skia.Color(color));\n lPaint.setAlphaf(lPaint.getAlphaf() * opacity);\n\n lPaint.setMaskFilter(\n Skia.MaskFilter.MakeBlur(BlurStyle.Normal, blur, true)\n );\n const inner = deflate(Skia, box, spread, spread, dx, dy);\n const outer = inflate(Skia, box, delta.x, delta.y);\n canvas.drawDRRect(outer, inner, lPaint);\n canvas.restore();\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAQ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AAMF,KAAK,GAAG,IAAA2B,cAAO,EAACpC,IAAI,EAAEE,GAAG,EAAEU,MAAM,EAAEA,MAAM,EAAEC,EAAE,EAAEC,EAAE,CAAC;IACxD,MAAMuB,KAAK,GAAG,IAAAX,cAAO,EAAC1B,IAAI,EAAEE,GAAG,EAAEyB,KAAK,CAACW,CAAC,EAAEX,KAAK,CAACY,CAAC,CAAC;IAClDtC,MAAM,CAACuC,UAAU,CAACH,KAAK,EAAE5B,KAAK,EAAEM,MAAM,CAAC;IACvCd,MAAM,CAACwC,OAAO,CAAC,CAAC;EAClB,CAAC,CAAC;AACN,CAAC;AAAClD,OAAA,CAAAC,OAAA,GAAAA,OAAA","ignoreList":[]}
|
@@ -1,9 +1,7 @@
|
|
1
|
-
import type { AtlasProps,
|
2
|
-
import type { Node } from "../../Node";
|
1
|
+
import type { AtlasProps, CircleProps, DiffRectProps, DrawingNodeProps, GlyphsProps, ImageProps, ImageSVGProps, LineProps, OvalProps, ParagraphProps, PatchProps, PathProps, PictureProps, PointsProps, RectProps, RoundedRectProps, TextBlobProps, TextPathProps, TextProps, VerticesProps } from "../../../dom/types";
|
3
2
|
import type { DrawingContext } from "../DrawingContext";
|
4
3
|
export declare const drawLine: (ctx: DrawingContext, props: LineProps) => void;
|
5
4
|
export declare const drawOval: (ctx: DrawingContext, props: OvalProps) => void;
|
6
|
-
export declare const drawBox: (ctx: DrawingContext, props: BoxProps, children: Node<any>[]) => void;
|
7
5
|
export declare const drawImage: (ctx: DrawingContext, props: ImageProps) => void;
|
8
6
|
export declare const drawPoints: (ctx: DrawingContext, props: PointsProps) => void;
|
9
7
|
export declare const drawVertices: (ctx: DrawingContext, props: VerticesProps) => void;
|
@@ -3,11 +3,10 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.drawVertices = exports.drawTextPath = exports.drawTextBlob = exports.drawText = exports.drawRect = exports.drawRRect = exports.drawPoints = exports.drawPicture = exports.drawPath = exports.drawPatch = exports.drawParagraph = exports.drawOval = exports.drawLine = exports.drawImageSVG = exports.drawImage = exports.drawGlyphs = exports.drawFill = exports.drawDiffRect = exports.drawCircle = exports.
|
6
|
+
exports.drawVertices = exports.drawTextPath = exports.drawTextBlob = exports.drawText = exports.drawRect = exports.drawRRect = exports.drawPoints = exports.drawPicture = exports.drawPath = exports.drawPatch = exports.drawParagraph = exports.drawOval = exports.drawLine = exports.drawImageSVG = exports.drawImage = exports.drawGlyphs = exports.drawFill = exports.drawDiffRect = exports.drawCircle = exports.drawAtlas = void 0;
|
7
7
|
var _nodes = require("../../../dom/nodes");
|
8
8
|
var _processors = require("../../../renderer/processors");
|
9
9
|
var _types = require("../../../skia/types");
|
10
|
-
var _utils = require("../../utils");
|
11
10
|
const drawLine = (ctx, props) => {
|
12
11
|
"worklet";
|
13
12
|
|
@@ -25,62 +24,6 @@ const drawOval = (ctx, props) => {
|
|
25
24
|
ctx.canvas.drawOval(rect, ctx.paint);
|
26
25
|
};
|
27
26
|
exports.drawOval = drawOval;
|
28
|
-
const drawBox = (ctx, props, children) => {
|
29
|
-
"worklet";
|
30
|
-
|
31
|
-
const {
|
32
|
-
paint,
|
33
|
-
Skia,
|
34
|
-
canvas
|
35
|
-
} = ctx;
|
36
|
-
const {
|
37
|
-
box: defaultBox
|
38
|
-
} = props;
|
39
|
-
const opacity = paint.getAlphaf();
|
40
|
-
const box = (0, _types.isRRect)(defaultBox) ? defaultBox : Skia.RRectXY(defaultBox, 0, 0);
|
41
|
-
const shadows = children.map(node => {
|
42
|
-
if (node.type === _nodes.NodeType.BoxShadow) {
|
43
|
-
return (0, _utils.materialize)(node.props);
|
44
|
-
}
|
45
|
-
return null;
|
46
|
-
}).filter(n => n !== null);
|
47
|
-
shadows.filter(shadow => !shadow.inner).map(shadow => {
|
48
|
-
const {
|
49
|
-
color = "black",
|
50
|
-
blur,
|
51
|
-
spread = 0,
|
52
|
-
dx = 0,
|
53
|
-
dy = 0
|
54
|
-
} = shadow;
|
55
|
-
const lPaint = Skia.Paint();
|
56
|
-
lPaint.setColor((0, _nodes.processColor)(Skia, color));
|
57
|
-
lPaint.setAlphaf(paint.getAlphaf() * opacity);
|
58
|
-
lPaint.setMaskFilter(Skia.MaskFilter.MakeBlur(_types.BlurStyle.Normal, blur, true));
|
59
|
-
canvas.drawRRect((0, _nodes.inflate)(Skia, box, spread, spread, dx, dy), lPaint);
|
60
|
-
});
|
61
|
-
canvas.drawRRect(box, paint);
|
62
|
-
shadows.filter(shadow => shadow.inner).map(shadow => {
|
63
|
-
const {
|
64
|
-
color = "black",
|
65
|
-
blur,
|
66
|
-
spread = 0,
|
67
|
-
dx = 0,
|
68
|
-
dy = 0
|
69
|
-
} = shadow;
|
70
|
-
const delta = Skia.Point(10 + Math.abs(dx), 10 + Math.abs(dy));
|
71
|
-
canvas.save();
|
72
|
-
canvas.clipRRect(box, _types.ClipOp.Intersect, false);
|
73
|
-
const lPaint = Skia.Paint();
|
74
|
-
lPaint.setColor((0, _nodes.processColor)(Skia, color));
|
75
|
-
lPaint.setAlphaf(paint.getAlphaf() * opacity);
|
76
|
-
lPaint.setMaskFilter(Skia.MaskFilter.MakeBlur(_types.BlurStyle.Normal, blur, true));
|
77
|
-
const inner = (0, _nodes.deflate)(Skia, box, spread, spread, dx, dy);
|
78
|
-
const outer = (0, _nodes.inflate)(Skia, box, delta.x, delta.y);
|
79
|
-
canvas.drawDRRect(outer, inner, lPaint);
|
80
|
-
canvas.restore();
|
81
|
-
});
|
82
|
-
};
|
83
|
-
exports.drawBox = drawBox;
|
84
27
|
const drawImage = (ctx, props) => {
|
85
28
|
"worklet";
|
86
29
|
|