feat: Replace *NativeMap and *NativeArray with Map<K,V> and List<T> for faster JSI -> JNI calls (#1720)
Replaces `ReadableNativeMap`/`WritableNativeMap` with `Map<String, Object>` and `ReadableNativeArray`/`WritableNativeArray` with `List<Object>`, making the JSI -> JNI conversion a bit faster and more logical. Also, we could now convert Array Buffers or HostObjects if we wanted to.
This commit is contained in:
@@ -4,7 +4,7 @@ import androidx.annotation.Keep;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Declares a Frame Processor Plugin.
|
||||
@@ -21,5 +21,5 @@ public abstract class FrameProcessorPlugin {
|
||||
*/
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
public abstract @Nullable Object callback(@NonNull Frame frame, @Nullable ReadableNativeMap params);
|
||||
public abstract @Nullable Object callback(@NonNull Frame frame, @Nullable Map<String, Object> params);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,9 @@ package com.mrousavy.camera.frameprocessor;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
@@ -24,7 +21,7 @@ public class FrameProcessorPluginRegistry {
|
||||
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
public static FrameProcessorPlugin getPlugin(String name, ReadableNativeMap options) {
|
||||
public static FrameProcessorPlugin getPlugin(String name, Map<String, Object> options) {
|
||||
PluginInitializer initializer = Plugins.get(name);
|
||||
if (initializer == null) {
|
||||
return null;
|
||||
@@ -33,6 +30,6 @@ public class FrameProcessorPluginRegistry {
|
||||
}
|
||||
|
||||
public interface PluginInitializer {
|
||||
FrameProcessorPlugin initializePlugin(@Nullable ReadableNativeMap options);
|
||||
FrameProcessorPlugin initializePlugin(@Nullable Map<String, Object> options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import androidx.annotation.UiThread
|
||||
import com.facebook.jni.HybridData
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.bridge.ReadableNativeMap
|
||||
import com.facebook.react.bridge.UiThreadUtil
|
||||
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl
|
||||
import com.facebook.react.uimanager.UIManagerHelper
|
||||
@@ -14,7 +13,6 @@ import com.mrousavy.camera.CameraView
|
||||
import com.mrousavy.camera.ViewNotFoundError
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
|
||||
@Suppress("KotlinJniMissingFunction") // we use fbjni.
|
||||
class VisionCameraProxy(context: ReactApplicationContext) {
|
||||
companion object {
|
||||
@@ -71,7 +69,7 @@ class VisionCameraProxy(context: ReactApplicationContext) {
|
||||
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
fun getFrameProcessorPlugin(name: String, options: ReadableNativeMap): FrameProcessorPlugin {
|
||||
fun getFrameProcessorPlugin(name: String, options: Map<String, Any>): FrameProcessorPlugin {
|
||||
return FrameProcessorPluginRegistry.getPlugin(name, options)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user