@shopify/react-native-skia 0.1.218 → 0.1.220
Sign up to get free protection for your applications and to get access to all the features.
- package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +9 -10
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +5 -1
- package/cpp/rnskia/RNSkView.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiImageNode.h +1 -6
- package/jestEnv.mjs +23 -0
- package/jestSetup.mjs +22 -0
- package/package.json +4 -3
- /package/cpp/rnskia/dom/props/{ImageProps.h → SkImageProps.h} +0 -0
@@ -1,7 +1,5 @@
|
|
1
1
|
package com.shopify.reactnative.skia;
|
2
2
|
|
3
|
-
import android.app.Application;
|
4
|
-
import android.graphics.Bitmap;
|
5
3
|
import android.os.Handler;
|
6
4
|
import android.os.Looper;
|
7
5
|
import android.util.Log;
|
@@ -10,7 +8,6 @@ import android.view.Choreographer;
|
|
10
8
|
import com.facebook.jni.HybridData;
|
11
9
|
import com.facebook.proguard.annotations.DoNotStrip;
|
12
10
|
import com.facebook.react.bridge.ReactContext;
|
13
|
-
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
|
14
11
|
|
15
12
|
import java.io.BufferedInputStream;
|
16
13
|
import java.io.ByteArrayOutputStream;
|
@@ -21,8 +18,6 @@ import java.net.URI;
|
|
21
18
|
import java.net.URISyntaxException;
|
22
19
|
import java.net.URL;
|
23
20
|
import java.net.URLConnection;
|
24
|
-
import java.util.concurrent.ExecutorService;
|
25
|
-
import java.util.concurrent.Executors;
|
26
21
|
|
27
22
|
public class PlatformContext {
|
28
23
|
@DoNotStrip
|
@@ -35,6 +30,9 @@ public class PlatformContext {
|
|
35
30
|
|
36
31
|
private final String TAG = "PlatformContext";
|
37
32
|
|
33
|
+
private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
34
|
+
|
35
|
+
|
38
36
|
public PlatformContext(ReactContext reactContext) {
|
39
37
|
mContext = reactContext;
|
40
38
|
mHybridData = initHybrid(reactContext.getResources().getDisplayMetrics().density);
|
@@ -66,9 +64,10 @@ public class PlatformContext {
|
|
66
64
|
Choreographer.getInstance().postFrameCallback(frameCallback);
|
67
65
|
}
|
68
66
|
|
67
|
+
|
69
68
|
@DoNotStrip
|
70
69
|
public void notifyTaskReadyOnMainThread() {
|
71
|
-
|
70
|
+
mainHandler.post(new Runnable() {
|
72
71
|
@Override
|
73
72
|
public void run() {
|
74
73
|
notifyTaskReady();
|
@@ -83,7 +82,7 @@ public class PlatformContext {
|
|
83
82
|
|
84
83
|
@DoNotStrip
|
85
84
|
public void raise(final String message) {
|
86
|
-
|
85
|
+
mainHandler.post(new Runnable() {
|
87
86
|
@Override
|
88
87
|
public void run() {
|
89
88
|
mContext.handleException(new Exception(message));
|
@@ -97,7 +96,7 @@ public class PlatformContext {
|
|
97
96
|
return;
|
98
97
|
}
|
99
98
|
_drawLoopActive = true;
|
100
|
-
|
99
|
+
mainHandler.post(new Runnable() {
|
101
100
|
@Override
|
102
101
|
public void run() {
|
103
102
|
postFrameLoop();
|
@@ -169,7 +168,7 @@ public class PlatformContext {
|
|
169
168
|
Log.i(TAG, "Resume");
|
170
169
|
if(_drawLoopActive) {
|
171
170
|
// Restart draw loop
|
172
|
-
|
171
|
+
mainHandler.post(new Runnable() {
|
173
172
|
@Override
|
174
173
|
public void run() {
|
175
174
|
postFrameLoop();
|
@@ -188,4 +187,4 @@ public class PlatformContext {
|
|
188
187
|
private native HybridData initHybrid(float pixelDensity);
|
189
188
|
private native void notifyDrawLoop();
|
190
189
|
private native void notifyTaskReady();
|
191
|
-
}
|
190
|
+
}
|
@@ -157,9 +157,13 @@ public abstract class SkiaBaseView extends ReactViewGroup implements TextureView
|
|
157
157
|
return false;
|
158
158
|
}
|
159
159
|
|
160
|
+
//private long _prevTimestamp = 0;
|
160
161
|
@Override
|
161
162
|
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
|
162
|
-
|
163
|
+
// long timestamp = surface.getTimestamp();
|
164
|
+
// long frameDuration = (timestamp - _prevTimestamp)/1000000;
|
165
|
+
// Log.i(tag, "onSurfaceTextureUpdated "+frameDuration+"ms");
|
166
|
+
// _prevTimestamp = timestamp;
|
163
167
|
}
|
164
168
|
|
165
169
|
protected abstract void surfaceAvailable(Object surface, int width, int height);
|
package/cpp/rnskia/RNSkView.h
CHANGED
package/jestEnv.mjs
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
/* eslint-disable import/no-default-export */
|
2
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
3
|
+
import { TestEnvironment } from "jest-environment-node";
|
4
|
+
import CanvasKitInit from "canvaskit-wasm/bin/full/canvaskit";
|
5
|
+
|
6
|
+
const CanvasKit = await CanvasKitInit({});
|
7
|
+
|
8
|
+
export default class SkiaEnvironment extends TestEnvironment {
|
9
|
+
constructor(config, context) {
|
10
|
+
super(config, context);
|
11
|
+
}
|
12
|
+
|
13
|
+
async setup() {
|
14
|
+
await super.setup();
|
15
|
+
this.global.CanvasKit = CanvasKit;
|
16
|
+
}
|
17
|
+
|
18
|
+
async teardown() {}
|
19
|
+
|
20
|
+
getVmContext() {
|
21
|
+
return super.getVmContext();
|
22
|
+
}
|
23
|
+
}
|
package/jestSetup.mjs
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
2
|
+
import { jest } from "@jest/globals";
|
3
|
+
import CanvasKitInit from "canvaskit-wasm/bin/full/canvaskit";
|
4
|
+
import { Mock } from "@shopify/react-native-skia/lib/module/mock";
|
5
|
+
|
6
|
+
global.CanvasKit = await CanvasKitInit({});
|
7
|
+
|
8
|
+
jest.mock("@shopify/react-native-skia", () => {
|
9
|
+
jest.mock("@shopify/react-native-skia/lib/commonjs/Platform", () => {
|
10
|
+
const Noop = () => undefined;
|
11
|
+
return {
|
12
|
+
OS: "web",
|
13
|
+
PixelRatio: 1,
|
14
|
+
requireNativeComponent: Noop,
|
15
|
+
resolveAsset: Noop,
|
16
|
+
findNodeHandle: Noop,
|
17
|
+
NativeModules: Noop,
|
18
|
+
View: Noop,
|
19
|
+
};
|
20
|
+
});
|
21
|
+
return Mock(global.CanvasKit);
|
22
|
+
});
|
package/package.json
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
"setup-skia-web": "./scripts/setup-canvaskit.js"
|
8
8
|
},
|
9
9
|
"title": "React Native Skia",
|
10
|
-
"version": "0.1.
|
10
|
+
"version": "0.1.220",
|
11
11
|
"description": "High-performance React Native Graphics using Skia",
|
12
12
|
"main": "lib/module/index.js",
|
13
13
|
"files": [
|
@@ -25,7 +25,8 @@
|
|
25
25
|
"libs/android/**",
|
26
26
|
"index.js",
|
27
27
|
"jestSetup.js",
|
28
|
-
"
|
28
|
+
"jestSetup.mjs",
|
29
|
+
"jestEnv.mjs",
|
29
30
|
"cpp/**/*.{h,cpp}",
|
30
31
|
"ios",
|
31
32
|
"libs/ios/libskia.xcframework",
|
@@ -140,5 +141,5 @@
|
|
140
141
|
},
|
141
142
|
"types": "lib/typescript/index.d.ts",
|
142
143
|
"module": "lib/module/index.js",
|
143
|
-
"react-native": "
|
144
|
+
"react-native": "src/index.ts"
|
144
145
|
}
|
File without changes
|