@shopify/react-native-skia 1.8.1 → 1.9.0
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/cpp/rnskia-android/MainThreadDispatcher.h +1 -1
- package/android/cpp/rnskia-android/OpenGLContext.h +4 -4
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +3 -3
- package/cpp/api/JsiSkCanvas.h +27 -25
- package/cpp/api/JsiSkImage.h +24 -0
- package/cpp/api/JsiSkPaint.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiAtlasNode.h +5 -1
- package/cpp/rnskia/dom/nodes/JsiImageNode.h +8 -4
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +9 -38
- package/cpp/rnskia/dom/props/SamplingProp.h +54 -0
- package/ios/RNSkia-iOS/SkiaManager.mm +2 -4
- package/lib/commonjs/dom/types/Drawings.d.ts +3 -1
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/dom/types/Shaders.d.ts +2 -3
- package/lib/commonjs/dom/types/Shaders.js.map +1 -1
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +1 -8
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -1
- package/lib/commonjs/renderer/components/image/ImageShader.d.ts +1 -1
- package/lib/commonjs/renderer/components/image/ImageShader.js +0 -4
- package/lib/commonjs/renderer/components/image/ImageShader.js.map +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.js +1 -1
- package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -1
- package/lib/commonjs/skia/core/Data.d.ts +1 -1
- package/lib/commonjs/skia/core/Data.js +2 -8
- package/lib/commonjs/skia/core/Data.js.map +1 -1
- package/lib/commonjs/skia/types/Canvas.d.ts +2 -2
- package/lib/commonjs/skia/types/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Image/Image.d.ts +18 -0
- package/lib/commonjs/skia/types/Image/Image.js +24 -1
- package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
- package/lib/commonjs/skia/types/Picture/PictureRecorder.d.ts +2 -1
- package/lib/commonjs/skia/types/Picture/PictureRecorder.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkCanvas.js +15 -2
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/sksg/Container.d.ts +17 -14
- package/lib/commonjs/sksg/Container.js +59 -61
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/HostConfig.js +4 -9
- package/lib/commonjs/sksg/HostConfig.js.map +1 -1
- package/lib/commonjs/sksg/Reconciler.js +1 -2
- package/lib/commonjs/sksg/Reconciler.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +11 -0
- package/lib/commonjs/sksg/Recorder/Recorder.js +9 -0
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +11 -4
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js +8 -3
- package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/module/dom/types/Drawings.d.ts +3 -1
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/dom/types/Shaders.d.ts +2 -3
- package/lib/module/dom/types/Shaders.js.map +1 -1
- package/lib/module/external/reanimated/useAnimatedImageValue.js +1 -8
- package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
- package/lib/module/renderer/components/image/ImageShader.d.ts +1 -1
- package/lib/module/renderer/components/image/ImageShader.js +0 -4
- package/lib/module/renderer/components/image/ImageShader.js.map +1 -1
- package/lib/module/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/module/skia/core/AnimatedImage.js +1 -1
- package/lib/module/skia/core/AnimatedImage.js.map +1 -1
- package/lib/module/skia/core/Data.d.ts +1 -1
- package/lib/module/skia/core/Data.js +2 -8
- package/lib/module/skia/core/Data.js.map +1 -1
- package/lib/module/skia/types/Canvas.d.ts +2 -2
- package/lib/module/skia/types/Canvas.js.map +1 -1
- package/lib/module/skia/types/Image/Image.d.ts +18 -0
- package/lib/module/skia/types/Image/Image.js +21 -0
- package/lib/module/skia/types/Image/Image.js.map +1 -1
- package/lib/module/skia/types/Picture/PictureRecorder.d.ts +2 -1
- package/lib/module/skia/types/Picture/PictureRecorder.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.d.ts +2 -2
- package/lib/module/skia/web/JsiSkCanvas.js +15 -2
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/sksg/Container.d.ts +17 -14
- package/lib/module/sksg/Container.js +56 -59
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/HostConfig.js +4 -9
- package/lib/module/sksg/HostConfig.js.map +1 -1
- package/lib/module/sksg/Reconciler.js +2 -3
- package/lib/module/sksg/Reconciler.js.map +1 -1
- package/lib/module/sksg/Recorder/Recorder.d.ts +11 -0
- package/lib/module/sksg/Recorder/Recorder.js +9 -0
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js +12 -5
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js +9 -4
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/typescript/lib/commonjs/renderer/components/image/ImageShader.d.ts +1 -3
- package/lib/typescript/lib/commonjs/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/core/Data.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/types/Image/Image.d.ts +21 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Container.d.ts +15 -10
- package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +4 -4
- package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +21 -2
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +5 -0
- package/lib/typescript/lib/module/mock/index.d.ts +19 -4
- package/lib/typescript/lib/module/renderer/components/image/ImageShader.d.ts +1 -3
- package/lib/typescript/lib/module/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/typescript/lib/module/skia/core/Data.d.ts +1 -1
- package/lib/typescript/lib/module/skia/types/Image/Image.d.ts +21 -0
- package/lib/typescript/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Container.d.ts +15 -10
- package/lib/typescript/lib/module/sksg/HostConfig.d.ts +4 -4
- package/lib/typescript/lib/module/sksg/Reconciler.d.ts +21 -2
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +5 -0
- package/lib/typescript/src/dom/types/Drawings.d.ts +3 -1
- package/lib/typescript/src/dom/types/Shaders.d.ts +2 -3
- package/lib/typescript/src/renderer/components/image/ImageShader.d.ts +1 -1
- package/lib/typescript/src/skia/core/AnimatedImage.d.ts +1 -1
- package/lib/typescript/src/skia/core/Data.d.ts +1 -1
- package/lib/typescript/src/skia/types/Canvas.d.ts +2 -2
- package/lib/typescript/src/skia/types/Image/Image.d.ts +18 -0
- package/lib/typescript/src/skia/types/Picture/PictureRecorder.d.ts +2 -1
- package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +2 -2
- package/lib/typescript/src/sksg/Container.d.ts +17 -14
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +11 -0
- package/libs/apple/libskia.xcframework/Info.plist +35 -2
- package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/apple/libskottie.xcframework/Info.plist +36 -3
- package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/apple/libskparagraph.xcframework/Info.plist +40 -7
- package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/apple/libsksg.xcframework/Info.plist +35 -2
- package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/apple/libskshaper.xcframework/Info.plist +33 -0
- package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/Info.plist +36 -3
- package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +35 -2
- package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libsvg.xcframework/Info.plist +36 -3
- package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +1 -1
- package/react-native-skia.podspec +2 -2
- package/src/__tests__/snapshots/animated-images/bird.png +0 -0
- package/src/__tests__/snapshots/demos/product.png +0 -0
- package/src/__tests__/snapshots/demos/product2.png +0 -0
- package/src/__tests__/snapshots/images/bundle-android.png +0 -0
- package/src/__tests__/snapshots/images/bundle-ios.png +0 -0
- package/src/__tests__/snapshots/images/bundle-node.png +0 -0
- package/src/__tests__/snapshots/images/filter.png +0 -0
- package/src/dom/types/Drawings.ts +3 -0
- package/src/dom/types/Shaders.ts +2 -4
- package/src/external/reanimated/useAnimatedImageValue.ts +4 -15
- package/src/renderer/__tests__/e2e/Text.spec.tsx +1 -1
- package/src/renderer/components/image/ImageShader.tsx +2 -15
- package/src/skia/core/AnimatedImage.ts +2 -3
- package/src/skia/core/Data.ts +3 -9
- package/src/skia/types/Canvas.ts +2 -3
- package/src/skia/types/Image/Image.ts +14 -0
- package/src/skia/types/Picture/PictureRecorder.ts +2 -1
- package/src/skia/web/JsiSkCanvas.ts +50 -29
- package/src/sksg/Container.ts +64 -67
- package/src/sksg/HostConfig.ts +4 -9
- package/src/sksg/Reconciler.ts +3 -3
- package/src/sksg/Recorder/Recorder.ts +20 -0
- package/src/sksg/Recorder/commands/Drawing.ts +33 -4
- package/src/sksg/Recorder/commands/Shaders.ts +21 -8
- package/lib/commonjs/sksg/Recorder/Recording.d.ts +0 -7
- package/lib/commonjs/sksg/Recorder/Recording.js +0 -12
- package/lib/commonjs/sksg/Recorder/Recording.js.map +0 -1
- package/lib/module/sksg/Recorder/Recording.d.ts +0 -7
- package/lib/module/sksg/Recorder/Recording.js +0 -5
- package/lib/module/sksg/Recorder/Recording.js.map +0 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recording.d.ts +0 -5
- package/lib/typescript/lib/module/sksg/Recorder/Recording.d.ts +0 -4
- package/lib/typescript/src/sksg/Recorder/Recording.d.ts +0 -7
- package/src/sksg/Recorder/Recording.ts +0 -13
|
@@ -122,8 +122,8 @@ public:
|
|
|
122
122
|
format = GrBackendFormats::MakeGL(GR_GL_RGBA16F, GR_GL_TEXTURE_EXTERNAL);
|
|
123
123
|
break;
|
|
124
124
|
case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
GrBackendFormats::MakeGL(GR_GL_RGB565, GR_GL_TEXTURE_EXTERNAL);
|
|
126
|
+
break;
|
|
127
127
|
case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
|
|
128
128
|
format = GrBackendFormats::MakeGL(GR_GL_RGB10_A2, GR_GL_TEXTURE_EXTERNAL);
|
|
129
129
|
break;
|
|
@@ -146,8 +146,8 @@ public:
|
|
|
146
146
|
auto height = static_cast<int>(description.height);
|
|
147
147
|
auto backendTex = MakeGLBackendTexture(
|
|
148
148
|
_directContext.get(), const_cast<AHardwareBuffer *>(hardwareBuffer),
|
|
149
|
-
width, height, &deleteImageProc,
|
|
150
|
-
|
|
149
|
+
width, height, &deleteImageProc, &updateImageProc, &deleteImageCtx,
|
|
150
|
+
false, format, false);
|
|
151
151
|
if (!backendTex.isValid()) {
|
|
152
152
|
RNSkLogger::logToConsole(
|
|
153
153
|
"Failed to convert HardwareBuffer to OpenGL Texture!");
|
|
@@ -26,7 +26,8 @@ namespace RNSkia {
|
|
|
26
26
|
RNSkOpenGLCanvasProvider::RNSkOpenGLCanvasProvider(
|
|
27
27
|
std::function<void()> requestRedraw,
|
|
28
28
|
std::shared_ptr<RNSkia::RNSkPlatformContext> platformContext)
|
|
29
|
-
: RNSkCanvasProvider(std::move(requestRedraw)),
|
|
29
|
+
: RNSkCanvasProvider(std::move(requestRedraw)),
|
|
30
|
+
_platformContext(std::move(platformContext)) {}
|
|
30
31
|
|
|
31
32
|
RNSkOpenGLCanvasProvider::~RNSkOpenGLCanvasProvider() = default;
|
|
32
33
|
|
|
@@ -109,8 +110,7 @@ void RNSkOpenGLCanvasProvider::surfaceAvailable(jobject jSurfaceTexture,
|
|
|
109
110
|
#if defined(SK_GRAPHITE)
|
|
110
111
|
_surfaceHolder = DawnContext::getInstance().MakeWindow(window, width, height);
|
|
111
112
|
#else
|
|
112
|
-
_surfaceHolder =
|
|
113
|
-
OpenGLContext::getInstance().MakeWindow(window);
|
|
113
|
+
_surfaceHolder = OpenGLContext::getInstance().MakeWindow(window);
|
|
114
114
|
#endif
|
|
115
115
|
|
|
116
116
|
// Post redraw request to ensure we paint in the next draw cycle.
|
package/cpp/api/JsiSkCanvas.h
CHANGED
|
@@ -525,32 +525,34 @@ public:
|
|
|
525
525
|
|
|
526
526
|
std::vector<SkColor> colors;
|
|
527
527
|
if (count > 5 && !arguments[5].isUndefined()) {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
528
|
+
auto colorsArray = arguments[5].asObject(runtime).asArray(runtime);
|
|
529
|
+
int colorsSize = static_cast<int>(colorsArray.size(runtime));
|
|
530
|
+
colors.reserve(colorsSize);
|
|
531
|
+
for (int i = 0; i < colorsSize; i++) {
|
|
532
|
+
// Convert from [r,g,b,a] in [0,1] to SkColor
|
|
533
|
+
auto val = colorsArray.getValueAtIndex(runtime, i).asObject(runtime);
|
|
534
|
+
float r = val.getProperty(runtime, "0").asNumber();
|
|
535
|
+
float g = val.getProperty(runtime, "1").asNumber();
|
|
536
|
+
float b = val.getProperty(runtime, "2").asNumber();
|
|
537
|
+
float a = val.getProperty(runtime, "3").asNumber();
|
|
538
|
+
|
|
539
|
+
// Convert to 8-bit color channels and pack into SkColor
|
|
540
|
+
uint8_t r8 = static_cast<uint8_t>(r * 255);
|
|
541
|
+
uint8_t g8 = static_cast<uint8_t>(g * 255);
|
|
542
|
+
uint8_t b8 = static_cast<uint8_t>(b * 255);
|
|
543
|
+
uint8_t a8 = static_cast<uint8_t>(a * 255);
|
|
544
|
+
|
|
545
|
+
SkColor color = SkColorSetARGB(a8, r8, g8, b8);
|
|
546
|
+
colors.push_back(color);
|
|
547
|
+
}
|
|
548
548
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
549
|
+
SkSamplingOptions sampling(SkFilterMode::kLinear);
|
|
550
|
+
if (count > 6) {
|
|
551
|
+
sampling = SamplingOptionsFromValue(runtime, arguments[5]);
|
|
552
|
+
}
|
|
553
|
+
_canvas->drawAtlas(atlas.get(), xforms.data(), skRects.data(),
|
|
554
|
+
colors.data(), skRects.size(), blendMode, sampling,
|
|
555
|
+
nullptr, paint.get());
|
|
554
556
|
|
|
555
557
|
return jsi::Value::undefined();
|
|
556
558
|
}
|
package/cpp/api/JsiSkImage.h
CHANGED
|
@@ -36,6 +36,30 @@ namespace RNSkia {
|
|
|
36
36
|
|
|
37
37
|
namespace jsi = facebook::jsi;
|
|
38
38
|
|
|
39
|
+
inline SkSamplingOptions SamplingOptionsFromValue(jsi::Runtime &runtime,
|
|
40
|
+
const jsi::Value &val) {
|
|
41
|
+
SkSamplingOptions samplingOptions(SkFilterMode::kLinear);
|
|
42
|
+
if (val.isObject()) {
|
|
43
|
+
auto object = val.asObject(runtime);
|
|
44
|
+
if (object.hasProperty(runtime, "B") && object.hasProperty(runtime, "C")) {
|
|
45
|
+
auto B = static_cast<float>(object.getProperty(runtime, "B").asNumber());
|
|
46
|
+
auto C = static_cast<float>(object.getProperty(runtime, "C").asNumber());
|
|
47
|
+
samplingOptions = SkSamplingOptions({B, C});
|
|
48
|
+
} else if (object.hasProperty(runtime, "filter")) {
|
|
49
|
+
auto filter = static_cast<SkFilterMode>(
|
|
50
|
+
object.getProperty(runtime, "filter").asNumber());
|
|
51
|
+
if (object.hasProperty(runtime, "mipmap")) {
|
|
52
|
+
auto mipmap = static_cast<SkMipmapMode>(
|
|
53
|
+
object.getProperty(runtime, "mipmap").asNumber());
|
|
54
|
+
samplingOptions = SkSamplingOptions(filter, mipmap);
|
|
55
|
+
} else {
|
|
56
|
+
samplingOptions = SkSamplingOptions(filter);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return samplingOptions;
|
|
61
|
+
}
|
|
62
|
+
|
|
39
63
|
class JsiSkImage : public JsiSkWrappingSkPtrHostObject<SkImage> {
|
|
40
64
|
public:
|
|
41
65
|
// TODO-API: Properties?
|
package/cpp/api/JsiSkPaint.h
CHANGED
|
@@ -28,7 +28,7 @@ public:
|
|
|
28
28
|
EXPORT_JSI_API_TYPENAME(JsiSkPaint, Paint)
|
|
29
29
|
|
|
30
30
|
JSI_HOST_FUNCTION(assign) {
|
|
31
|
-
SkPaint*
|
|
31
|
+
SkPaint *paint = JsiSkPaint::fromValue(runtime, arguments[0]).get();
|
|
32
32
|
*getObject() = *paint;
|
|
33
33
|
return jsi::Value::undefined();
|
|
34
34
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#include "JsiDomDrawingNode.h"
|
|
4
4
|
#include "RSXformProp.h"
|
|
5
5
|
#include "RectProp.h"
|
|
6
|
+
#include "SamplingProp.h"
|
|
6
7
|
#include "SkImageProps.h"
|
|
7
8
|
|
|
8
9
|
#include <memory>
|
|
@@ -28,7 +29,8 @@ protected:
|
|
|
28
29
|
? *_blendModeProp->getDerivedValue()
|
|
29
30
|
: SkBlendMode::kDstOver;
|
|
30
31
|
auto paint = *context->getPaint();
|
|
31
|
-
|
|
32
|
+
auto sampling = _samplingProp->isSet() ? *_samplingProp->getDerivedValue()
|
|
33
|
+
: SkSamplingOptions(SkFilterMode::kLinear);
|
|
32
34
|
context->getCanvas()->drawAtlas(
|
|
33
35
|
image.get(), transforms->data(), sprites->data(),
|
|
34
36
|
colors == nullptr ? nullptr : colors->data(), sprites->size(),
|
|
@@ -43,6 +45,7 @@ protected:
|
|
|
43
45
|
_imageProp = container->defineProperty<ImageProp>("image");
|
|
44
46
|
_colorsProp = container->defineProperty<ColorsProp>("colors");
|
|
45
47
|
_blendModeProp = container->defineProperty<BlendModeProp>("blendMode");
|
|
48
|
+
_samplingProp = container->defineProperty<SamplingProp>("sampling");
|
|
46
49
|
|
|
47
50
|
_rectsProp->require();
|
|
48
51
|
_rsxFormsProp->require();
|
|
@@ -54,6 +57,7 @@ private:
|
|
|
54
57
|
RSXFormsProp *_rsxFormsProp;
|
|
55
58
|
ColorsProp *_colorsProp;
|
|
56
59
|
BlendModeProp *_blendModeProp;
|
|
60
|
+
SamplingProp *_samplingProp;
|
|
57
61
|
};
|
|
58
62
|
|
|
59
63
|
} // namespace RNSkia
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include "JsiDomDrawingNode.h"
|
|
4
|
+
#include "SamplingProp.h"
|
|
4
5
|
#include "SkImageProps.h"
|
|
5
6
|
|
|
6
7
|
#include <memory>
|
|
@@ -20,19 +21,22 @@ protected:
|
|
|
20
21
|
if (image == nullptr) {
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
auto sampling = _samplingProp->isSet() ? *_samplingProp->getDerivedValue()
|
|
25
|
+
: SkSamplingOptions(SkFilterMode::kLinear);
|
|
26
|
+
context->getCanvas()->drawImageRect(image, rects->src, rects->dst, sampling,
|
|
27
|
+
context->getPaint().get(),
|
|
28
|
+
SkCanvas::kStrict_SrcRectConstraint);
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
void defineProperties(NodePropsContainer *container) override {
|
|
30
32
|
JsiDomDrawingNode::defineProperties(container);
|
|
31
33
|
_imageProps = container->defineProperty<ImageProps>();
|
|
34
|
+
_samplingProp = container->defineProperty<SamplingProp>("sampling");
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
private:
|
|
35
38
|
ImageProps *_imageProps;
|
|
39
|
+
SamplingProp *_samplingProp;
|
|
36
40
|
};
|
|
37
41
|
|
|
38
42
|
} // namespace RNSkia
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#include "ColorProp.h"
|
|
7
7
|
#include "NodeProp.h"
|
|
8
8
|
#include "NumbersProp.h"
|
|
9
|
+
#include "SamplingProp.h"
|
|
9
10
|
#include "TileModeProp.h"
|
|
10
11
|
#include "TransformsProps.h"
|
|
11
12
|
#include "UniformsProp.h"
|
|
@@ -120,12 +121,12 @@ public:
|
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
auto samplingOptions = _samplingProp->isSet()
|
|
125
|
+
? *_samplingProp->getDerivedValue()
|
|
126
|
+
: SkSamplingOptions(SkFilterMode::kLinear);
|
|
127
|
+
context->getShaders()->push(image->makeShader(*_txProp->getDerivedValue(),
|
|
128
|
+
*_tyProp->getDerivedValue(),
|
|
129
|
+
samplingOptions, &_matrix));
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
protected:
|
|
@@ -133,17 +134,14 @@ protected:
|
|
|
133
134
|
JsiDomDeclarationNode::defineProperties(container);
|
|
134
135
|
_txProp = container->defineProperty<TileModeProp>("tx");
|
|
135
136
|
_tyProp = container->defineProperty<TileModeProp>("ty");
|
|
136
|
-
_filterModeProp = container->defineProperty<NodeProp>("fm");
|
|
137
|
-
_mipmapModeProp = container->defineProperty<NodeProp>("mm");
|
|
138
137
|
|
|
138
|
+
_samplingProp = container->defineProperty<SamplingProp>("sampling");
|
|
139
139
|
_imageProps = container->defineProperty<ImageProps>();
|
|
140
140
|
_transformProp = container->defineProperty<TransformProp>("transform");
|
|
141
141
|
_originProp = container->defineProperty<PointProp>("origin");
|
|
142
142
|
|
|
143
143
|
_txProp->require();
|
|
144
144
|
_tyProp->require();
|
|
145
|
-
_filterModeProp->require();
|
|
146
|
-
_mipmapModeProp->require();
|
|
147
145
|
|
|
148
146
|
_transformProp->require();
|
|
149
147
|
|
|
@@ -152,41 +150,14 @@ protected:
|
|
|
152
150
|
}
|
|
153
151
|
|
|
154
152
|
private:
|
|
155
|
-
SkFilterMode getFilterModeFromString(const std::string &value) {
|
|
156
|
-
if (value == "last") {
|
|
157
|
-
return SkFilterMode::kLast;
|
|
158
|
-
} else if (value == "linear") {
|
|
159
|
-
return SkFilterMode::kLinear;
|
|
160
|
-
} else if (value == "nearest") {
|
|
161
|
-
return SkFilterMode::kNearest;
|
|
162
|
-
}
|
|
163
|
-
throw std::runtime_error("The value \"" + value +
|
|
164
|
-
"\" is not a valid Filter Mode.");
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
SkMipmapMode getMipmapModeFromString(const std::string &value) {
|
|
168
|
-
if (value == "last") {
|
|
169
|
-
return SkMipmapMode::kLast;
|
|
170
|
-
} else if (value == "last") {
|
|
171
|
-
return SkMipmapMode::kLast;
|
|
172
|
-
} else if (value == "last") {
|
|
173
|
-
return SkMipmapMode::kLast;
|
|
174
|
-
} else if (value == "none") {
|
|
175
|
-
return SkMipmapMode::kNone;
|
|
176
|
-
}
|
|
177
|
-
throw std::runtime_error("The value \"" + value +
|
|
178
|
-
"\" is not a valid Mipmap Mode.");
|
|
179
|
-
}
|
|
180
|
-
|
|
181
153
|
SkMatrix _matrix;
|
|
182
154
|
|
|
183
155
|
TileModeProp *_txProp;
|
|
184
156
|
TileModeProp *_tyProp;
|
|
185
|
-
NodeProp *_filterModeProp;
|
|
186
|
-
NodeProp *_mipmapModeProp;
|
|
187
157
|
ImageProps *_imageProps;
|
|
188
158
|
TransformProp *_transformProp;
|
|
189
159
|
PointProp *_originProp;
|
|
160
|
+
SamplingProp *_samplingProp;
|
|
190
161
|
};
|
|
191
162
|
|
|
192
163
|
class JsiColorShaderNode : public JsiDomDeclarationNode,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "include/core/SkSamplingOptions.h"
|
|
4
|
+
|
|
5
|
+
namespace RNSkia {
|
|
6
|
+
|
|
7
|
+
static PropId PropNameCubicB = JsiPropId::get("B");
|
|
8
|
+
static PropId PropNameCubicC = JsiPropId::get("C");
|
|
9
|
+
static PropId PropNameFilter = JsiPropId::get("filter");
|
|
10
|
+
static PropId PropNameMipmap = JsiPropId::get("mipmap");
|
|
11
|
+
|
|
12
|
+
class SamplingProp : public DerivedProp<SkSamplingOptions> {
|
|
13
|
+
public:
|
|
14
|
+
explicit SamplingProp(PropId name,
|
|
15
|
+
const std::function<void(BaseNodeProp *)> &onChange)
|
|
16
|
+
: DerivedProp(onChange) {
|
|
17
|
+
_prop = defineProperty<NodeProp>(name);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static SkSamplingOptions processSamplingOptions(const JsiValue &value) {
|
|
21
|
+
SkSamplingOptions samplingOptions(SkFilterMode::kLinear);
|
|
22
|
+
if (value.getType() == PropType::Object) {
|
|
23
|
+
if (value.hasValue(PropNameCubicB) && value.hasValue(PropNameCubicC)) {
|
|
24
|
+
auto B =
|
|
25
|
+
static_cast<float>(value.getValue(PropNameCubicB).getAsNumber());
|
|
26
|
+
auto C =
|
|
27
|
+
static_cast<float>(value.getValue(PropNameCubicC).getAsNumber());
|
|
28
|
+
samplingOptions = SkSamplingOptions({B, C});
|
|
29
|
+
} else if (value.hasValue(PropNameFilter)) {
|
|
30
|
+
auto filter = static_cast<SkFilterMode>(
|
|
31
|
+
value.getValue(PropNameFilter).getAsNumber());
|
|
32
|
+
if (value.hasValue(PropNameMipmap)) {
|
|
33
|
+
auto mipmap = static_cast<SkMipmapMode>(
|
|
34
|
+
value.getValue(PropNameMipmap).getAsNumber());
|
|
35
|
+
samplingOptions = SkSamplingOptions(filter, mipmap);
|
|
36
|
+
} else {
|
|
37
|
+
samplingOptions = SkSamplingOptions(filter);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return samplingOptions;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void updateDerivedValue() override {
|
|
46
|
+
if (_prop->isSet()) {
|
|
47
|
+
setDerivedValue(SamplingProp::processSamplingOptions(_prop->value()));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private:
|
|
52
|
+
NodeProp *_prop;
|
|
53
|
+
};
|
|
54
|
+
} // namespace RNSkia
|
|
@@ -47,14 +47,12 @@ static __weak SkiaManager *sharedInstance = nil;
|
|
|
47
47
|
return self;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
- (void)dealloc
|
|
51
|
-
{
|
|
50
|
+
- (void)dealloc {
|
|
52
51
|
sharedInstance = nil;
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
56
|
-
+ (std::shared_ptr<RNSkia::RNSkManager>)latestActiveSkManager
|
|
57
|
-
{
|
|
55
|
+
+ (std::shared_ptr<RNSkia::RNSkManager>)latestActiveSkManager {
|
|
58
56
|
if (sharedInstance != nil) {
|
|
59
57
|
return [sharedInstance skManager];
|
|
60
58
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FillType, SkImage, StrokeOpts, Vector, Color, SkPoint, BlendMode, PointMode, VertexMode, SkFont, SkRRect, SkTextBlob, SkPicture, SkSVG, SkPaint, SkRect, SkRSXform, SkColor } from "../../skia/types";
|
|
1
|
+
import type { FillType, SkImage, StrokeOpts, Vector, Color, SkPoint, BlendMode, PointMode, VertexMode, SkFont, SkRRect, SkTextBlob, SkPicture, SkSVG, SkPaint, SkRect, SkRSXform, SkColor, SamplingOptions } from "../../skia/types";
|
|
2
2
|
import type { CircleDef, Fit, GroupProps, PathDef, RectDef, RRectDef, SkEnum } from "./Common";
|
|
3
3
|
export interface DrawingNodeProps extends GroupProps {
|
|
4
4
|
paint?: SkPaint;
|
|
@@ -6,6 +6,7 @@ export interface DrawingNodeProps extends GroupProps {
|
|
|
6
6
|
export type ImageProps = DrawingNodeProps & RectDef & {
|
|
7
7
|
fit?: Fit;
|
|
8
8
|
image: SkImage | null;
|
|
9
|
+
sampling?: SamplingOptions;
|
|
9
10
|
};
|
|
10
11
|
export type CircleProps = CircleDef & DrawingNodeProps;
|
|
11
12
|
export interface PathProps extends DrawingNodeProps {
|
|
@@ -27,6 +28,7 @@ export interface AtlasProps extends DrawingNodeProps {
|
|
|
27
28
|
sprites: SkRect[];
|
|
28
29
|
transforms: SkRSXform[];
|
|
29
30
|
colors?: SkColor[];
|
|
31
|
+
sampling?: SamplingOptions;
|
|
30
32
|
}
|
|
31
33
|
export interface CubicBezierHandle {
|
|
32
34
|
pos: Vector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["Drawings.ts"],"sourcesContent":["import type {\n FillType,\n SkImage,\n StrokeOpts,\n Vector,\n Color,\n SkPoint,\n BlendMode,\n PointMode,\n VertexMode,\n SkFont,\n SkRRect,\n SkTextBlob,\n SkPicture,\n SkSVG,\n SkPaint,\n SkRect,\n SkRSXform,\n SkColor,\n} from \"../../skia/types\";\n\nimport type {\n CircleDef,\n Fit,\n GroupProps,\n PathDef,\n RectDef,\n RRectDef,\n SkEnum,\n} from \"./Common\";\n\nexport interface DrawingNodeProps extends GroupProps {\n paint?: SkPaint;\n}\n\nexport type ImageProps = DrawingNodeProps &\n RectDef & {\n fit?: Fit;\n image: SkImage | null;\n };\n\nexport type CircleProps = CircleDef & DrawingNodeProps;\n\nexport interface PathProps extends DrawingNodeProps {\n path: PathDef;\n start: number;\n end: number;\n stroke?: StrokeOpts;\n fillType?: SkEnum<typeof FillType>;\n}\n\nexport interface LineProps extends DrawingNodeProps {\n p1: Vector;\n p2: Vector;\n}\n\nexport type OvalProps = RectDef & DrawingNodeProps;\n\nexport type RectProps = RectDef & DrawingNodeProps;\n\nexport type RoundedRectProps = RRectDef & DrawingNodeProps;\n\nexport interface AtlasProps extends DrawingNodeProps {\n image: SkImage | null;\n sprites: SkRect[];\n transforms: SkRSXform[];\n colors?: SkColor[];\n}\n\nexport interface CubicBezierHandle {\n pos: Vector;\n c1: Vector;\n c2: Vector;\n}\n\nexport interface PatchProps extends DrawingNodeProps {\n colors?: Color[];\n patch: [\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle\n ];\n texture?: readonly [SkPoint, SkPoint, SkPoint, SkPoint];\n blendMode?: SkEnum<typeof BlendMode>;\n}\n\nexport interface VerticesProps extends DrawingNodeProps {\n colors?: string[];\n vertices: SkPoint[];\n textures?: SkPoint[];\n mode: SkEnum<typeof VertexMode>;\n blendMode?: SkEnum<typeof BlendMode>;\n indices?: number[];\n}\n\nexport interface ImageSVGProps extends DrawingNodeProps {\n svg: SkSVG | null;\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n rect?: SkRect;\n}\n\nexport interface PictureProps extends DrawingNodeProps {\n picture: SkPicture;\n}\n\nexport interface PointsProps extends DrawingNodeProps {\n points: SkPoint[];\n mode: SkEnum<typeof PointMode>;\n}\n\nexport interface DiffRectProps extends DrawingNodeProps {\n inner: SkRRect;\n outer: SkRRect;\n}\n\nexport interface TextProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n x: number;\n y: number;\n}\n\nexport interface TextPathProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n path: PathDef;\n initialOffset: number;\n}\n\nexport interface TextBlobProps extends DrawingNodeProps {\n blob: SkTextBlob;\n x: number;\n y: number;\n}\n\nexport interface Glyph {\n id: number;\n pos: SkPoint;\n}\n\nexport interface GlyphsProps extends DrawingNodeProps {\n font: SkFont | null;\n x: number;\n y: number;\n glyphs: Glyph[];\n}\n\nexport interface BoxProps extends DrawingNodeProps {\n box: SkRRect | SkRect;\n}\n\nexport interface BoxShadowProps {\n dx?: number;\n dy?: number;\n spread?: number;\n blur: number;\n color?: Color;\n inner?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["Drawings.ts"],"sourcesContent":["import type {\n FillType,\n SkImage,\n StrokeOpts,\n Vector,\n Color,\n SkPoint,\n BlendMode,\n PointMode,\n VertexMode,\n SkFont,\n SkRRect,\n SkTextBlob,\n SkPicture,\n SkSVG,\n SkPaint,\n SkRect,\n SkRSXform,\n SkColor,\n SamplingOptions,\n} from \"../../skia/types\";\n\nimport type {\n CircleDef,\n Fit,\n GroupProps,\n PathDef,\n RectDef,\n RRectDef,\n SkEnum,\n} from \"./Common\";\n\nexport interface DrawingNodeProps extends GroupProps {\n paint?: SkPaint;\n}\n\nexport type ImageProps = DrawingNodeProps &\n RectDef & {\n fit?: Fit;\n image: SkImage | null;\n sampling?: SamplingOptions;\n };\n\nexport type CircleProps = CircleDef & DrawingNodeProps;\n\nexport interface PathProps extends DrawingNodeProps {\n path: PathDef;\n start: number;\n end: number;\n stroke?: StrokeOpts;\n fillType?: SkEnum<typeof FillType>;\n}\n\nexport interface LineProps extends DrawingNodeProps {\n p1: Vector;\n p2: Vector;\n}\n\nexport type OvalProps = RectDef & DrawingNodeProps;\n\nexport type RectProps = RectDef & DrawingNodeProps;\n\nexport type RoundedRectProps = RRectDef & DrawingNodeProps;\n\nexport interface AtlasProps extends DrawingNodeProps {\n image: SkImage | null;\n sprites: SkRect[];\n transforms: SkRSXform[];\n colors?: SkColor[];\n sampling?: SamplingOptions;\n}\n\nexport interface CubicBezierHandle {\n pos: Vector;\n c1: Vector;\n c2: Vector;\n}\n\nexport interface PatchProps extends DrawingNodeProps {\n colors?: Color[];\n patch: [\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle\n ];\n texture?: readonly [SkPoint, SkPoint, SkPoint, SkPoint];\n blendMode?: SkEnum<typeof BlendMode>;\n}\n\nexport interface VerticesProps extends DrawingNodeProps {\n colors?: string[];\n vertices: SkPoint[];\n textures?: SkPoint[];\n mode: SkEnum<typeof VertexMode>;\n blendMode?: SkEnum<typeof BlendMode>;\n indices?: number[];\n}\n\nexport interface ImageSVGProps extends DrawingNodeProps {\n svg: SkSVG | null;\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n rect?: SkRect;\n}\n\nexport interface PictureProps extends DrawingNodeProps {\n picture: SkPicture;\n}\n\nexport interface PointsProps extends DrawingNodeProps {\n points: SkPoint[];\n mode: SkEnum<typeof PointMode>;\n}\n\nexport interface DiffRectProps extends DrawingNodeProps {\n inner: SkRRect;\n outer: SkRRect;\n}\n\nexport interface TextProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n x: number;\n y: number;\n}\n\nexport interface TextPathProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n path: PathDef;\n initialOffset: number;\n}\n\nexport interface TextBlobProps extends DrawingNodeProps {\n blob: SkTextBlob;\n x: number;\n y: number;\n}\n\nexport interface Glyph {\n id: number;\n pos: SkPoint;\n}\n\nexport interface GlyphsProps extends DrawingNodeProps {\n font: SkFont | null;\n x: number;\n y: number;\n glyphs: Glyph[];\n}\n\nexport interface BoxProps extends DrawingNodeProps {\n box: SkRRect | SkRect;\n}\n\nexport interface BoxShadowProps {\n dx?: number;\n dy?: number;\n spread?: number;\n blur: number;\n color?: Color;\n inner?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Color,
|
|
1
|
+
import type { Color, SamplingOptions, SkImage, SkRect, SkRuntimeEffect, TileMode, Uniforms, Vector } from "../../skia/types";
|
|
2
2
|
import type { SkEnum, TransformProps, ChildrenProps, RectCtor, Fit } from "./Common";
|
|
3
3
|
export interface ShaderProps extends TransformProps, ChildrenProps {
|
|
4
4
|
source: SkRuntimeEffect;
|
|
@@ -7,11 +7,10 @@ export interface ShaderProps extends TransformProps, ChildrenProps {
|
|
|
7
7
|
export interface ImageShaderProps extends TransformProps, Partial<RectCtor> {
|
|
8
8
|
tx: SkEnum<typeof TileMode>;
|
|
9
9
|
ty: SkEnum<typeof TileMode>;
|
|
10
|
-
fm: SkEnum<typeof FilterMode>;
|
|
11
|
-
mm: SkEnum<typeof MipmapMode>;
|
|
12
10
|
fit: Fit;
|
|
13
11
|
rect?: SkRect;
|
|
14
12
|
image: SkImage | null;
|
|
13
|
+
sampling?: SamplingOptions;
|
|
15
14
|
}
|
|
16
15
|
export interface ColorProps {
|
|
17
16
|
color: Color;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["Shaders.ts"],"sourcesContent":["import type {\n Color,\n
|
|
1
|
+
{"version":3,"names":[],"sources":["Shaders.ts"],"sourcesContent":["import type {\n Color,\n SamplingOptions,\n SkImage,\n SkRect,\n SkRuntimeEffect,\n TileMode,\n Uniforms,\n Vector,\n} from \"../../skia/types\";\n\nimport type {\n SkEnum,\n TransformProps,\n ChildrenProps,\n RectCtor,\n Fit,\n} from \"./Common\";\n\nexport interface ShaderProps extends TransformProps, ChildrenProps {\n source: SkRuntimeEffect;\n uniforms: Uniforms;\n}\n\nexport interface ImageShaderProps extends TransformProps, Partial<RectCtor> {\n tx: SkEnum<typeof TileMode>;\n ty: SkEnum<typeof TileMode>;\n fit: Fit;\n rect?: SkRect;\n image: SkImage | null;\n sampling?: SamplingOptions;\n}\n\nexport interface ColorProps {\n color: Color;\n}\n\nexport interface TurbulenceProps {\n freqX: number;\n freqY: number;\n octaves: number;\n seed: number;\n tileWidth: number;\n tileHeight: number;\n}\n\nexport interface FractalNoiseProps {\n freqX: number;\n freqY: number;\n octaves: number;\n seed: number;\n tileWidth: number;\n tileHeight: number;\n}\n\nexport interface GradientProps extends TransformProps {\n colors: Color[];\n positions?: number[];\n mode?: SkEnum<typeof TileMode>;\n flags?: number;\n}\n\nexport interface LinearGradientProps extends GradientProps {\n start: Vector;\n end: Vector;\n}\n\nexport interface RadialGradientProps extends GradientProps {\n c: Vector;\n r: number;\n}\n\nexport interface SweepGradientProps extends GradientProps {\n c: Vector;\n start?: number;\n end?: number;\n}\n\nexport interface TwoPointConicalGradientProps extends GradientProps {\n start: Vector;\n startR: number;\n end: Vector;\n endR: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useAnimatedImageValue = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
7
|
var _AnimatedImage = require("../../skia/core/AnimatedImage");
|
|
9
8
|
var _ReanimatedProxy = _interopRequireDefault(require("./ReanimatedProxy"));
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -17,7 +16,7 @@ const useAnimatedImageValue = (source, paused) => {
|
|
|
17
16
|
const animatedImage = (0, _AnimatedImage.useAnimatedImage)(source, err => {
|
|
18
17
|
console.error(err);
|
|
19
18
|
throw new Error(`Could not load animated image - got '${err.message}'`);
|
|
20
|
-
}
|
|
19
|
+
});
|
|
21
20
|
const frameDuration = (animatedImage === null || animatedImage === void 0 ? void 0 : animatedImage.currentFrameDuration()) || DEFAULT_FRAME_DURATION;
|
|
22
21
|
_ReanimatedProxy.default.useFrameCallback(frameInfo => {
|
|
23
22
|
if (!animatedImage) {
|
|
@@ -47,12 +46,6 @@ const useAnimatedImageValue = (source, paused) => {
|
|
|
47
46
|
// Update the last timestamp
|
|
48
47
|
lastTimestamp.value = timestamp;
|
|
49
48
|
});
|
|
50
|
-
(0, _react.useEffect)(() => {
|
|
51
|
-
return () => {
|
|
52
|
-
animatedImage === null || animatedImage === void 0 || animatedImage.dispose();
|
|
53
|
-
};
|
|
54
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
|
-
}, []);
|
|
56
49
|
return currentFrame;
|
|
57
50
|
};
|
|
58
51
|
exports.useAnimatedImageValue = useAnimatedImageValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_AnimatedImage","require","_ReanimatedProxy","_interopRequireDefault","e","__esModule","default","DEFAULT_FRAME_DURATION","useAnimatedImageValue","source","paused","defaultPaused","Rea","useSharedValue","isPaused","currentFrame","lastTimestamp","animatedImage","useAnimatedImage","err","console","error","Error","message","frameDuration","currentFrameDuration","useFrameCallback","frameInfo","value","timestamp","elapsed","decodeNextFrame","dispose","getCurrentFrame","exports"],"sources":["useAnimatedImageValue.ts"],"sourcesContent":["import type { FrameInfo, SharedValue } from \"react-native-reanimated\";\n\nimport { useAnimatedImage } from \"../../skia/core/AnimatedImage\";\nimport type { DataSourceParam, SkImage } from \"../../skia/types\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst DEFAULT_FRAME_DURATION = 60;\n\nexport const useAnimatedImageValue = (\n source: DataSourceParam,\n paused?: SharedValue<boolean>\n) => {\n const defaultPaused = Rea.useSharedValue(false);\n const isPaused = paused ?? defaultPaused;\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const lastTimestamp = Rea.useSharedValue(-1);\n const animatedImage = useAnimatedImage(source, (err) => {\n console.error(err);\n throw new Error(`Could not load animated image - got '${err.message}'`);\n });\n const frameDuration =\n animatedImage?.currentFrameDuration() || DEFAULT_FRAME_DURATION;\n\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n if (!animatedImage) {\n currentFrame.value = null;\n return;\n }\n if (isPaused.value && lastTimestamp.value !== -1) {\n return;\n }\n const { timestamp } = frameInfo;\n const elapsed = timestamp - lastTimestamp.value;\n\n // Check if it's time to switch frames based on GIF frame duration\n if (elapsed < frameDuration) {\n return;\n }\n\n // Update the current frame\n animatedImage.decodeNextFrame();\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n currentFrame.value = animatedImage.getCurrentFrame();\n\n // Update the last timestamp\n lastTimestamp.value = timestamp;\n });\n return currentFrame;\n};\n"],"mappings":";;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAGA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAoC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEpC,MAAMG,sBAAsB,GAAG,EAAE;AAE1B,MAAMC,qBAAqB,GAAGA,CACnCC,MAAuB,EACvBC,MAA6B,KAC1B;EACH,MAAMC,aAAa,GAAGC,wBAAG,CAACC,cAAc,CAAC,KAAK,CAAC;EAC/C,MAAMC,QAAQ,GAAGJ,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIC,aAAa;EACxC,MAAMI,YAAY,GAAGH,wBAAG,CAACC,cAAc,CAAiB,IAAI,CAAC;EAC7D,MAAMG,aAAa,GAAGJ,wBAAG,CAACC,cAAc,CAAC,CAAC,CAAC,CAAC;EAC5C,MAAMI,aAAa,GAAG,IAAAC,+BAAgB,EAACT,MAAM,EAAGU,GAAG,IAAK;IACtDC,OAAO,CAACC,KAAK,CAACF,GAAG,CAAC;IAClB,MAAM,IAAIG,KAAK,CAAC,wCAAwCH,GAAG,CAACI,OAAO,GAAG,CAAC;EACzE,CAAC,CAAC;EACF,MAAMC,aAAa,GACjB,CAAAP,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEQ,oBAAoB,CAAC,CAAC,KAAIlB,sBAAsB;EAEjEK,wBAAG,CAACc,gBAAgB,CAAEC,SAAoB,IAAK;IAC7C,IAAI,CAACV,aAAa,EAAE;MAClBF,YAAY,CAACa,KAAK,GAAG,IAAI;MACzB;IACF;IACA,IAAId,QAAQ,CAACc,KAAK,IAAIZ,aAAa,CAACY,KAAK,KAAK,CAAC,CAAC,EAAE;MAChD;IACF;IACA,MAAM;MAAEC;IAAU,CAAC,GAAGF,SAAS;IAC/B,MAAMG,OAAO,GAAGD,SAAS,GAAGb,aAAa,CAACY,KAAK;;IAE/C;IACA,IAAIE,OAAO,GAAGN,aAAa,EAAE;MAC3B;IACF;;IAEA;IACAP,aAAa,CAACc,eAAe,CAAC,CAAC;IAC/B,IAAIhB,YAAY,CAACa,KAAK,EAAE;MACtBb,YAAY,CAACa,KAAK,CAACI,OAAO,CAAC,CAAC;IAC9B;IACAjB,YAAY,CAACa,KAAK,GAAGX,aAAa,CAACgB,eAAe,CAAC,CAAC;;IAEpD;IACAjB,aAAa,CAACY,KAAK,GAAGC,SAAS;EACjC,CAAC,CAAC;EACF,OAAOd,YAAY;AACrB,CAAC;AAACmB,OAAA,CAAA1B,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ImageShaderProps } from "../../../dom/types";
|
|
3
3
|
import type { SkiaDefaultProps } from "../../processors";
|
|
4
|
-
export declare const ImageShader: ({ tx, ty,
|
|
4
|
+
export declare const ImageShader: ({ tx, ty, fit, transform, ...props }: SkiaDefaultProps<ImageShaderProps, "tx" | "ty" | "fit" | "transform">) => React.JSX.Element;
|
|
@@ -10,8 +10,6 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
10
10
|
const ImageShader = ({
|
|
11
11
|
tx = "decal",
|
|
12
12
|
ty = "decal",
|
|
13
|
-
fm = "nearest",
|
|
14
|
-
mm = "none",
|
|
15
13
|
fit = "none",
|
|
16
14
|
transform = [],
|
|
17
15
|
...props
|
|
@@ -19,8 +17,6 @@ const ImageShader = ({
|
|
|
19
17
|
return /*#__PURE__*/_react.default.createElement("skImageShader", _extends({
|
|
20
18
|
tx: tx,
|
|
21
19
|
ty: ty,
|
|
22
|
-
fm: fm,
|
|
23
|
-
mm: mm,
|
|
24
20
|
fit: fit,
|
|
25
21
|
transform: transform
|
|
26
22
|
}, props));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","ImageShader","tx","ty","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","ImageShader","tx","ty","fit","transform","props","createElement","exports"],"sources":["ImageShader.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { ImageShaderProps } from \"../../../dom/types\";\nimport type { SkiaDefaultProps } from \"../../processors\";\n\nexport const ImageShader = ({\n tx = \"decal\",\n ty = \"decal\",\n fit = \"none\",\n transform = [],\n ...props\n}: SkiaDefaultProps<ImageShaderProps, \"tx\" | \"ty\" | \"fit\" | \"transform\">) => {\n return (\n <skImageShader tx={tx} ty={ty} fit={fit} transform={transform} {...props} />\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,CAAA,aAAAP,CAAA,MAAAA,CAAA,GAAAQ,SAAA,CAAAC,MAAA,EAAAT,CAAA,UAAAU,CAAA,GAAAF,SAAA,CAAAR,CAAA,YAAAW,CAAA,IAAAD,CAAA,OAAAE,cAAA,CAAAC,IAAA,CAAAH,CAAA,EAAAC,CAAA,MAAAJ,CAAA,CAAAI,CAAA,IAAAD,CAAA,CAAAC,CAAA,aAAAJ,CAAA,KAAAJ,QAAA,CAAAW,KAAA,OAAAN,SAAA;AAKnB,MAAMO,WAAW,GAAGA,CAAC;EAC1BC,EAAE,GAAG,OAAO;EACZC,EAAE,GAAG,OAAO;EACZC,GAAG,GAAG,MAAM;EACZC,SAAS,GAAG,EAAE;EACd,GAAGC;AACkE,CAAC,KAAK;EAC3E,oBACEvB,MAAA,CAAAK,OAAA,CAAAmB,aAAA,kBAAAlB,QAAA;IAAea,EAAE,EAAEA,EAAG;IAACC,EAAE,EAAEA,EAAG;IAACC,GAAG,EAAEA,GAAI;IAACC,SAAS,EAAEA;EAAU,GAAKC,KAAK,CAAG,CAAC;AAEhF,CAAC;AAACE,OAAA,CAAAP,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -2,4 +2,4 @@ import type { DataSourceParam } from "../types";
|
|
|
2
2
|
/**
|
|
3
3
|
* Returns a Skia Animated Image object
|
|
4
4
|
* */
|
|
5
|
-
export declare const useAnimatedImage: (source: DataSourceParam, onError?: (err: Error) => void
|
|
5
|
+
export declare const useAnimatedImage: (source: DataSourceParam, onError?: (err: Error) => void) => import("../types").SkAnimatedImage | null;
|
|
@@ -11,6 +11,6 @@ const animatedImgFactory = _Skia.Skia.AnimatedImage.MakeAnimatedImageFromEncoded
|
|
|
11
11
|
/**
|
|
12
12
|
* Returns a Skia Animated Image object
|
|
13
13
|
* */
|
|
14
|
-
const useAnimatedImage = (source, onError
|
|
14
|
+
const useAnimatedImage = (source, onError) => (0, _Data.useRawData)(source, animatedImgFactory, onError);
|
|
15
15
|
exports.useAnimatedImage = useAnimatedImage;
|
|
16
16
|
//# sourceMappingURL=AnimatedImage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Skia","require","_Data","animatedImgFactory","Skia","AnimatedImage","MakeAnimatedImageFromEncoded","bind","useAnimatedImage","source","onError","
|
|
1
|
+
{"version":3,"names":["_Skia","require","_Data","animatedImgFactory","Skia","AnimatedImage","MakeAnimatedImageFromEncoded","bind","useAnimatedImage","source","onError","useRawData","exports"],"sources":["AnimatedImage.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSourceParam } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n\nconst animatedImgFactory = Skia.AnimatedImage.MakeAnimatedImageFromEncoded.bind(\n Skia.AnimatedImage\n);\n\n/**\n * Returns a Skia Animated Image object\n * */\nexport const useAnimatedImage = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => useRawData(source, animatedImgFactory, onError);\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AAEA,MAAME,kBAAkB,GAAGC,UAAI,CAACC,aAAa,CAACC,4BAA4B,CAACC,IAAI,CAC7EH,UAAI,CAACC,aACP,CAAC;;AAED;AACA;AACA;AACO,MAAMG,gBAAgB,GAAGA,CAC9BC,MAAuB,EACvBC,OAA8B,KAC3B,IAAAC,gBAAU,EAACF,MAAM,EAAEN,kBAAkB,EAAEO,OAAO,CAAC;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SkData, DataSourceParam, SkJSIInstance } from "../types";
|
|
2
2
|
export declare const loadData: <T>(source: DataSourceParam, factory: (data: SkData) => T | null, onError?: (err: Error) => void) => Promise<T | null>;
|
|
3
3
|
export declare const useCollectionLoading: <T extends SkJSIInstance<string>>(source: DataSourceParam[], loader: () => Promise<(T | null)[]>) => T[] | null;
|
|
4
|
-
export declare const useRawData: <T extends SkJSIInstance<string>>(source: DataSourceParam, factory: (data: SkData) => T | null, onError?: (err: Error) => void
|
|
4
|
+
export declare const useRawData: <T extends SkJSIInstance<string>>(source: DataSourceParam, factory: (data: SkData) => T | null, onError?: (err: Error) => void) => T | null;
|
|
5
5
|
export declare const useData: (source: DataSourceParam, onError?: (err: Error) => void) => SkData | null;
|
|
@@ -27,7 +27,7 @@ const loadData = (source, factory, onError) => {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
exports.loadData = loadData;
|
|
30
|
-
const useLoading = (source, loader
|
|
30
|
+
const useLoading = (source, loader) => {
|
|
31
31
|
const mounted = (0, _react.useRef)(false);
|
|
32
32
|
const [data, setData] = (0, _react.useState)(null);
|
|
33
33
|
const dataRef = (0, _react.useRef)(null);
|
|
@@ -40,10 +40,6 @@ const useLoading = (source, loader, manage = true) => {
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
return () => {
|
|
43
|
-
if (manage) {
|
|
44
|
-
var _dataRef$current;
|
|
45
|
-
(_dataRef$current = dataRef.current) === null || _dataRef$current === void 0 || _dataRef$current.dispose();
|
|
46
|
-
}
|
|
47
43
|
mounted.current = false;
|
|
48
44
|
};
|
|
49
45
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -64,8 +60,6 @@ const useCollectionLoading = (source, loader) => {
|
|
|
64
60
|
}
|
|
65
61
|
});
|
|
66
62
|
return () => {
|
|
67
|
-
var _dataRef$current2;
|
|
68
|
-
(_dataRef$current2 = dataRef.current) === null || _dataRef$current2 === void 0 || _dataRef$current2.forEach(instance => instance === null || instance === void 0 ? void 0 : instance.dispose());
|
|
69
63
|
mounted.current = false;
|
|
70
64
|
};
|
|
71
65
|
|
|
@@ -74,7 +68,7 @@ const useCollectionLoading = (source, loader) => {
|
|
|
74
68
|
return data;
|
|
75
69
|
};
|
|
76
70
|
exports.useCollectionLoading = useCollectionLoading;
|
|
77
|
-
const useRawData = (source, factory, onError
|
|
71
|
+
const useRawData = (source, factory, onError) => useLoading(source, () => loadData(source, factory, onError));
|
|
78
72
|
exports.useRawData = useRawData;
|
|
79
73
|
const identity = data => data;
|
|
80
74
|
const useData = (source, onError) => useRawData(source, identity, onError);
|