Files
react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java
T
Andrei ShikovandFacebook GitHub Bot 8dc5ca6a6a Use SurfaceHandler in ReactSurface
Summary:
Changelog: [Internal]

Updates `ReactSurface` to use `SurfaceHandler` internally.
This removes most of the internal state in `ReactSurface` and propagates all the calls to the `SurfaceHandler`.

`FabricUIManager` now uses `SurfaceHandler` to start/stop the surface.
SurfaceId is still used for view operations. SurfaceId is also now mutable to play better with existing Android infra.

Reviewed By: shergin, mdvacca

Differential Revision: D26112992

fbshipit-source-id: 52e6860084d739381317035dc3011956d452063c
2021-03-08 12:20:41 -08:00

108 lines
3.0 KiB
Java

/*
* Copyright (c) Facebook, Inc. and its 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.RuntimeExecutor;
import com.facebook.react.bridge.queue.MessageQueueThread;
import com.facebook.react.fabric.events.EventBeatManager;
import com.facebook.react.uimanager.PixelUtil;
@DoNotStrip
@SuppressLint("MissingNativeLoadLibrary")
public class Binding {
static {
FabricSoLoader.staticInit();
}
@DoNotStrip private final HybridData mHybridData;
private static native HybridData initHybrid();
public Binding() {
mHybridData = initHybrid();
}
private native void installFabricUIManager(
RuntimeExecutor runtimeExecutor,
Object uiManager,
EventBeatManager eventBeatManager,
MessageQueueThread jsMessageQueueThread,
ComponentFactory componentsRegistry,
Object reactNativeConfig);
public native void startSurface(
int surfaceId, @NonNull String moduleName, @NonNull NativeMap initialProps);
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);
public native void renderTemplateToSurface(int surfaceId, String uiTemplate);
public native void stopSurface(int surfaceId);
public native void setPixelDensity(float pointScaleFactor);
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 void register(
@NonNull RuntimeExecutor runtimeExecutor,
@NonNull FabricUIManager fabricUIManager,
@NonNull EventBeatManager eventBeatManager,
@NonNull MessageQueueThread jsMessageQueueThread,
@NonNull ComponentFactory componentFactory,
@NonNull ReactNativeConfig reactNativeConfig) {
fabricUIManager.setBinding(this);
installFabricUIManager(
runtimeExecutor,
fabricUIManager,
eventBeatManager,
jsMessageQueueThread,
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);
}