Integrate execution of C++ ViewManagers in React Native Android renderer

Summary:
Execution of C++ ViewManagers in RN Android renderer

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D38725770

fbshipit-source-id: cd18e02940c4cb2559acdaf535e60f98b4cada13
This commit is contained in:
David Vacca
2022-09-15 09:48:25 -07:00
committed by Facebook GitHub Bot
parent 0519dfeeaf
commit 5fb0ad0a48
6 changed files with 86 additions and 5 deletions
@@ -16,6 +16,7 @@ import com.facebook.common.logging.FLog;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
import com.facebook.react.fabric.CppViewMutationsWrapper;
import com.facebook.react.fabric.events.EventEmitterWrapper;
import com.facebook.react.fabric.mounting.MountingManager;
import com.facebook.react.fabric.mounting.SurfaceMountingManager;
@@ -50,6 +51,7 @@ public class IntBufferBatchMountItem implements MountItem {
static final int INSTRUCTION_UPDATE_PADDING = 512;
static final int INSTRUCTION_UPDATE_OVERFLOW_INSET = 1024;
static final int INSTRUCTION_REMOVE_DELETE_TREE = 2048;
static final int INSTRUCTION_RUN_CPP_VIEWS = 4096;
private final int mSurfaceId;
private final int mCommitNumber;
@@ -97,6 +99,10 @@ public class IntBufferBatchMountItem implements MountItem {
return obj != null ? (EventEmitterWrapper) obj : null;
}
private static CppViewMutationsWrapper castToCppViewMutationWrapper(Object obj) {
return obj != null ? (CppViewMutationsWrapper) obj : null;
}
@Override
public void execute(@NonNull MountingManager mountingManager) {
SurfaceMountingManager surfaceMountingManager = mountingManager.getSurfaceManager(mSurfaceId);
@@ -178,6 +184,8 @@ public class IntBufferBatchMountItem implements MountItem {
} else if (type == INSTRUCTION_UPDATE_EVENT_EMITTER) {
surfaceMountingManager.updateEventEmitter(
mIntBuffer[i++], castToEventEmitter(mObjBuffer[j++]));
} else if (type == INSTRUCTION_RUN_CPP_VIEWS) {
castToCppViewMutationWrapper(mObjBuffer[j++]).runCppViewMutations();
} else {
throw new IllegalArgumentException(
"Invalid type argument to IntBufferBatchMountItem: " + type + " at index: " + i);
@@ -280,6 +288,9 @@ public class IntBufferBatchMountItem implements MountItem {
} else if (type == INSTRUCTION_UPDATE_EVENT_EMITTER) {
j += 1;
s.append(String.format("UPDATE EVENTEMITTER [%d]\n", mIntBuffer[i++]));
} else if (type == INSTRUCTION_RUN_CPP_VIEWS) {
j += 1;
s.append(String.format("RUN CPP_VIEWS [%d]\n", mIntBuffer[i++]));
} else {
FLog.e(TAG, "String so far: " + s.toString());
throw new IllegalArgumentException(