move percent auto style properties to vanilla jni (YogaStyleProperties Part 3)
Summary: Move Yoga style properties to vanilla JNI under a flag. Reviewed By: amir-shalem Differential Revision: D17666674 fbshipit-source-id: 08490bf7c214c856a93214088a27dd4e6df9e0fd
This commit is contained in:
Родитель
69fb812c1d
Коммит
abb77b34cc
|
@ -140,6 +140,30 @@ public class YogaNative {
|
|||
static native void jni_YGNodeStyleSetFlexGrowJNI(long nativePointer, float flexGrow);
|
||||
static native float jni_YGNodeStyleGetFlexShrinkJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetFlexShrinkJNI(long nativePointer, float flexShrink);
|
||||
static native long jni_YGNodeStyleGetFlexBasisJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetFlexBasisJNI(long nativePointer, float flexBasis);
|
||||
static native void jni_YGNodeStyleSetFlexBasisPercentJNI(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetFlexBasisAutoJNI(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetWidthJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetWidthJNI(long nativePointer, float width);
|
||||
static native void jni_YGNodeStyleSetWidthPercentJNI(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetWidthAutoJNI(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetHeightJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetHeightJNI(long nativePointer, float height);
|
||||
static native void jni_YGNodeStyleSetHeightPercentJNI(long nativePointer, float percent);
|
||||
static native void jni_YGNodeStyleSetHeightAutoJNI(long nativePointer);
|
||||
static native long jni_YGNodeStyleGetMinWidthJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMinWidthJNI(long nativePointer, float minWidth);
|
||||
static native void jni_YGNodeStyleSetMinWidthPercentJNI(long nativePointer, float percent);
|
||||
static native long jni_YGNodeStyleGetMinHeightJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMinHeightJNI(long nativePointer, float minHeight);
|
||||
static native void jni_YGNodeStyleSetMinHeightPercentJNI(long nativePointer, float percent);
|
||||
static native long jni_YGNodeStyleGetMaxWidthJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMaxWidthJNI(long nativePointer, float maxWidth);
|
||||
static native void jni_YGNodeStyleSetMaxWidthPercentJNI(long nativePointer, float percent);
|
||||
static native long jni_YGNodeStyleGetMaxHeightJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetMaxHeightJNI(long nativePointer, float maxheight);
|
||||
static native void jni_YGNodeStyleSetMaxHeightPercentJNI(long nativePointer, float percent);
|
||||
static native float jni_YGNodeStyleGetAspectRatioJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetAspectRatioJNI(long nativePointer, float aspectRatio);
|
||||
}
|
||||
|
|
|
@ -347,18 +347,27 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||
}
|
||||
|
||||
public YogaValue getFlexBasis() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetFlexBasis(mNativePointer));
|
||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexBasisJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlexBasis(mNativePointer));
|
||||
}
|
||||
|
||||
public void setFlexBasis(float flexBasis) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasisJNI(mNativePointer, flexBasis);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
|
||||
}
|
||||
|
||||
public void setFlexBasisPercent(float percent) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasisPercentJNI(mNativePointer, percent);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public void setFlexBasisAuto() {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasisAutoJNI(mNativePointer);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
|
||||
}
|
||||
|
||||
|
@ -411,82 +420,124 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||
}
|
||||
|
||||
public YogaValue getWidth() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetWidth(mNativePointer));
|
||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetWidthJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetWidth(mNativePointer));
|
||||
}
|
||||
|
||||
public void setWidth(float width) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetWidthJNI(mNativePointer, width);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetWidth(mNativePointer, width);
|
||||
}
|
||||
|
||||
public void setWidthPercent(float percent) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetWidthPercentJNI(mNativePointer, percent);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public void setWidthAuto() {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetWidthAutoJNI(mNativePointer);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetWidthAuto(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaValue getHeight() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetHeight(mNativePointer));
|
||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetHeightJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetHeight(mNativePointer));
|
||||
}
|
||||
|
||||
public void setHeight(float height) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetHeightJNI(mNativePointer, height);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetHeight(mNativePointer, height);
|
||||
}
|
||||
|
||||
public void setHeightPercent(float percent) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetHeightPercentJNI(mNativePointer, percent);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public void setHeightAuto() {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetHeightAutoJNI(mNativePointer);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetHeightAuto(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaValue getMinWidth() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinWidth(mNativePointer));
|
||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMinWidthJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMinWidth(mNativePointer));
|
||||
}
|
||||
|
||||
public void setMinWidth(float minWidth) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetMinWidthJNI(mNativePointer, minWidth);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
|
||||
}
|
||||
|
||||
public void setMinWidthPercent(float percent) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetMinWidthPercentJNI(mNativePointer, percent);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public YogaValue getMinHeight() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinHeight(mNativePointer));
|
||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMinHeightJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMinHeight(mNativePointer));
|
||||
}
|
||||
|
||||
public void setMinHeight(float minHeight) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetMinHeightJNI(mNativePointer, minHeight);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
|
||||
}
|
||||
|
||||
public void setMinHeightPercent(float percent) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetMinHeightPercentJNI(mNativePointer, percent);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public YogaValue getMaxWidth() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxWidth(mNativePointer));
|
||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMaxWidthJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMaxWidth(mNativePointer));
|
||||
}
|
||||
|
||||
public void setMaxWidth(float maxWidth) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetMaxWidthJNI(mNativePointer, maxWidth);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
|
||||
}
|
||||
|
||||
public void setMaxWidthPercent(float percent) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetMaxWidthPercentJNI(mNativePointer, percent);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
public YogaValue getMaxHeight() {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxHeight(mNativePointer));
|
||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMaxHeightJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMaxHeight(mNativePointer));
|
||||
}
|
||||
|
||||
public void setMaxHeight(float maxheight) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetMaxHeightJNI(mNativePointer, maxheight);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
|
||||
}
|
||||
|
||||
public void setMaxHeightPercent(float percent) {
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeStyleSetMaxHeightPercentJNI(mNativePointer, percent);
|
||||
else
|
||||
YogaNative.jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <yoga/Yoga-internal.h>
|
||||
#include <yoga/log.h>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
*/
|
||||
#include <cstring>
|
||||
|
||||
namespace {
|
||||
|
||||
union YGNodeContext {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "jni.h"
|
||||
#include "YGJNIVanilla.h"
|
||||
#include <yoga/YGNode.h>
|
||||
#include "YGJNI.h"
|
||||
|
||||
static inline YGNodeRef _jlong2YGNodeRef(jlong addr) {
|
||||
return reinterpret_cast<YGNodeRef>(static_cast<intptr_t>(addr));
|
||||
|
@ -24,6 +25,32 @@ static inline YGNodeRef _jlong2YGNodeRef(jlong addr) {
|
|||
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
|
||||
}
|
||||
|
||||
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
||||
static jlong jni_YGNodeStyleGet##name##JNI( \
|
||||
JNIEnv* env, jobject obj, jlong nativePointer) { \
|
||||
return YogaValue::asJavaLong( \
|
||||
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
|
||||
} \
|
||||
\
|
||||
static void jni_YGNodeStyleSet##name##JNI( \
|
||||
JNIEnv* env, jobject obj, jlong nativePointer, jfloat value) { \
|
||||
YGNodeStyleSet##name( \
|
||||
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
||||
} \
|
||||
\
|
||||
static void jni_YGNodeStyleSet##name##PercentJNI( \
|
||||
JNIEnv* env, jobject obj, jlong nativePointer, jfloat value) { \
|
||||
YGNodeStyleSet##name##Percent( \
|
||||
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
||||
}
|
||||
|
||||
#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
||||
static void jni_YGNodeStyleSet##name##AutoJNI( \
|
||||
JNIEnv* env, jobject obj, jlong nativePointer) { \
|
||||
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
|
||||
}
|
||||
|
||||
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
|
||||
YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
|
||||
YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
|
||||
|
@ -38,6 +65,14 @@ YG_NODE_JNI_STYLE_PROP(jfloat, float, Flex);
|
|||
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
|
||||
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(FlexBasis);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Width);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP(MinWidth);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP(MaxWidth);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Height);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP(MinHeight);
|
||||
YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
|
||||
|
||||
// Yoga specific properties, not compatible with flexbox specification
|
||||
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
|
||||
|
||||
|
@ -138,6 +173,74 @@ static JNINativeMethod methods[] = {
|
|||
{"jni_YGNodeStyleSetFlexShrinkJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetFlexShrinkJNI},
|
||||
{"jni_YGNodeStyleGetFlexBasisJNI",
|
||||
"(J)J",
|
||||
(void*) jni_YGNodeStyleGetFlexBasisJNI},
|
||||
{"jni_YGNodeStyleSetFlexBasisJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetFlexBasisJNI},
|
||||
{"jni_YGNodeStyleSetFlexBasisPercentJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetFlexBasisPercentJNI},
|
||||
{"jni_YGNodeStyleSetFlexBasisAutoJNI",
|
||||
"(J)V",
|
||||
(void*) jni_YGNodeStyleSetFlexBasisAutoJNI},
|
||||
{"jni_YGNodeStyleGetWidthJNI", "(J)J", (void*) jni_YGNodeStyleGetWidthJNI},
|
||||
{"jni_YGNodeStyleSetWidthJNI", "(JF)V", (void*) jni_YGNodeStyleSetWidthJNI},
|
||||
{"jni_YGNodeStyleSetWidthPercentJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetWidthPercentJNI},
|
||||
{"jni_YGNodeStyleSetWidthAutoJNI",
|
||||
"(J)V",
|
||||
(void*) jni_YGNodeStyleSetWidthAutoJNI},
|
||||
{"jni_YGNodeStyleGetHeightJNI",
|
||||
"(J)J",
|
||||
(void*) jni_YGNodeStyleGetHeightJNI},
|
||||
{"jni_YGNodeStyleSetHeightJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetHeightJNI},
|
||||
{"jni_YGNodeStyleSetHeightPercentJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetHeightPercentJNI},
|
||||
{"jni_YGNodeStyleSetHeightAutoJNI",
|
||||
"(J)V",
|
||||
(void*) jni_YGNodeStyleSetHeightAutoJNI},
|
||||
{"jni_YGNodeStyleGetMinWidthJNI",
|
||||
"(J)J",
|
||||
(void*) jni_YGNodeStyleGetMinWidthJNI},
|
||||
{"jni_YGNodeStyleSetMinWidthJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetMinWidthJNI},
|
||||
{"jni_YGNodeStyleSetMinWidthPercentJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetMinWidthPercentJNI},
|
||||
{"jni_YGNodeStyleGetMinHeightJNI",
|
||||
"(J)J",
|
||||
(void*) jni_YGNodeStyleGetMinHeightJNI},
|
||||
{"jni_YGNodeStyleSetMinHeightJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetMinHeightJNI},
|
||||
{"jni_YGNodeStyleSetMinHeightPercentJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetMinHeightPercentJNI},
|
||||
{"jni_YGNodeStyleGetMaxWidthJNI",
|
||||
"(J)J",
|
||||
(void*) jni_YGNodeStyleGetMaxWidthJNI},
|
||||
{"jni_YGNodeStyleSetMaxWidthJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetMaxWidthJNI},
|
||||
{"jni_YGNodeStyleSetMaxWidthPercentJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetMaxWidthPercentJNI},
|
||||
{"jni_YGNodeStyleGetMaxHeightJNI",
|
||||
"(J)J",
|
||||
(void*) jni_YGNodeStyleGetMaxHeightJNI},
|
||||
{"jni_YGNodeStyleSetMaxHeightJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetMaxHeightJNI},
|
||||
{"jni_YGNodeStyleSetMaxHeightPercentJNI",
|
||||
"(JF)V",
|
||||
(void*) jni_YGNodeStyleSetMaxHeightPercentJNI},
|
||||
{"jni_YGNodeStyleGetAspectRatioJNI",
|
||||
"(J)F",
|
||||
(void*) jni_YGNodeStyleGetAspectRatioJNI},
|
||||
|
|
Загрузка…
Ссылка в новой задаче