Skip to content

Commit

Permalink
Migrate YGNodeStyleGetFlex method to vanilla jni (YogaStyleProperties…
Browse files Browse the repository at this point in the history
… Part 2)

Summary: Move Yoga style properties to vanilla JNI under a flag.

Reviewed By: amir-shalem

Differential Revision: D17666090

fbshipit-source-id: 121b939c310799c79f2fce0ea293f88b2940c4fc
  • Loading branch information
SidharthGuglani-zz authored and facebook-github-bot committed Oct 8, 2019
1 parent 60973b5 commit c15cefd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
3 changes: 2 additions & 1 deletion ReactAndroid/src/main/java/com/facebook/yoga/YogaNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ public class YogaNative {
static native void jni_YGNodeStyleSetOverflowJNI(long nativePointer, int overflow);
static native int jni_YGNodeStyleGetDisplayJNI(long nativePointer);
static native void jni_YGNodeStyleSetDisplayJNI(long nativePointer, int display);
public static native void jni_YGNodeStyleSetFlexJNI(long nativePointer, float flex);
static native float jni_YGNodeStyleGetFlexJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexJNI(long nativePointer, float flex);
static native float jni_YGNodeStyleGetFlexGrowJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexGrowJNI(long nativePointer, float flexGrow);
static native float jni_YGNodeStyleGetFlexShrinkJNI(long nativePointer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public void setDisplay(YogaDisplay display) {
}

public float getFlex() {
return YogaNative.jni_YGNodeStyleGetFlex(mNativePointer);
return useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlex(mNativePointer);
}

public void setFlex(float flex) {
Expand Down
13 changes: 3 additions & 10 deletions ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNIVanilla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,10 @@ YG_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType);
YG_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
YG_NODE_JNI_STYLE_PROP(jint, YGDisplay, Display);
YG_NODE_JNI_STYLE_PROP(jfloat, float, Flex);
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);

void jni_YGNodeStyleSetFlexJNI(
JNIEnv* env,
jobject obj,
jlong nativePointer,
jfloat value) {
YGNodeStyleSetFlex(
_jlong2YGNodeRef(nativePointer), static_cast<float>(value));
}

// Yoga specific properties, not compatible with flexbox specification
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);

Expand All @@ -72,7 +64,6 @@ void registerNativeMethods(
}

static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetFlexJNI", "(JF)V", (void*) jni_YGNodeStyleSetFlexJNI},
{"jni_YGNodeStyleGetDirectionJNI",
"(J)I",
(void*) jni_YGNodeStyleGetDirectionJNI},
Expand Down Expand Up @@ -133,6 +124,8 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetDisplayJNI",
"(JI)V",
(void*) jni_YGNodeStyleSetDisplayJNI},
{"jni_YGNodeStyleGetFlexJNI", "(J)F", (void*) jni_YGNodeStyleGetFlexJNI},
{"jni_YGNodeStyleSetFlexJNI", "(JF)V", (void*) jni_YGNodeStyleSetFlexJNI},
{"jni_YGNodeStyleGetFlexGrowJNI",
"(J)F",
(void*) jni_YGNodeStyleGetFlexGrowJNI},
Expand Down

0 comments on commit c15cefd

Please sign in to comment.