@shopify/react-native-skia 0.1.218 → 0.1.219

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- new Handler(Looper.getMainLooper()).post(new Runnable() {
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
- new Handler(Looper.getMainLooper()).post(new Runnable() {
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
- new Handler(Looper.getMainLooper()).post(new Runnable() {
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
- new Handler(Looper.getMainLooper()).post(new Runnable() {
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
- // Nothing special to do here
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);
@@ -398,7 +398,7 @@ private:
398
398
 
399
399
  std::shared_ptr<RNSkValue> _onSize;
400
400
  std::function<void()> _onSizeUnsubscribe;
401
- RNSkDrawingMode _drawingMode;
401
+ RNSkDrawingMode _drawingMode = RNSkDrawingMode::Default;
402
402
  size_t _nativeId;
403
403
 
404
404
  size_t _drawingLoopId = 0;
@@ -1,12 +1,7 @@
1
1
  #pragma once
2
2
 
3
- #ifdef TARGET_OS_IPHONE
4
- #include <react-native-skia/ImageProps.h>
5
- #else
6
- #include "ImageProps.h"
7
- #endif
8
-
9
3
  #include "JsiDomDrawingNode.h"
4
+ #include "SkImageProps.h"
10
5
 
11
6
  #include <memory>
12
7
 
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.218",
10
+ "version": "0.1.219",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [