@shopify/react-native-skia 0.1.172 → 0.1.174
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/CMakeLists.txt +1 -0
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +5 -0
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.cpp +106 -5
- package/android/cpp/rnskia-android/SkiaOpenGLRenderer.h +3 -1
- package/cpp/api/JsiSkSurface.h +7 -1
- package/cpp/api/JsiSkSurfaceFactory.h +15 -2
- package/cpp/rnskia/RNSkDomView.cpp +2 -4
- package/cpp/rnskia/RNSkJsView.cpp +3 -0
- package/cpp/rnskia/RNSkPictureView.h +3 -0
- package/cpp/rnskia/RNSkPlatformContext.h +9 -0
- package/cpp/rnskia/dom/JsiDomApi.h +1 -0
- package/cpp/rnskia/dom/base/ConcatablePaint.cpp +117 -0
- package/cpp/rnskia/dom/base/ConcatablePaint.h +49 -0
- package/cpp/rnskia/dom/base/Declaration.h +88 -0
- package/cpp/rnskia/dom/base/DeclarationContext.h +79 -0
- package/cpp/rnskia/dom/base/DerivedNodeProp.h +25 -9
- package/cpp/rnskia/dom/base/DrawingContext.cpp +32 -186
- package/cpp/rnskia/dom/base/DrawingContext.h +45 -64
- package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +35 -106
- package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +28 -9
- package/cpp/rnskia/dom/base/JsiDomNode.h +46 -17
- package/cpp/rnskia/dom/base/JsiDomRenderNode.h +81 -67
- package/cpp/rnskia/dom/base/NodeProp.h +12 -2
- package/cpp/rnskia/dom/base/NodePropsContainer.h +15 -16
- package/cpp/rnskia/dom/nodes/JsiBackdropFilterNode.h +22 -11
- package/cpp/rnskia/dom/nodes/JsiBlendNode.h +43 -59
- package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +16 -17
- package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +6 -5
- package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +45 -69
- package/cpp/rnskia/dom/nodes/JsiGroupNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +121 -161
- package/cpp/rnskia/dom/nodes/JsiImageNode.h +1 -0
- package/cpp/rnskia/dom/nodes/JsiLayerNode.h +28 -18
- package/cpp/rnskia/dom/nodes/JsiPaintNode.h +82 -45
- package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +68 -101
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +3 -2
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +150 -207
- package/cpp/rnskia/dom/props/BezierProps.h +4 -2
- package/cpp/rnskia/dom/props/BlendModeProp.h +4 -2
- package/cpp/rnskia/dom/props/BoxShadowProps.h +8 -10
- package/cpp/rnskia/dom/props/CircleProp.h +6 -5
- package/cpp/rnskia/dom/props/ClipProp.h +6 -4
- package/cpp/rnskia/dom/props/ColorProp.h +8 -4
- package/cpp/rnskia/dom/props/DrawingProp.h +5 -3
- package/cpp/rnskia/dom/props/FontProp.h +4 -2
- package/cpp/rnskia/dom/props/GlyphsProp.h +4 -2
- package/cpp/rnskia/dom/props/ImageProps.h +9 -6
- package/cpp/rnskia/dom/props/LayerProp.h +6 -4
- package/cpp/rnskia/dom/props/MatrixProp.h +4 -2
- package/cpp/rnskia/dom/props/NumbersProp.h +8 -4
- package/cpp/rnskia/dom/props/PaintProps.h +55 -92
- package/cpp/rnskia/dom/props/PathProp.h +4 -2
- package/cpp/rnskia/dom/props/PictureProp.h +4 -2
- package/cpp/rnskia/dom/props/PointProp.h +4 -2
- package/cpp/rnskia/dom/props/PointsProp.h +8 -4
- package/cpp/rnskia/dom/props/RRectProp.h +23 -16
- package/cpp/rnskia/dom/props/RadiusProp.h +4 -2
- package/cpp/rnskia/dom/props/RectProp.h +18 -12
- package/cpp/rnskia/dom/props/StrokeProps.h +8 -4
- package/cpp/rnskia/dom/props/SvgProp.h +4 -2
- package/cpp/rnskia/dom/props/TextBlobProp.h +10 -8
- package/cpp/rnskia/dom/props/TileModeProp.h +4 -2
- package/cpp/rnskia/dom/props/TransformProp.h +4 -2
- package/cpp/rnskia/dom/props/TransformsProps.h +5 -7
- package/cpp/rnskia/dom/props/UniformsProp.h +4 -2
- package/cpp/rnskia/dom/props/VertexModeProp.h +4 -2
- package/cpp/rnskia/dom/props/VerticesProps.h +7 -11
- package/ios/RNSkia-iOS/DisplayLink.mm +22 -24
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +53 -50
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +2 -0
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +56 -25
- package/ios/RNSkia-iOS/SkiaDomViewManager.mm +17 -17
- package/ios/RNSkia-iOS/SkiaDrawViewManager.mm +17 -17
- package/ios/RNSkia-iOS/SkiaManager.mm +12 -10
- package/ios/RNSkia-iOS/SkiaMetalRenderer.h +5 -0
- package/ios/RNSkia-iOS/SkiaMetalRenderer.mm +53 -0
- package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +17 -17
- package/ios/RNSkia-iOS/SkiaUIView.mm +63 -53
- package/ios/RNSkiaModule.mm +5 -7
- package/lib/commonjs/dom/nodes/DrawingNode.js +5 -1
- package/lib/commonjs/dom/nodes/DrawingNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +33 -34
- package/lib/commonjs/dom/nodes/LayerNode.js +13 -6
- package/lib/commonjs/dom/nodes/LayerNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/Node.d.ts +6 -11
- package/lib/commonjs/dom/nodes/Node.js +8 -26
- package/lib/commonjs/dom/nodes/Node.js.map +1 -1
- package/lib/commonjs/dom/nodes/PaintContext.js.map +1 -1
- package/lib/commonjs/dom/nodes/PaintNode.d.ts +3 -3
- package/lib/commonjs/dom/nodes/PaintNode.js +32 -15
- package/lib/commonjs/dom/nodes/PaintNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/RenderNode.d.ts +2 -3
- package/lib/commonjs/dom/nodes/RenderNode.js +19 -187
- package/lib/commonjs/dom/nodes/RenderNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
- package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js +25 -7
- package/lib/commonjs/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/Box.d.ts +3 -1
- package/lib/commonjs/dom/nodes/drawings/Box.js +3 -0
- package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/BlendNode.d.ts +3 -7
- package/lib/commonjs/dom/nodes/paint/BlendNode.js +16 -47
- package/lib/commonjs/dom/nodes/paint/BlendNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/ColorFilters.d.ts +10 -11
- package/lib/commonjs/dom/nodes/paint/ColorFilters.js +29 -43
- package/lib/commonjs/dom/nodes/paint/ColorFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/ImageFilters.d.ts +11 -11
- package/lib/commonjs/dom/nodes/paint/ImageFilters.js +45 -42
- package/lib/commonjs/dom/nodes/paint/ImageFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/MaskFilters.d.ts +3 -3
- package/lib/commonjs/dom/nodes/paint/MaskFilters.js +3 -2
- package/lib/commonjs/dom/nodes/paint/MaskFilters.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/PathEffects.d.ts +15 -18
- package/lib/commonjs/dom/nodes/paint/PathEffects.js +30 -72
- package/lib/commonjs/dom/nodes/paint/PathEffects.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/Shaders.d.ts +11 -12
- package/lib/commonjs/dom/nodes/paint/Shaders.js +28 -18
- package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/commonjs/dom/types/DeclarationContext.d.ts +29 -0
- package/lib/commonjs/dom/types/DeclarationContext.js +118 -0
- package/lib/commonjs/dom/types/DeclarationContext.js.map +1 -0
- package/lib/commonjs/dom/types/DrawingContext.d.ts +18 -1
- package/lib/commonjs/dom/types/DrawingContext.js +330 -0
- package/lib/commonjs/dom/types/DrawingContext.js.map +1 -1
- package/lib/commonjs/dom/types/Node.d.ts +4 -10
- package/lib/commonjs/dom/types/Node.js.map +1 -1
- package/lib/commonjs/dom/types/SkDOM.d.ts +22 -23
- package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
- package/lib/commonjs/dom/types/index.d.ts +1 -0
- package/lib/commonjs/dom/types/index.js +13 -0
- package/lib/commonjs/dom/types/index.js.map +1 -1
- package/lib/commonjs/index.d.ts +1 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +3 -3
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/DrawingContext.d.ts +4 -3
- package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
- package/lib/commonjs/renderer/HostComponents.d.ts +35 -35
- package/lib/commonjs/renderer/HostComponents.js.map +1 -1
- package/lib/commonjs/renderer/HostConfig.js +1 -0
- package/lib/commonjs/renderer/HostConfig.js.map +1 -1
- package/lib/commonjs/renderer/Offscreen.d.ts +2 -0
- package/lib/commonjs/renderer/Offscreen.js +31 -0
- package/lib/commonjs/renderer/Offscreen.js.map +1 -0
- package/lib/commonjs/renderer/Reconciler.js +0 -1
- package/lib/commonjs/renderer/Reconciler.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/Surface.d.ts +4 -0
- package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +6 -0
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkDataFactory.js +0 -1
- package/lib/commonjs/skia/web/JsiSkDataFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkImage.js +34 -3
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkSurface.js +4 -0
- package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +21 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/commonjs/views/SkiaBaseWebView.js +14 -8
- package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.web.js +3 -14
- package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.web.js +0 -7
- package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
- package/lib/commonjs/views/SkiaView.web.js +0 -7
- package/lib/commonjs/views/SkiaView.web.js.map +1 -1
- package/lib/module/dom/nodes/DrawingNode.js +5 -1
- package/lib/module/dom/nodes/DrawingNode.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.d.ts +33 -34
- package/lib/module/dom/nodes/LayerNode.js +13 -7
- package/lib/module/dom/nodes/LayerNode.js.map +1 -1
- package/lib/module/dom/nodes/Node.d.ts +6 -11
- package/lib/module/dom/nodes/Node.js +8 -25
- package/lib/module/dom/nodes/Node.js.map +1 -1
- package/lib/module/dom/nodes/PaintContext.js.map +1 -1
- package/lib/module/dom/nodes/PaintNode.d.ts +3 -3
- package/lib/module/dom/nodes/PaintNode.js +32 -15
- package/lib/module/dom/nodes/PaintNode.js.map +1 -1
- package/lib/module/dom/nodes/RenderNode.d.ts +2 -3
- package/lib/module/dom/nodes/RenderNode.js +20 -187
- package/lib/module/dom/nodes/RenderNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
- package/lib/module/dom/nodes/drawings/BackdropFilterNode.js +23 -4
- package/lib/module/dom/nodes/drawings/BackdropFilterNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Box.d.ts +3 -1
- package/lib/module/dom/nodes/drawings/Box.js +3 -0
- package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/module/dom/nodes/paint/BlendNode.d.ts +3 -7
- package/lib/module/dom/nodes/paint/BlendNode.js +15 -46
- package/lib/module/dom/nodes/paint/BlendNode.js.map +1 -1
- package/lib/module/dom/nodes/paint/ColorFilters.d.ts +10 -11
- package/lib/module/dom/nodes/paint/ColorFilters.js +29 -43
- package/lib/module/dom/nodes/paint/ColorFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/ImageFilters.d.ts +11 -11
- package/lib/module/dom/nodes/paint/ImageFilters.js +48 -41
- package/lib/module/dom/nodes/paint/ImageFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/MaskFilters.d.ts +3 -3
- package/lib/module/dom/nodes/paint/MaskFilters.js +3 -2
- package/lib/module/dom/nodes/paint/MaskFilters.js.map +1 -1
- package/lib/module/dom/nodes/paint/PathEffects.d.ts +15 -18
- package/lib/module/dom/nodes/paint/PathEffects.js +29 -72
- package/lib/module/dom/nodes/paint/PathEffects.js.map +1 -1
- package/lib/module/dom/nodes/paint/Shaders.d.ts +11 -12
- package/lib/module/dom/nodes/paint/Shaders.js +28 -18
- package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/module/dom/types/DeclarationContext.d.ts +29 -0
- package/lib/module/dom/types/DeclarationContext.js +107 -0
- package/lib/module/dom/types/DeclarationContext.js.map +1 -0
- package/lib/module/dom/types/DrawingContext.d.ts +18 -1
- package/lib/module/dom/types/DrawingContext.js +322 -1
- package/lib/module/dom/types/DrawingContext.js.map +1 -1
- package/lib/module/dom/types/Node.d.ts +4 -10
- package/lib/module/dom/types/Node.js.map +1 -1
- package/lib/module/dom/types/SkDOM.d.ts +22 -23
- package/lib/module/dom/types/SkDOM.js.map +1 -1
- package/lib/module/dom/types/index.d.ts +1 -0
- package/lib/module/dom/types/index.js +1 -0
- package/lib/module/dom/types/index.js.map +1 -1
- package/lib/module/index.d.ts +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +3 -3
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/DrawingContext.d.ts +4 -3
- package/lib/module/renderer/DrawingContext.js.map +1 -1
- package/lib/module/renderer/HostComponents.d.ts +35 -35
- package/lib/module/renderer/HostComponents.js.map +1 -1
- package/lib/module/renderer/HostConfig.js +1 -0
- package/lib/module/renderer/HostConfig.js.map +1 -1
- package/lib/module/renderer/Offscreen.d.ts +2 -0
- package/lib/module/renderer/Offscreen.js +19 -0
- package/lib/module/renderer/Offscreen.js.map +1 -0
- package/lib/module/renderer/Reconciler.js +0 -1
- package/lib/module/renderer/Reconciler.js.map +1 -1
- package/lib/module/skia/types/Surface/Surface.d.ts +4 -0
- package/lib/module/skia/types/Surface/Surface.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +6 -0
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkDataFactory.js +0 -1
- package/lib/module/skia/web/JsiSkDataFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/module/skia/web/JsiSkImage.js +31 -3
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/module/skia/web/JsiSkSurface.js +4 -0
- package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js +21 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.js +14 -8
- package/lib/module/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/views/SkiaDomView.web.js +2 -11
- package/lib/module/views/SkiaDomView.web.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +0 -5
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/views/SkiaView.web.js +0 -5
- package/lib/module/views/SkiaView.web.js.map +1 -1
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +33 -34
- package/lib/typescript/src/dom/nodes/Node.d.ts +6 -11
- package/lib/typescript/src/dom/nodes/PaintNode.d.ts +3 -3
- package/lib/typescript/src/dom/nodes/RenderNode.d.ts +2 -3
- package/lib/typescript/src/dom/nodes/drawings/BackdropFilterNode.d.ts +1 -1
- package/lib/typescript/src/dom/nodes/drawings/Box.d.ts +3 -1
- package/lib/typescript/src/dom/nodes/paint/BlendNode.d.ts +3 -7
- package/lib/typescript/src/dom/nodes/paint/ColorFilters.d.ts +10 -11
- package/lib/typescript/src/dom/nodes/paint/ImageFilters.d.ts +11 -11
- package/lib/typescript/src/dom/nodes/paint/MaskFilters.d.ts +3 -3
- package/lib/typescript/src/dom/nodes/paint/PathEffects.d.ts +15 -18
- package/lib/typescript/src/dom/nodes/paint/Shaders.d.ts +11 -12
- package/lib/typescript/src/dom/types/DeclarationContext.d.ts +29 -0
- package/lib/typescript/src/dom/types/DrawingContext.d.ts +18 -1
- package/lib/typescript/src/dom/types/Node.d.ts +4 -10
- package/lib/typescript/src/dom/types/SkDOM.d.ts +22 -23
- package/lib/typescript/src/dom/types/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/renderer/DrawingContext.d.ts +4 -3
- package/lib/typescript/src/renderer/HostComponents.d.ts +35 -35
- package/lib/typescript/src/renderer/Offscreen.d.ts +2 -0
- package/lib/typescript/src/skia/types/Surface/Surface.d.ts +4 -0
- package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +6 -0
- package/lib/typescript/src/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
- package/package.json +1 -1
- package/src/dom/nodes/DrawingNode.ts +5 -1
- package/src/dom/nodes/LayerNode.ts +13 -11
- package/src/dom/nodes/Node.ts +18 -41
- package/src/dom/nodes/PaintContext.ts +1 -0
- package/src/dom/nodes/PaintNode.ts +28 -18
- package/src/dom/nodes/RenderNode.ts +25 -183
- package/src/dom/nodes/drawings/BackdropFilterNode.ts +18 -11
- package/src/dom/nodes/drawings/Box.ts +6 -4
- package/src/dom/nodes/paint/BlendNode.ts +16 -63
- package/src/dom/nodes/paint/ColorFilters.ts +32 -55
- package/src/dom/nodes/paint/ImageFilters.ts +58 -53
- package/src/dom/nodes/paint/MaskFilters.ts +5 -7
- package/src/dom/nodes/paint/PathEffects.ts +37 -90
- package/src/dom/nodes/paint/Shaders.ts +31 -29
- package/src/dom/types/DeclarationContext.ts +105 -0
- package/src/dom/types/DrawingContext.ts +304 -1
- package/src/dom/types/Node.ts +4 -20
- package/src/dom/types/SkDOM.ts +22 -43
- package/src/dom/types/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/renderer/Canvas.tsx +3 -3
- package/src/renderer/DrawingContext.ts +4 -5
- package/src/renderer/HostComponents.ts +34 -53
- package/src/renderer/HostConfig.ts +1 -0
- package/src/renderer/Offscreen.tsx +24 -0
- package/src/renderer/Reconciler.tsx +0 -1
- package/src/skia/types/Surface/Surface.ts +5 -0
- package/src/skia/types/Surface/SurfaceFactory.ts +7 -0
- package/src/skia/web/JsiSkDataFactory.ts +0 -1
- package/src/skia/web/JsiSkImage.ts +26 -2
- package/src/skia/web/JsiSkSurface.ts +4 -0
- package/src/skia/web/JsiSkSurfaceFactory.ts +21 -2
- package/src/views/SkiaBaseWebView.tsx +9 -2
- package/src/views/SkiaDomView.web.tsx +2 -13
- package/src/views/SkiaPictureView.web.tsx +0 -7
- package/src/views/SkiaView.web.tsx +0 -7
|
@@ -21,17 +21,13 @@ namespace RNSkia {
|
|
|
21
21
|
|
|
22
22
|
class VerticesProps : public DerivedSkProp<SkVertices> {
|
|
23
23
|
public:
|
|
24
|
-
VerticesProps(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_colorsProp =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_texturesProp =
|
|
32
|
-
addProperty(std::make_shared<PointsProp>(JsiPropId::get("textures")));
|
|
33
|
-
_indicesProp =
|
|
34
|
-
addProperty(std::make_shared<Numbers16Prop>(JsiPropId::get("indices")));
|
|
24
|
+
explicit VerticesProps(const std::function<void(BaseNodeProp *)> &onChange)
|
|
25
|
+
: DerivedSkProp<SkVertices>(onChange) {
|
|
26
|
+
_vertexModeProp = defineProperty<VertexModeProp>("mode");
|
|
27
|
+
_colorsProp = defineProperty<ColorsProp>("colors");
|
|
28
|
+
_verticesProp = defineProperty<PointsProp>("vertices");
|
|
29
|
+
_texturesProp = defineProperty<PointsProp>("textures");
|
|
30
|
+
_indicesProp = defineProperty<Numbers16Prop>("indices");
|
|
35
31
|
|
|
36
32
|
_vertexModeProp->require();
|
|
37
33
|
_verticesProp->require();
|
|
@@ -2,35 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
@implementation DisplayLink
|
|
4
4
|
|
|
5
|
-
- (void)start:(block_t)block
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(update:)];
|
|
5
|
+
- (void)start:(block_t)block {
|
|
6
|
+
self.updateBlock = block;
|
|
7
|
+
// check whether the loop is already running
|
|
8
|
+
if (_displayLink == nil) {
|
|
9
|
+
// specify update method
|
|
10
|
+
_displayLink = [CADisplayLink displayLinkWithTarget:self
|
|
11
|
+
selector:@selector(update:)];
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
// add the display link to the main run loop
|
|
14
|
+
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop]
|
|
15
|
+
forMode:NSRunLoopCommonModes];
|
|
16
|
+
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
- (void)stop
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
19
|
+
- (void)stop {
|
|
20
|
+
// check whether the loop is already stopped
|
|
21
|
+
if (_displayLink != nil) {
|
|
22
|
+
// if the display link is present, it gets invalidated (loop stops)
|
|
23
|
+
|
|
24
|
+
[_displayLink invalidate];
|
|
25
|
+
_displayLink = nil;
|
|
26
|
+
}
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
- (void)update:(CADisplayLink *)sender
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
_updateBlock(time);
|
|
29
|
+
- (void)update:(CADisplayLink *)sender {
|
|
30
|
+
double time = [sender timestamp];
|
|
31
|
+
_updateBlock(time);
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
@end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
#import <RNSkMetalCanvasProvider.h>
|
|
2
1
|
#import <RNSkLog.h>
|
|
2
|
+
#import <RNSkMetalCanvasProvider.h>
|
|
3
3
|
|
|
4
4
|
#pragma clang diagnostic push
|
|
5
5
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
6
6
|
|
|
7
|
+
#import "SkCanvas.h"
|
|
7
8
|
#import "SkColorSpace.h"
|
|
8
9
|
#import "SkSurface.h"
|
|
9
|
-
#import "SkCanvas.h"
|
|
10
10
|
|
|
11
11
|
#import <include/gpu/GrDirectContext.h>
|
|
12
12
|
|
|
@@ -25,14 +25,14 @@ RNSkMetalCanvasProvider::getMetalRenderContext() {
|
|
|
25
25
|
return renderContexts.at(threadId);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
RNSkMetalCanvasProvider::RNSkMetalCanvasProvider(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
RNSkMetalCanvasProvider::RNSkMetalCanvasProvider(
|
|
29
|
+
std::function<void()> requestRedraw,
|
|
30
|
+
std::shared_ptr<RNSkia::RNSkPlatformContext> context)
|
|
31
|
+
: RNSkCanvasProvider(requestRedraw), _context(context) {
|
|
32
|
+
#pragma clang diagnostic push
|
|
33
|
+
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
|
|
34
34
|
_layer = [CAMetalLayer layer];
|
|
35
|
-
|
|
35
|
+
#pragma clang diagnostic pop
|
|
36
36
|
|
|
37
37
|
auto device = MTLCreateSystemDefaultDevice();
|
|
38
38
|
|
|
@@ -44,79 +44,82 @@ RNSkCanvasProvider(requestRedraw),
|
|
|
44
44
|
_layer.contentsGravity = kCAGravityBottomLeft;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
RNSkMetalCanvasProvider::~RNSkMetalCanvasProvider() {
|
|
48
|
-
|
|
49
|
-
}
|
|
47
|
+
RNSkMetalCanvasProvider::~RNSkMetalCanvasProvider() {}
|
|
50
48
|
|
|
51
49
|
/**
|
|
52
50
|
Returns the scaled width of the view
|
|
53
51
|
*/
|
|
54
|
-
float RNSkMetalCanvasProvider::getScaledWidth() {
|
|
52
|
+
float RNSkMetalCanvasProvider::getScaledWidth() {
|
|
53
|
+
return _width * _context->getPixelDensity();
|
|
54
|
+
};
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
Returns the scaled height of the view
|
|
58
58
|
*/
|
|
59
|
-
float RNSkMetalCanvasProvider::getScaledHeight() {
|
|
59
|
+
float RNSkMetalCanvasProvider::getScaledHeight() {
|
|
60
|
+
return _height * _context->getPixelDensity();
|
|
61
|
+
};
|
|
60
62
|
|
|
61
63
|
/**
|
|
62
64
|
Render to a canvas
|
|
63
65
|
*/
|
|
64
|
-
void RNSkMetalCanvasProvider::renderToCanvas(
|
|
66
|
+
void RNSkMetalCanvasProvider::renderToCanvas(
|
|
67
|
+
const std::function<void(SkCanvas *)> &cb) {
|
|
65
68
|
if (_width <= 0 || _height <= 0) {
|
|
66
69
|
return;
|
|
67
70
|
}
|
|
68
|
-
|
|
69
|
-
// Make sure to NOT render or try any render operations while we're in the
|
|
70
|
-
// This will cause an error that might clear the
|
|
71
|
-
// the app receives focus again.
|
|
71
|
+
|
|
72
|
+
// Make sure to NOT render or try any render operations while we're in the
|
|
73
|
+
// background or inactive. This will cause an error that might clear the
|
|
74
|
+
// CAMetalLayer so that the canvas is empty when the app receives focus again.
|
|
72
75
|
// Reference: https://github.com/Shopify/react-native-skia/issues/1257
|
|
73
76
|
auto state = UIApplication.sharedApplication.applicationState;
|
|
74
|
-
if (state == UIApplicationStateBackground ||
|
|
75
|
-
|
|
77
|
+
if (state == UIApplicationStateBackground ||
|
|
78
|
+
state == UIApplicationStateInactive) {
|
|
76
79
|
// Request a redraw in the next run loop callback
|
|
77
80
|
_requestRedraw();
|
|
78
|
-
// and don't draw now since it might cause errors in the metal renderer if
|
|
81
|
+
// and don't draw now since it might cause errors in the metal renderer if
|
|
79
82
|
// we try to render while in the background. (see above issue)
|
|
80
83
|
return;
|
|
81
84
|
}
|
|
82
|
-
|
|
85
|
+
|
|
83
86
|
// Get render context for current thread
|
|
84
87
|
auto renderContext = getMetalRenderContext();
|
|
85
|
-
|
|
88
|
+
|
|
86
89
|
if (renderContext->skContext == nullptr) {
|
|
87
90
|
auto device = MTLCreateSystemDefaultDevice();
|
|
88
|
-
renderContext->commandQueue =
|
|
89
|
-
|
|
91
|
+
renderContext->commandQueue =
|
|
92
|
+
id<MTLCommandQueue>(CFRetain((GrMTLHandle)[device newCommandQueue]));
|
|
93
|
+
renderContext->skContext = GrDirectContext::MakeMetal(
|
|
94
|
+
(__bridge void *)device, (__bridge void *)renderContext->commandQueue);
|
|
90
95
|
}
|
|
91
96
|
|
|
92
|
-
// Wrap in auto release pool since we want the system to clean up after
|
|
93
|
-
// and not wait until later - we've seen some example of memory
|
|
94
|
-
// fast in the simulator without this.
|
|
95
|
-
@autoreleasepool
|
|
96
|
-
{
|
|
97
|
+
// Wrap in auto release pool since we want the system to clean up after
|
|
98
|
+
// rendering and not wait until later - we've seen some example of memory
|
|
99
|
+
// usage growing very fast in the simulator without this.
|
|
100
|
+
@autoreleasepool {
|
|
97
101
|
|
|
98
102
|
GrMTLHandle drawableHandle;
|
|
99
|
-
auto skSurface = SkSurface::MakeFromCAMetalLayer(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if(skSurface == nullptr || skSurface->getCanvas() == nullptr) {
|
|
109
|
-
RNSkia::RNSkLogger::logToConsole("Skia surface could not be created from parameters.");
|
|
103
|
+
auto skSurface = SkSurface::MakeFromCAMetalLayer(
|
|
104
|
+
renderContext->skContext.get(), (__bridge GrMTLHandle)_layer,
|
|
105
|
+
kTopLeft_GrSurfaceOrigin, 1, kBGRA_8888_SkColorType, nullptr, nullptr,
|
|
106
|
+
&drawableHandle);
|
|
107
|
+
|
|
108
|
+
if (skSurface == nullptr || skSurface->getCanvas() == nullptr) {
|
|
109
|
+
RNSkia::RNSkLogger::logToConsole(
|
|
110
|
+
"Skia surface could not be created from parameters.");
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
+
|
|
113
114
|
SkCanvas *canvas = skSurface->getCanvas();
|
|
114
|
-
canvas
|
|
115
|
-
|
|
115
|
+
cb(canvas);
|
|
116
|
+
|
|
116
117
|
skSurface->flushAndSubmit();
|
|
117
|
-
|
|
118
|
-
id<CAMetalDrawable> currentDrawable =
|
|
119
|
-
|
|
118
|
+
|
|
119
|
+
id<CAMetalDrawable> currentDrawable =
|
|
120
|
+
(__bridge id<CAMetalDrawable>)drawableHandle;
|
|
121
|
+
id<MTLCommandBuffer> commandBuffer(
|
|
122
|
+
[renderContext->commandQueue commandBuffer]);
|
|
120
123
|
commandBuffer.label = @"PresentSkia";
|
|
121
124
|
[commandBuffer presentDrawable:currentDrawable];
|
|
122
125
|
[commandBuffer commit];
|
|
@@ -128,9 +131,9 @@ void RNSkMetalCanvasProvider::setSize(int width, int height) {
|
|
|
128
131
|
_height = height;
|
|
129
132
|
_layer.frame = CGRectMake(0, 0, width, height);
|
|
130
133
|
_layer.drawableSize = CGSizeMake(width * _context->getPixelDensity(),
|
|
131
|
-
height* _context->getPixelDensity());
|
|
134
|
+
height * _context->getPixelDensity());
|
|
132
135
|
|
|
133
136
|
_requestRedraw();
|
|
134
137
|
}
|
|
135
138
|
|
|
136
|
-
CALayer*
|
|
139
|
+
CALayer *RNSkMetalCanvasProvider::getLayer() { return _layer; }
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
14
14
|
|
|
15
15
|
#include "SkStream.h"
|
|
16
|
+
#include "SkSurface.h"
|
|
16
17
|
|
|
17
18
|
#pragma clang diagnostic pop
|
|
18
19
|
|
|
@@ -59,6 +60,7 @@ public:
|
|
|
59
60
|
const std::function<void(std::unique_ptr<SkStreamAsset>)> &op) override;
|
|
60
61
|
|
|
61
62
|
void raiseError(const std::exception &err) override;
|
|
63
|
+
sk_sp<SkSurface> makeOffscreenSurface(int width, int height) override;
|
|
62
64
|
|
|
63
65
|
void willInvalidateModules() {
|
|
64
66
|
// We need to do some house-cleaning here!
|
|
@@ -5,35 +5,67 @@
|
|
|
5
5
|
#include <utility>
|
|
6
6
|
|
|
7
7
|
#include <RNSkMeasureTime.h>
|
|
8
|
+
#include <SkiaMetalRenderer.h>
|
|
9
|
+
|
|
10
|
+
#pragma clang diagnostic push
|
|
11
|
+
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
12
|
+
|
|
13
|
+
#include "SkSurface.h"
|
|
14
|
+
|
|
15
|
+
#pragma clang diagnostic pop
|
|
8
16
|
|
|
9
17
|
namespace RNSkia {
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
void RNSkiOSPlatformContext::performStreamOperation(
|
|
20
|
+
const std::string &sourceUri,
|
|
21
|
+
const std::function<void(std::unique_ptr<SkStreamAsset>)> &op) {
|
|
22
|
+
|
|
23
|
+
RNSkMeasureTime("PlatformContext::performStreamOperation");
|
|
24
|
+
auto loader = [=]() {
|
|
25
|
+
NSURL *url = [[NSURL alloc]
|
|
26
|
+
initWithString:[NSString stringWithUTF8String:sourceUri.c_str()]];
|
|
27
|
+
|
|
28
|
+
NSData *data = nullptr;
|
|
29
|
+
auto scheme = url.scheme;
|
|
30
|
+
auto extension = url.pathExtension;
|
|
31
|
+
|
|
32
|
+
if (scheme == nullptr &&
|
|
33
|
+
(extension == nullptr || [extension isEqualToString:@""])) {
|
|
34
|
+
// If the extension and scheme is nil, we assume that we're trying to
|
|
35
|
+
// load from the embedded iOS app bundle and will try to load image
|
|
36
|
+
// and get data from the image directly. imageNamed will return the
|
|
37
|
+
// best version of the requested image:
|
|
38
|
+
auto image = [UIImage imageNamed:[url absoluteString]];
|
|
39
|
+
// We don't know the image format (png, jpg, etc) but
|
|
40
|
+
// UIImagePNGRepresentation will support all of them
|
|
41
|
+
data = UIImagePNGRepresentation(image);
|
|
42
|
+
} else {
|
|
43
|
+
// Load from metro / node
|
|
44
|
+
data = [NSData dataWithContentsOfURL:url];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
auto bytes = [data bytes];
|
|
48
|
+
auto skData = SkData::MakeWithCopy(bytes, [data length]);
|
|
49
|
+
auto stream = SkMemoryStream::Make(skData);
|
|
50
|
+
|
|
51
|
+
op(std::move(stream));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Fire and forget the thread - will be resolved on completion
|
|
55
|
+
std::thread(loader).detach();
|
|
56
|
+
}
|
|
30
57
|
|
|
31
58
|
void RNSkiOSPlatformContext::raiseError(const std::exception &err) {
|
|
32
|
-
|
|
59
|
+
RCTFatal(RCTErrorWithMessage([NSString stringWithUTF8String:err.what()]));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
sk_sp<SkSurface> RNSkiOSPlatformContext::makeOffscreenSurface(int width,
|
|
63
|
+
int height) {
|
|
64
|
+
return MakeOffscreenMetalSurface(width, height);
|
|
33
65
|
}
|
|
34
66
|
|
|
35
67
|
void RNSkiOSPlatformContext::startDrawLoop() {
|
|
36
|
-
if(_displayLink == nullptr) {
|
|
68
|
+
if (_displayLink == nullptr) {
|
|
37
69
|
_displayLink = [[DisplayLink alloc] init];
|
|
38
70
|
[_displayLink start:^(double time) {
|
|
39
71
|
notifyDrawLoop(false);
|
|
@@ -42,11 +74,10 @@ void RNSkiOSPlatformContext::startDrawLoop() {
|
|
|
42
74
|
}
|
|
43
75
|
|
|
44
76
|
void RNSkiOSPlatformContext::stopDrawLoop() {
|
|
45
|
-
if(_displayLink != nullptr) {
|
|
77
|
+
if (_displayLink != nullptr) {
|
|
46
78
|
[_displayLink stop];
|
|
47
79
|
_displayLink = nullptr;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
80
|
+
}
|
|
51
81
|
}
|
|
52
82
|
|
|
83
|
+
} // namespace RNSkia
|
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
|
|
2
|
-
#include <SkiaDomViewManager.h>
|
|
3
2
|
#include <React/RCTBridge+Private.h>
|
|
3
|
+
#include <SkiaDomViewManager.h>
|
|
4
4
|
|
|
5
|
-
#include <RNSkPlatformContext.h>
|
|
6
5
|
#include <RNSkDomView.h>
|
|
7
6
|
#include <RNSkIOSView.h>
|
|
7
|
+
#include <RNSkPlatformContext.h>
|
|
8
8
|
|
|
9
|
-
#include <SkiaManager.h>
|
|
10
9
|
#include <RNSkiaModule.h>
|
|
10
|
+
#include <SkiaManager.h>
|
|
11
11
|
#include <SkiaUIView.h>
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
13
|
@implementation SkiaDomViewManager
|
|
16
14
|
|
|
17
15
|
RCT_EXPORT_MODULE(SkiaDomView)
|
|
18
16
|
|
|
19
|
-
- (SkiaManager*)
|
|
17
|
+
- (SkiaManager *)skiaManager {
|
|
20
18
|
auto bridge = [RCTBridge currentBridge];
|
|
21
|
-
auto skiaModule = (RNSkiaModule*)[bridge moduleForName:@"RNSkia"];
|
|
19
|
+
auto skiaModule = (RNSkiaModule *)[bridge moduleForName:@"RNSkia"];
|
|
22
20
|
return [skiaModule manager];
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
RCT_CUSTOM_VIEW_PROPERTY(nativeID, NSNumber, SkiaUIView) {
|
|
26
24
|
// Get parameter
|
|
27
25
|
int nativeId = [[RCTConvert NSString:json] intValue];
|
|
28
|
-
[(SkiaUIView*)view setNativeId:nativeId];
|
|
26
|
+
[(SkiaUIView *)view setNativeId:nativeId];
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
RCT_CUSTOM_VIEW_PROPERTY(mode, NSString, SkiaUIView) {
|
|
32
|
-
std::string mode =
|
|
33
|
-
|
|
30
|
+
std::string mode =
|
|
31
|
+
json != NULL ? [[RCTConvert NSString:json] UTF8String] : "default";
|
|
32
|
+
[(SkiaUIView *)view setDrawingMode:mode];
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
RCT_CUSTOM_VIEW_PROPERTY(debug, BOOL, SkiaUIView) {
|
|
37
36
|
bool debug = json != NULL ? [RCTConvert BOOL:json] : false;
|
|
38
|
-
[(SkiaUIView*)view setDebugMode:
|
|
37
|
+
[(SkiaUIView *)view setDebugMode:debug];
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
- (UIView *)view
|
|
42
|
-
{
|
|
40
|
+
- (UIView *)view {
|
|
43
41
|
auto skManager = [[self skiaManager] skManager];
|
|
44
42
|
// Pass SkManager as a raw pointer to avoid circular dependenciesr
|
|
45
|
-
return [[SkiaUIView alloc]
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
return [[SkiaUIView alloc]
|
|
44
|
+
initWithManager:skManager.get()
|
|
45
|
+
factory:[](std::shared_ptr<RNSkia::RNSkPlatformContext> context) {
|
|
46
|
+
return std::make_shared<RNSkiOSView<RNSkia::RNSkDomView>>(
|
|
47
|
+
context);
|
|
48
|
+
}];
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
@end
|
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
#include "SkiaDrawViewManager.h"
|
|
2
2
|
#include <React/RCTBridge+Private.h>
|
|
3
3
|
|
|
4
|
-
#include <RNSkPlatformContext.h>
|
|
5
|
-
#include <RNSkJsView.h>
|
|
6
4
|
#include <RNSkIOSView.h>
|
|
5
|
+
#include <RNSkJsView.h>
|
|
6
|
+
#include <RNSkPlatformContext.h>
|
|
7
7
|
|
|
8
8
|
#include "SkiaManager.h"
|
|
9
|
-
#include <RNSkiaModule.h>
|
|
10
9
|
#include "SkiaUIView.h"
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
#include <RNSkiaModule.h>
|
|
13
11
|
|
|
14
12
|
@implementation SkiaDrawViewManager
|
|
15
13
|
|
|
16
14
|
RCT_EXPORT_MODULE(SkiaDrawView)
|
|
17
15
|
|
|
18
|
-
- (SkiaManager*)
|
|
16
|
+
- (SkiaManager *)skiaManager {
|
|
19
17
|
auto bridge = [RCTBridge currentBridge];
|
|
20
|
-
auto skiaModule = (RNSkiaModule*)[bridge moduleForName:@"RNSkia"];
|
|
18
|
+
auto skiaModule = (RNSkiaModule *)[bridge moduleForName:@"RNSkia"];
|
|
21
19
|
return [skiaModule manager];
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
RCT_CUSTOM_VIEW_PROPERTY(nativeID, NSNumber, SkiaUIView) {
|
|
25
23
|
// Get parameter
|
|
26
24
|
int nativeId = [[RCTConvert NSString:json] intValue];
|
|
27
|
-
[(SkiaUIView*)view setNativeId:nativeId];
|
|
25
|
+
[(SkiaUIView *)view setNativeId:nativeId];
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
RCT_CUSTOM_VIEW_PROPERTY(mode, NSString, SkiaUIView) {
|
|
31
|
-
std::string mode =
|
|
32
|
-
|
|
29
|
+
std::string mode =
|
|
30
|
+
json != NULL ? [[RCTConvert NSString:json] UTF8String] : "default";
|
|
31
|
+
[(SkiaUIView *)view setDrawingMode:mode];
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
RCT_CUSTOM_VIEW_PROPERTY(debug, BOOL, SkiaUIView) {
|
|
36
35
|
bool debug = json != NULL ? [RCTConvert BOOL:json] : false;
|
|
37
|
-
[(SkiaUIView*)view setDebugMode:
|
|
36
|
+
[(SkiaUIView *)view setDebugMode:debug];
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
- (UIView *)view
|
|
41
|
-
{
|
|
39
|
+
- (UIView *)view {
|
|
42
40
|
auto skManager = [[self skiaManager] skManager];
|
|
43
41
|
// Pass SkManager as a raw pointer to avoid circular dependenciesr
|
|
44
|
-
return [[SkiaUIView alloc]
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
return [[SkiaUIView alloc]
|
|
43
|
+
initWithManager:skManager.get()
|
|
44
|
+
factory:[](std::shared_ptr<RNSkia::RNSkPlatformContext> context) {
|
|
45
|
+
return std::make_shared<RNSkiOSView<RNSkia::RNSkJsView>>(
|
|
46
|
+
context);
|
|
47
|
+
}];
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
@end
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
#import <Foundation/Foundation.h>
|
|
4
4
|
|
|
5
|
-
#import <React/RCTBridge.h>
|
|
6
5
|
#import <React/RCTBridge+Private.h>
|
|
6
|
+
#import <React/RCTBridge.h>
|
|
7
7
|
|
|
8
8
|
#import <ReactCommon/RCTTurboModule.h>
|
|
9
9
|
|
|
@@ -12,36 +12,38 @@
|
|
|
12
12
|
@implementation SkiaManager {
|
|
13
13
|
std::shared_ptr<RNSkia::RNSkManager> _skManager;
|
|
14
14
|
std::shared_ptr<RNSkia::RNSkiOSPlatformContext> _platformContext;
|
|
15
|
-
__weak RCTBridge*
|
|
15
|
+
__weak RCTBridge *weakBridge;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
- (std::shared_ptr<RNSkia::RNSkManager>)
|
|
18
|
+
- (std::shared_ptr<RNSkia::RNSkManager>)skManager {
|
|
19
19
|
return _skManager;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
- (void)
|
|
23
|
-
if(_skManager != nullptr) {
|
|
22
|
+
- (void)invalidate {
|
|
23
|
+
if (_skManager != nullptr) {
|
|
24
24
|
_skManager->invalidate();
|
|
25
25
|
}
|
|
26
26
|
_skManager = nullptr;
|
|
27
27
|
_platformContext = nullptr;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
- (instancetype)
|
|
30
|
+
- (instancetype)initWithBridge:(RCTBridge *)bridge {
|
|
31
31
|
self = [super init];
|
|
32
32
|
if (self) {
|
|
33
33
|
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
|
|
34
34
|
if (cxxBridge.runtime) {
|
|
35
35
|
|
|
36
36
|
auto callInvoker = bridge.jsCallInvoker;
|
|
37
|
-
facebook::jsi::Runtime*
|
|
37
|
+
facebook::jsi::Runtime *jsRuntime =
|
|
38
|
+
(facebook::jsi::Runtime *)cxxBridge.runtime;
|
|
38
39
|
|
|
39
40
|
// Create platform context
|
|
40
|
-
_platformContext = std::make_shared<RNSkia::RNSkiOSPlatformContext>(
|
|
41
|
+
_platformContext = std::make_shared<RNSkia::RNSkiOSPlatformContext>(
|
|
42
|
+
jsRuntime, callInvoker);
|
|
41
43
|
|
|
42
44
|
// Create the RNSkiaManager (cross platform)
|
|
43
|
-
_skManager = std::make_shared<RNSkia::RNSkManager>(jsRuntime, callInvoker,
|
|
44
|
-
|
|
45
|
+
_skManager = std::make_shared<RNSkia::RNSkManager>(jsRuntime, callInvoker,
|
|
46
|
+
_platformContext);
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
return self;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#pragma clang diagnostic push
|
|
2
|
+
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
3
|
+
|
|
4
|
+
#import "SkCanvas.h"
|
|
5
|
+
#import "SkColorSpace.h"
|
|
6
|
+
#import "SkSurface.h"
|
|
7
|
+
|
|
8
|
+
#import <include/gpu/GrDirectContext.h>
|
|
9
|
+
|
|
10
|
+
#pragma clang diagnostic pop
|
|
11
|
+
|
|
12
|
+
#import <MetalKit/MetalKit.h>
|
|
13
|
+
|
|
14
|
+
struct OffscreenRenderContext {
|
|
15
|
+
id<MTLDevice> device;
|
|
16
|
+
id<MTLCommandQueue> commandQueue;
|
|
17
|
+
sk_sp<GrDirectContext> skiaContext;
|
|
18
|
+
id<MTLTexture> texture;
|
|
19
|
+
|
|
20
|
+
OffscreenRenderContext(int width, int height) {
|
|
21
|
+
device = MTLCreateSystemDefaultDevice();
|
|
22
|
+
commandQueue =
|
|
23
|
+
id<MTLCommandQueue>(CFRetain((GrMTLHandle)[device newCommandQueue]));
|
|
24
|
+
skiaContext = GrDirectContext::MakeMetal((__bridge void *)device,
|
|
25
|
+
(__bridge void *)commandQueue);
|
|
26
|
+
// Create a Metal texture descriptor
|
|
27
|
+
MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor
|
|
28
|
+
texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm
|
|
29
|
+
width:width
|
|
30
|
+
height:height
|
|
31
|
+
mipmapped:NO];
|
|
32
|
+
textureDescriptor.usage =
|
|
33
|
+
MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
|
|
34
|
+
texture = [device newTextureWithDescriptor:textureDescriptor];
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
sk_sp<SkSurface> MakeOffscreenMetalSurface(int width, int height) {
|
|
39
|
+
auto ctx = new OffscreenRenderContext(width, height);
|
|
40
|
+
|
|
41
|
+
// Create a GrBackendTexture from the Metal texture
|
|
42
|
+
GrMtlTextureInfo info;
|
|
43
|
+
info.fTexture.retain((__bridge void *)ctx->texture);
|
|
44
|
+
GrBackendTexture backendTexture(width, height, GrMipMapped::kNo, info);
|
|
45
|
+
|
|
46
|
+
// Create a SkSurface from the GrBackendTexture
|
|
47
|
+
auto surface = SkSurface::MakeFromBackendTexture(
|
|
48
|
+
ctx->skiaContext.get(), backendTexture, kTopLeft_GrSurfaceOrigin, 0,
|
|
49
|
+
kBGRA_8888_SkColorType, nullptr, nullptr,
|
|
50
|
+
[](void *addr) { delete (OffscreenRenderContext *)addr; }, ctx);
|
|
51
|
+
|
|
52
|
+
return surface;
|
|
53
|
+
}
|