Add boolean flag to decide whether to use fbjni or jni
Summary: Adds a flag useVanillaJNI in YogaConfig to determine whether to use FbJNI or JNI. Currently default is set to false. We will experiment based on this flag once all code have been migrated. Reviewed By: Andrey-Mishanin Differential Revision: D17601703 fbshipit-source-id: 377a5bd2a6f8a7584e84932e87fa7044d8165efd
This commit is contained in:
committed by
Facebook Github Bot
parent
b29e144649
commit
0875b6b542
@@ -37,4 +37,8 @@ public abstract class YogaConfig {
|
||||
public abstract YogaLogger getLogger();
|
||||
|
||||
abstract long getNativePointer();
|
||||
|
||||
public abstract void setUseVanillaJNI(boolean useVanillaJNI);
|
||||
|
||||
public abstract boolean useVanillaJNI();
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
|
||||
|
||||
long mNativePointer;
|
||||
private YogaLogger mLogger;
|
||||
private boolean useVanillaJNI = false;
|
||||
|
||||
private YogaConfigJNIBase(long nativePointer) {
|
||||
if (nativePointer == 0) {
|
||||
@@ -70,4 +71,14 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
|
||||
long getNativePointer() {
|
||||
return mNativePointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseVanillaJNI(boolean useVanillaJNI) {
|
||||
this.useVanillaJNI = useVanillaJNI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useVanillaJNI() {
|
||||
return this.useVanillaJNI;
|
||||
}
|
||||
}
|
||||
|
@@ -46,6 +46,8 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
|
||||
private boolean mHasNewLayout = true;
|
||||
|
||||
private boolean useVanillaJNI = false;
|
||||
|
||||
private YogaNodeJNIBase(long nativePointer) {
|
||||
if (nativePointer == 0) {
|
||||
throw new IllegalStateException("Failed to allocate native memory");
|
||||
@@ -59,6 +61,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
|
||||
YogaNodeJNIBase(YogaConfig config) {
|
||||
this(YogaNative.jni_YGNodeNewWithConfig(((YogaConfigJNIBase)config).mNativePointer));
|
||||
this.useVanillaJNI = config.useVanillaJNI();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
@@ -284,7 +287,11 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
}
|
||||
|
||||
public void setFlex(float flex) {
|
||||
YogaNative.jni_YGNodeStyleSetFlex(mNativePointer, flex);
|
||||
if (useVanillaJNI) {
|
||||
YogaNative.jni_YGNodeStyleSetFlexJNI(mNativePointer, flex);
|
||||
} else {
|
||||
YogaNative.jni_YGNodeStyleSetFlex(mNativePointer, flex);
|
||||
}
|
||||
}
|
||||
|
||||
public float getFlexGrow() {
|
||||
|
Reference in New Issue
Block a user