react-native-skia 3.0.3 → 3.0.5
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 +0 -2
- package/android/build.gradle +15 -7
- package/android/cpp/jni/JniPlatformContext.cpp +0 -24
- package/android/cpp/jni/include/JniPlatformContext.h +0 -2
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +0 -140
- package/android/src/main/java/com/reactnative/skia/BackingViewKind.java +24 -0
- package/android/src/main/java/com/reactnative/skia/FrameScheduler.java +104 -0
- package/android/src/main/java/com/reactnative/skia/PlatformContext.java +0 -5
- package/android/src/main/java/com/reactnative/skia/SkiaView.java +55 -44
- package/android/src/test/java/com/reactnative/skia/FrameSchedulerTest.java +186 -0
- package/apple/RNSkApplePlatformContext.h +0 -10
- package/apple/RNSkApplePlatformContext.mm +0 -182
- package/cpp/api/JsiGPUTexture.h +48 -0
- package/cpp/api/JsiSkApi.h +1 -16
- package/cpp/api/JsiSkImage.h +0 -12
- package/cpp/api/JsiSkImageFactory.h +36 -57
- package/cpp/api/JsiSkSurface.h +3 -10
- package/cpp/api/JsiSkSurfaceFactory.h +13 -18
- package/cpp/rnskia/RNDawnContext.h +5 -113
- package/cpp/rnskia/RNDawnUtils.h +33 -0
- package/cpp/rnskia/RNSkPlatformContext.h +0 -54
- package/cpp/rnskia/RNSkView.h +10 -7
- package/lib/commonjs/external/reanimated/index.d.ts +0 -1
- package/lib/commonjs/external/reanimated/index.js +0 -11
- package/lib/commonjs/external/reanimated/index.js.map +1 -1
- package/lib/commonjs/mock/index.js +1 -2
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/skia/types/GPUTexture.d.ts +11 -0
- package/lib/commonjs/skia/types/GPUTexture.js +2 -0
- package/lib/commonjs/skia/types/GPUTexture.js.map +1 -0
- package/lib/commonjs/skia/types/Image/Image.d.ts +0 -10
- package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +25 -48
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +0 -4
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/Surface.d.ts +3 -14
- package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +10 -9
- package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/commonjs/skia/types/index.d.ts +1 -2
- package/lib/commonjs/skia/types/index.js +11 -22
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.d.ts +0 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +0 -4
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +4 -5
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +6 -10
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurface.d.ts +0 -1
- package/lib/commonjs/skia/web/JsiSkSurface.js +0 -4
- package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +0 -4
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/external/reanimated/index.d.ts +0 -1
- package/lib/module/external/reanimated/index.js +0 -1
- package/lib/module/external/reanimated/index.js.map +1 -1
- package/lib/module/mock/index.js +1 -2
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/skia/types/GPUTexture.d.ts +11 -0
- package/lib/module/skia/types/GPUTexture.js +2 -0
- package/lib/module/skia/types/GPUTexture.js.map +1 -0
- package/lib/module/skia/types/Image/Image.d.ts +0 -10
- package/lib/module/skia/types/Image/Image.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +25 -48
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +0 -4
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/Surface/Surface.d.ts +3 -14
- package/lib/module/skia/types/Surface/Surface.js.map +1 -1
- package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +10 -9
- package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
- package/lib/module/skia/types/index.d.ts +1 -2
- package/lib/module/skia/types/index.js +1 -2
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.d.ts +0 -1
- package/lib/module/skia/web/JsiSkImage.js +0 -4
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.d.ts +4 -5
- package/lib/module/skia/web/JsiSkImageFactory.js +6 -10
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurface.d.ts +0 -1
- package/lib/module/skia/web/JsiSkSurface.js +0 -4
- package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -2
- package/lib/module/skia/web/JsiSkSurfaceFactory.js +1 -1
- package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +0 -4
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/typescript/src/external/reanimated/index.d.ts +0 -1
- package/lib/typescript/src/skia/types/GPUTexture.d.ts +11 -0
- package/lib/typescript/src/skia/types/Image/Image.d.ts +0 -10
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +25 -48
- package/lib/typescript/src/skia/types/Skia.d.ts +0 -4
- package/lib/typescript/src/skia/types/Surface/Surface.d.ts +3 -14
- package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +10 -9
- package/lib/typescript/src/skia/types/index.d.ts +1 -2
- package/lib/typescript/src/skia/web/JsiSkImage.d.ts +0 -1
- package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +4 -5
- package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +0 -1
- package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -2
- package/package.json +1 -1
- package/src/external/reanimated/index.ts +0 -1
- package/src/mock/index.ts +0 -1
- package/src/skia/types/GPUTexture.ts +9 -0
- package/src/skia/types/Image/Image.ts +0 -11
- package/src/skia/types/Image/ImageFactory.ts +25 -55
- package/src/skia/types/Skia.ts +0 -4
- package/src/skia/types/Surface/Surface.ts +3 -15
- package/src/skia/types/Surface/SurfaceFactory.ts +11 -9
- package/src/skia/types/index.ts +1 -2
- package/src/skia/web/JsiSkImage.ts +0 -5
- package/src/skia/web/JsiSkImageFactory.ts +16 -16
- package/src/skia/web/JsiSkSurface.ts +0 -5
- package/src/skia/web/JsiSkSurfaceFactory.ts +2 -2
- package/src/skia/web/JsiSkia.ts +0 -4
- package/android/cpp/rnskia-android/AHardwareBufferUtils.cpp +0 -31
- package/android/cpp/rnskia-android/AHardwareBufferUtils.h +0 -13
- package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +0 -200
- package/android/cpp/rnskia-android/RNSkAndroidVideo.h +0 -44
- package/android/src/main/java/com/reactnative/skia/RNSkVideo.java +0 -320
- package/apple/RNSkAppleVideo.h +0 -78
- package/apple/RNSkAppleVideo.mm +0 -292
- package/cpp/api/JsiNativeBuffer.h +0 -56
- package/cpp/api/JsiTextureInfo.h +0 -53
- package/cpp/api/JsiVideo.h +0 -101
- package/cpp/rnskia/RNSkVideo.h +0 -31
- package/lib/commonjs/external/reanimated/useVideo.d.ts +0 -21
- package/lib/commonjs/external/reanimated/useVideo.js +0 -150
- package/lib/commonjs/external/reanimated/useVideo.js.map +0 -1
- package/lib/commonjs/external/reanimated/useVideoLoading.d.ts +0 -4
- package/lib/commonjs/external/reanimated/useVideoLoading.js +0 -40
- package/lib/commonjs/external/reanimated/useVideoLoading.js.map +0 -1
- package/lib/commonjs/external/reanimated/useVideoLoading.web.d.ts +0 -4
- package/lib/commonjs/external/reanimated/useVideoLoading.web.js +0 -20
- package/lib/commonjs/external/reanimated/useVideoLoading.web.js.map +0 -1
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.d.ts +0 -29
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js +0 -15
- package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +0 -1
- package/lib/commonjs/skia/types/NativeBuffer/index.d.ts +0 -1
- package/lib/commonjs/skia/types/NativeBuffer/index.js +0 -17
- package/lib/commonjs/skia/types/NativeBuffer/index.js.map +0 -1
- package/lib/commonjs/skia/types/Video/Video.d.ts +0 -20
- package/lib/commonjs/skia/types/Video/Video.js +0 -6
- package/lib/commonjs/skia/types/Video/Video.js.map +0 -1
- package/lib/commonjs/skia/types/Video/index.d.ts +0 -1
- package/lib/commonjs/skia/types/Video/index.js +0 -17
- package/lib/commonjs/skia/types/Video/index.js.map +0 -1
- package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.d.ts +0 -9
- package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.js +0 -30
- package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.js.map +0 -1
- package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.d.ts +0 -9
- package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js +0 -48
- package/lib/commonjs/skia/web/JsiSkNativeBufferFactory.js.map +0 -1
- package/lib/commonjs/skia/web/JsiVideo.d.ts +0 -28
- package/lib/commonjs/skia/web/JsiVideo.js +0 -96
- package/lib/commonjs/skia/web/JsiVideo.js.map +0 -1
- package/lib/module/external/reanimated/useVideo.d.ts +0 -21
- package/lib/module/external/reanimated/useVideo.js +0 -142
- package/lib/module/external/reanimated/useVideo.js.map +0 -1
- package/lib/module/external/reanimated/useVideoLoading.d.ts +0 -4
- package/lib/module/external/reanimated/useVideoLoading.js +0 -33
- package/lib/module/external/reanimated/useVideoLoading.js.map +0 -1
- package/lib/module/external/reanimated/useVideoLoading.web.d.ts +0 -4
- package/lib/module/external/reanimated/useVideoLoading.web.js +0 -13
- package/lib/module/external/reanimated/useVideoLoading.web.js.map +0 -1
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.d.ts +0 -29
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js +0 -5
- package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +0 -1
- package/lib/module/skia/types/NativeBuffer/index.d.ts +0 -1
- package/lib/module/skia/types/NativeBuffer/index.js +0 -2
- package/lib/module/skia/types/NativeBuffer/index.js.map +0 -1
- package/lib/module/skia/types/Video/Video.d.ts +0 -20
- package/lib/module/skia/types/Video/Video.js +0 -2
- package/lib/module/skia/types/Video/Video.js.map +0 -1
- package/lib/module/skia/types/Video/index.d.ts +0 -1
- package/lib/module/skia/types/Video/index.js +0 -2
- package/lib/module/skia/types/Video/index.js.map +0 -1
- package/lib/module/skia/web/CanvasKitWebGLBufferImpl.d.ts +0 -9
- package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js +0 -23
- package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js.map +0 -1
- package/lib/module/skia/web/JsiSkNativeBufferFactory.d.ts +0 -9
- package/lib/module/skia/web/JsiSkNativeBufferFactory.js +0 -41
- package/lib/module/skia/web/JsiSkNativeBufferFactory.js.map +0 -1
- package/lib/module/skia/web/JsiVideo.d.ts +0 -28
- package/lib/module/skia/web/JsiVideo.js +0 -88
- package/lib/module/skia/web/JsiVideo.js.map +0 -1
- package/lib/typescript/src/external/reanimated/useVideo.d.ts +0 -21
- package/lib/typescript/src/external/reanimated/useVideoLoading.d.ts +0 -4
- package/lib/typescript/src/external/reanimated/useVideoLoading.web.d.ts +0 -4
- package/lib/typescript/src/skia/types/NativeBuffer/NativeBufferFactory.d.ts +0 -29
- package/lib/typescript/src/skia/types/NativeBuffer/index.d.ts +0 -1
- package/lib/typescript/src/skia/types/Video/Video.d.ts +0 -20
- package/lib/typescript/src/skia/types/Video/index.d.ts +0 -1
- package/lib/typescript/src/skia/web/CanvasKitWebGLBufferImpl.d.ts +0 -9
- package/lib/typescript/src/skia/web/JsiSkNativeBufferFactory.d.ts +0 -9
- package/lib/typescript/src/skia/web/JsiVideo.d.ts +0 -28
- package/src/external/reanimated/useVideo.ts +0 -161
- package/src/external/reanimated/useVideoLoading.ts +0 -39
- package/src/external/reanimated/useVideoLoading.web.ts +0 -17
- package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +0 -52
- package/src/skia/types/NativeBuffer/index.ts +0 -1
- package/src/skia/types/Video/Video.ts +0 -19
- package/src/skia/types/Video/index.ts +0 -1
- package/src/skia/web/CanvasKitWebGLBufferImpl.ts +0 -25
- package/src/skia/web/JsiSkNativeBufferFactory.ts +0 -51
- package/src/skia/web/JsiVideo.ts +0 -113
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
package com.reactnative.skia;
|
|
2
|
+
|
|
3
|
+
import static org.junit.Assert.assertEquals;
|
|
4
|
+
|
|
5
|
+
import java.util.ArrayDeque;
|
|
6
|
+
import java.util.ArrayList;
|
|
7
|
+
import java.util.Arrays;
|
|
8
|
+
import java.util.Deque;
|
|
9
|
+
import java.util.List;
|
|
10
|
+
|
|
11
|
+
import org.junit.Test;
|
|
12
|
+
|
|
13
|
+
public class FrameSchedulerTest {
|
|
14
|
+
private enum Call {
|
|
15
|
+
POST_FRAME_CALLBACK,
|
|
16
|
+
POST_BEHIND_PENDING_DRAW,
|
|
17
|
+
PRESENT
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private static final class RecordingHost implements FrameScheduler.Host {
|
|
21
|
+
final List<Call> calls = new ArrayList<>();
|
|
22
|
+
final Deque<Boolean> leftOverAfterPresent = new ArrayDeque<>();
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
public void postFrameCallback() {
|
|
26
|
+
calls.add(Call.POST_FRAME_CALLBACK);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public void postBehindPendingDraw() {
|
|
31
|
+
calls.add(Call.POST_BEHIND_PENDING_DRAW);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
public boolean presentFrame() {
|
|
36
|
+
calls.add(Call.PRESENT);
|
|
37
|
+
return !leftOverAfterPresent.isEmpty() && leftOverAfterPresent.removeFirst();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
List<Call> takeCalls() {
|
|
41
|
+
List<Call> taken = new ArrayList<>(calls);
|
|
42
|
+
calls.clear();
|
|
43
|
+
return taken;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private final RecordingHost mHost = new RecordingHost();
|
|
48
|
+
private final FrameScheduler mScheduler = new FrameScheduler(mHost);
|
|
49
|
+
|
|
50
|
+
@Test
|
|
51
|
+
public void surfaceViewFrameIsPresentedOnTheNextVsync() {
|
|
52
|
+
mScheduler.requestFrame(BackingViewKind.SURFACE_VIEW);
|
|
53
|
+
assertEquals(Arrays.asList(Call.POST_FRAME_CALLBACK), mHost.takeCalls());
|
|
54
|
+
|
|
55
|
+
mScheduler.onFrame(BackingViewKind.SURFACE_VIEW);
|
|
56
|
+
assertEquals(Arrays.asList(Call.PRESENT), mHost.takeCalls());
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Test
|
|
60
|
+
public void textureViewFrameIsPresentedBehindThePendingDraw() {
|
|
61
|
+
mScheduler.requestFrame(BackingViewKind.TEXTURE_VIEW);
|
|
62
|
+
assertEquals(Arrays.asList(Call.POST_BEHIND_PENDING_DRAW), mHost.takeCalls());
|
|
63
|
+
|
|
64
|
+
mScheduler.onPosted();
|
|
65
|
+
assertEquals(Arrays.asList(Call.PRESENT), mHost.takeCalls());
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Test
|
|
69
|
+
public void textureViewIsNeverPresentedInsideAChoreographerFrame() {
|
|
70
|
+
mScheduler.onFrame(BackingViewKind.TEXTURE_VIEW);
|
|
71
|
+
assertEquals(Arrays.asList(Call.POST_BEHIND_PENDING_DRAW), mHost.takeCalls());
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@Test
|
|
75
|
+
public void textureViewLeftoverIsPresentedBehindTheDrawOfTheNextVsync() {
|
|
76
|
+
mHost.leftOverAfterPresent.add(true);
|
|
77
|
+
mScheduler.requestFrame(BackingViewKind.TEXTURE_VIEW);
|
|
78
|
+
mScheduler.onPosted();
|
|
79
|
+
assertEquals(
|
|
80
|
+
Arrays.asList(Call.POST_BEHIND_PENDING_DRAW, Call.PRESENT, Call.POST_FRAME_CALLBACK),
|
|
81
|
+
mHost.takeCalls());
|
|
82
|
+
|
|
83
|
+
mScheduler.onFrame(BackingViewKind.TEXTURE_VIEW);
|
|
84
|
+
mScheduler.onPosted();
|
|
85
|
+
assertEquals(Arrays.asList(Call.POST_BEHIND_PENDING_DRAW, Call.PRESENT), mHost.takeCalls());
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Test
|
|
89
|
+
public void textureViewRequestWhileARetryIsOutstandingWaitsForThatVsync() {
|
|
90
|
+
mHost.leftOverAfterPresent.add(true);
|
|
91
|
+
mScheduler.requestFrame(BackingViewKind.TEXTURE_VIEW);
|
|
92
|
+
mScheduler.onPosted();
|
|
93
|
+
assertEquals(
|
|
94
|
+
Arrays.asList(Call.POST_BEHIND_PENDING_DRAW, Call.PRESENT, Call.POST_FRAME_CALLBACK),
|
|
95
|
+
mHost.takeCalls());
|
|
96
|
+
|
|
97
|
+
mScheduler.requestFrame(BackingViewKind.TEXTURE_VIEW);
|
|
98
|
+
assertEquals(Arrays.asList(), mHost.takeCalls());
|
|
99
|
+
|
|
100
|
+
mScheduler.onFrame(BackingViewKind.TEXTURE_VIEW);
|
|
101
|
+
mScheduler.onPosted();
|
|
102
|
+
assertEquals(Arrays.asList(Call.POST_BEHIND_PENDING_DRAW, Call.PRESENT), mHost.takeCalls());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@Test
|
|
106
|
+
public void surfaceViewLeftoverIsPresentedOnTheNextVsync() {
|
|
107
|
+
mHost.leftOverAfterPresent.add(true);
|
|
108
|
+
mScheduler.requestFrame(BackingViewKind.SURFACE_VIEW);
|
|
109
|
+
mScheduler.onFrame(BackingViewKind.SURFACE_VIEW);
|
|
110
|
+
assertEquals(
|
|
111
|
+
Arrays.asList(Call.POST_FRAME_CALLBACK, Call.PRESENT, Call.POST_FRAME_CALLBACK),
|
|
112
|
+
mHost.takeCalls());
|
|
113
|
+
|
|
114
|
+
mScheduler.onFrame(BackingViewKind.SURFACE_VIEW);
|
|
115
|
+
assertEquals(Arrays.asList(Call.PRESENT), mHost.takeCalls());
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@Test
|
|
119
|
+
public void requestsWaitingForTheSameFrameArePostedOnce() {
|
|
120
|
+
mScheduler.requestFrame(BackingViewKind.SURFACE_VIEW);
|
|
121
|
+
mScheduler.requestFrame(BackingViewKind.SURFACE_VIEW);
|
|
122
|
+
mScheduler.onFrame(BackingViewKind.SURFACE_VIEW);
|
|
123
|
+
mScheduler.requestFrame(BackingViewKind.TEXTURE_VIEW);
|
|
124
|
+
mScheduler.requestFrame(BackingViewKind.TEXTURE_VIEW);
|
|
125
|
+
assertEquals(
|
|
126
|
+
Arrays.asList(Call.POST_FRAME_CALLBACK, Call.PRESENT, Call.POST_BEHIND_PENDING_DRAW),
|
|
127
|
+
mHost.takeCalls());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@Test
|
|
131
|
+
public void requestAfterTheFrameRanIsPostedAgain() {
|
|
132
|
+
mScheduler.requestFrame(BackingViewKind.SURFACE_VIEW);
|
|
133
|
+
mScheduler.onFrame(BackingViewKind.SURFACE_VIEW);
|
|
134
|
+
mScheduler.requestFrame(BackingViewKind.SURFACE_VIEW);
|
|
135
|
+
mScheduler.onFrame(BackingViewKind.SURFACE_VIEW);
|
|
136
|
+
mScheduler.requestFrame(BackingViewKind.TEXTURE_VIEW);
|
|
137
|
+
mScheduler.onPosted();
|
|
138
|
+
mScheduler.requestFrame(BackingViewKind.TEXTURE_VIEW);
|
|
139
|
+
assertEquals(
|
|
140
|
+
Arrays.asList(
|
|
141
|
+
Call.POST_FRAME_CALLBACK,
|
|
142
|
+
Call.PRESENT,
|
|
143
|
+
Call.POST_FRAME_CALLBACK,
|
|
144
|
+
Call.PRESENT,
|
|
145
|
+
Call.POST_BEHIND_PENDING_DRAW,
|
|
146
|
+
Call.PRESENT,
|
|
147
|
+
Call.POST_BEHIND_PENDING_DRAW),
|
|
148
|
+
mHost.takeCalls());
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@Test
|
|
152
|
+
public void kindSwitchWhileAFrameCallbackIsOutstandingPresentsBehindThePendingDraw() {
|
|
153
|
+
mScheduler.requestFrame(BackingViewKind.SURFACE_VIEW);
|
|
154
|
+
// updateView() replaced the SurfaceView with a TextureView meanwhile.
|
|
155
|
+
mScheduler.requestFrame(BackingViewKind.TEXTURE_VIEW);
|
|
156
|
+
mScheduler.onFrame(BackingViewKind.TEXTURE_VIEW);
|
|
157
|
+
mScheduler.onPosted();
|
|
158
|
+
assertEquals(
|
|
159
|
+
Arrays.asList(Call.POST_FRAME_CALLBACK, Call.POST_BEHIND_PENDING_DRAW, Call.PRESENT),
|
|
160
|
+
mHost.takeCalls());
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@Test
|
|
164
|
+
public void withoutABackingViewNothingIsPostedOrPresented() {
|
|
165
|
+
mScheduler.requestFrame(null);
|
|
166
|
+
mScheduler.onFrame(null);
|
|
167
|
+
assertEquals(Arrays.asList(), mHost.takeCalls());
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@Test
|
|
171
|
+
public void cancelDropsOutstandingRequests() {
|
|
172
|
+
for (BackingViewKind kind : BackingViewKind.values()) {
|
|
173
|
+
mScheduler.requestFrame(kind);
|
|
174
|
+
mScheduler.cancel();
|
|
175
|
+
mScheduler.requestFrame(kind);
|
|
176
|
+
mScheduler.cancel();
|
|
177
|
+
}
|
|
178
|
+
assertEquals(
|
|
179
|
+
Arrays.asList(
|
|
180
|
+
Call.POST_FRAME_CALLBACK,
|
|
181
|
+
Call.POST_FRAME_CALLBACK,
|
|
182
|
+
Call.POST_BEHIND_PENDING_DRAW,
|
|
183
|
+
Call.POST_BEHIND_PENDING_DRAW),
|
|
184
|
+
mHost.takeCalls());
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -51,16 +51,6 @@ public:
|
|
|
51
51
|
|
|
52
52
|
sk_sp<SkImage> takeScreenshotFromViewTag(size_t tag) override;
|
|
53
53
|
|
|
54
|
-
sk_sp<SkImage> makeImageFromNativeBuffer(void *buffer) override;
|
|
55
|
-
|
|
56
|
-
uint64_t makeNativeBuffer(sk_sp<SkImage> image) override;
|
|
57
|
-
|
|
58
|
-
uint64_t makeTestNativeBuffer(int width, int height) override;
|
|
59
|
-
|
|
60
|
-
void releaseNativeBuffer(uint64_t pointer) override;
|
|
61
|
-
|
|
62
|
-
std::shared_ptr<RNSkVideo> createVideo(const std::string &url) override;
|
|
63
|
-
|
|
64
54
|
virtual void performStreamOperation(
|
|
65
55
|
const std::string &sourceUri,
|
|
66
56
|
const std::function<void(std::unique_ptr<SkStreamAsset>)> &op) override;
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
#import "RNSkApplePlatformContext.h"
|
|
2
2
|
|
|
3
|
-
#import <CoreMedia/CMSampleBuffer.h>
|
|
4
3
|
#import <React/RCTUtils.h>
|
|
5
|
-
#include <algorithm>
|
|
6
4
|
#include <set>
|
|
7
5
|
#include <thread>
|
|
8
6
|
#include <utility>
|
|
9
7
|
|
|
10
8
|
#include "RNDawnContext.h"
|
|
11
|
-
#include "RNSkAppleVideo.h"
|
|
12
9
|
|
|
13
10
|
#pragma clang diagnostic push
|
|
14
11
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
15
12
|
|
|
16
|
-
#include "include/core/SkBlendMode.h"
|
|
17
|
-
#include "include/core/SkCanvas.h"
|
|
18
|
-
#include "include/core/SkColor.h"
|
|
19
|
-
#import "include/core/SkColorSpace.h"
|
|
20
13
|
#include "include/core/SkFontMgr.h"
|
|
21
|
-
#include "include/core/SkPaint.h"
|
|
22
|
-
#include "include/core/SkSamplingOptions.h"
|
|
23
14
|
#include "include/core/SkSurface.h"
|
|
24
15
|
|
|
25
16
|
#include "include/ports/SkFontMgr_mac_ct.h"
|
|
@@ -70,174 +61,6 @@ void RNSkApplePlatformContext::performStreamOperation(
|
|
|
70
61
|
std::thread(loader).detach();
|
|
71
62
|
}
|
|
72
63
|
|
|
73
|
-
void RNSkApplePlatformContext::releaseNativeBuffer(uint64_t pointer) {
|
|
74
|
-
CVPixelBufferRef pixelBuffer = reinterpret_cast<CVPixelBufferRef>(pointer);
|
|
75
|
-
if (pixelBuffer) {
|
|
76
|
-
CFRelease(pixelBuffer);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
uint64_t RNSkApplePlatformContext::makeNativeBuffer(sk_sp<SkImage> image) {
|
|
81
|
-
// A Graphite GPU texture can't be read with readPixels(nullptr) (and can't be
|
|
82
|
-
// drawn onto a raster surface): both yield uninitialized/black pixels. Read
|
|
83
|
-
// it back to a raster image first.
|
|
84
|
-
if (image && image->isTextureBacked()) {
|
|
85
|
-
image = DawnContext::getInstance().MakeRasterImage(image);
|
|
86
|
-
}
|
|
87
|
-
// 0. If Image is not in BGRA, convert to BGRA as only BGRA is supported.
|
|
88
|
-
if (image->colorType() != kBGRA_8888_SkColorType) {
|
|
89
|
-
const SkImageInfo bgraInfo =
|
|
90
|
-
SkImageInfo::Make(image->dimensions(), kBGRA_8888_SkColorType,
|
|
91
|
-
kPremul_SkAlphaType, SkColorSpace::MakeSRGB());
|
|
92
|
-
auto surface = SkSurfaces::Raster(bgraInfo);
|
|
93
|
-
if (!surface) {
|
|
94
|
-
throw std::runtime_error(
|
|
95
|
-
"Failed to allocate raster surface for BGRA conversion");
|
|
96
|
-
}
|
|
97
|
-
SkCanvas *canvas = surface->getCanvas();
|
|
98
|
-
canvas->clear(SK_ColorTRANSPARENT);
|
|
99
|
-
SkPaint paint;
|
|
100
|
-
paint.setBlendMode(SkBlendMode::kSrc);
|
|
101
|
-
canvas->drawImage(image.get(), 0.0f, 0.0f, SkSamplingOptions(), &paint);
|
|
102
|
-
auto bgraImage = surface->makeImageSnapshot();
|
|
103
|
-
if (bgraImage == nullptr) {
|
|
104
|
-
throw std::runtime_error(
|
|
105
|
-
"Failed to convert image to BGRA_8888 colortype! Only BGRA_8888 "
|
|
106
|
-
"NativeBuffers are supported.");
|
|
107
|
-
}
|
|
108
|
-
image = std::move(bgraImage);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// 1. Get image info
|
|
112
|
-
auto bytesPerPixel = image->imageInfo().bytesPerPixel();
|
|
113
|
-
int bytesPerRow = image->width() * bytesPerPixel;
|
|
114
|
-
auto buf = SkData::MakeUninitialized(image->width() * image->height() *
|
|
115
|
-
bytesPerPixel);
|
|
116
|
-
SkImageInfo info = SkImageInfo::Make(image->width(), image->height(),
|
|
117
|
-
image->colorType(), image->alphaType());
|
|
118
|
-
// 2. Copy pixels into our buffer
|
|
119
|
-
image->readPixels(nullptr, info, const_cast<void *>(buf->data()), bytesPerRow,
|
|
120
|
-
0, 0);
|
|
121
|
-
|
|
122
|
-
// 3. Create an IOSurface (GPU + CPU memory)
|
|
123
|
-
CFMutableDictionaryRef dict = CFDictionaryCreateMutable(
|
|
124
|
-
kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks,
|
|
125
|
-
&kCFTypeDictionaryValueCallBacks);
|
|
126
|
-
int width = image->width();
|
|
127
|
-
int height = image->height();
|
|
128
|
-
int pitch = width * bytesPerPixel;
|
|
129
|
-
int size = width * height * bytesPerPixel;
|
|
130
|
-
OSType pixelFormat = kCVPixelFormatType_32BGRA;
|
|
131
|
-
CFDictionarySetValue(
|
|
132
|
-
dict, kIOSurfaceBytesPerRow,
|
|
133
|
-
CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &pitch));
|
|
134
|
-
CFDictionarySetValue(
|
|
135
|
-
dict, kIOSurfaceBytesPerElement,
|
|
136
|
-
CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &bytesPerPixel));
|
|
137
|
-
CFDictionarySetValue(
|
|
138
|
-
dict, kIOSurfaceWidth,
|
|
139
|
-
CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &width));
|
|
140
|
-
CFDictionarySetValue(
|
|
141
|
-
dict, kIOSurfaceHeight,
|
|
142
|
-
CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &height));
|
|
143
|
-
CFDictionarySetValue(
|
|
144
|
-
dict, kIOSurfacePixelFormat,
|
|
145
|
-
CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &pixelFormat));
|
|
146
|
-
CFDictionarySetValue(
|
|
147
|
-
dict, kIOSurfaceAllocSize,
|
|
148
|
-
CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &size));
|
|
149
|
-
IOSurfaceRef surface = IOSurfaceCreate(dict);
|
|
150
|
-
if (surface == nil) {
|
|
151
|
-
throw std::runtime_error("Failed to create " + std::to_string(width) + "x" +
|
|
152
|
-
std::to_string(height) + " IOSurface!");
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// 4. Copy over the memory from the pixels into the IOSurface
|
|
156
|
-
IOSurfaceLock(surface, 0, nil);
|
|
157
|
-
void *base = IOSurfaceGetBaseAddress(surface);
|
|
158
|
-
memcpy(base, buf->data(), buf->size());
|
|
159
|
-
IOSurfaceUnlock(surface, 0, nil);
|
|
160
|
-
|
|
161
|
-
// 5. Create a CVPixelBuffer from the IOSurface
|
|
162
|
-
CVPixelBufferRef pixelBuffer = nullptr;
|
|
163
|
-
CVReturn result =
|
|
164
|
-
CVPixelBufferCreateWithIOSurface(nil, surface, nil, &pixelBuffer);
|
|
165
|
-
if (result != kCVReturnSuccess) {
|
|
166
|
-
throw std::runtime_error(
|
|
167
|
-
"Failed to create CVPixelBuffer from SkImage! Return value: " +
|
|
168
|
-
std::to_string(result));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// 8. Return CVPixelBuffer casted to uint64_t
|
|
172
|
-
return reinterpret_cast<uint64_t>(pixelBuffer);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
uint64_t RNSkApplePlatformContext::makeTestNativeBuffer(int width, int height) {
|
|
176
|
-
// Allocate a BGRA IOSurface and fill it with a procedural test pattern (RGB
|
|
177
|
-
// gradient + diagonal stripes), entirely on the CPU. No GPU / SkImage round
|
|
178
|
-
// trip, so this works the same on every backend.
|
|
179
|
-
const int bytesPerElement = 4;
|
|
180
|
-
const int pitch = width * bytesPerElement;
|
|
181
|
-
const int allocSize = width * height * bytesPerElement;
|
|
182
|
-
OSType pixelFormat = kCVPixelFormatType_32BGRA;
|
|
183
|
-
CFMutableDictionaryRef dict = CFDictionaryCreateMutable(
|
|
184
|
-
kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks,
|
|
185
|
-
&kCFTypeDictionaryValueCallBacks);
|
|
186
|
-
auto setInt = [&](CFStringRef key, int value) {
|
|
187
|
-
CFNumberRef num =
|
|
188
|
-
CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
|
|
189
|
-
CFDictionarySetValue(dict, key, num);
|
|
190
|
-
CFRelease(num);
|
|
191
|
-
};
|
|
192
|
-
setInt(kIOSurfaceWidth, width);
|
|
193
|
-
setInt(kIOSurfaceHeight, height);
|
|
194
|
-
setInt(kIOSurfaceBytesPerRow, pitch);
|
|
195
|
-
setInt(kIOSurfaceBytesPerElement, bytesPerElement);
|
|
196
|
-
setInt(kIOSurfacePixelFormat, static_cast<int>(pixelFormat));
|
|
197
|
-
setInt(kIOSurfaceAllocSize, allocSize);
|
|
198
|
-
IOSurfaceRef surface = IOSurfaceCreate(dict);
|
|
199
|
-
CFRelease(dict);
|
|
200
|
-
if (surface == nil) {
|
|
201
|
-
throw std::runtime_error("Failed to create " + std::to_string(width) + "x" +
|
|
202
|
-
std::to_string(height) + " test IOSurface!");
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
IOSurfaceLock(surface, 0, nil);
|
|
206
|
-
auto *base = static_cast<uint8_t *>(IOSurfaceGetBaseAddress(surface));
|
|
207
|
-
const size_t rowBytes = IOSurfaceGetBytesPerRow(surface);
|
|
208
|
-
for (int y = 0; y < height; ++y) {
|
|
209
|
-
uint8_t *row = base + y * rowBytes;
|
|
210
|
-
for (int x = 0; x < width; ++x) {
|
|
211
|
-
uint8_t r = static_cast<uint8_t>((x * 255) / std::max(width - 1, 1));
|
|
212
|
-
uint8_t g = static_cast<uint8_t>((y * 255) / std::max(height - 1, 1));
|
|
213
|
-
uint8_t b = static_cast<uint8_t>(((x + y) & 0x20) ? 220 : 30);
|
|
214
|
-
row[x * 4 + 0] = b; // BGRA byte order
|
|
215
|
-
row[x * 4 + 1] = g;
|
|
216
|
-
row[x * 4 + 2] = r;
|
|
217
|
-
row[x * 4 + 3] = 0xFF;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
IOSurfaceUnlock(surface, 0, nil);
|
|
221
|
-
|
|
222
|
-
CVPixelBufferRef pixelBuffer = nullptr;
|
|
223
|
-
CVReturn result =
|
|
224
|
-
CVPixelBufferCreateWithIOSurface(nil, surface, nil, &pixelBuffer);
|
|
225
|
-
// The CVPixelBuffer retains the IOSurface; drop our reference so the
|
|
226
|
-
// CVPixelBuffer is its sole owner (freed by releaseNativeBuffer).
|
|
227
|
-
CFRelease(surface);
|
|
228
|
-
if (result != kCVReturnSuccess) {
|
|
229
|
-
throw std::runtime_error("Failed to create CVPixelBuffer for test native "
|
|
230
|
-
"buffer! Return value: " +
|
|
231
|
-
std::to_string(result));
|
|
232
|
-
}
|
|
233
|
-
return reinterpret_cast<uint64_t>(pixelBuffer);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
std::shared_ptr<RNSkVideo>
|
|
237
|
-
RNSkApplePlatformContext::createVideo(const std::string &url) {
|
|
238
|
-
return std::make_shared<RNSkAppleVideo>(url, this);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
64
|
void RNSkApplePlatformContext::raiseError(const std::exception &err) {
|
|
242
65
|
RCTFatal(RCTErrorWithMessage([NSString stringWithUTF8String:err.what()]));
|
|
243
66
|
}
|
|
@@ -266,11 +89,6 @@ RNSkApplePlatformContext::makeOffscreenSurface(int width, int height,
|
|
|
266
89
|
useP3ColorSpace);
|
|
267
90
|
}
|
|
268
91
|
|
|
269
|
-
sk_sp<SkImage>
|
|
270
|
-
RNSkApplePlatformContext::makeImageFromNativeBuffer(void *buffer) {
|
|
271
|
-
return DawnContext::getInstance().MakeImageFromBuffer(buffer);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
92
|
sk_sp<SkFontMgr> RNSkApplePlatformContext::createFontMgr() {
|
|
275
93
|
return SkFontMgr_New_CoreText(nullptr);
|
|
276
94
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <stdexcept>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include <jsi/jsi.h>
|
|
7
|
+
|
|
8
|
+
#include "webgpu/webgpu_cpp.h"
|
|
9
|
+
|
|
10
|
+
namespace RNSkia {
|
|
11
|
+
|
|
12
|
+
namespace jsi = facebook::jsi;
|
|
13
|
+
|
|
14
|
+
// Reads a GPUTexture argument: the react-native-webgpu object, whose
|
|
15
|
+
// nativePointer (a non-spec extension) holds the WGPUTexture handle, or the
|
|
16
|
+
// handle itself as a BigInt for libraries that export textures without
|
|
17
|
+
// react-native-webgpu. The returned wgpu::Texture holds a reference of its
|
|
18
|
+
// own, so the image or surface wrapping it keeps the texture alive while the
|
|
19
|
+
// caller keeps ownership of the JS object.
|
|
20
|
+
inline wgpu::Texture gpuTextureFromValue(jsi::Runtime &runtime,
|
|
21
|
+
const jsi::Value &value,
|
|
22
|
+
const char *method) {
|
|
23
|
+
uint64_t raw = 0;
|
|
24
|
+
if (value.isBigInt()) {
|
|
25
|
+
raw = value.asBigInt(runtime).asUint64(runtime);
|
|
26
|
+
} else if (value.isObject()) {
|
|
27
|
+
auto pointer =
|
|
28
|
+
value.asObject(runtime).getProperty(runtime, "nativePointer");
|
|
29
|
+
if (!pointer.isBigInt()) {
|
|
30
|
+
throw std::runtime_error(
|
|
31
|
+
std::string(method) +
|
|
32
|
+
" expects a GPUTexture created with react-native-webgpu on the "
|
|
33
|
+
"shared device (or a WGPUTexture pointer as a BigInt)");
|
|
34
|
+
}
|
|
35
|
+
raw = pointer.asBigInt(runtime).asUint64(runtime);
|
|
36
|
+
} else {
|
|
37
|
+
throw std::runtime_error(std::string(method) +
|
|
38
|
+
" expects a GPUTexture or a WGPUTexture pointer");
|
|
39
|
+
}
|
|
40
|
+
auto texture = reinterpret_cast<WGPUTexture>(raw);
|
|
41
|
+
if (texture == nullptr) {
|
|
42
|
+
throw std::runtime_error(std::string(method) + ": the texture is null");
|
|
43
|
+
}
|
|
44
|
+
wgpuTextureAddRef(texture);
|
|
45
|
+
return wgpu::Texture::Acquire(texture);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
} // namespace RNSkia
|
package/cpp/api/JsiSkApi.h
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
#include "rnskia/RNDawnContext.h"
|
|
10
10
|
|
|
11
|
-
#include "JsiNativeBuffer.h"
|
|
12
11
|
#include "JsiSkAnimatedImage.h"
|
|
13
12
|
#include "JsiSkAnimatedImageFactory.h"
|
|
14
13
|
#include "JsiSkColor.h"
|
|
@@ -55,7 +54,6 @@
|
|
|
55
54
|
#include "JsiSkTypefaceFontProviderFactory.h"
|
|
56
55
|
#include "JsiSkVertices.h"
|
|
57
56
|
#include "JsiSkottieFactory.h"
|
|
58
|
-
#include "JsiVideo.h"
|
|
59
57
|
#include "api/recorder/JsiRecorder.h"
|
|
60
58
|
|
|
61
59
|
namespace RNSkia {
|
|
@@ -98,9 +96,7 @@ public:
|
|
|
98
96
|
_typefaceFontProviderFactory(
|
|
99
97
|
std::make_shared<JsiSkTypefaceFontProviderFactory>(context)),
|
|
100
98
|
_paragraphBuilderFactory(
|
|
101
|
-
std::make_shared<JsiSkParagraphBuilderFactory>(context))
|
|
102
|
-
_nativeBufferFactory(
|
|
103
|
-
std::make_shared<JsiNativeBufferFactory>(context)) {
|
|
99
|
+
std::make_shared<JsiSkParagraphBuilderFactory>(context)) {
|
|
104
100
|
// We create the system font manager eagerly since it has proven to be too
|
|
105
101
|
// slow to do it on demand
|
|
106
102
|
JsiSkFontMgrFactory::getFontMgr(getContext());
|
|
@@ -109,10 +105,6 @@ public:
|
|
|
109
105
|
// Constructor functions: each delegates to the class's createCtor host
|
|
110
106
|
// function using the platform context resolved from native state, so the
|
|
111
107
|
// prototype stays context-free and can be installed on any runtime.
|
|
112
|
-
JSI_HOST_FUNCTION(Video) {
|
|
113
|
-
return JsiVideo::createCtor(getContext())(runtime, thisValue, arguments,
|
|
114
|
-
count);
|
|
115
|
-
}
|
|
116
108
|
JSI_HOST_FUNCTION(Font) {
|
|
117
109
|
return JsiSkFont::createCtor(getContext())(runtime, thisValue, arguments,
|
|
118
110
|
count);
|
|
@@ -234,12 +226,8 @@ public:
|
|
|
234
226
|
std::shared_ptr<JsiSkParagraphBuilderFactory> getParagraphBuilderFactory() {
|
|
235
227
|
return _paragraphBuilderFactory;
|
|
236
228
|
}
|
|
237
|
-
std::shared_ptr<JsiNativeBufferFactory> getNativeBufferFactory() {
|
|
238
|
-
return _nativeBufferFactory;
|
|
239
|
-
}
|
|
240
229
|
|
|
241
230
|
static void definePrototype(jsi::Runtime &runtime, jsi::Object &prototype) {
|
|
242
|
-
installHostMethod(runtime, prototype, "Video", &JsiSkApi::Video);
|
|
243
231
|
installHostMethod(runtime, prototype, "getNativeDevice",
|
|
244
232
|
&JsiSkApi::getNativeDevice);
|
|
245
233
|
installHostMethod(runtime, prototype, "Font", &JsiSkApi::Font);
|
|
@@ -292,8 +280,6 @@ public:
|
|
|
292
280
|
&JsiSkApi::getTypefaceFontProviderFactory);
|
|
293
281
|
installGetter(runtime, prototype, "ParagraphBuilder",
|
|
294
282
|
&JsiSkApi::getParagraphBuilderFactory);
|
|
295
|
-
installGetter(runtime, prototype, "NativeBuffer",
|
|
296
|
-
&JsiSkApi::getNativeBufferFactory);
|
|
297
283
|
}
|
|
298
284
|
|
|
299
285
|
private:
|
|
@@ -318,6 +304,5 @@ private:
|
|
|
318
304
|
std::shared_ptr<JsiSkTypefaceFontProviderFactory>
|
|
319
305
|
_typefaceFontProviderFactory;
|
|
320
306
|
std::shared_ptr<JsiSkParagraphBuilderFactory> _paragraphBuilderFactory;
|
|
321
|
-
std::shared_ptr<JsiNativeBufferFactory> _nativeBufferFactory;
|
|
322
307
|
};
|
|
323
308
|
} // namespace RNSkia
|
package/cpp/api/JsiSkImage.h
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
#include "JsiSkShader.h"
|
|
15
15
|
#include "api/third_party/base64.h"
|
|
16
16
|
|
|
17
|
-
#include "JsiTextureInfo.h"
|
|
18
17
|
#include "utils/RNSkTypedArray.h"
|
|
19
18
|
|
|
20
19
|
#include "include/gpu/graphite/Context.h"
|
|
@@ -314,15 +313,6 @@ public:
|
|
|
314
313
|
return std::make_shared<JsiSkImage>(getContext(), std::move(rasterImage));
|
|
315
314
|
}
|
|
316
315
|
|
|
317
|
-
JSI_HOST_FUNCTION(getNativeTextureUnstable) {
|
|
318
|
-
auto image = getObject();
|
|
319
|
-
if (!image->isTextureBacked()) {
|
|
320
|
-
return jsi::Value::null();
|
|
321
|
-
}
|
|
322
|
-
auto texInfo = getContext()->getTexture(image);
|
|
323
|
-
return JsiTextureInfo::toValue(runtime, texInfo);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
316
|
bool isTextureBacked() { return getObject()->isTextureBacked(); }
|
|
327
317
|
|
|
328
318
|
/**
|
|
@@ -351,8 +341,6 @@ public:
|
|
|
351
341
|
&JsiSkImage::readPixels);
|
|
352
342
|
installMethod(runtime, prototype, "makeNonTextureImage",
|
|
353
343
|
&JsiSkImage::makeNonTextureImage);
|
|
354
|
-
installHostMethod(runtime, prototype, "getNativeTextureUnstable",
|
|
355
|
-
&JsiSkImage::getNativeTextureUnstable);
|
|
356
344
|
installMethod(runtime, prototype, "isTextureBacked",
|
|
357
345
|
&JsiSkImage::isTextureBacked);
|
|
358
346
|
}
|