forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make FabricUIManager's Binding an interface (facebook#36613)
Summary: Pull Request resolved: facebook#36613 Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D44340265 fbshipit-source-id: 1ab4e434fa20840a40590ac2157fd7f817807990
- Loading branch information
1 parent
8fa0b02
commit a1d56ff
Showing
4 changed files
with
135 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/BindingImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters