react-native-skia 3.0.1 → 3.0.3
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/Package.swift +14 -13
- package/README.md +19 -2
- package/android/CMakeLists.txt +13 -42
- package/android/build.gradle +54 -63
- package/android/cpp/jni/JniLoad.cpp +2 -4
- package/android/cpp/jni/include/JniSkiaView.h +123 -0
- package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.cpp → RNSkAndroidCanvasProvider.cpp} +45 -100
- package/android/cpp/rnskia-android/{RNSkOpenGLCanvasProvider.h → RNSkAndroidCanvasProvider.h} +24 -22
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -83
- package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +0 -8
- package/android/src/main/java/com/reactnative/skia/RNSkiaPackage.java +1 -2
- package/android/src/main/java/com/reactnative/skia/SkiaSurfaceView.java +1 -3
- package/android/src/main/java/com/reactnative/skia/SkiaTextureView.java +1 -17
- package/android/src/main/java/com/reactnative/skia/{SkiaBaseView.java → SkiaView.java} +78 -16
- package/android/src/main/java/com/reactnative/skia/SkiaViewManager.java +85 -0
- package/apple/MetalLayerColorSpace.mm +10 -12
- package/apple/RNSkApplePlatformContext.h +12 -14
- package/apple/RNSkApplePlatformContext.mm +19 -112
- package/apple/RNSkMetalCanvasProvider.h +14 -19
- package/apple/RNSkMetalCanvasProvider.mm +39 -70
- package/apple/RNSkiaModule.mm +10 -0
- package/apple/SkiaView.h +20 -0
- package/apple/SkiaView.mm +210 -0
- package/cpp/api/JsiSkApi.h +2 -13
- package/cpp/api/JsiSkCanvas.h +4 -18
- package/cpp/api/JsiSkGraphiteContext.h +1 -5
- package/cpp/api/JsiSkGraphiteRecording.h +1 -5
- package/cpp/api/JsiSkImage.h +7 -41
- package/cpp/api/JsiSkImageFactory.h +0 -14
- package/cpp/api/JsiSkSurface.h +2 -16
- package/cpp/api/JsiSkSurfaceFactory.h +0 -8
- package/cpp/rnskia/RNDawnContext.h +3 -2
- package/cpp/rnskia/RNDawnInterop.cpp +0 -4
- package/cpp/rnskia/RNDawnUtils.h +12 -1
- package/cpp/rnskia/RNDawnWindowContext.cpp +12 -1
- package/cpp/rnskia/RNDawnWindowContext.h +19 -7
- package/cpp/rnskia/RNMetalLayerColorSpace.h +4 -2
- package/cpp/rnskia/RNSkCanvasProvider.h +231 -0
- package/cpp/rnskia/RNSkGraphiteProducer.cpp +36 -14
- package/cpp/rnskia/RNSkGraphiteProducer.h +23 -8
- package/cpp/rnskia/RNSkGraphiteTarget.h +396 -0
- package/cpp/rnskia/RNSkJsiViewApi.h +9 -18
- package/cpp/rnskia/RNSkPlatformContext.h +17 -15
- package/cpp/rnskia/RNSkView.h +362 -246
- package/jestSetup.js +1 -3
- package/lib/commonjs/Platform/Platform.web.js +1 -1
- package/lib/commonjs/Platform/Platform.web.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.js +1 -1
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/index.d.ts +1 -3
- package/lib/commonjs/index.js +3 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mock/index.js +0 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.d.ts +15 -12
- package/lib/commonjs/renderer/Canvas.js +25 -21
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Graphite.d.ts +3 -3
- package/lib/commonjs/skia/types/Graphite.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +1 -2
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/commonjs/specs/NativeSkiaModule.web.js +5 -9
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/{typescript/src/specs/SkiaPictureViewNativeComponent.d.ts → commonjs/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/commonjs/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
- package/lib/commonjs/specs/SkiaViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.js +27 -0
- package/lib/commonjs/specs/SkiaViewNativeComponent.web.js.map +1 -0
- package/lib/commonjs/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/commonjs/views/SkiaGraphiteView.js +23 -12
- package/lib/commonjs/views/SkiaGraphiteView.js.map +1 -1
- package/lib/commonjs/views/SkiaPictureView.d.ts +4 -1
- package/lib/commonjs/views/SkiaPictureView.js +12 -10
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/SkiaView.web.d.ts +12 -0
- package/lib/commonjs/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +82 -38
- package/lib/commonjs/views/SkiaView.web.js.map +1 -0
- package/lib/commonjs/views/SkiaWebRenderer.js +1 -1
- package/lib/commonjs/views/SkiaWebRenderer.js.map +1 -1
- package/lib/commonjs/views/android.d.ts +6 -0
- package/lib/commonjs/views/android.js +17 -0
- package/lib/commonjs/views/android.js.map +1 -0
- package/lib/commonjs/views/types.d.ts +3 -12
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/Platform/Platform.web.js +1 -1
- package/lib/module/Platform/Platform.web.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.js +1 -1
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/index.d.ts +1 -3
- package/lib/module/index.js +1 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/mock/index.js +0 -1
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +15 -12
- package/lib/module/renderer/Canvas.js +25 -20
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/types/Graphite.d.ts +3 -3
- package/lib/module/skia/types/Graphite.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +1 -2
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/module/specs/NativeSkiaModule.web.js +5 -9
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/{commonjs/specs/SkiaPictureViewNativeComponent.d.ts → module/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/module/specs/{SkiaPictureViewNativeComponent.js → SkiaViewNativeComponent.js} +2 -2
- package/lib/module/specs/SkiaViewNativeComponent.js.map +1 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.js +21 -0
- package/lib/module/specs/SkiaViewNativeComponent.web.js.map +1 -0
- package/lib/module/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/module/views/SkiaGraphiteView.js +23 -12
- package/lib/module/views/SkiaGraphiteView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.d.ts +4 -1
- package/lib/module/views/SkiaPictureView.js +12 -10
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaView.web.d.ts +12 -0
- package/lib/module/views/{SkiaGraphiteView.web.js → SkiaView.web.js} +80 -36
- package/lib/module/views/SkiaView.web.js.map +1 -0
- package/lib/module/views/SkiaWebRenderer.js +1 -1
- package/lib/module/views/SkiaWebRenderer.js.map +1 -1
- package/lib/module/views/android.d.ts +6 -0
- package/lib/module/views/android.js +10 -0
- package/lib/module/views/android.js.map +1 -0
- package/lib/module/views/types.d.ts +3 -12
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -3
- package/lib/typescript/src/renderer/Canvas.d.ts +15 -12
- package/lib/typescript/src/skia/types/Graphite.d.ts +3 -3
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +2 -2
- package/lib/typescript/src/skia/types/Skia.d.ts +1 -2
- package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +1 -1
- package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +5 -4
- package/lib/{module/specs/SkiaPictureViewNativeComponent.d.ts → typescript/src/specs/SkiaViewNativeComponent.d.ts} +0 -3
- package/lib/typescript/src/specs/SkiaViewNativeComponent.web.d.ts +10 -0
- package/lib/typescript/src/views/SkiaGraphiteView.d.ts +3 -4
- package/lib/typescript/src/views/SkiaPictureView.d.ts +4 -1
- package/lib/typescript/src/views/SkiaView.web.d.ts +12 -0
- package/lib/typescript/src/views/android.d.ts +6 -0
- package/lib/typescript/src/views/types.d.ts +3 -12
- package/package.json +5 -13
- package/react-native-skia.podspec +34 -58
- package/src/Platform/Platform.web.tsx +1 -1
- package/src/external/reanimated/interpolators.ts +1 -1
- package/src/index.ts +1 -3
- package/src/mock/index.ts +0 -1
- package/src/renderer/Canvas.tsx +24 -28
- package/src/skia/types/Graphite.ts +3 -3
- package/src/skia/types/Image/ImageFactory.ts +2 -2
- package/src/skia/types/Skia.ts +1 -2
- package/src/skia/types/Surface/SurfaceFactory.ts +1 -1
- package/src/specs/NativeSkiaModule.web.ts +9 -21
- package/src/specs/{SkiaPictureViewNativeComponent.ts → SkiaViewNativeComponent.ts} +1 -4
- package/src/specs/{SkiaPictureViewNativeComponent.web.ts → SkiaViewNativeComponent.web.ts} +8 -10
- package/src/views/SkiaGraphiteView.tsx +27 -16
- package/src/views/SkiaPictureView.tsx +11 -10
- package/src/views/{SkiaGraphiteView.web.tsx → SkiaView.web.tsx} +100 -53
- package/src/views/SkiaWebRenderer.ts +1 -1
- package/src/views/android.ts +16 -0
- package/src/views/types.ts +3 -14
- package/android/cpp/jni/include/JniSkiaBaseView.h +0 -92
- package/android/cpp/jni/include/JniSkiaGraphiteView.h +0 -176
- package/android/cpp/jni/include/JniSkiaPictureView.h +0 -172
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp +0 -245
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.h +0 -33
- package/android/cpp/rnskia-android/OpenGLContext.h +0 -248
- package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +0 -67
- package/android/cpp/rnskia-android/OpenGLWindowContext.h +0 -75
- package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -67
- package/android/cpp/rnskia-android/gl/Context.h +0 -80
- package/android/cpp/rnskia-android/gl/Display.h +0 -123
- package/android/cpp/rnskia-android/gl/Error.cpp +0 -45
- package/android/cpp/rnskia-android/gl/Error.h +0 -8
- package/android/cpp/rnskia-android/gl/Surface.h +0 -43
- package/android/src/main/java/com/reactnative/skia/SkiaBaseViewManager.java +0 -65
- package/android/src/main/java/com/reactnative/skia/SkiaGraphiteView.java +0 -78
- package/android/src/main/java/com/reactnative/skia/SkiaGraphiteViewManager.java +0 -32
- package/android/src/main/java/com/reactnative/skia/SkiaPictureView.java +0 -105
- package/android/src/main/java/com/reactnative/skia/SkiaPictureViewManager.java +0 -44
- package/apple/MetalContext.h +0 -116
- package/apple/MetalContext.mm +0 -38
- package/apple/MetalWindowContext.h +0 -42
- package/apple/MetalWindowContext.mm +0 -95
- package/apple/RNSkAppleView.h +0 -49
- package/apple/RNSkAppleView.mm +0 -35
- package/apple/SkiaCVPixelBufferUtils.h +0 -122
- package/apple/SkiaCVPixelBufferUtils.mm +0 -535
- package/apple/SkiaGraphiteView.h +0 -26
- package/apple/SkiaGraphiteView.mm +0 -180
- package/apple/SkiaPictureView.h +0 -7
- package/apple/SkiaPictureView.mm +0 -70
- package/apple/SkiaUIView.h +0 -31
- package/apple/SkiaUIView.mm +0 -164
- package/cpp/rnskia/RNSkGraphiteView.h +0 -708
- package/cpp/rnskia/RNSkPictureView.cpp +0 -69
- package/cpp/rnskia/RNSkPictureView.h +0 -211
- package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +0 -1162
- package/lib/commonjs/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/commonjs/renderer/DefaultCanvas.js +0 -42
- package/lib/commonjs/renderer/DefaultCanvas.js.map +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/commonjs/renderer/GraphiteCanvas.js +0 -64
- package/lib/commonjs/renderer/GraphiteCanvas.js.map +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/commonjs/renderer/GraphiteCanvas.web.js +0 -13
- package/lib/commonjs/renderer/GraphiteCanvas.web.js.map +0 -1
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js +0 -12
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js +0 -28
- package/lib/commonjs/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +0 -1
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js +0 -29
- package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
- package/lib/commonjs/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/commonjs/views/SkiaGraphiteView.web.js.map +0 -1
- package/lib/commonjs/views/SkiaPictureView.web.d.ts +0 -11
- package/lib/commonjs/views/SkiaPictureView.web.js +0 -165
- package/lib/commonjs/views/SkiaPictureView.web.js.map +0 -1
- package/lib/module/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/module/renderer/DefaultCanvas.js +0 -34
- package/lib/module/renderer/DefaultCanvas.js.map +0 -1
- package/lib/module/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/module/renderer/GraphiteCanvas.js +0 -57
- package/lib/module/renderer/GraphiteCanvas.js.map +0 -1
- package/lib/module/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/module/renderer/GraphiteCanvas.web.js +0 -4
- package/lib/module/renderer/GraphiteCanvas.web.js.map +0 -1
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.js +0 -8
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.js.map +0 -1
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js +0 -22
- package/lib/module/specs/SkiaGraphiteViewNativeComponent.web.js.map +0 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +0 -1
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.js +0 -23
- package/lib/module/specs/SkiaPictureViewNativeComponent.web.js.map +0 -1
- package/lib/module/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/module/views/SkiaGraphiteView.web.js.map +0 -1
- package/lib/module/views/SkiaPictureView.web.d.ts +0 -11
- package/lib/module/views/SkiaPictureView.web.js +0 -156
- package/lib/module/views/SkiaPictureView.web.js.map +0 -1
- package/lib/typescript/src/renderer/DefaultCanvas.d.ts +0 -8
- package/lib/typescript/src/renderer/GraphiteCanvas.d.ts +0 -22
- package/lib/typescript/src/renderer/GraphiteCanvas.web.d.ts +0 -1
- package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.d.ts +0 -10
- package/lib/typescript/src/specs/SkiaGraphiteViewNativeComponent.web.d.ts +0 -9
- package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +0 -10
- package/lib/typescript/src/views/SkiaGraphiteView.web.d.ts +0 -14
- package/lib/typescript/src/views/SkiaPictureView.web.d.ts +0 -11
- package/libs/.graphite +0 -1
- package/src/renderer/DefaultCanvas.tsx +0 -41
- package/src/renderer/GraphiteCanvas.tsx +0 -61
- package/src/renderer/GraphiteCanvas.web.tsx +0 -3
- package/src/specs/SkiaGraphiteViewNativeComponent.ts +0 -17
- package/src/specs/SkiaGraphiteViewNativeComponent.web.ts +0 -31
- package/src/views/SkiaPictureView.web.tsx +0 -224
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
#import "SkiaGraphiteView.h"
|
|
2
|
-
|
|
3
|
-
#import <React/RCTConversions.h>
|
|
4
|
-
#import <React/RCTConvert.h>
|
|
5
|
-
#import <React/RCTFabricComponentsPlugins.h>
|
|
6
|
-
#import <React/RCTLog.h>
|
|
7
|
-
|
|
8
|
-
#import <react/renderer/components/rnskia/ComponentDescriptors.h>
|
|
9
|
-
#import <react/renderer/components/rnskia/EventEmitters.h>
|
|
10
|
-
#import <react/renderer/components/rnskia/Props.h>
|
|
11
|
-
#import <react/renderer/components/rnskia/RCTComponentViewHelpers.h>
|
|
12
|
-
|
|
13
|
-
using namespace facebook::react;
|
|
14
|
-
|
|
15
|
-
#if defined(SK_GRAPHITE)
|
|
16
|
-
|
|
17
|
-
#import <QuartzCore/CADisplayLink.h>
|
|
18
|
-
|
|
19
|
-
#import "RNSkAppleView.h"
|
|
20
|
-
#import "RNSkGraphiteView.h"
|
|
21
|
-
#import "RNSkPlatformContext.h"
|
|
22
|
-
#import "RNSkiaModule.h"
|
|
23
|
-
|
|
24
|
-
@implementation SkiaGraphiteView {
|
|
25
|
-
#if !TARGET_OS_OSX
|
|
26
|
-
CADisplayLink *_displayLink;
|
|
27
|
-
#endif
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
- (instancetype)initWithFrame:(CGRect)frame {
|
|
31
|
-
if (self = [super initWithFrame:frame]) {
|
|
32
|
-
// Pass SkManager as a raw pointer to avoid circular dependencies
|
|
33
|
-
auto skManager = [RNSkiaModule latestActiveSkManager].get();
|
|
34
|
-
[self initCommon:skManager
|
|
35
|
-
factory:[](std::shared_ptr<RNSkia::RNSkPlatformContext> context) {
|
|
36
|
-
return std::make_shared<RNSkAppleView<RNSkia::RNSkGraphiteView>>(
|
|
37
|
-
context);
|
|
38
|
-
}];
|
|
39
|
-
static const auto defaultProps =
|
|
40
|
-
std::make_shared<const SkiaGraphiteViewProps>();
|
|
41
|
-
_props = defaultProps;
|
|
42
|
-
}
|
|
43
|
-
return self;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
- (std::shared_ptr<RNSkia::RNSkGraphiteView>)graphiteView {
|
|
47
|
-
auto impl = [self impl];
|
|
48
|
-
if (impl == nullptr) {
|
|
49
|
-
return nullptr;
|
|
50
|
-
}
|
|
51
|
-
return std::static_pointer_cast<RNSkia::RNSkGraphiteView>(
|
|
52
|
-
impl->getDrawView());
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
#pragma mark - Frames
|
|
56
|
-
|
|
57
|
-
// Presents on the display link: armed when a recording is submitted, paused
|
|
58
|
-
// again once the queue is empty. macOS has no CADisplayLink on the minimum
|
|
59
|
-
// deployment target, so frames are presented as soon as the main thread gets
|
|
60
|
-
// to them there.
|
|
61
|
-
- (void)scheduleFrame {
|
|
62
|
-
#if !TARGET_OS_OSX
|
|
63
|
-
if (_displayLink == nil) {
|
|
64
|
-
_displayLink = [CADisplayLink displayLinkWithTarget:self
|
|
65
|
-
selector:@selector(onFrame:)];
|
|
66
|
-
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop]
|
|
67
|
-
forMode:NSRunLoopCommonModes];
|
|
68
|
-
}
|
|
69
|
-
_displayLink.paused = NO;
|
|
70
|
-
#else
|
|
71
|
-
auto view = [self graphiteView];
|
|
72
|
-
if (view) {
|
|
73
|
-
view->presentFrame();
|
|
74
|
-
}
|
|
75
|
-
#endif
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
#if !TARGET_OS_OSX
|
|
79
|
-
- (void)onFrame:(CADisplayLink *)link {
|
|
80
|
-
auto view = [self graphiteView];
|
|
81
|
-
if (view == nullptr || !view->presentFrame()) {
|
|
82
|
-
link.paused = YES;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
- (void)stopDisplayLink {
|
|
87
|
-
[_displayLink invalidate];
|
|
88
|
-
_displayLink = nil;
|
|
89
|
-
}
|
|
90
|
-
#endif
|
|
91
|
-
|
|
92
|
-
#pragma mark - Lifecycle
|
|
93
|
-
|
|
94
|
-
#if !TARGET_OS_OSX
|
|
95
|
-
- (void)willMoveToSuperview:(UIView *)newSuperView {
|
|
96
|
-
[super willMoveToSuperview:newSuperView];
|
|
97
|
-
#else
|
|
98
|
-
- (void)viewWillMoveToSuperview:(NSView *)newSuperView {
|
|
99
|
-
[super viewWillMoveToSuperview:newSuperView];
|
|
100
|
-
#endif // !TARGET_OS_OSX
|
|
101
|
-
if (newSuperView != nullptr) {
|
|
102
|
-
if (auto view = [self graphiteView]) {
|
|
103
|
-
__weak SkiaGraphiteView *weakSelf = self;
|
|
104
|
-
view->setFrameScheduler([weakSelf]() { [weakSelf scheduleFrame]; });
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
- (void)removeFromSuperview {
|
|
110
|
-
#if !TARGET_OS_OSX
|
|
111
|
-
[self stopDisplayLink];
|
|
112
|
-
#endif
|
|
113
|
-
[super removeFromSuperview];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
- (void)prepareForRecycle {
|
|
117
|
-
#if !TARGET_OS_OSX
|
|
118
|
-
[self stopDisplayLink];
|
|
119
|
-
#endif
|
|
120
|
-
[super prepareForRecycle];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
- (void)dealloc {
|
|
124
|
-
#if !TARGET_OS_OSX
|
|
125
|
-
[self stopDisplayLink];
|
|
126
|
-
#endif
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
#pragma mark - RCTComponentViewProtocol
|
|
130
|
-
|
|
131
|
-
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
132
|
-
return concreteComponentDescriptorProvider<
|
|
133
|
-
SkiaGraphiteViewComponentDescriptor>();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
- (void)updateProps:(const Props::Shared &)props
|
|
137
|
-
oldProps:(const Props::Shared &)oldProps {
|
|
138
|
-
const auto &newProps =
|
|
139
|
-
*std::static_pointer_cast<const SkiaGraphiteViewProps>(props);
|
|
140
|
-
[super updateProps:props oldProps:oldProps];
|
|
141
|
-
int nativeId =
|
|
142
|
-
[[RCTConvert NSString:RCTNSStringFromString(newProps.nativeId)] intValue];
|
|
143
|
-
[self setNativeId:nativeId];
|
|
144
|
-
[self setDebugMode:newProps.debug];
|
|
145
|
-
[self setOpaque:newProps.opaque];
|
|
146
|
-
[self setHighBitDepth:newProps.highBitDepth];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
@end
|
|
150
|
-
|
|
151
|
-
#else // SK_GRAPHITE
|
|
152
|
-
|
|
153
|
-
@implementation SkiaGraphiteView
|
|
154
|
-
|
|
155
|
-
- (instancetype)initWithFrame:(CGRect)frame {
|
|
156
|
-
if (self = [super initWithFrame:frame]) {
|
|
157
|
-
static dispatch_once_t once;
|
|
158
|
-
dispatch_once(&once, ^{
|
|
159
|
-
RCTLogError(@"SkiaGraphiteView requires the Graphite backend. Rebuild "
|
|
160
|
-
@"with SK_GRAPHITE enabled; the view renders nothing.");
|
|
161
|
-
});
|
|
162
|
-
static const auto defaultProps =
|
|
163
|
-
std::make_shared<const SkiaGraphiteViewProps>();
|
|
164
|
-
_props = defaultProps;
|
|
165
|
-
}
|
|
166
|
-
return self;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
170
|
-
return concreteComponentDescriptorProvider<
|
|
171
|
-
SkiaGraphiteViewComponentDescriptor>();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
@end
|
|
175
|
-
|
|
176
|
-
#endif // SK_GRAPHITE
|
|
177
|
-
|
|
178
|
-
Class<RCTComponentViewProtocol> SkiaGraphiteViewCls(void) {
|
|
179
|
-
return SkiaGraphiteView.class;
|
|
180
|
-
}
|
package/apple/SkiaPictureView.h
DELETED
package/apple/SkiaPictureView.mm
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
#import "SkiaPictureView.h"
|
|
2
|
-
|
|
3
|
-
#import "RNSkAppleView.h"
|
|
4
|
-
#import "RNSkPictureView.h"
|
|
5
|
-
#import "RNSkPlatformContext.h"
|
|
6
|
-
|
|
7
|
-
#import "RNSkiaModule.h"
|
|
8
|
-
#import "SkiaUIView.h"
|
|
9
|
-
|
|
10
|
-
#import <React/RCTConversions.h>
|
|
11
|
-
#import <React/RCTConvert.h>
|
|
12
|
-
#import <React/RCTFabricComponentsPlugins.h>
|
|
13
|
-
|
|
14
|
-
#import <react/renderer/components/rnskia/ComponentDescriptors.h>
|
|
15
|
-
#import <react/renderer/components/rnskia/EventEmitters.h>
|
|
16
|
-
#import <react/renderer/components/rnskia/Props.h>
|
|
17
|
-
#import <react/renderer/components/rnskia/RCTComponentViewHelpers.h>
|
|
18
|
-
|
|
19
|
-
using namespace facebook::react;
|
|
20
|
-
|
|
21
|
-
@implementation SkiaPictureView
|
|
22
|
-
|
|
23
|
-
- (instancetype)initWithFrame:(CGRect)frame {
|
|
24
|
-
if (self = [super initWithFrame:frame]) {
|
|
25
|
-
// Pass SkManager as a raw pointer to avoid circular dependencies
|
|
26
|
-
auto skManager = [RNSkiaModule latestActiveSkManager].get();
|
|
27
|
-
[self initCommon:skManager
|
|
28
|
-
factory:[](std::shared_ptr<RNSkia::RNSkPlatformContext> context) {
|
|
29
|
-
return std::make_shared<RNSkAppleView<RNSkia::RNSkPictureView>>(
|
|
30
|
-
context);
|
|
31
|
-
}];
|
|
32
|
-
static const auto defaultProps =
|
|
33
|
-
std::make_shared<const SkiaPictureViewProps>();
|
|
34
|
-
_props = defaultProps;
|
|
35
|
-
}
|
|
36
|
-
return self;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
#pragma mark - RCTComponentViewProtocol
|
|
40
|
-
|
|
41
|
-
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
42
|
-
return concreteComponentDescriptorProvider<
|
|
43
|
-
SkiaPictureViewComponentDescriptor>();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
- (void)updateProps:(const Props::Shared &)props
|
|
47
|
-
oldProps:(const Props::Shared &)oldProps {
|
|
48
|
-
const auto &newProps =
|
|
49
|
-
*std::static_pointer_cast<const SkiaPictureViewProps>(props);
|
|
50
|
-
[super updateProps:props oldProps:oldProps];
|
|
51
|
-
int nativeId =
|
|
52
|
-
[[RCTConvert NSString:RCTNSStringFromString(newProps.nativeId)] intValue];
|
|
53
|
-
[self setNativeId:nativeId];
|
|
54
|
-
[self setDebugMode:newProps.debug];
|
|
55
|
-
[self setOpaque:newProps.opaque];
|
|
56
|
-
[self setHighBitDepth:newProps.highBitDepth];
|
|
57
|
-
if (newProps.colorSpace == "" || newProps.colorSpace == "srgb") {
|
|
58
|
-
bool useP3 = false;
|
|
59
|
-
[self setUseP3ColorSpace:useP3];
|
|
60
|
-
} else if (newProps.colorSpace == "p3") {
|
|
61
|
-
bool useP3 = true;
|
|
62
|
-
[self setUseP3ColorSpace:useP3];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@end
|
|
67
|
-
|
|
68
|
-
Class<RCTComponentViewProtocol> SkiaPictureViewCls(void) {
|
|
69
|
-
return SkiaPictureView.class;
|
|
70
|
-
}
|
package/apple/SkiaUIView.h
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#import <memory>
|
|
4
|
-
#import <string>
|
|
5
|
-
|
|
6
|
-
#import <CoreFoundation/CoreFoundation.h>
|
|
7
|
-
#if !TARGET_OS_OSX
|
|
8
|
-
#import <UIKit/UIKit.h>
|
|
9
|
-
#else
|
|
10
|
-
#import <React/RCTUIKit.h>
|
|
11
|
-
#endif // !TARGET_OS_OSX
|
|
12
|
-
|
|
13
|
-
#import <React/RCTViewComponentView.h>
|
|
14
|
-
|
|
15
|
-
#import "RNSkAppleView.h"
|
|
16
|
-
#import "RNSkManager.h"
|
|
17
|
-
|
|
18
|
-
@interface SkiaUIView : RCTViewComponentView
|
|
19
|
-
|
|
20
|
-
- (void)initCommon:(RNSkia::RNSkManager *)manager
|
|
21
|
-
factory:(std::function<std::shared_ptr<RNSkBaseAppleView>(
|
|
22
|
-
std::shared_ptr<RNSkia::RNSkPlatformContext>)>)factory;
|
|
23
|
-
- (std::shared_ptr<RNSkBaseAppleView>)impl;
|
|
24
|
-
|
|
25
|
-
- (void)setDebugMode:(bool)debugMode;
|
|
26
|
-
- (void)setOpaque:(bool)opaque;
|
|
27
|
-
- (void)setNativeId:(size_t)nativeId;
|
|
28
|
-
- (void)setUseP3ColorSpace:(bool)useP3ColorSpace;
|
|
29
|
-
- (void)setHighBitDepth:(bool)highBitDepth;
|
|
30
|
-
|
|
31
|
-
@end
|
package/apple/SkiaUIView.mm
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
#import <QuartzCore/CATransaction.h>
|
|
2
|
-
|
|
3
|
-
#import "RNSkiaModule.h"
|
|
4
|
-
#import "SkiaUIView.h"
|
|
5
|
-
|
|
6
|
-
#include <utility>
|
|
7
|
-
#include <vector>
|
|
8
|
-
|
|
9
|
-
#import "RNSkManager.h"
|
|
10
|
-
|
|
11
|
-
@implementation SkiaUIView {
|
|
12
|
-
std::shared_ptr<RNSkBaseAppleView> _impl;
|
|
13
|
-
RNSkia::RNSkManager *_manager;
|
|
14
|
-
std::function<std::shared_ptr<RNSkBaseAppleView>(
|
|
15
|
-
std::shared_ptr<RNSkia::RNSkPlatformContext>)>
|
|
16
|
-
_factory;
|
|
17
|
-
bool _debugMode;
|
|
18
|
-
bool _opaque;
|
|
19
|
-
bool _useP3ColorSpace;
|
|
20
|
-
bool _highBitDepth;
|
|
21
|
-
size_t _nativeId;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
#pragma mark Initialization and destruction
|
|
25
|
-
|
|
26
|
-
- (void)initCommon:(RNSkia::RNSkManager *)manager
|
|
27
|
-
factory:(std::function<std::shared_ptr<RNSkBaseAppleView>(
|
|
28
|
-
std::shared_ptr<RNSkia::RNSkPlatformContext>)>)factory {
|
|
29
|
-
_manager = manager;
|
|
30
|
-
_nativeId = 0;
|
|
31
|
-
_debugMode = false;
|
|
32
|
-
_factory = factory;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
#pragma mark Lifecycle
|
|
36
|
-
|
|
37
|
-
#if !TARGET_OS_OSX
|
|
38
|
-
- (void)willMoveToSuperview:(UIView *)newSuperView {
|
|
39
|
-
#else
|
|
40
|
-
- (void)viewWillMoveToSuperview:(NSView *)newSuperView {
|
|
41
|
-
#endif // !TARGET_OS_OSX
|
|
42
|
-
if (newSuperView != nullptr) {
|
|
43
|
-
// Create implementation view when the parent view is set
|
|
44
|
-
if (_impl == nullptr && _manager != nullptr) {
|
|
45
|
-
_impl = _factory(_manager->getPlatformContext());
|
|
46
|
-
if (_impl == nullptr) {
|
|
47
|
-
throw std::runtime_error(
|
|
48
|
-
"Expected Skia view implementation, got nullptr.");
|
|
49
|
-
}
|
|
50
|
-
[self.layer addSublayer:_impl->getLayer()];
|
|
51
|
-
if (_nativeId != 0) {
|
|
52
|
-
_manager->setSkiaView(_nativeId, _impl->getDrawView());
|
|
53
|
-
}
|
|
54
|
-
_impl->getDrawView()->setShowDebugOverlays(_debugMode);
|
|
55
|
-
_impl->setUseP3ColorSpace(_useP3ColorSpace);
|
|
56
|
-
_impl->setHighBitDepth(_highBitDepth);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
- (void)removeFromSuperview {
|
|
62
|
-
// Cleanup when removed from view hierarchy
|
|
63
|
-
if (_impl != nullptr) {
|
|
64
|
-
[_impl->getLayer() removeFromSuperlayer];
|
|
65
|
-
|
|
66
|
-
if (_nativeId != 0 && _manager != nullptr) {
|
|
67
|
-
_manager->setSkiaView(_nativeId, nullptr);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
_impl = nullptr;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
[super removeFromSuperview];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
- (void)dealloc {
|
|
77
|
-
[self unregisterView];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
- (void)prepareForRecycle {
|
|
81
|
-
[super prepareForRecycle];
|
|
82
|
-
[self unregisterView];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask {
|
|
86
|
-
[super finalizeUpdates:updateMask];
|
|
87
|
-
if (updateMask == RNComponentViewUpdateMaskAll) {
|
|
88
|
-
// this flag is only set when the view is inserted and we want to set the
|
|
89
|
-
// manager here since the view could be recycled or the app could be
|
|
90
|
-
// refreshed and we would have a stale manager then
|
|
91
|
-
_manager = [RNSkiaModule latestActiveSkManager].get();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
- (void)unregisterView {
|
|
96
|
-
if (_manager != nullptr && _nativeId != 0) {
|
|
97
|
-
_manager->unregisterSkiaView(_nativeId);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
#pragma Render
|
|
102
|
-
|
|
103
|
-
- (void)drawRect:(CGRect)rect {
|
|
104
|
-
// We override drawRect to ensure we to direct rendering when the
|
|
105
|
-
// underlying OS view needs to render:
|
|
106
|
-
if (_impl != nullptr) {
|
|
107
|
-
_impl->getDrawView()->redraw();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
#pragma mark Layout
|
|
112
|
-
|
|
113
|
-
- (void)layoutSubviews {
|
|
114
|
-
[super layoutSubviews];
|
|
115
|
-
if (_impl != nullptr) {
|
|
116
|
-
[CATransaction begin];
|
|
117
|
-
[CATransaction setDisableActions:YES];
|
|
118
|
-
_impl->setSize(self.bounds.size.width, self.bounds.size.height);
|
|
119
|
-
[CATransaction commit];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
#pragma mark Properties
|
|
124
|
-
|
|
125
|
-
- (void)setDebugMode:(bool)debugMode {
|
|
126
|
-
_debugMode = debugMode;
|
|
127
|
-
if (_impl != nullptr) {
|
|
128
|
-
_impl->getDrawView()->setShowDebugOverlays(debugMode);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
- (void)setOpaque:(bool)opaque {
|
|
133
|
-
_opaque = opaque;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
- (void)setNativeId:(size_t)nativeId {
|
|
137
|
-
_nativeId = nativeId;
|
|
138
|
-
|
|
139
|
-
if (_impl != nullptr) {
|
|
140
|
-
_manager->registerSkiaView(nativeId, _impl->getDrawView());
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
- (void)setUseP3ColorSpace:(bool)useP3ColorSpace {
|
|
145
|
-
_useP3ColorSpace = useP3ColorSpace;
|
|
146
|
-
if (_impl != nullptr) {
|
|
147
|
-
_impl->setUseP3ColorSpace(_useP3ColorSpace);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
- (void)setHighBitDepth:(bool)highBitDepth {
|
|
152
|
-
_highBitDepth = highBitDepth;
|
|
153
|
-
if (_impl != nullptr) {
|
|
154
|
-
_impl->setHighBitDepth(_highBitDepth);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
#pragma mark External API
|
|
159
|
-
|
|
160
|
-
- (std::shared_ptr<RNSkBaseAppleView>)impl {
|
|
161
|
-
return _impl;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
@end
|