@shopify/react-native-skia 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +38 -6
- package/android/build.gradle +1 -0
- package/android/cpp/jni/JniSkiaManager.cpp +1 -1
- package/android/cpp/jni/include/JniSkiaBaseView.h +0 -3
- package/android/cpp/jni/include/JniSkiaDomView.h +0 -6
- package/android/cpp/jni/include/JniSkiaPictureView.h +0 -5
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.cpp +3 -3
- package/android/cpp/rnskia-android/GrAHardwareBufferUtils.h +2 -2
- package/android/cpp/rnskia-android/RNSkAndroidView.h +0 -20
- package/android/cpp/rnskia-android/SkiaOpenGLHelper.h +2 -2
- package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.h +3 -3
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +0 -72
- package/cpp/api/JsiSkSurface.h +1 -1
- package/cpp/rnskia/RNSkDomView.cpp +0 -79
- package/cpp/rnskia/RNSkDomView.h +1 -39
- package/cpp/rnskia/RNSkPictureView.h +0 -1
- package/cpp/rnskia/RNSkView.h +0 -17
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +1 -1
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +2 -2
- package/ios/RNSkia-iOS/SkiaCVPixelBufferUtils.h +2 -2
- package/ios/RNSkia-iOS/SkiaCVPixelBufferUtils.mm +1 -1
- package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.h +1 -1
- package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.mm +2 -2
- package/ios/RNSkia-iOS/SkiaUIView.mm +0 -51
- package/lib/commonjs/mock/index.js +0 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.d.ts +1 -2
- package/lib/commonjs/renderer/Canvas.js +0 -3
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/views/SkiaBaseWebView.d.ts +2 -11
- package/lib/commonjs/views/SkiaBaseWebView.js +3 -31
- package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.js +0 -12
- package/lib/commonjs/views/SkiaDomView.js.map +1 -1
- package/lib/commonjs/views/SkiaDomView.web.d.ts +2 -2
- package/lib/commonjs/views/SkiaDomView.web.js +1 -6
- package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
- package/lib/commonjs/views/SkiaJSDomView.js +0 -12
- package/lib/commonjs/views/SkiaJSDomView.js.map +1 -1
- package/lib/commonjs/views/index.d.ts +0 -1
- package/lib/commonjs/views/index.js +0 -11
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/commonjs/views/types.d.ts +0 -26
- package/lib/commonjs/views/types.js +0 -8
- package/lib/commonjs/views/types.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 +1 -2
- package/lib/module/renderer/Canvas.js +0 -3
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.d.ts +2 -11
- package/lib/module/views/SkiaBaseWebView.js +3 -31
- package/lib/module/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/views/SkiaDomView.js +0 -12
- package/lib/module/views/SkiaDomView.js.map +1 -1
- package/lib/module/views/SkiaDomView.web.d.ts +2 -2
- package/lib/module/views/SkiaDomView.web.js +1 -6
- package/lib/module/views/SkiaDomView.web.js.map +1 -1
- package/lib/module/views/SkiaJSDomView.js +0 -12
- package/lib/module/views/SkiaJSDomView.js.map +1 -1
- package/lib/module/views/index.d.ts +0 -1
- package/lib/module/views/index.js +0 -1
- package/lib/module/views/index.js.map +1 -1
- package/lib/module/views/types.d.ts +0 -26
- package/lib/module/views/types.js +1 -7
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/lib/commonjs/mock/index.d.ts +0 -1
- package/lib/typescript/lib/commonjs/views/SkiaBaseWebView.d.ts +0 -3
- package/lib/typescript/lib/commonjs/views/SkiaDomView.web.d.ts +1 -1
- package/lib/typescript/lib/commonjs/views/types.d.ts +0 -1
- package/lib/typescript/lib/module/mock/index.d.ts +0 -1
- package/lib/typescript/lib/module/views/SkiaBaseWebView.d.ts +0 -3
- package/lib/typescript/lib/module/views/SkiaDomView.web.d.ts +1 -1
- package/lib/typescript/lib/module/views/index.d.ts +0 -1
- package/lib/typescript/lib/module/views/types.d.ts +1 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +1 -2
- package/lib/typescript/src/views/SkiaBaseWebView.d.ts +2 -11
- package/lib/typescript/src/views/SkiaDomView.web.d.ts +2 -2
- package/lib/typescript/src/views/index.d.ts +0 -1
- package/lib/typescript/src/views/types.d.ts +0 -26
- package/libs/ios/libskunicode_core.xcframework/Info.plist +46 -0
- package/libs/ios/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
- package/libs/ios/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
- package/libs/ios/libskunicode_libgrapheme.xcframework/Info.plist +46 -0
- package/libs/ios/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
- package/libs/ios/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
- package/package.json +2 -8
- package/react-native-skia.podspec +5 -4
- package/src/mock/index.ts +0 -1
- package/src/renderer/Canvas.tsx +1 -5
- package/src/renderer/__tests__/setup.tsx +0 -2
- package/src/skia/web/JsiSkia.ts +1 -1
- package/src/views/SkiaBaseWebView.tsx +5 -42
- package/src/views/SkiaDomView.tsx +2 -14
- package/src/views/SkiaDomView.web.tsx +2 -9
- package/src/views/SkiaJSDomView.tsx +2 -14
- package/src/views/index.ts +0 -1
- package/src/views/types.ts +0 -32
- package/cpp/rnskia/RNSkInfoParameter.h +0 -92
- package/cpp/skia/include/gpu/GrBackendSemaphore.h +0 -8
- package/cpp/skia/include/gpu/GrBackendSurface.h +0 -8
- package/cpp/skia/include/gpu/GrContextOptions.h +0 -8
- package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +0 -8
- package/cpp/skia/include/gpu/GrDirectContext.h +0 -8
- package/cpp/skia/include/gpu/GrDriverBugWorkarounds.h +0 -8
- package/cpp/skia/include/gpu/GrDriverBugWorkaroundsAutogen.h +0 -6
- package/cpp/skia/include/gpu/GrRecordingContext.h +0 -8
- package/cpp/skia/include/gpu/GrTypes.h +0 -8
- package/cpp/skia/include/gpu/GrYUVABackendTextures.h +0 -8
- package/cpp/skia/include/gpu/d3d/GrD3DBackendContext.h +0 -8
- package/cpp/skia/include/gpu/d3d/GrD3DTypes.h +0 -8
- package/cpp/skia/include/gpu/gl/GrGLAssembleHelpers.h +0 -8
- package/cpp/skia/include/gpu/gl/GrGLAssembleInterface.h +0 -8
- package/cpp/skia/include/gpu/gl/GrGLConfig.h +0 -8
- package/cpp/skia/include/gpu/gl/GrGLExtensions.h +0 -8
- package/cpp/skia/include/gpu/gl/GrGLFunctions.h +0 -8
- package/cpp/skia/include/gpu/gl/GrGLInterface.h +0 -8
- package/cpp/skia/include/gpu/gl/GrGLTypes.h +0 -8
- package/cpp/skia/include/gpu/mock/GrMockTypes.h +0 -8
- package/cpp/skia/include/gpu/vk/GrVkTypes.h +0 -8
- package/lib/commonjs/renderer/__tests__/TouchHandler.spec.d.ts +0 -1
- package/lib/commonjs/views/useTouchHandler.d.ts +0 -22
- package/lib/commonjs/views/useTouchHandler.js +0 -83
- package/lib/commonjs/views/useTouchHandler.js.map +0 -1
- package/lib/module/renderer/__tests__/TouchHandler.spec.d.ts +0 -1
- package/lib/module/views/useTouchHandler.d.ts +0 -22
- package/lib/module/views/useTouchHandler.js +0 -75
- package/lib/module/views/useTouchHandler.js.map +0 -1
- package/lib/typescript/lib/commonjs/views/useTouchHandler.d.ts +0 -12
- package/lib/typescript/lib/module/views/useTouchHandler.d.ts +0 -2
- package/lib/typescript/src/renderer/__tests__/TouchHandler.spec.d.ts +0 -1
- package/lib/typescript/src/views/useTouchHandler.d.ts +0 -22
- package/src/renderer/__tests__/TouchHandler.spec.tsx +0 -113
- package/src/views/useTouchHandler.ts +0 -107
package/android/CMakeLists.txt
CHANGED
@@ -155,10 +155,13 @@ endif()
|
|
155
155
|
message("-- JSI : " ${JSI_LIB})
|
156
156
|
|
157
157
|
unset(REACT_LIB CACHE)
|
158
|
-
if(${REACT_NATIVE_VERSION} GREATER_EQUAL
|
158
|
+
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
|
159
|
+
# RN 0.76 packs react_nativemodule_core into ReactAndroid::reactnative
|
160
|
+
set (REACT_LIB ReactAndroid::reactnative)
|
161
|
+
elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
|
159
162
|
# RN 0.71 distributes prebuilt binaries.
|
160
163
|
set (REACT_LIB ReactAndroid::react_nativemodule_core)
|
161
|
-
else()
|
164
|
+
else()
|
162
165
|
find_library(
|
163
166
|
REACT_LIB
|
164
167
|
react_nativemodule_core
|
@@ -183,7 +186,10 @@ endif()
|
|
183
186
|
message("-- FBJNI : " ${FBJNI_LIBRARY})
|
184
187
|
|
185
188
|
unset(REACTNATIVEJNI_LIB CACHE)
|
186
|
-
if(${REACT_NATIVE_VERSION} GREATER_EQUAL
|
189
|
+
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
|
190
|
+
# RN 0.76 doesn't have reactnativejni
|
191
|
+
# DO NOTHING, we'll not link these libraries
|
192
|
+
elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
|
187
193
|
# RN 0.71 distributes prebuilt binaries.
|
188
194
|
set (REACTNATIVEJNI_LIB "ReactAndroid::reactnativejni")
|
189
195
|
else()
|
@@ -197,7 +203,10 @@ endif()
|
|
197
203
|
message("-- REACTNATIVEJNI : " ${REACTNATIVEJNI_LIB})
|
198
204
|
|
199
205
|
unset(RUNTIMEEXECUTOR_LIB CACHE)
|
200
|
-
if(${REACT_NATIVE_VERSION} GREATER_EQUAL
|
206
|
+
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
|
207
|
+
# RN 0.76 doesn't have runtimeexecutor
|
208
|
+
# DO NOTHING, we'll not link these libraries
|
209
|
+
elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
|
201
210
|
# RN 0.71 distributes prebuilt binaries.
|
202
211
|
set (RUNTIMEEXECUTOR_LIB "ReactAndroid::runtimeexecutor")
|
203
212
|
else()
|
@@ -211,7 +220,10 @@ endif()
|
|
211
220
|
message("-- RUNTIMEEXECUTOR : " ${RUNTIMEEXECUTOR_LIB})
|
212
221
|
|
213
222
|
unset(TURBOMODULES_LIB CACHE)
|
214
|
-
if(${REACT_NATIVE_VERSION} GREATER_EQUAL
|
223
|
+
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
|
224
|
+
# RN 0.76 doesn't have turbomodulejsijni
|
225
|
+
# DO NOTHING, we'll not link these libraries
|
226
|
+
elseif(${REACT_NATIVE_VERSION} GREATER_EQUAL 71)
|
215
227
|
# RN 0.71 distributes prebuilt binaries.
|
216
228
|
set (TURBOMODULES_LIB "ReactAndroid::turbomodulejsijni")
|
217
229
|
else()
|
@@ -227,7 +239,26 @@ message("-- TURBO : " ${TURBOMODULES_LIB})
|
|
227
239
|
add_definitions(-DREACT_NATIVE_VERSION=${REACT_NATIVE_VERSION})
|
228
240
|
|
229
241
|
# Link
|
230
|
-
|
242
|
+
if(${REACT_NATIVE_VERSION} GREATER_EQUAL 76)
|
243
|
+
target_link_libraries(
|
244
|
+
${PACKAGE_NAME}
|
245
|
+
${LOG_LIB}
|
246
|
+
${REACT_LIB}
|
247
|
+
${FBJNI_LIBRARY}
|
248
|
+
${JSI_LIB}
|
249
|
+
${SKIA_SVG_LIB}
|
250
|
+
${SKIA_SKSHAPER_LIB}
|
251
|
+
${SKIA_SKPARAGRAPH_LIB}
|
252
|
+
${SKIA_SKUNICODE_CORE_LIB}
|
253
|
+
${SKIA_SKUNICODE_ICU_LIB}
|
254
|
+
${SKIA_LIB}
|
255
|
+
-ljnigraphics
|
256
|
+
-lGLESv2
|
257
|
+
-lEGL
|
258
|
+
-landroid
|
259
|
+
)
|
260
|
+
else()
|
261
|
+
target_link_libraries(
|
231
262
|
${PACKAGE_NAME}
|
232
263
|
${LOG_LIB}
|
233
264
|
${FBJNI_LIBRARY}
|
@@ -247,3 +278,4 @@ target_link_libraries(
|
|
247
278
|
-lEGL
|
248
279
|
-landroid
|
249
280
|
)
|
281
|
+
endif()
|
package/android/build.gradle
CHANGED
@@ -29,9 +29,6 @@ public:
|
|
29
29
|
}
|
30
30
|
|
31
31
|
protected:
|
32
|
-
virtual void updateTouchPoints(jni::JArrayDouble touches) {
|
33
|
-
_skiaAndroidView->updateTouchPoints(touches);
|
34
|
-
}
|
35
32
|
|
36
33
|
virtual void surfaceAvailable(jobject surface, int width, int height) {
|
37
34
|
_skiaAndroidView->surfaceAvailable(surface, width, height);
|
@@ -42,17 +42,11 @@ public:
|
|
42
42
|
JniSkiaDomView::surfaceSizeChanged),
|
43
43
|
makeNativeMethod("setMode", JniSkiaDomView::setMode),
|
44
44
|
makeNativeMethod("setDebugMode", JniSkiaDomView::setDebugMode),
|
45
|
-
makeNativeMethod("updateTouchPoints",
|
46
|
-
JniSkiaDomView::updateTouchPoints),
|
47
45
|
makeNativeMethod("registerView", JniSkiaDomView::registerView),
|
48
46
|
makeNativeMethod("unregisterView", JniSkiaDomView::unregisterView)});
|
49
47
|
}
|
50
48
|
|
51
49
|
protected:
|
52
|
-
void updateTouchPoints(jni::JArrayDouble touches) override {
|
53
|
-
JniSkiaBaseView::updateTouchPoints(touches);
|
54
|
-
}
|
55
|
-
|
56
50
|
void surfaceAvailable(jobject surface, int width, int height) override {
|
57
51
|
JniSkiaBaseView::surfaceAvailable(surface, width, height);
|
58
52
|
}
|
@@ -43,17 +43,12 @@ public:
|
|
43
43
|
JniSkiaPictureView::surfaceSizeChanged),
|
44
44
|
makeNativeMethod("setMode", JniSkiaPictureView::setMode),
|
45
45
|
makeNativeMethod("setDebugMode", JniSkiaPictureView::setDebugMode),
|
46
|
-
makeNativeMethod("updateTouchPoints",
|
47
|
-
JniSkiaPictureView::updateTouchPoints),
|
48
46
|
makeNativeMethod("registerView", JniSkiaPictureView::registerView),
|
49
47
|
makeNativeMethod("unregisterView",
|
50
48
|
JniSkiaPictureView::unregisterView)});
|
51
49
|
}
|
52
50
|
|
53
51
|
protected:
|
54
|
-
void updateTouchPoints(jni::JArrayDouble touches) override {
|
55
|
-
JniSkiaBaseView::updateTouchPoints(touches);
|
56
|
-
}
|
57
52
|
|
58
53
|
void surfaceAvailable(jobject surface, int width, int height) override {
|
59
54
|
JniSkiaBaseView::surfaceAvailable(surface, width, height);
|
@@ -11,10 +11,10 @@
|
|
11
11
|
#define GL_GLEXT_PROTOTYPES
|
12
12
|
#define EGL_EGLEXT_PROTOTYPES
|
13
13
|
|
14
|
-
#include "include/gpu/GrBackendSurface.h"
|
15
|
-
#include "include/gpu/GrDirectContext.h"
|
14
|
+
#include "include/gpu/ganesh/GrBackendSurface.h"
|
15
|
+
#include "include/gpu/ganesh/GrDirectContext.h"
|
16
16
|
#include "include/gpu/ganesh/gl/GrGLBackendSurface.h"
|
17
|
-
#include "include/gpu/gl/GrGLTypes.h"
|
17
|
+
#include "include/gpu/ganesh/gl/GrGLTypes.h"
|
18
18
|
#include "src/gpu/ganesh/gl/GrGLDefines.h"
|
19
19
|
// #include "src/gpu/ganesh/GrDirectContextPriv.h"
|
20
20
|
// #include "src/gpu/ganesh/gl/GrGLUtil.h"
|
@@ -19,8 +19,6 @@ public:
|
|
19
19
|
|
20
20
|
virtual float getPixelDensity() = 0;
|
21
21
|
|
22
|
-
virtual void updateTouchPoints(jni::JArrayDouble touches) = 0;
|
23
|
-
|
24
22
|
virtual void setMode(std::string mode) = 0;
|
25
23
|
|
26
24
|
virtual void setShowDebugInfo(bool show) = 0;
|
@@ -76,24 +74,6 @@ public:
|
|
76
74
|
|
77
75
|
void viewDidUnmount() override { T::endDrawingLoop(); }
|
78
76
|
|
79
|
-
void updateTouchPoints(jni::JArrayDouble touches) override {
|
80
|
-
// Create touch points
|
81
|
-
std::vector<RNSkia::RNSkTouchInfo> points;
|
82
|
-
auto pin = touches.pin();
|
83
|
-
auto scale = getPixelDensity();
|
84
|
-
points.reserve(pin.size() / 5);
|
85
|
-
for (size_t i = 0; i < pin.size(); i += 5) {
|
86
|
-
RNSkTouchInfo point;
|
87
|
-
point.x = pin[i] / scale;
|
88
|
-
point.y = pin[i + 1] / scale;
|
89
|
-
point.force = pin[i + 2];
|
90
|
-
point.type = (RNSkia::RNSkTouchInfo::TouchType)pin[i + 3];
|
91
|
-
point.id = pin[i + 4];
|
92
|
-
points.push_back(point);
|
93
|
-
}
|
94
|
-
T::updateTouchState(points);
|
95
|
-
}
|
96
|
-
|
97
77
|
std::shared_ptr<RNSkView> getSkiaView() override {
|
98
78
|
return T::shared_from_this();
|
99
79
|
}
|
@@ -15,9 +15,9 @@
|
|
15
15
|
#include "include/core/SkCanvas.h"
|
16
16
|
#include "include/core/SkColorSpace.h"
|
17
17
|
#include "include/core/SkSurface.h"
|
18
|
-
#include "include/gpu/GrDirectContext.h"
|
18
|
+
#include "include/gpu/ganesh/GrDirectContext.h"
|
19
19
|
#include "include/gpu/ganesh/gl/GrGLDirectContext.h"
|
20
|
-
#include "include/gpu/gl/GrGLInterface.h"
|
20
|
+
#include "include/gpu/ganesh/gl/GrGLInterface.h"
|
21
21
|
|
22
22
|
#pragma clang diagnostic pop
|
23
23
|
|
@@ -22,10 +22,10 @@
|
|
22
22
|
#include "include/core/SkCanvas.h"
|
23
23
|
#include "include/core/SkColorSpace.h"
|
24
24
|
#include "include/core/SkSurface.h"
|
25
|
-
#include "include/gpu/GrBackendSurface.h"
|
26
|
-
#include "include/gpu/GrDirectContext.h"
|
25
|
+
#include "include/gpu/ganesh/GrBackendSurface.h"
|
26
|
+
#include "include/gpu/ganesh/GrDirectContext.h"
|
27
27
|
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
|
28
|
-
#include "include/gpu/gl/GrGLInterface.h"
|
28
|
+
#include "include/gpu/ganesh/gl/GrGLInterface.h"
|
29
29
|
|
30
30
|
#pragma clang diagnostic pop
|
31
31
|
|
@@ -53,76 +53,6 @@ public abstract class SkiaBaseView extends ReactViewGroup implements TextureView
|
|
53
53
|
mTexture.layout(0, 0, this.getMeasuredWidth(), this.getMeasuredHeight());
|
54
54
|
}
|
55
55
|
|
56
|
-
@Override
|
57
|
-
public boolean onTouchEvent(MotionEvent ev) {
|
58
|
-
// https://developer.android.com/training/gestures/multi
|
59
|
-
int action = ev.getActionMasked();
|
60
|
-
|
61
|
-
MotionEvent.PointerCoords r = new MotionEvent.PointerCoords();
|
62
|
-
|
63
|
-
double[] points;
|
64
|
-
|
65
|
-
// If this is a pointer_up/down event we need to handle it a bit specialized
|
66
|
-
switch (action) {
|
67
|
-
case MotionEvent.ACTION_POINTER_DOWN:
|
68
|
-
case MotionEvent.ACTION_POINTER_UP: {
|
69
|
-
points = new double[5];
|
70
|
-
int pointerIndex = ev.getActionIndex();
|
71
|
-
ev.getPointerCoords(pointerIndex, r);
|
72
|
-
points[0] = r.x;
|
73
|
-
points[1] = r.y;
|
74
|
-
points[2] = ev.getPressure(pointerIndex);
|
75
|
-
points[3] = motionActionToType(action);
|
76
|
-
points[4] = ev.getPointerId(pointerIndex);
|
77
|
-
|
78
|
-
updateTouchPoints(points);
|
79
|
-
|
80
|
-
break;
|
81
|
-
}
|
82
|
-
default: {
|
83
|
-
// For the rest we can just handle it like expected
|
84
|
-
int count = ev.getPointerCount();
|
85
|
-
int pointerIndex = 0;
|
86
|
-
points = new double[5 * count];
|
87
|
-
for (int i = 0; i < count; i++) {
|
88
|
-
ev.getPointerCoords(i, r);
|
89
|
-
points[pointerIndex++] = r.x;
|
90
|
-
points[pointerIndex++] = r.y;
|
91
|
-
points[pointerIndex++] = ev.getPressure(i);
|
92
|
-
points[pointerIndex++] = motionActionToType(action);
|
93
|
-
points[pointerIndex++] = ev.getPointerId(i);
|
94
|
-
}
|
95
|
-
|
96
|
-
updateTouchPoints(points);
|
97
|
-
|
98
|
-
break;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
return true;
|
103
|
-
}
|
104
|
-
|
105
|
-
private static int motionActionToType(int action) {
|
106
|
-
int actionType = 3;
|
107
|
-
switch (action) {
|
108
|
-
case MotionEvent.ACTION_DOWN:
|
109
|
-
case MotionEvent.ACTION_POINTER_DOWN:
|
110
|
-
actionType = 0;
|
111
|
-
break;
|
112
|
-
case MotionEvent.ACTION_MOVE:
|
113
|
-
actionType = 1;
|
114
|
-
break;
|
115
|
-
case MotionEvent.ACTION_UP:
|
116
|
-
case MotionEvent.ACTION_POINTER_UP:
|
117
|
-
actionType = 2;
|
118
|
-
break;
|
119
|
-
case MotionEvent.ACTION_CANCEL:
|
120
|
-
actionType = 3;
|
121
|
-
break;
|
122
|
-
}
|
123
|
-
return actionType;
|
124
|
-
}
|
125
|
-
|
126
56
|
@Override
|
127
57
|
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
|
128
58
|
Log.i(tag, "onSurfaceTextureAvailable " + width + "/" + height);
|
@@ -172,8 +102,6 @@ public abstract class SkiaBaseView extends ReactViewGroup implements TextureView
|
|
172
102
|
|
173
103
|
protected abstract void setDebugMode(boolean show);
|
174
104
|
|
175
|
-
protected abstract void updateTouchPoints(double[] points);
|
176
|
-
|
177
105
|
protected abstract void registerView(int nativeId);
|
178
106
|
|
179
107
|
protected abstract void unregisterView();
|
package/cpp/api/JsiSkSurface.h
CHANGED
@@ -17,7 +17,6 @@ RNSkDomRenderer::RNSkDomRenderer(std::function<void()> requestRedraw,
|
|
17
17
|
std::shared_ptr<RNSkPlatformContext> context)
|
18
18
|
: RNSkRenderer(requestRedraw), _platformContext(std::move(context)),
|
19
19
|
_renderLock(std::make_shared<std::timed_mutex>()),
|
20
|
-
_touchCallbackLock(std::make_shared<std::timed_mutex>()),
|
21
20
|
_renderTimingInfo("SKIA/RENDER") {}
|
22
21
|
|
23
22
|
RNSkDomRenderer::~RNSkDomRenderer() {
|
@@ -29,10 +28,6 @@ RNSkDomRenderer::~RNSkDomRenderer() {
|
|
29
28
|
|
30
29
|
bool RNSkDomRenderer::tryRender(
|
31
30
|
std::shared_ptr<RNSkCanvasProvider> canvasProvider) {
|
32
|
-
// If we have touches we need to call the touch callback as well
|
33
|
-
if (_currentTouches.size() > 0) {
|
34
|
-
callOnTouch();
|
35
|
-
}
|
36
31
|
|
37
32
|
// We render on the main thread
|
38
33
|
if (_renderLock->try_lock()) {
|
@@ -70,11 +65,6 @@ void RNSkDomRenderer::setRoot(std::shared_ptr<JsiDomRenderNode> node) {
|
|
70
65
|
_root = node;
|
71
66
|
}
|
72
67
|
|
73
|
-
void RNSkDomRenderer::setOnTouchCallback(
|
74
|
-
std::shared_ptr<jsi::Function> onTouchCallback) {
|
75
|
-
_touchCallback = onTouchCallback;
|
76
|
-
}
|
77
|
-
|
78
68
|
void RNSkDomRenderer::renderCanvas(SkCanvas *canvas, float scaledWidth,
|
79
69
|
float scaledHeight) {
|
80
70
|
_renderTimingInfo.beginTiming();
|
@@ -125,75 +115,6 @@ void RNSkDomRenderer::renderCanvas(SkCanvas *canvas, float scaledWidth,
|
|
125
115
|
_renderTimingInfo.stopTiming();
|
126
116
|
}
|
127
117
|
|
128
|
-
void RNSkDomRenderer::updateTouches(std::vector<RNSkTouchInfo> &touches) {
|
129
|
-
std::lock_guard<std::mutex> lock(_touchMutex);
|
130
|
-
// Add timestamp
|
131
|
-
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
132
|
-
std::chrono::system_clock::now().time_since_epoch())
|
133
|
-
.count();
|
134
|
-
|
135
|
-
for (size_t i = 0; i < touches.size(); i++) {
|
136
|
-
touches.at(i).timestamp = ms;
|
137
|
-
}
|
138
|
-
_currentTouches.push_back(std::move(touches));
|
139
|
-
}
|
140
|
-
|
141
|
-
void RNSkDomRenderer::callOnTouch() {
|
142
|
-
|
143
|
-
if (_touchCallback == nullptr) {
|
144
|
-
return;
|
145
|
-
}
|
146
|
-
|
147
|
-
if (_touchCallbackLock->try_lock()) {
|
148
|
-
|
149
|
-
{
|
150
|
-
std::lock_guard<std::mutex> lock(_touchMutex);
|
151
|
-
_touchesCache.clear();
|
152
|
-
_touchesCache.reserve(_currentTouches.size());
|
153
|
-
for (size_t i = 0; i < _currentTouches.size(); ++i) {
|
154
|
-
_touchesCache.push_back(_currentTouches.at(i));
|
155
|
-
}
|
156
|
-
_currentTouches.clear();
|
157
|
-
}
|
158
|
-
|
159
|
-
// We have an onDraw method - use it to render since we don't have a
|
160
|
-
// DOM-node yet.
|
161
|
-
_platformContext->runOnJavascriptThread([weakSelf = weak_from_this()]() {
|
162
|
-
auto self = weakSelf.lock();
|
163
|
-
if (self) {
|
164
|
-
jsi::Runtime &runtime = *self->_platformContext->getJsRuntime();
|
165
|
-
// Set up touches
|
166
|
-
auto size = self->_touchesCache.size();
|
167
|
-
auto ops = jsi::Array(runtime, size);
|
168
|
-
for (size_t i = 0; i < size; i++) {
|
169
|
-
auto cur = self->_touchesCache.at(i);
|
170
|
-
auto curSize = cur.size();
|
171
|
-
auto touches = jsi::Array(runtime, curSize);
|
172
|
-
for (size_t n = 0; n < curSize; n++) {
|
173
|
-
auto touchObj = jsi::Object(runtime);
|
174
|
-
auto t = cur.at(n);
|
175
|
-
touchObj.setProperty(runtime, "x", t.x);
|
176
|
-
touchObj.setProperty(runtime, "y", t.y);
|
177
|
-
touchObj.setProperty(runtime, "force", t.force);
|
178
|
-
touchObj.setProperty(runtime, "type", static_cast<double>(t.type));
|
179
|
-
touchObj.setProperty(runtime, "timestamp",
|
180
|
-
static_cast<double>(t.timestamp) / 1000.0);
|
181
|
-
touchObj.setProperty(runtime, "id", static_cast<double>(t.id));
|
182
|
-
touches.setValueAtIndex(runtime, n, touchObj);
|
183
|
-
}
|
184
|
-
ops.setValueAtIndex(runtime, i, touches);
|
185
|
-
}
|
186
|
-
// Call on touch callback
|
187
|
-
self->_touchCallback->call(runtime, ops, 1);
|
188
|
-
}
|
189
|
-
self->_touchCallbackLock->unlock();
|
190
|
-
});
|
191
|
-
} else {
|
192
|
-
// We'll try next time - schedule a new redraw
|
193
|
-
_requestRedraw();
|
194
|
-
}
|
195
|
-
}
|
196
|
-
|
197
118
|
void RNSkDomRenderer::renderDebugOverlays(SkCanvas *canvas) {
|
198
119
|
if (!getShowDebugOverlays()) {
|
199
120
|
return;
|
package/cpp/rnskia/RNSkDomView.h
CHANGED
@@ -13,7 +13,6 @@
|
|
13
13
|
#include "RNSkView.h"
|
14
14
|
|
15
15
|
#include "JsiDomRenderNode.h"
|
16
|
-
#include "RNSkInfoParameter.h"
|
17
16
|
#include "RNSkLog.h"
|
18
17
|
#include "RNSkPlatformContext.h"
|
19
18
|
#include "RNSkTimingInfo.h"
|
@@ -50,29 +49,19 @@ public:
|
|
50
49
|
|
51
50
|
void setRoot(std::shared_ptr<JsiDomRenderNode> node);
|
52
51
|
|
53
|
-
void setOnTouchCallback(std::shared_ptr<jsi::Function> onTouchCallback);
|
54
|
-
|
55
|
-
void updateTouches(std::vector<RNSkTouchInfo> &touches);
|
56
|
-
|
57
52
|
private:
|
58
|
-
void callOnTouch();
|
59
53
|
void renderCanvas(SkCanvas *canvas, float scaledWidth, float scaledHeight);
|
60
54
|
void renderDebugOverlays(SkCanvas *canvas);
|
61
55
|
|
62
56
|
std::shared_ptr<RNSkPlatformContext> _platformContext;
|
63
|
-
std::shared_ptr<jsi::Function> _touchCallback;
|
64
57
|
|
65
58
|
std::shared_ptr<std::timed_mutex> _renderLock;
|
66
|
-
std::shared_ptr<std::timed_mutex> _touchCallbackLock;
|
67
59
|
|
68
60
|
std::shared_ptr<JsiDomRenderNode> _root;
|
69
61
|
std::shared_ptr<DrawingContext> _drawingContext;
|
70
62
|
|
71
63
|
RNSkTimingInfo _renderTimingInfo;
|
72
64
|
|
73
|
-
std::mutex _touchMutex;
|
74
|
-
std::vector<std::vector<RNSkTouchInfo>> _currentTouches;
|
75
|
-
std::vector<std::vector<RNSkTouchInfo>> _touchesCache;
|
76
65
|
std::mutex _rootLock;
|
77
66
|
};
|
78
67
|
|
@@ -87,40 +76,13 @@ public:
|
|
87
76
|
std::make_shared<RNSkDomRenderer>(
|
88
77
|
std::bind(&RNSkView::requestRedraw, this), context)) {}
|
89
78
|
|
90
|
-
void updateTouchState(std::vector<RNSkTouchInfo> &touches) override {
|
91
|
-
std::static_pointer_cast<RNSkDomRenderer>(getRenderer())
|
92
|
-
->updateTouches(touches);
|
93
|
-
RNSkView::updateTouchState(touches);
|
94
|
-
}
|
95
|
-
|
96
79
|
void setJsiProperties(
|
97
80
|
std::unordered_map<std::string, JsiValueWrapper> &props) override {
|
98
81
|
|
99
82
|
RNSkView::setJsiProperties(props);
|
100
83
|
|
101
84
|
for (auto &prop : props) {
|
102
|
-
if (prop.first == "
|
103
|
-
if (prop.second.isUndefinedOrNull()) {
|
104
|
-
// Clear touchCallback
|
105
|
-
std::static_pointer_cast<RNSkDomRenderer>(getRenderer())
|
106
|
-
->setOnTouchCallback(nullptr);
|
107
|
-
requestRedraw();
|
108
|
-
continue;
|
109
|
-
|
110
|
-
} else if (prop.second.getType() != JsiWrapperValueType::Function) {
|
111
|
-
// We expect a function for the draw callback custom property
|
112
|
-
throw std::runtime_error(
|
113
|
-
"Expected a function for the onTouch property.");
|
114
|
-
}
|
115
|
-
|
116
|
-
// Save callback
|
117
|
-
std::static_pointer_cast<RNSkDomRenderer>(getRenderer())
|
118
|
-
->setOnTouchCallback(prop.second.getAsFunction());
|
119
|
-
|
120
|
-
// Request redraw
|
121
|
-
requestRedraw();
|
122
|
-
|
123
|
-
} else if (prop.first == "root") {
|
85
|
+
if (prop.first == "root") {
|
124
86
|
// Save root
|
125
87
|
if (prop.second.isUndefined() || prop.second.isNull()) {
|
126
88
|
std::static_pointer_cast<RNSkDomRenderer>(getRenderer())
|
package/cpp/rnskia/RNSkView.h
CHANGED
@@ -138,16 +138,6 @@ private:
|
|
138
138
|
|
139
139
|
enum RNSkDrawingMode { Default, Continuous };
|
140
140
|
|
141
|
-
using RNSkTouchInfo = struct {
|
142
|
-
enum TouchType { Start, Active, End, Cancelled };
|
143
|
-
double x;
|
144
|
-
double y;
|
145
|
-
double force;
|
146
|
-
TouchType type;
|
147
|
-
size_t id;
|
148
|
-
long timestamp;
|
149
|
-
};
|
150
|
-
|
151
141
|
class RNSkView : public std::enable_shared_from_this<RNSkView> {
|
152
142
|
public:
|
153
143
|
/**
|
@@ -218,13 +208,6 @@ public:
|
|
218
208
|
requestRedraw();
|
219
209
|
}
|
220
210
|
|
221
|
-
/**
|
222
|
-
Update touch state with new touch points
|
223
|
-
*/
|
224
|
-
virtual void updateTouchState(std::vector<RNSkTouchInfo> &) {
|
225
|
-
requestRedraw();
|
226
|
-
}
|
227
|
-
|
228
211
|
/**
|
229
212
|
Renders the view into an SkImage instead of the screen.
|
230
213
|
*/
|
@@ -9,8 +9,8 @@
|
|
9
9
|
#import "include/core/SkColorSpace.h"
|
10
10
|
#import "include/core/SkSurface.h"
|
11
11
|
|
12
|
-
#import <include/gpu/GrBackendSurface.h>
|
13
|
-
#import <include/gpu/GrDirectContext.h>
|
12
|
+
#import <include/gpu/ganesh/GrBackendSurface.h>
|
13
|
+
#import <include/gpu/ganesh/GrDirectContext.h>
|
14
14
|
#import <include/gpu/ganesh/SkSurfaceGanesh.h>
|
15
15
|
|
16
16
|
#pragma clang diagnostic pop
|
@@ -17,8 +17,8 @@
|
|
17
17
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
18
18
|
#import "include/core/SkColorSpace.h"
|
19
19
|
#import "include/core/SkImage.h"
|
20
|
-
#import "include/gpu/GrBackendSurface.h"
|
21
|
-
#import "include/gpu/GrYUVABackendTextures.h"
|
20
|
+
#import "include/gpu/ganesh/GrBackendSurface.h"
|
21
|
+
#import "include/gpu/ganesh/GrYUVABackendTextures.h"
|
22
22
|
#pragma clang diagnostic pop
|
23
23
|
|
24
24
|
/**
|
@@ -11,7 +11,7 @@
|
|
11
11
|
#pragma clang diagnostic push
|
12
12
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
13
13
|
#import "include/core/SkColorSpace.h"
|
14
|
-
#import <include/gpu/GrBackendSurface.h>
|
14
|
+
#import <include/gpu/ganesh/GrBackendSurface.h>
|
15
15
|
#import <include/gpu/ganesh/SkImageGanesh.h>
|
16
16
|
#import <include/gpu/ganesh/mtl/GrMtlBackendContext.h>
|
17
17
|
#import <include/gpu/ganesh/mtl/GrMtlBackendSurface.h>
|
@@ -10,8 +10,8 @@
|
|
10
10
|
#import "include/core/SkColorSpace.h"
|
11
11
|
#import "include/core/SkSurface.h"
|
12
12
|
|
13
|
-
#import <include/gpu/GrBackendSurface.h>
|
14
|
-
#import <include/gpu/GrDirectContext.h>
|
13
|
+
#import <include/gpu/ganesh/GrBackendSurface.h>
|
14
|
+
#import <include/gpu/ganesh/GrDirectContext.h>
|
15
15
|
#import <include/gpu/ganesh/SkImageGanesh.h>
|
16
16
|
#import <include/gpu/ganesh/SkSurfaceGanesh.h>
|
17
17
|
#import <include/gpu/ganesh/mtl/GrMtlBackendContext.h>
|