mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make FabricUIManager's Binding an interface (#36613)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36613 Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D44340265 fbshipit-source-id: 1ab4e434fa20840a40590ac2157fd7f817807990
This commit is contained in:
committed by
Facebook GitHub Bot
parent
04df252aa7
commit
406f9fc37b
+13
-57
@@ -7,48 +7,20 @@
|
||||
|
||||
package com.facebook.react.fabric;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.NativeMap;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
import com.facebook.react.bridge.RuntimeExecutor;
|
||||
import com.facebook.react.bridge.RuntimeScheduler;
|
||||
import com.facebook.react.common.mapbuffer.MapBufferSoLoader;
|
||||
import com.facebook.react.fabric.events.EventBeatManager;
|
||||
import com.facebook.react.fabric.events.EventEmitterWrapper;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
|
||||
@DoNotStrip
|
||||
@SuppressLint("MissingNativeLoadLibrary")
|
||||
public class Binding {
|
||||
public interface Binding {
|
||||
|
||||
static {
|
||||
FabricSoLoader.staticInit();
|
||||
MapBufferSoLoader.staticInit();
|
||||
}
|
||||
|
||||
@DoNotStrip private final HybridData mHybridData;
|
||||
|
||||
private static native HybridData initHybrid();
|
||||
|
||||
public Binding() {
|
||||
mHybridData = initHybrid();
|
||||
}
|
||||
|
||||
private native void installFabricUIManager(
|
||||
RuntimeExecutor runtimeExecutor,
|
||||
RuntimeScheduler runtimeScheduler,
|
||||
FabricUIManager uiManager,
|
||||
EventBeatManager eventBeatManager,
|
||||
ComponentFactory componentsRegistry,
|
||||
Object reactNativeConfig);
|
||||
|
||||
public native void startSurface(
|
||||
public void startSurface(
|
||||
int surfaceId, @NonNull String moduleName, @NonNull NativeMap initialProps);
|
||||
|
||||
public native void startSurfaceWithConstraints(
|
||||
public void startSurfaceWithConstraints(
|
||||
int surfaceId,
|
||||
String moduleName,
|
||||
NativeMap initialProps,
|
||||
@@ -61,13 +33,13 @@ public class Binding {
|
||||
boolean isRTL,
|
||||
boolean doLeftAndRightSwapInRTL);
|
||||
|
||||
public native void renderTemplateToSurface(int surfaceId, String uiTemplate);
|
||||
public void renderTemplateToSurface(int surfaceId, String uiTemplate);
|
||||
|
||||
public native void stopSurface(int surfaceId);
|
||||
public void stopSurface(int surfaceId);
|
||||
|
||||
public native void setPixelDensity(float pointScaleFactor);
|
||||
public void setPixelDensity(float pointScaleFactor);
|
||||
|
||||
public native void setConstraints(
|
||||
public void setConstraints(
|
||||
int surfaceId,
|
||||
float minWidth,
|
||||
float maxWidth,
|
||||
@@ -78,10 +50,9 @@ public class Binding {
|
||||
boolean isRTL,
|
||||
boolean doLeftAndRightSwapInRTL);
|
||||
|
||||
public native void driveCxxAnimations();
|
||||
public void driveCxxAnimations();
|
||||
|
||||
public native ReadableNativeMap getInspectorDataForInstance(
|
||||
EventEmitterWrapper eventEmitterWrapper);
|
||||
public ReadableNativeMap getInspectorDataForInstance(EventEmitterWrapper eventEmitterWrapper);
|
||||
|
||||
public void register(
|
||||
@NonNull RuntimeExecutor runtimeExecutor,
|
||||
@@ -89,26 +60,11 @@ public class Binding {
|
||||
@NonNull FabricUIManager fabricUIManager,
|
||||
@NonNull EventBeatManager eventBeatManager,
|
||||
@NonNull ComponentFactory componentFactory,
|
||||
@NonNull ReactNativeConfig reactNativeConfig) {
|
||||
fabricUIManager.setBinding(this);
|
||||
installFabricUIManager(
|
||||
runtimeExecutor,
|
||||
runtimeScheduler,
|
||||
fabricUIManager,
|
||||
eventBeatManager,
|
||||
componentFactory,
|
||||
reactNativeConfig);
|
||||
@NonNull ReactNativeConfig reactNativeConfig);
|
||||
|
||||
setPixelDensity(PixelUtil.getDisplayMetricDensity());
|
||||
}
|
||||
public void unregister();
|
||||
|
||||
private native void uninstallFabricUIManager();
|
||||
public void registerSurface(SurfaceHandlerBinding surfaceHandler);
|
||||
|
||||
public void unregister() {
|
||||
uninstallFabricUIManager();
|
||||
}
|
||||
|
||||
public native void registerSurface(SurfaceHandlerBinding surfaceHandler);
|
||||
|
||||
public native void unregisterSurface(SurfaceHandlerBinding surfaceHandler);
|
||||
public void unregisterSurface(SurfaceHandlerBinding surfaceHandler);
|
||||
}
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.fabric;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.NativeMap;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
import com.facebook.react.bridge.RuntimeExecutor;
|
||||
import com.facebook.react.bridge.RuntimeScheduler;
|
||||
import com.facebook.react.common.mapbuffer.MapBufferSoLoader;
|
||||
import com.facebook.react.fabric.events.EventBeatManager;
|
||||
import com.facebook.react.fabric.events.EventEmitterWrapper;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
|
||||
@DoNotStrip
|
||||
@SuppressLint("MissingNativeLoadLibrary")
|
||||
public class BindingImpl implements Binding {
|
||||
|
||||
static {
|
||||
FabricSoLoader.staticInit();
|
||||
MapBufferSoLoader.staticInit();
|
||||
}
|
||||
|
||||
@DoNotStrip private final HybridData mHybridData;
|
||||
|
||||
private static native HybridData initHybrid();
|
||||
|
||||
public BindingImpl() {
|
||||
mHybridData = initHybrid();
|
||||
}
|
||||
|
||||
private native void installFabricUIManager(
|
||||
RuntimeExecutor runtimeExecutor,
|
||||
RuntimeScheduler runtimeScheduler,
|
||||
FabricUIManager uiManager,
|
||||
EventBeatManager eventBeatManager,
|
||||
ComponentFactory componentsRegistry,
|
||||
Object reactNativeConfig);
|
||||
|
||||
@Override
|
||||
public native void startSurface(
|
||||
int surfaceId, @NonNull String moduleName, @NonNull NativeMap initialProps);
|
||||
|
||||
@Override
|
||||
public native void startSurfaceWithConstraints(
|
||||
int surfaceId,
|
||||
String moduleName,
|
||||
NativeMap initialProps,
|
||||
float minWidth,
|
||||
float maxWidth,
|
||||
float minHeight,
|
||||
float maxHeight,
|
||||
float offsetX,
|
||||
float offsetY,
|
||||
boolean isRTL,
|
||||
boolean doLeftAndRightSwapInRTL);
|
||||
|
||||
@Override
|
||||
public native void renderTemplateToSurface(int surfaceId, String uiTemplate);
|
||||
|
||||
@Override
|
||||
public native void stopSurface(int surfaceId);
|
||||
|
||||
@Override
|
||||
public native void setPixelDensity(float pointScaleFactor);
|
||||
|
||||
@Override
|
||||
public native void setConstraints(
|
||||
int surfaceId,
|
||||
float minWidth,
|
||||
float maxWidth,
|
||||
float minHeight,
|
||||
float maxHeight,
|
||||
float offsetX,
|
||||
float offsetY,
|
||||
boolean isRTL,
|
||||
boolean doLeftAndRightSwapInRTL);
|
||||
|
||||
public native void driveCxxAnimations();
|
||||
|
||||
public native ReadableNativeMap getInspectorDataForInstance(
|
||||
EventEmitterWrapper eventEmitterWrapper);
|
||||
|
||||
public void register(
|
||||
@NonNull RuntimeExecutor runtimeExecutor,
|
||||
@NonNull RuntimeScheduler runtimeScheduler,
|
||||
@NonNull FabricUIManager fabricUIManager,
|
||||
@NonNull EventBeatManager eventBeatManager,
|
||||
@NonNull ComponentFactory componentFactory,
|
||||
@NonNull ReactNativeConfig reactNativeConfig) {
|
||||
fabricUIManager.setBinding(this);
|
||||
installFabricUIManager(
|
||||
runtimeExecutor,
|
||||
runtimeScheduler,
|
||||
fabricUIManager,
|
||||
eventBeatManager,
|
||||
componentFactory,
|
||||
reactNativeConfig);
|
||||
|
||||
setPixelDensity(PixelUtil.getDisplayMetricDensity());
|
||||
}
|
||||
|
||||
private native void uninstallFabricUIManager();
|
||||
|
||||
public void unregister() {
|
||||
uninstallFabricUIManager();
|
||||
}
|
||||
|
||||
public native void registerSurface(SurfaceHandlerBinding surfaceHandler);
|
||||
|
||||
public native void unregisterSurface(SurfaceHandlerBinding surfaceHandler);
|
||||
}
|
||||
+1
-1
@@ -41,7 +41,7 @@ public class FabricJSIModuleProvider implements JSIModuleProvider<UIManager> {
|
||||
|
||||
Systrace.beginSection(
|
||||
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.registerBinding");
|
||||
final Binding binding = new Binding();
|
||||
final Binding binding = new BindingImpl();
|
||||
|
||||
binding.register(
|
||||
mReactApplicationContext.getCatalystInstance().getRuntimeExecutor(),
|
||||
|
||||
@@ -39,7 +39,7 @@ class Binding : public jni::HybridClass<Binding>,
|
||||
public LayoutAnimationStatusDelegate {
|
||||
public:
|
||||
constexpr static const char *const kJavaDescriptor =
|
||||
"Lcom/facebook/react/fabric/Binding;";
|
||||
"Lcom/facebook/react/fabric/BindingImpl;";
|
||||
|
||||
static void registerNatives();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user