added flag for useBatchingForLayoutOutputs experiment
Summary: Using a config flag to switch between different implementations of transferring layout outputs - YogaNodeJNI uses multiple access of java fields to pass all properties like width, height, margin etc... - YogaNodeJNIBatching uses a float array to pass all the data in one java field access Reviewed By: davidaurelio Differential Revision: D14378301 fbshipit-source-id: 0da5b28e6a67ad8fd60eb7efe622d9b2deaf177f
This commit is contained in:
committed by
Facebook Github Bot
parent
c11faf2d56
commit
74ce5afd9e
@@ -11,6 +11,7 @@ import com.facebook.soloader.SoLoader;
|
||||
public class YogaConfig {
|
||||
|
||||
public static int SPACING_TYPE = 1;
|
||||
public static boolean useBatchingForLayoutOutputs = false;
|
||||
|
||||
long mNativePointer;
|
||||
private YogaLogger mLogger;
|
||||
|
@@ -29,8 +29,8 @@ public class YogaNative {
|
||||
|
||||
// YGNode related
|
||||
static native int jni_YGNodeGetInstanceCount();
|
||||
static native long jni_YGNodeNew();
|
||||
static native long jni_YGNodeNewWithConfig(long configPointer);
|
||||
static native long jni_YGNodeNew(boolean useBatchingForLayoutOutputs);
|
||||
static native long jni_YGNodeNewWithConfig(long configPointer, boolean useBatchingForLayoutOutputs);
|
||||
static native void jni_YGNodeFree(long nativePointer);
|
||||
static native void jni_YGNodeReset(long nativePointer);
|
||||
static native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
|
||||
|
@@ -10,11 +10,11 @@ import javax.annotation.Nullable;
|
||||
|
||||
public abstract class YogaNode {
|
||||
public static YogaNode create() {
|
||||
return new YogaNodeJNI();
|
||||
return YogaConfig.useBatchingForLayoutOutputs ? new YogaNodeJNIBatching() : new YogaNodeJNI();
|
||||
}
|
||||
|
||||
public static YogaNode create(YogaConfig config) {
|
||||
return new YogaNodeJNI(config);
|
||||
return YogaConfig.useBatchingForLayoutOutputs ? new YogaNodeJNIBatching(config) : new YogaNodeJNI(config);
|
||||
}
|
||||
|
||||
public abstract void reset();
|
||||
|
@@ -22,14 +22,14 @@ public abstract class YogaNodeJNIBase extends YogaNode {
|
||||
@Nullable private Object mData;
|
||||
|
||||
public YogaNodeJNIBase() {
|
||||
mNativePointer = YogaNative.jni_YGNodeNew();
|
||||
mNativePointer = YogaNative.jni_YGNodeNew(YogaConfig.useBatchingForLayoutOutputs);
|
||||
if (mNativePointer == 0) {
|
||||
throw new IllegalStateException("Failed to allocate native memory");
|
||||
}
|
||||
}
|
||||
|
||||
public YogaNodeJNIBase(YogaConfig config) {
|
||||
mNativePointer = YogaNative.jni_YGNodeNewWithConfig(config.mNativePointer);
|
||||
mNativePointer = YogaNative.jni_YGNodeNewWithConfig(config.mNativePointer, YogaConfig.useBatchingForLayoutOutputs);
|
||||
if (mNativePointer == 0) {
|
||||
throw new IllegalStateException("Failed to allocate native memory");
|
||||
}
|
||||
|
Reference in New Issue
Block a user