Remove useVanillaJNI flag and usage of fbjni in yoga build
Summary: ## Changelog: [General] [Yoga] - Use vanilla jni instead of fbjni for all the jni communication Reviewed By: astreet Differential Revision: D17808005 fbshipit-source-id: 5e9a1ed73978f519c71c248774a28e5a294e7c7f
This commit is contained in:
committed by
Facebook Github Bot
parent
5960dd888d
commit
f99da09716
17
BUCK
17
BUCK
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "LIBRARY_COMPILER_FLAGS", "subdir_glob", "yoga_cxx_library", "yoga_cxx_test", "yoga_dep")
|
load("//tools/build_defs/oss:yoga_defs.bzl", "BASE_COMPILER_FLAGS", "GTEST_TARGET", "LIBRARY_COMPILER_FLAGS", "YOGA_ROOTS", "subdir_glob", "yoga_cxx_library", "yoga_cxx_test", "yoga_dep", "yoga_prebuilt_cxx_library")
|
||||||
|
|
||||||
GMOCK_OVERRIDE_FLAGS = [
|
GMOCK_OVERRIDE_FLAGS = [
|
||||||
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
# gmock does not mark mocked methods as override, ignore the warnings in tests
|
||||||
@@ -14,6 +14,18 @@ TEST_COMPILER_FLAGS = BASE_COMPILER_FLAGS + GMOCK_OVERRIDE_FLAGS + [
|
|||||||
"-DYG_ENABLE_EVENTS",
|
"-DYG_ENABLE_EVENTS",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
yoga_prebuilt_cxx_library(
|
||||||
|
name = "ndklog",
|
||||||
|
exported_platform_linker_flags = [
|
||||||
|
(
|
||||||
|
"^android.*",
|
||||||
|
["-llog"],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
header_only = True,
|
||||||
|
visibility = YOGA_ROOTS,
|
||||||
|
)
|
||||||
|
|
||||||
yoga_cxx_library(
|
yoga_cxx_library(
|
||||||
name = "yoga",
|
name = "yoga",
|
||||||
srcs = glob(["yoga/**/*.cpp"]),
|
srcs = glob(["yoga/**/*.cpp"]),
|
||||||
@@ -24,7 +36,7 @@ yoga_cxx_library(
|
|||||||
tests = [":YogaTests"],
|
tests = [":YogaTests"],
|
||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
yoga_dep("lib/fb:ndklog"),
|
":ndklog",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -39,7 +51,6 @@ yoga_cxx_library(
|
|||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
":yoga",
|
":yoga",
|
||||||
yoga_dep("lib/fb:ndklog"),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
18
java/BUCK
18
java/BUCK
@@ -3,7 +3,7 @@
|
|||||||
# This source code is licensed under the MIT license found in the
|
# This source code is licensed under the MIT license found in the
|
||||||
# LICENSE file in the root directory of this source tree.
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID", "CXX_LIBRARY_WHITELIST", "FBJNI_JAVA_TARGET", "FBJNI_TARGET", "JNI_TARGET", "JSR_305_TARGET", "JUNIT_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "yoga_cxx_lib", "yoga_cxx_library", "yoga_dep", "yoga_java_binary", "yoga_java_library", "yoga_java_test")
|
load("//tools/build_defs/oss:yoga_defs.bzl", "ANDROID", "CXX_LIBRARY_WHITELIST", "JNI_TARGET", "JSR_305_TARGET", "JUNIT_TARGET", "PROGRUARD_ANNOTATIONS_TARGET", "SOLOADER_TARGET", "YOGA_ROOTS", "yoga_cxx_lib", "yoga_cxx_library", "yoga_dep", "yoga_java_binary", "yoga_java_library", "yoga_java_test", "yoga_prebuilt_cxx_library")
|
||||||
|
|
||||||
CXX_LIBRARY_WHITELIST_FOR_TESTS = CXX_LIBRARY_WHITELIST + [
|
CXX_LIBRARY_WHITELIST_FOR_TESTS = CXX_LIBRARY_WHITELIST + [
|
||||||
yoga_cxx_lib("testutil:jni"),
|
yoga_cxx_lib("testutil:jni"),
|
||||||
@@ -16,6 +16,18 @@ YOGA_JAVA_IMPLEMENTATION_FILES = [
|
|||||||
"com/facebook/yoga/YogaNative.java",
|
"com/facebook/yoga/YogaNative.java",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
yoga_prebuilt_cxx_library(
|
||||||
|
name = "ndklog",
|
||||||
|
exported_platform_linker_flags = [
|
||||||
|
(
|
||||||
|
"^android.*",
|
||||||
|
["-llog"],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
header_only = True,
|
||||||
|
visibility = YOGA_ROOTS,
|
||||||
|
)
|
||||||
|
|
||||||
yoga_cxx_library(
|
yoga_cxx_library(
|
||||||
name = "jni",
|
name = "jni",
|
||||||
srcs = glob(["jni/*.cpp"]),
|
srcs = glob(["jni/*.cpp"]),
|
||||||
@@ -41,9 +53,9 @@ yoga_cxx_library(
|
|||||||
soname = "libyoga.$(ext)",
|
soname = "libyoga.$(ext)",
|
||||||
visibility = ["PUBLIC"],
|
visibility = ["PUBLIC"],
|
||||||
deps = [
|
deps = [
|
||||||
FBJNI_TARGET,
|
|
||||||
JNI_TARGET,
|
JNI_TARGET,
|
||||||
yoga_dep(":yoga"),
|
yoga_dep(":yoga"),
|
||||||
|
":ndklog",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -72,7 +84,6 @@ yoga_java_library(
|
|||||||
deps = [
|
deps = [
|
||||||
":java-interface",
|
":java-interface",
|
||||||
":jni",
|
":jni",
|
||||||
FBJNI_JAVA_TARGET,
|
|
||||||
JSR_305_TARGET,
|
JSR_305_TARGET,
|
||||||
PROGRUARD_ANNOTATIONS_TARGET,
|
PROGRUARD_ANNOTATIONS_TARGET,
|
||||||
SOLOADER_TARGET,
|
SOLOADER_TARGET,
|
||||||
@@ -111,6 +122,5 @@ yoga_java_binary(
|
|||||||
name = "yoga",
|
name = "yoga",
|
||||||
deps = [
|
deps = [
|
||||||
":java",
|
":java",
|
||||||
FBJNI_JAVA_TARGET,
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@@ -8,17 +8,14 @@ cmake_minimum_required(VERSION 3.4.1)
|
|||||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||||
|
|
||||||
# configure import libs
|
# configure import libs
|
||||||
set(libfb_DIR ${CMAKE_SOURCE_DIR}/../lib/fb/src/main/cpp)
|
|
||||||
set(yogacore_DIR ${CMAKE_SOURCE_DIR}/..)
|
set(yogacore_DIR ${CMAKE_SOURCE_DIR}/..)
|
||||||
|
|
||||||
set(build_DIR ${CMAKE_SOURCE_DIR}/build)
|
set(build_DIR ${CMAKE_SOURCE_DIR}/build)
|
||||||
|
|
||||||
set(libfb_build_DIR ${build_DIR}/libfb/${ANDROID_ABI})
|
|
||||||
set(yogacore_build_DIR ${build_DIR}/yogacore/${ANDROID_ABI})
|
set(yogacore_build_DIR ${build_DIR}/yogacore/${ANDROID_ABI})
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${build_DIR})
|
file(MAKE_DIRECTORY ${build_DIR})
|
||||||
|
|
||||||
add_subdirectory(${libfb_DIR} ${libfb_build_DIR})
|
|
||||||
add_subdirectory(${yogacore_DIR} ${yogacore_build_DIR})
|
add_subdirectory(${yogacore_DIR} ${yogacore_build_DIR})
|
||||||
|
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
@@ -36,7 +33,6 @@ file(GLOB jni_SRC
|
|||||||
add_library(yoga SHARED ${jni_SRC})
|
add_library(yoga SHARED ${jni_SRC})
|
||||||
|
|
||||||
target_include_directories(yoga PRIVATE
|
target_include_directories(yoga PRIVATE
|
||||||
${libfb_DIR}/include
|
|
||||||
${yogacore_DIR})
|
${yogacore_DIR})
|
||||||
|
|
||||||
target_link_libraries(yoga -Wl,--gc-sections yogacore fb)
|
target_link_libraries(yoga -Wl,--gc-sections yogacore)
|
||||||
|
@@ -38,8 +38,4 @@ public abstract class YogaConfig {
|
|||||||
public abstract YogaLogger getLogger();
|
public abstract YogaLogger getLogger();
|
||||||
|
|
||||||
abstract long getNativePointer();
|
abstract long getNativePointer();
|
||||||
|
|
||||||
public abstract void setUseVanillaJNI(boolean useVanillaJNI);
|
|
||||||
|
|
||||||
public abstract boolean useVanillaJNI();
|
|
||||||
}
|
}
|
||||||
|
@@ -11,8 +11,4 @@ public abstract class YogaConfigFactory {
|
|||||||
public static YogaConfig create() {
|
public static YogaConfig create() {
|
||||||
return new YogaConfigJNIFinalizer();
|
return new YogaConfigJNIFinalizer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static YogaConfig create(boolean useVanillaJNI) {
|
|
||||||
return new YogaConfigJNIFinalizer(useVanillaJNI);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
|
|||||||
|
|
||||||
long mNativePointer;
|
long mNativePointer;
|
||||||
private YogaLogger mLogger;
|
private YogaLogger mLogger;
|
||||||
protected boolean useVanillaJNI = false;
|
|
||||||
|
|
||||||
private YogaConfigJNIBase(long nativePointer) {
|
private YogaConfigJNIBase(long nativePointer) {
|
||||||
if (nativePointer == 0) {
|
if (nativePointer == 0) {
|
||||||
@@ -21,40 +20,27 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
YogaConfigJNIBase() {
|
YogaConfigJNIBase() {
|
||||||
this(YogaNative.jni_YGConfigNew());
|
this(YogaNative.jni_YGConfigNewJNI());
|
||||||
}
|
}
|
||||||
|
|
||||||
YogaConfigJNIBase(boolean useVanillaJNI) {
|
YogaConfigJNIBase(boolean useVanillaJNI) {
|
||||||
this(useVanillaJNI ? YogaNative.jni_YGConfigNewJNI() : YogaNative.jni_YGConfigNew());
|
this(YogaNative.jni_YGConfigNewJNI());
|
||||||
this.useVanillaJNI = useVanillaJNI;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) {
|
public void setExperimentalFeatureEnabled(YogaExperimentalFeature feature, boolean enabled) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGConfigSetExperimentalFeatureEnabledJNI(mNativePointer, feature.intValue(), enabled);
|
||||||
YogaNative.jni_YGConfigSetExperimentalFeatureEnabledJNI(mNativePointer, feature.intValue(), enabled);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGConfigSetExperimentalFeatureEnabled(mNativePointer, feature.intValue(), enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUseWebDefaults(boolean useWebDefaults) {
|
public void setUseWebDefaults(boolean useWebDefaults) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGConfigSetUseWebDefaultsJNI(mNativePointer, useWebDefaults);
|
||||||
YogaNative.jni_YGConfigSetUseWebDefaultsJNI(mNativePointer, useWebDefaults);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGConfigSetUseWebDefaults(mNativePointer, useWebDefaults);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrintTreeFlag(boolean enable) {
|
public void setPrintTreeFlag(boolean enable) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGConfigSetPrintTreeFlagJNI(mNativePointer, enable);
|
||||||
YogaNative.jni_YGConfigSetPrintTreeFlagJNI(mNativePointer, enable);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGConfigSetPrintTreeFlag(mNativePointer, enable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPointScaleFactor(float pixelsInPoint) {
|
public void setPointScaleFactor(float pixelsInPoint) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGConfigSetPointScaleFactorJNI(mNativePointer, pixelsInPoint);
|
||||||
YogaNative.jni_YGConfigSetPointScaleFactorJNI(mNativePointer, pixelsInPoint);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGConfigSetPointScaleFactor(mNativePointer, pixelsInPoint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,10 +49,7 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
|
|||||||
* Because this was such a long-standing bug we must allow legacy users to switch back to this behaviour.
|
* Because this was such a long-standing bug we must allow legacy users to switch back to this behaviour.
|
||||||
*/
|
*/
|
||||||
public void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour) {
|
public void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviourJNI(mNativePointer, useLegacyStretchBehaviour);
|
||||||
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviourJNI(mNativePointer, useLegacyStretchBehaviour);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,20 +59,13 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
|
|||||||
*/
|
*/
|
||||||
public void setShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
public void setShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||||
boolean shouldDiffLayoutWithoutLegacyStretchBehaviour) {
|
boolean shouldDiffLayoutWithoutLegacyStretchBehaviour) {
|
||||||
if (useVanillaJNI)
|
|
||||||
YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI(
|
YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI(
|
||||||
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
||||||
else
|
|
||||||
YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
|
||||||
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLogger(YogaLogger logger) {
|
public void setLogger(YogaLogger logger) {
|
||||||
mLogger = logger;
|
mLogger = logger;
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGConfigSetLoggerJNI(mNativePointer, logger);
|
||||||
YogaNative.jni_YGConfigSetLoggerJNI(mNativePointer, logger);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGConfigSetLogger(mNativePointer, logger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaLogger getLogger() {
|
public YogaLogger getLogger() {
|
||||||
@@ -99,14 +75,4 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
|
|||||||
long getNativePointer() {
|
long getNativePointer() {
|
||||||
return mNativePointer;
|
return mNativePointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUseVanillaJNI(boolean useVanillaJNI) {
|
|
||||||
this.useVanillaJNI = useVanillaJNI;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean useVanillaJNI() {
|
|
||||||
return this.useVanillaJNI;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -12,10 +12,6 @@ public class YogaConfigJNIFinalizer extends YogaConfigJNIBase {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaConfigJNIFinalizer(boolean useVanillaJNI) {
|
|
||||||
super(useVanillaJNI);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
try {
|
try {
|
||||||
@@ -29,10 +25,7 @@ public class YogaConfigJNIFinalizer extends YogaConfigJNIBase {
|
|||||||
if (mNativePointer != 0) {
|
if (mNativePointer != 0) {
|
||||||
long nativePointer = mNativePointer;
|
long nativePointer = mNativePointer;
|
||||||
mNativePointer = 0;
|
mNativePointer = 0;
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGConfigFreeJNI(nativePointer);
|
||||||
YogaNative.jni_YGConfigFreeJNI(nativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGConfigFree(nativePointer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,105 +15,7 @@ public class YogaNative {
|
|||||||
static {
|
static {
|
||||||
SoLoader.loadLibrary("yoga");
|
SoLoader.loadLibrary("yoga");
|
||||||
}
|
}
|
||||||
|
|
||||||
// YGConfig related
|
|
||||||
static native long jni_YGConfigNew();
|
|
||||||
static native void jni_YGConfigFree(long nativePointer);
|
|
||||||
static native void jni_YGConfigSetExperimentalFeatureEnabled(long nativePointer, int feature, boolean enabled);
|
|
||||||
static native void jni_YGConfigSetUseWebDefaults(long nativePointer, boolean useWebDefaults);
|
|
||||||
static native void jni_YGConfigSetPrintTreeFlag(long nativePointer, boolean enable);
|
|
||||||
static native void jni_YGConfigSetPointScaleFactor(long nativePointer, float pixelsInPoint);
|
|
||||||
static native void jni_YGConfigSetUseLegacyStretchBehaviour(long nativePointer, boolean useLegacyStretchBehaviour);
|
|
||||||
static native void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(long nativePointer, boolean shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
|
||||||
static native void jni_YGConfigSetLogger(long nativePointer, Object logger);
|
|
||||||
|
|
||||||
|
|
||||||
// YGNode related
|
|
||||||
static native long jni_YGNodeNew();
|
|
||||||
static native long jni_YGNodeNewWithConfig(long configPointer);
|
|
||||||
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);
|
|
||||||
static native void jni_YGNodeSetIsReferenceBaseline(long nativePointer, boolean isReferenceBaseline);
|
|
||||||
static native boolean jni_YGNodeIsReferenceBaseline(long nativePointer);
|
|
||||||
static native void jni_YGNodeClearChildren(long nativePointer);
|
|
||||||
static native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
|
|
||||||
static native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height, long[] nativePointers, YogaNodeJNIBase[] nodes);
|
|
||||||
static native void jni_YGNodeMarkDirty(long nativePointer);
|
|
||||||
static native void jni_YGNodeMarkDirtyAndPropogateToDescendants(long nativePointer);
|
|
||||||
static native boolean jni_YGNodeIsDirty(long nativePointer);
|
|
||||||
static native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
|
|
||||||
static native int jni_YGNodeStyleGetDirection(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
|
|
||||||
static native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
|
|
||||||
static native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
|
|
||||||
static native int jni_YGNodeStyleGetAlignItems(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
|
|
||||||
static native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
|
|
||||||
static native int jni_YGNodeStyleGetAlignContent(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
|
|
||||||
static native int jni_YGNodeStyleGetPositionType(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
|
|
||||||
static native int jni_YGNodeStyleGetFlexWrap(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
|
|
||||||
static native int jni_YGNodeStyleGetOverflow(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
|
|
||||||
static native int jni_YGNodeStyleGetDisplay(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
|
|
||||||
static native float jni_YGNodeStyleGetFlex(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
|
|
||||||
static native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
|
|
||||||
static native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
|
|
||||||
static native long jni_YGNodeStyleGetFlexBasis(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
|
|
||||||
static native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
|
|
||||||
static native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer);
|
|
||||||
static native long jni_YGNodeStyleGetMargin(long nativePointer, int edge);
|
|
||||||
static native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
|
|
||||||
static native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
|
|
||||||
static native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
|
|
||||||
static native long jni_YGNodeStyleGetPadding(long nativePointer, int edge);
|
|
||||||
static native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
|
|
||||||
static native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
|
|
||||||
static native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
|
|
||||||
static native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
|
|
||||||
static native long jni_YGNodeStyleGetPosition(long nativePointer, int edge);
|
|
||||||
static native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
|
|
||||||
static native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
|
|
||||||
static native long jni_YGNodeStyleGetWidth(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
|
|
||||||
static native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
|
|
||||||
static native void jni_YGNodeStyleSetWidthAuto(long nativePointer);
|
|
||||||
static native long jni_YGNodeStyleGetHeight(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
|
|
||||||
static native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
|
|
||||||
static native void jni_YGNodeStyleSetHeightAuto(long nativePointer);
|
|
||||||
static native long jni_YGNodeStyleGetMinWidth(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
|
|
||||||
static native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
|
|
||||||
static native long jni_YGNodeStyleGetMinHeight(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
|
|
||||||
static native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
|
|
||||||
static native long jni_YGNodeStyleGetMaxWidth(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
|
|
||||||
static native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
|
|
||||||
static native long jni_YGNodeStyleGetMaxHeight(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
|
|
||||||
static native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
|
|
||||||
static native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
|
|
||||||
static native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
|
|
||||||
static native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
|
|
||||||
static native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
|
|
||||||
static native void jni_YGNodePrint(long nativePointer);
|
|
||||||
static native void jni_YGNodeSetStyleInputs(long nativePointer, float[] styleInputsArray, int size);
|
|
||||||
static native long jni_YGNodeClone(long nativePointer);
|
|
||||||
|
|
||||||
|
|
||||||
// JNI methods that use Vanilla JNI
|
// JNI methods that use Vanilla JNI
|
||||||
// YGConfig related
|
// YGConfig related
|
||||||
static native long jni_YGConfigNewJNI();
|
static native long jni_YGConfigNewJNI();
|
||||||
|
@@ -12,10 +12,6 @@ public abstract class YogaNodeFactory {
|
|||||||
return new YogaNodeJNIFinalizer();
|
return new YogaNodeJNIFinalizer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static YogaNode create(boolean useVanillaJNI) {
|
|
||||||
return new YogaNodeJNIFinalizer(useVanillaJNI);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static YogaNode create(YogaConfig config) {
|
public static YogaNode create(YogaConfig config) {
|
||||||
return new YogaNodeJNIFinalizer(config);
|
return new YogaNodeJNIFinalizer(config);
|
||||||
}
|
}
|
||||||
|
@@ -47,8 +47,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
|
|
||||||
private boolean mHasNewLayout = true;
|
private boolean mHasNewLayout = true;
|
||||||
|
|
||||||
protected boolean useVanillaJNI = false;
|
|
||||||
|
|
||||||
private YogaNodeJNIBase(long nativePointer) {
|
private YogaNodeJNIBase(long nativePointer) {
|
||||||
if (nativePointer == 0) {
|
if (nativePointer == 0) {
|
||||||
throw new IllegalStateException("Failed to allocate native memory");
|
throw new IllegalStateException("Failed to allocate native memory");
|
||||||
@@ -57,17 +55,11 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
YogaNodeJNIBase() {
|
YogaNodeJNIBase() {
|
||||||
this(YogaNative.jni_YGNodeNew());
|
this(YogaNative.jni_YGNodeNewJNI());
|
||||||
}
|
|
||||||
|
|
||||||
YogaNodeJNIBase(boolean useVanillaJNI) {
|
|
||||||
this(useVanillaJNI ? YogaNative.jni_YGNodeNewJNI() : YogaNative.jni_YGNodeNew());
|
|
||||||
this.useVanillaJNI = useVanillaJNI;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
YogaNodeJNIBase(YogaConfig config) {
|
YogaNodeJNIBase(YogaConfig config) {
|
||||||
this(config.useVanillaJNI() ? YogaNative.jni_YGNodeNewWithConfigJNI(((YogaConfigJNIBase)config).mNativePointer) : YogaNative.jni_YGNodeNewWithConfig(((YogaConfigJNIBase)config).mNativePointer));
|
this(YogaNative.jni_YGNodeNewWithConfigJNI(((YogaConfigJNIBase)config).mNativePointer));
|
||||||
this.useVanillaJNI = config.useVanillaJNI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
@@ -78,10 +70,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
mHasNewLayout = true;
|
mHasNewLayout = true;
|
||||||
mLayoutDirection = 0;
|
mLayoutDirection = 0;
|
||||||
|
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeResetJNI(mNativePointer);
|
||||||
YogaNative.jni_YGNodeResetJNI(mNativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeReset(mNativePointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getChildCount() {
|
public int getChildCount() {
|
||||||
@@ -106,28 +95,22 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
}
|
}
|
||||||
mChildren.add(i, child);
|
mChildren.add(i, child);
|
||||||
child.mOwner = this;
|
child.mOwner = this;
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeInsertChildJNI(mNativePointer, child.mNativePointer, i);
|
||||||
YogaNative.jni_YGNodeInsertChildJNI(mNativePointer, child.mNativePointer, i);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsReferenceBaseline(boolean isReferenceBaseline) {
|
public void setIsReferenceBaseline(boolean isReferenceBaseline) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeSetIsReferenceBaselineJNI(mNativePointer, isReferenceBaseline);
|
||||||
YogaNative.jni_YGNodeSetIsReferenceBaselineJNI(mNativePointer, isReferenceBaseline);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeSetIsReferenceBaseline(mNativePointer, isReferenceBaseline);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReferenceBaseline() {
|
public boolean isReferenceBaseline() {
|
||||||
return useVanillaJNI ? YogaNative.jni_YGNodeIsReferenceBaselineJNI(mNativePointer) : YogaNative.jni_YGNodeIsReferenceBaseline(mNativePointer);
|
return YogaNative.jni_YGNodeIsReferenceBaselineJNI(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YogaNodeJNIBase cloneWithoutChildren() {
|
public YogaNodeJNIBase cloneWithoutChildren() {
|
||||||
try {
|
try {
|
||||||
YogaNodeJNIBase clonedYogaNode = (YogaNodeJNIBase) super.clone();
|
YogaNodeJNIBase clonedYogaNode = (YogaNodeJNIBase) super.clone();
|
||||||
long clonedNativePointer = useVanillaJNI ? YogaNative.jni_YGNodeCloneJNI(mNativePointer) : YogaNative.jni_YGNodeClone(mNativePointer);;
|
long clonedNativePointer = YogaNative.jni_YGNodeCloneJNI(mNativePointer);
|
||||||
clonedYogaNode.mOwner = null;
|
clonedYogaNode.mOwner = null;
|
||||||
clonedYogaNode.mNativePointer = clonedNativePointer;
|
clonedYogaNode.mNativePointer = clonedNativePointer;
|
||||||
clonedYogaNode.clearChildren();
|
clonedYogaNode.clearChildren();
|
||||||
@@ -140,10 +123,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
|
|
||||||
private void clearChildren() {
|
private void clearChildren() {
|
||||||
mChildren = null;
|
mChildren = null;
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeClearChildrenJNI(mNativePointer);
|
||||||
YogaNative.jni_YGNodeClearChildrenJNI(mNativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeClearChildren(mNativePointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaNodeJNIBase removeChildAt(int i) {
|
public YogaNodeJNIBase removeChildAt(int i) {
|
||||||
@@ -153,10 +133,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
}
|
}
|
||||||
final YogaNodeJNIBase child = mChildren.remove(i);
|
final YogaNodeJNIBase child = mChildren.remove(i);
|
||||||
child.mOwner = null;
|
child.mOwner = null;
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeRemoveChildJNI(mNativePointer, child.mNativePointer);
|
||||||
YogaNative.jni_YGNodeRemoveChildJNI(mNativePointer, child.mNativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
|
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,418 +180,285 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
nativePointers[i] = nodes[i].mNativePointer;
|
nativePointers[i] = nodes[i].mNativePointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeCalculateLayoutJNI(mNativePointer, width, height, nativePointers, nodes);
|
||||||
YogaNative.jni_YGNodeCalculateLayoutJNI(mNativePointer, width, height, nativePointers, nodes);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeCalculateLayout(mNativePointer, width, height, nativePointers, nodes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dirty() {
|
public void dirty() {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeMarkDirtyJNI(mNativePointer);
|
||||||
YogaNative.jni_YGNodeMarkDirtyJNI(mNativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeMarkDirty(mNativePointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dirtyAllDescendants() {
|
public void dirtyAllDescendants() {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeMarkDirtyAndPropogateToDescendantsJNI(mNativePointer);
|
||||||
YogaNative.jni_YGNodeMarkDirtyAndPropogateToDescendantsJNI(mNativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeMarkDirtyAndPropogateToDescendants(mNativePointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDirty() {
|
public boolean isDirty() {
|
||||||
return useVanillaJNI ? YogaNative.jni_YGNodeIsDirtyJNI(mNativePointer) : YogaNative.jni_YGNodeIsDirty(mNativePointer);
|
return YogaNative.jni_YGNodeIsDirtyJNI(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyStyle(YogaNode srcNode) {
|
public void copyStyle(YogaNode srcNode) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeCopyStyleJNI(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
|
||||||
YogaNative.jni_YGNodeCopyStyleJNI(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeCopyStyle(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaDirection getStyleDirection() {
|
public YogaDirection getStyleDirection() {
|
||||||
return YogaDirection.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetDirectionJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetDirection(mNativePointer));
|
return YogaDirection.fromInt(YogaNative.jni_YGNodeStyleGetDirectionJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDirection(YogaDirection direction) {
|
public void setDirection(YogaDirection direction) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetDirectionJNI(mNativePointer, direction.intValue());
|
||||||
YogaNative.jni_YGNodeStyleSetDirectionJNI(mNativePointer, direction.intValue());
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaFlexDirection getFlexDirection() {
|
public YogaFlexDirection getFlexDirection() {
|
||||||
return YogaFlexDirection.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexDirectionJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlexDirection(mNativePointer));
|
return YogaFlexDirection.fromInt(YogaNative.jni_YGNodeStyleGetFlexDirectionJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlexDirection(YogaFlexDirection flexDirection) {
|
public void setFlexDirection(YogaFlexDirection flexDirection) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetFlexDirectionJNI(mNativePointer, flexDirection.intValue());
|
||||||
YogaNative.jni_YGNodeStyleSetFlexDirectionJNI(mNativePointer, flexDirection.intValue());
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaJustify getJustifyContent() {
|
public YogaJustify getJustifyContent() {
|
||||||
return YogaJustify.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetJustifyContentJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetJustifyContent(mNativePointer));
|
return YogaJustify.fromInt(YogaNative.jni_YGNodeStyleGetJustifyContentJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJustifyContent(YogaJustify justifyContent) {
|
public void setJustifyContent(YogaJustify justifyContent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetJustifyContentJNI(mNativePointer, justifyContent.intValue());
|
||||||
YogaNative.jni_YGNodeStyleSetJustifyContentJNI(mNativePointer, justifyContent.intValue());
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaAlign getAlignItems() {
|
public YogaAlign getAlignItems() {
|
||||||
return YogaAlign.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetAlignItemsJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetAlignItems(mNativePointer));
|
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignItemsJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlignItems(YogaAlign alignItems) {
|
public void setAlignItems(YogaAlign alignItems) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetAlignItemsJNI(mNativePointer, alignItems.intValue());
|
||||||
YogaNative.jni_YGNodeStyleSetAlignItemsJNI(mNativePointer, alignItems.intValue());
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaAlign getAlignSelf() {
|
public YogaAlign getAlignSelf() {
|
||||||
return YogaAlign.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetAlignSelfJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetAlignSelf(mNativePointer));
|
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignSelfJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlignSelf(YogaAlign alignSelf) {
|
public void setAlignSelf(YogaAlign alignSelf) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetAlignSelfJNI(mNativePointer, alignSelf.intValue());
|
||||||
YogaNative.jni_YGNodeStyleSetAlignSelfJNI(mNativePointer, alignSelf.intValue());
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaAlign getAlignContent() {
|
public YogaAlign getAlignContent() {
|
||||||
return YogaAlign.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetAlignContentJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetAlignContent(mNativePointer));
|
return YogaAlign.fromInt(YogaNative.jni_YGNodeStyleGetAlignContentJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlignContent(YogaAlign alignContent) {
|
public void setAlignContent(YogaAlign alignContent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetAlignContentJNI(mNativePointer, alignContent.intValue());
|
||||||
YogaNative.jni_YGNodeStyleSetAlignContentJNI(mNativePointer, alignContent.intValue());
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaPositionType getPositionType() {
|
public YogaPositionType getPositionType() {
|
||||||
return YogaPositionType.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetPositionTypeJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetPositionType(mNativePointer));
|
return YogaPositionType.fromInt(YogaNative.jni_YGNodeStyleGetPositionTypeJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPositionType(YogaPositionType positionType) {
|
public void setPositionType(YogaPositionType positionType) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetPositionTypeJNI(mNativePointer, positionType.intValue());
|
||||||
YogaNative.jni_YGNodeStyleSetPositionTypeJNI(mNativePointer, positionType.intValue());
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaWrap getWrap() {
|
public YogaWrap getWrap() {
|
||||||
return YogaWrap.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexWrapJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlexWrap(mNativePointer));
|
return YogaWrap.fromInt(YogaNative.jni_YGNodeStyleGetFlexWrapJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWrap(YogaWrap flexWrap) {
|
public void setWrap(YogaWrap flexWrap) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetFlexWrapJNI(mNativePointer, flexWrap.intValue());
|
||||||
YogaNative.jni_YGNodeStyleSetFlexWrapJNI(mNativePointer, flexWrap.intValue());
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaOverflow getOverflow() {
|
public YogaOverflow getOverflow() {
|
||||||
return YogaOverflow.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetOverflowJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetOverflow(mNativePointer));
|
return YogaOverflow.fromInt(YogaNative.jni_YGNodeStyleGetOverflowJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOverflow(YogaOverflow overflow) {
|
public void setOverflow(YogaOverflow overflow) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetOverflowJNI(mNativePointer, overflow.intValue());
|
||||||
YogaNative.jni_YGNodeStyleSetOverflowJNI(mNativePointer, overflow.intValue());
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaDisplay getDisplay() {
|
public YogaDisplay getDisplay() {
|
||||||
return YogaDisplay.fromInt(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetDisplayJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetDisplay(mNativePointer));
|
return YogaDisplay.fromInt(YogaNative.jni_YGNodeStyleGetDisplayJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisplay(YogaDisplay display) {
|
public void setDisplay(YogaDisplay display) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetDisplayJNI(mNativePointer, display.intValue());
|
||||||
YogaNative.jni_YGNodeStyleSetDisplayJNI(mNativePointer, display.intValue());
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getFlex() {
|
public float getFlex() {
|
||||||
return useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlex(mNativePointer);
|
return YogaNative.jni_YGNodeStyleGetFlexJNI(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlex(float flex) {
|
public void setFlex(float flex) {
|
||||||
if (useVanillaJNI) {
|
YogaNative.jni_YGNodeStyleSetFlexJNI(mNativePointer, flex);
|
||||||
YogaNative.jni_YGNodeStyleSetFlexJNI(mNativePointer, flex);
|
|
||||||
} else {
|
|
||||||
YogaNative.jni_YGNodeStyleSetFlex(mNativePointer, flex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getFlexGrow() {
|
public float getFlexGrow() {
|
||||||
return useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexGrowJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlexGrow(mNativePointer);
|
return YogaNative.jni_YGNodeStyleGetFlexGrowJNI(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlexGrow(float flexGrow) {
|
public void setFlexGrow(float flexGrow) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetFlexGrowJNI(mNativePointer, flexGrow);
|
||||||
YogaNative.jni_YGNodeStyleSetFlexGrowJNI(mNativePointer, flexGrow);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getFlexShrink() {
|
public float getFlexShrink() {
|
||||||
return useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexShrinkJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlexShrink(mNativePointer);
|
return YogaNative.jni_YGNodeStyleGetFlexShrinkJNI(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlexShrink(float flexShrink) {
|
public void setFlexShrink(float flexShrink) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetFlexShrinkJNI(mNativePointer, flexShrink);
|
||||||
YogaNative.jni_YGNodeStyleSetFlexShrinkJNI(mNativePointer, flexShrink);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaValue getFlexBasis() {
|
public YogaValue getFlexBasis() {
|
||||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetFlexBasisJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetFlexBasis(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetFlexBasisJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlexBasis(float flexBasis) {
|
public void setFlexBasis(float flexBasis) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetFlexBasisJNI(mNativePointer, flexBasis);
|
||||||
YogaNative.jni_YGNodeStyleSetFlexBasisJNI(mNativePointer, flexBasis);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlexBasisPercent(float percent) {
|
public void setFlexBasisPercent(float percent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetFlexBasisPercentJNI(mNativePointer, percent);
|
||||||
YogaNative.jni_YGNodeStyleSetFlexBasisPercentJNI(mNativePointer, percent);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlexBasisAuto() {
|
public void setFlexBasisAuto() {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetFlexBasisAutoJNI(mNativePointer);
|
||||||
YogaNative.jni_YGNodeStyleSetFlexBasisAutoJNI(mNativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaValue getMargin(YogaEdge edge) {
|
public YogaValue getMargin(YogaEdge edge) {
|
||||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMarginJNI(mNativePointer, edge.intValue()) : YogaNative.jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue()));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetMarginJNI(mNativePointer, edge.intValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMargin(YogaEdge edge, float margin) {
|
public void setMargin(YogaEdge edge, float margin) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetMarginJNI(mNativePointer, edge.intValue(), margin);
|
||||||
YogaNative.jni_YGNodeStyleSetMarginJNI(mNativePointer, edge.intValue(), margin);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMarginPercent(YogaEdge edge, float percent) {
|
public void setMarginPercent(YogaEdge edge, float percent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetMarginPercentJNI(mNativePointer, edge.intValue(), percent);
|
||||||
YogaNative.jni_YGNodeStyleSetMarginPercentJNI(mNativePointer, edge.intValue(), percent);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMarginAuto(YogaEdge edge) {
|
public void setMarginAuto(YogaEdge edge) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetMarginAutoJNI(mNativePointer, edge.intValue());
|
||||||
YogaNative.jni_YGNodeStyleSetMarginAutoJNI(mNativePointer, edge.intValue());
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaValue getPadding(YogaEdge edge) {
|
public YogaValue getPadding(YogaEdge edge) {
|
||||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetPaddingJNI(mNativePointer, edge.intValue()) : YogaNative.jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue()));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetPaddingJNI(mNativePointer, edge.intValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPadding(YogaEdge edge, float padding) {
|
public void setPadding(YogaEdge edge, float padding) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetPaddingJNI(mNativePointer, edge.intValue(), padding);
|
||||||
YogaNative.jni_YGNodeStyleSetPaddingJNI(mNativePointer, edge.intValue(), padding);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPaddingPercent(YogaEdge edge, float percent) {
|
public void setPaddingPercent(YogaEdge edge, float percent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetPaddingPercentJNI(mNativePointer, edge.intValue(), percent);
|
||||||
YogaNative.jni_YGNodeStyleSetPaddingPercentJNI(mNativePointer, edge.intValue(), percent);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBorder(YogaEdge edge) {
|
public float getBorder(YogaEdge edge) {
|
||||||
return useVanillaJNI ? YogaNative.jni_YGNodeStyleGetBorderJNI(mNativePointer, edge.intValue()) : YogaNative.jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
|
return YogaNative.jni_YGNodeStyleGetBorderJNI(mNativePointer, edge.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBorder(YogaEdge edge, float border) {
|
public void setBorder(YogaEdge edge, float border) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetBorderJNI(mNativePointer, edge.intValue(), border);
|
||||||
YogaNative.jni_YGNodeStyleSetBorderJNI(mNativePointer, edge.intValue(), border);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaValue getPosition(YogaEdge edge) {
|
public YogaValue getPosition(YogaEdge edge) {
|
||||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetPositionJNI(mNativePointer, edge.intValue()) : YogaNative.jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue()));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetPositionJNI(mNativePointer, edge.intValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(YogaEdge edge, float position) {
|
public void setPosition(YogaEdge edge, float position) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetPositionJNI(mNativePointer, edge.intValue(), position);
|
||||||
YogaNative.jni_YGNodeStyleSetPositionJNI(mNativePointer, edge.intValue(), position);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPositionPercent(YogaEdge edge, float percent) {
|
public void setPositionPercent(YogaEdge edge, float percent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetPositionPercentJNI(mNativePointer, edge.intValue(), percent);
|
||||||
YogaNative.jni_YGNodeStyleSetPositionPercentJNI(mNativePointer, edge.intValue(), percent);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaValue getWidth() {
|
public YogaValue getWidth() {
|
||||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetWidthJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetWidth(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetWidthJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWidth(float width) {
|
public void setWidth(float width) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetWidthJNI(mNativePointer, width);
|
||||||
YogaNative.jni_YGNodeStyleSetWidthJNI(mNativePointer, width);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetWidth(mNativePointer, width);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWidthPercent(float percent) {
|
public void setWidthPercent(float percent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetWidthPercentJNI(mNativePointer, percent);
|
||||||
YogaNative.jni_YGNodeStyleSetWidthPercentJNI(mNativePointer, percent);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWidthAuto() {
|
public void setWidthAuto() {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetWidthAutoJNI(mNativePointer);
|
||||||
YogaNative.jni_YGNodeStyleSetWidthAutoJNI(mNativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetWidthAuto(mNativePointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaValue getHeight() {
|
public YogaValue getHeight() {
|
||||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetHeightJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetHeight(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetHeightJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHeight(float height) {
|
public void setHeight(float height) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetHeightJNI(mNativePointer, height);
|
||||||
YogaNative.jni_YGNodeStyleSetHeightJNI(mNativePointer, height);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetHeight(mNativePointer, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHeightPercent(float percent) {
|
public void setHeightPercent(float percent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetHeightPercentJNI(mNativePointer, percent);
|
||||||
YogaNative.jni_YGNodeStyleSetHeightPercentJNI(mNativePointer, percent);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHeightAuto() {
|
public void setHeightAuto() {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetHeightAutoJNI(mNativePointer);
|
||||||
YogaNative.jni_YGNodeStyleSetHeightAutoJNI(mNativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetHeightAuto(mNativePointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaValue getMinWidth() {
|
public YogaValue getMinWidth() {
|
||||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMinWidthJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMinWidth(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinWidthJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinWidth(float minWidth) {
|
public void setMinWidth(float minWidth) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetMinWidthJNI(mNativePointer, minWidth);
|
||||||
YogaNative.jni_YGNodeStyleSetMinWidthJNI(mNativePointer, minWidth);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinWidthPercent(float percent) {
|
public void setMinWidthPercent(float percent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetMinWidthPercentJNI(mNativePointer, percent);
|
||||||
YogaNative.jni_YGNodeStyleSetMinWidthPercentJNI(mNativePointer, percent);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaValue getMinHeight() {
|
public YogaValue getMinHeight() {
|
||||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMinHeightJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMinHeight(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetMinHeightJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinHeight(float minHeight) {
|
public void setMinHeight(float minHeight) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetMinHeightJNI(mNativePointer, minHeight);
|
||||||
YogaNative.jni_YGNodeStyleSetMinHeightJNI(mNativePointer, minHeight);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinHeightPercent(float percent) {
|
public void setMinHeightPercent(float percent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetMinHeightPercentJNI(mNativePointer, percent);
|
||||||
YogaNative.jni_YGNodeStyleSetMinHeightPercentJNI(mNativePointer, percent);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaValue getMaxWidth() {
|
public YogaValue getMaxWidth() {
|
||||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMaxWidthJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMaxWidth(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxWidthJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxWidth(float maxWidth) {
|
public void setMaxWidth(float maxWidth) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetMaxWidthJNI(mNativePointer, maxWidth);
|
||||||
YogaNative.jni_YGNodeStyleSetMaxWidthJNI(mNativePointer, maxWidth);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxWidthPercent(float percent) {
|
public void setMaxWidthPercent(float percent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetMaxWidthPercentJNI(mNativePointer, percent);
|
||||||
YogaNative.jni_YGNodeStyleSetMaxWidthPercentJNI(mNativePointer, percent);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaValue getMaxHeight() {
|
public YogaValue getMaxHeight() {
|
||||||
return valueFromLong(useVanillaJNI ? YogaNative.jni_YGNodeStyleGetMaxHeightJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetMaxHeight(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetMaxHeightJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxHeight(float maxheight) {
|
public void setMaxHeight(float maxheight) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetMaxHeightJNI(mNativePointer, maxheight);
|
||||||
YogaNative.jni_YGNodeStyleSetMaxHeightJNI(mNativePointer, maxheight);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxHeightPercent(float percent) {
|
public void setMaxHeightPercent(float percent) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetMaxHeightPercentJNI(mNativePointer, percent);
|
||||||
YogaNative.jni_YGNodeStyleSetMaxHeightPercentJNI(mNativePointer, percent);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAspectRatio() {
|
public float getAspectRatio() {
|
||||||
return useVanillaJNI ? YogaNative.jni_YGNodeStyleGetAspectRatioJNI(mNativePointer) : YogaNative.jni_YGNodeStyleGetAspectRatio(mNativePointer);
|
return YogaNative.jni_YGNodeStyleGetAspectRatioJNI(mNativePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAspectRatio(float aspectRatio) {
|
public void setAspectRatio(float aspectRatio) {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeStyleSetAspectRatioJNI(mNativePointer, aspectRatio);
|
||||||
YogaNative.jni_YGNodeStyleSetAspectRatioJNI(mNativePointer, aspectRatio);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
|
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
|
||||||
mMeasureFunction = measureFunction;
|
mMeasureFunction = measureFunction;
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeSetHasMeasureFuncJNI(mNativePointer, measureFunction != null);
|
||||||
YogaNative.jni_YGNodeSetHasMeasureFuncJNI(mNativePointer, measureFunction != null);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementation Note: Why this method needs to stay final
|
// Implementation Note: Why this method needs to stay final
|
||||||
@@ -638,10 +482,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
|
|
||||||
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
|
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
|
||||||
mBaselineFunction = baselineFunction;
|
mBaselineFunction = baselineFunction;
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeSetHasBaselineFuncJNI(mNativePointer, baselineFunction != null);
|
||||||
YogaNative.jni_YGNodeSetHasBaselineFuncJNI(mNativePointer, baselineFunction != null);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
@@ -672,10 +513,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
* layout of the tree rooted at this node.
|
* layout of the tree rooted at this node.
|
||||||
*/
|
*/
|
||||||
public void print() {
|
public void print() {
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodePrintJNI(mNativePointer);
|
||||||
YogaNative.jni_YGNodePrintJNI(mNativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodePrint(mNativePointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -12,10 +12,6 @@ public class YogaNodeJNIFinalizer extends YogaNodeJNIBase {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public YogaNodeJNIFinalizer(boolean useVanillaJNI) {
|
|
||||||
super(useVanillaJNI);
|
|
||||||
}
|
|
||||||
|
|
||||||
public YogaNodeJNIFinalizer(YogaConfig config) {
|
public YogaNodeJNIFinalizer(YogaConfig config) {
|
||||||
super(config);
|
super(config);
|
||||||
}
|
}
|
||||||
@@ -33,10 +29,7 @@ public class YogaNodeJNIFinalizer extends YogaNodeJNIBase {
|
|||||||
if (mNativePointer != 0) {
|
if (mNativePointer != 0) {
|
||||||
long nativePointer = mNativePointer;
|
long nativePointer = mNativePointer;
|
||||||
mNativePointer = 0;
|
mNativePointer = 0;
|
||||||
if (useVanillaJNI)
|
YogaNative.jni_YGNodeFreeJNI(nativePointer);
|
||||||
YogaNative.jni_YGNodeFreeJNI(nativePointer);
|
|
||||||
else
|
|
||||||
YogaNative.jni_YGNodeFree(nativePointer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,712 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fbjni/fbjni.h>
|
|
||||||
#include <yoga/YGNode.h>
|
|
||||||
#include <yoga/Yoga.h>
|
|
||||||
#include <yoga/Yoga-internal.h>
|
|
||||||
#include <yoga/log.h>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include "YGJTypes.h"
|
|
||||||
#include "YGJNIVanilla.h"
|
|
||||||
#include "YGJNI.h"
|
|
||||||
#include "yogajni.h"
|
|
||||||
|
|
||||||
using namespace facebook::jni;
|
|
||||||
using namespace std;
|
|
||||||
using facebook::yoga::detail::Log;
|
|
||||||
|
|
||||||
static inline local_ref<JYogaNode> YGNodeJobject(
|
|
||||||
YGNodeRef node,
|
|
||||||
void* layoutContext) {
|
|
||||||
return reinterpret_cast<PtrJNodeMap*>(layoutContext)->ref(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void YGTransferLayoutDirection(
|
|
||||||
YGNodeRef node,
|
|
||||||
alias_ref<jobject> javaNode) {
|
|
||||||
static auto layoutDirectionField =
|
|
||||||
javaNode->getClass()->getField<jint>("mLayoutDirection");
|
|
||||||
javaNode->setFieldValue(
|
|
||||||
layoutDirectionField, static_cast<jint>(YGNodeLayoutGetDirection(node)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void YGTransferLayoutOutputsRecursive(
|
|
||||||
YGNodeRef root,
|
|
||||||
void* layoutContext) {
|
|
||||||
if (!root->getHasNewLayout()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto obj = YGNodeJobject(root, layoutContext);
|
|
||||||
if (!obj) {
|
|
||||||
Log::log(
|
|
||||||
root,
|
|
||||||
YGLogLevelError,
|
|
||||||
nullptr,
|
|
||||||
"Java YGNode was GCed during layout calculation\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto edgesSet = YGNodeEdges{root};
|
|
||||||
|
|
||||||
bool marginFieldSet = edgesSet.has(YGNodeEdges::MARGIN);
|
|
||||||
bool paddingFieldSet = edgesSet.has(YGNodeEdges::PADDING);
|
|
||||||
bool borderFieldSet = edgesSet.has(YGNodeEdges::BORDER);
|
|
||||||
|
|
||||||
int fieldFlags = edgesSet.get();
|
|
||||||
fieldFlags |= HAS_NEW_LAYOUT;
|
|
||||||
if (YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root)) {
|
|
||||||
fieldFlags |= DOES_LEGACY_STRETCH_BEHAVIOUR;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int arrSize = 6 + (marginFieldSet ? 4 : 0) + (paddingFieldSet ? 4 : 0) +
|
|
||||||
(borderFieldSet ? 4 : 0);
|
|
||||||
float arr[18];
|
|
||||||
arr[LAYOUT_EDGE_SET_FLAG_INDEX] = fieldFlags;
|
|
||||||
arr[LAYOUT_WIDTH_INDEX] = YGNodeLayoutGetWidth(root);
|
|
||||||
arr[LAYOUT_HEIGHT_INDEX] = YGNodeLayoutGetHeight(root);
|
|
||||||
arr[LAYOUT_LEFT_INDEX] = YGNodeLayoutGetLeft(root);
|
|
||||||
arr[LAYOUT_TOP_INDEX] = YGNodeLayoutGetTop(root);
|
|
||||||
arr[LAYOUT_DIRECTION_INDEX] =
|
|
||||||
static_cast<jint>(YGNodeLayoutGetDirection(root));
|
|
||||||
if (marginFieldSet) {
|
|
||||||
arr[LAYOUT_MARGIN_START_INDEX] = YGNodeLayoutGetMargin(root, YGEdgeLeft);
|
|
||||||
arr[LAYOUT_MARGIN_START_INDEX + 1] = YGNodeLayoutGetMargin(root, YGEdgeTop);
|
|
||||||
arr[LAYOUT_MARGIN_START_INDEX + 2] =
|
|
||||||
YGNodeLayoutGetMargin(root, YGEdgeRight);
|
|
||||||
arr[LAYOUT_MARGIN_START_INDEX + 3] =
|
|
||||||
YGNodeLayoutGetMargin(root, YGEdgeBottom);
|
|
||||||
}
|
|
||||||
if (paddingFieldSet) {
|
|
||||||
int paddingStartIndex =
|
|
||||||
LAYOUT_PADDING_START_INDEX - (marginFieldSet ? 0 : 4);
|
|
||||||
arr[paddingStartIndex] = YGNodeLayoutGetPadding(root, YGEdgeLeft);
|
|
||||||
arr[paddingStartIndex + 1] = YGNodeLayoutGetPadding(root, YGEdgeTop);
|
|
||||||
arr[paddingStartIndex + 2] = YGNodeLayoutGetPadding(root, YGEdgeRight);
|
|
||||||
arr[paddingStartIndex + 3] = YGNodeLayoutGetPadding(root, YGEdgeBottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (borderFieldSet) {
|
|
||||||
int borderStartIndex = LAYOUT_BORDER_START_INDEX -
|
|
||||||
(marginFieldSet ? 0 : 4) - (paddingFieldSet ? 0 : 4);
|
|
||||||
arr[borderStartIndex] = YGNodeLayoutGetBorder(root, YGEdgeLeft);
|
|
||||||
arr[borderStartIndex + 1] = YGNodeLayoutGetBorder(root, YGEdgeTop);
|
|
||||||
arr[borderStartIndex + 2] = YGNodeLayoutGetBorder(root, YGEdgeRight);
|
|
||||||
arr[borderStartIndex + 3] = YGNodeLayoutGetBorder(root, YGEdgeBottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
static auto arrField = obj->getClass()->getField<jfloatArray>("arr");
|
|
||||||
local_ref<jfloatArray> arrFinal = make_float_array(arrSize);
|
|
||||||
arrFinal->setRegion(0, arrSize, arr);
|
|
||||||
obj->setFieldValue<jfloatArray>(arrField, arrFinal.get());
|
|
||||||
|
|
||||||
root->setHasNewLayout(false);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
|
|
||||||
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i), layoutContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void YGPrint(YGNodeRef node, void* layoutContext) {
|
|
||||||
if (auto obj = YGNodeJobject(node, layoutContext)) {
|
|
||||||
cout << obj->toString() << endl;
|
|
||||||
} else {
|
|
||||||
Log::log(
|
|
||||||
node,
|
|
||||||
YGLogLevelError,
|
|
||||||
nullptr,
|
|
||||||
"Java YGNode was GCed during layout calculation\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static float YGJNIBaselineFunc(
|
|
||||||
YGNodeRef node,
|
|
||||||
float width,
|
|
||||||
float height,
|
|
||||||
void* layoutContext) {
|
|
||||||
if (auto obj = YGNodeJobject(node, layoutContext)) {
|
|
||||||
return obj->baseline(width, height);
|
|
||||||
} else {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline YGNodeRef _jlong2YGNodeRef(jlong addr) {
|
|
||||||
return reinterpret_cast<YGNodeRef>(static_cast<intptr_t>(addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline YGConfigRef _jlong2YGConfigRef(jlong addr) {
|
|
||||||
return reinterpret_cast<YGConfigRef>(static_cast<intptr_t>(addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
jlong jni_YGNodeClone(alias_ref<jobject> thiz, jlong nativePointer) {
|
|
||||||
auto node = _jlong2YGNodeRef(nativePointer);
|
|
||||||
const YGNodeRef clonedYogaNode = YGNodeClone(node);
|
|
||||||
clonedYogaNode->setContext(node->getContext());
|
|
||||||
|
|
||||||
return reinterpret_cast<jlong>(clonedYogaNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
static YGSize YGJNIMeasureFunc(
|
|
||||||
YGNodeRef node,
|
|
||||||
float width,
|
|
||||||
YGMeasureMode widthMode,
|
|
||||||
float height,
|
|
||||||
YGMeasureMode heightMode,
|
|
||||||
void* layoutContext) {
|
|
||||||
if (auto obj = YGNodeJobject(node, layoutContext)) {
|
|
||||||
YGTransferLayoutDirection(node, obj);
|
|
||||||
const auto measureResult =
|
|
||||||
obj->measure(width, widthMode, height, heightMode);
|
|
||||||
|
|
||||||
static_assert(
|
|
||||||
sizeof(measureResult) == 8,
|
|
||||||
"Expected measureResult to be 8 bytes, or two 32 bit ints");
|
|
||||||
|
|
||||||
int32_t wBits = 0xFFFFFFFF & (measureResult >> 32);
|
|
||||||
int32_t hBits = 0xFFFFFFFF & measureResult;
|
|
||||||
|
|
||||||
const float* measuredWidth = reinterpret_cast<float*>(&wBits);
|
|
||||||
const float* measuredHeight = reinterpret_cast<float*>(&hBits);
|
|
||||||
|
|
||||||
return YGSize{*measuredWidth, *measuredHeight};
|
|
||||||
} else {
|
|
||||||
Log::log(
|
|
||||||
node,
|
|
||||||
YGLogLevelError,
|
|
||||||
nullptr,
|
|
||||||
"Java YGNode was GCed during layout calculation\n");
|
|
||||||
return YGSize{
|
|
||||||
widthMode == YGMeasureModeUndefined ? 0 : width,
|
|
||||||
heightMode == YGMeasureModeUndefined ? 0 : height,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int YGJNILogFunc(
|
|
||||||
const YGConfigRef config,
|
|
||||||
const YGNodeRef node,
|
|
||||||
YGLogLevel level,
|
|
||||||
void* layoutContext,
|
|
||||||
const char* format,
|
|
||||||
va_list args) {
|
|
||||||
int result = vsnprintf(NULL, 0, format, args);
|
|
||||||
std::vector<char> buffer(1 + result);
|
|
||||||
vsnprintf(buffer.data(), buffer.size(), format, args);
|
|
||||||
|
|
||||||
auto jloggerPtr =
|
|
||||||
static_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config));
|
|
||||||
if (jloggerPtr != nullptr) {
|
|
||||||
(*jloggerPtr)
|
|
||||||
->log(
|
|
||||||
JYogaLogLevel::fromInt(level),
|
|
||||||
Environment::current()->NewStringUTF(buffer.data()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
|
|
||||||
const YGNodeRef node = YGNodeNew();
|
|
||||||
node->setContext(YGNodeContext{}.asVoidPtr);
|
|
||||||
node->setPrintFunc(YGPrint);
|
|
||||||
return reinterpret_cast<jlong>(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
jlong jni_YGNodeNewWithConfig(alias_ref<jclass>, jlong configPointer) {
|
|
||||||
const YGNodeRef node = YGNodeNewWithConfig(_jlong2YGConfigRef(configPointer));
|
|
||||||
node->setContext(YGNodeContext{}.asVoidPtr);
|
|
||||||
return reinterpret_cast<jlong>(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeFree(alias_ref<jclass>, jlong nativePointer) {
|
|
||||||
if (nativePointer == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
|
||||||
YGNodeFree(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeClearChildren(jlong nativePointer) {
|
|
||||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
|
||||||
node->clearChildren();
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeReset(jlong nativePointer) {
|
|
||||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
|
||||||
void* context = node->getContext();
|
|
||||||
YGNodeReset(node);
|
|
||||||
node->setContext(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodePrint(jlong nativePointer) {
|
|
||||||
#ifdef DEBUG
|
|
||||||
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
|
||||||
YGNodePrint(
|
|
||||||
node,
|
|
||||||
(YGPrintOptions)(
|
|
||||||
YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeInsertChild(
|
|
||||||
jlong nativePointer,
|
|
||||||
jlong childPointer,
|
|
||||||
jint index) {
|
|
||||||
YGNodeInsertChild(
|
|
||||||
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeRemoveChild(jlong nativePointer, jlong childPointer) {
|
|
||||||
YGNodeRemoveChild(
|
|
||||||
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeSetIsReferenceBaseline(
|
|
||||||
jlong nativePointer,
|
|
||||||
jboolean isReferenceBaseline) {
|
|
||||||
YGNodeSetIsReferenceBaseline(
|
|
||||||
_jlong2YGNodeRef(nativePointer), isReferenceBaseline);
|
|
||||||
}
|
|
||||||
|
|
||||||
jboolean jni_YGNodeIsReferenceBaseline(jlong nativePointer) {
|
|
||||||
return YGNodeIsReferenceBaseline(_jlong2YGNodeRef(nativePointer));
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeCalculateLayout(
|
|
||||||
alias_ref<jclass>,
|
|
||||||
jlong nativePointer,
|
|
||||||
jfloat width,
|
|
||||||
jfloat height,
|
|
||||||
alias_ref<JArrayLong> nativePointers,
|
|
||||||
alias_ref<JArrayClass<JYogaNode::javaobject>> javaNodes) {
|
|
||||||
|
|
||||||
void* layoutContext = nullptr;
|
|
||||||
auto map = PtrJNodeMap{};
|
|
||||||
if (nativePointers) {
|
|
||||||
map = PtrJNodeMap{nativePointers, javaNodes};
|
|
||||||
layoutContext = ↦
|
|
||||||
}
|
|
||||||
|
|
||||||
const YGNodeRef root = _jlong2YGNodeRef(nativePointer);
|
|
||||||
YGNodeCalculateLayoutWithContext(
|
|
||||||
root,
|
|
||||||
static_cast<float>(width),
|
|
||||||
static_cast<float>(height),
|
|
||||||
YGNodeStyleGetDirection(_jlong2YGNodeRef(nativePointer)),
|
|
||||||
layoutContext);
|
|
||||||
YGTransferLayoutOutputsRecursive(root, layoutContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeMarkDirty(jlong nativePointer) {
|
|
||||||
YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer));
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeMarkDirtyAndPropogateToDescendants(jlong nativePointer) {
|
|
||||||
YGNodeMarkDirtyAndPropogateToDescendants(_jlong2YGNodeRef(nativePointer));
|
|
||||||
}
|
|
||||||
|
|
||||||
jboolean jni_YGNodeIsDirty(jlong nativePointer) {
|
|
||||||
return (jboolean) _jlong2YGNodeRef(nativePointer)->isDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeSetHasMeasureFunc(jlong nativePointer, jboolean hasMeasureFunc) {
|
|
||||||
_jlong2YGNodeRef(nativePointer)
|
|
||||||
->setMeasureFunc(hasMeasureFunc ? YGJNIMeasureFunc : nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeSetHasBaselineFunc(
|
|
||||||
jlong nativePointer,
|
|
||||||
jboolean hasBaselineFunc) {
|
|
||||||
_jlong2YGNodeRef(nativePointer)
|
|
||||||
->setBaselineFunc(hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeCopyStyle(jlong dstNativePointer, jlong srcNativePointer) {
|
|
||||||
YGNodeCopyStyle(
|
|
||||||
_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
|
|
||||||
javatype jni_YGNodeStyleGet##name(jlong nativePointer) { \
|
|
||||||
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
void jni_YGNodeStyleSet##name(jlong nativePointer, javatype value) { \
|
|
||||||
YGNodeStyleSet##name( \
|
|
||||||
_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
|
||||||
jlong jni_YGNodeStyleGet##name(jlong nativePointer) { \
|
|
||||||
return YogaValue::asJavaLong( \
|
|
||||||
YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer))); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
void jni_YGNodeStyleSet##name(jlong nativePointer, jfloat value) { \
|
|
||||||
YGNodeStyleSet##name( \
|
|
||||||
_jlong2YGNodeRef(nativePointer), static_cast<float>(value)); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
void jni_YGNodeStyleSet##name##Percent(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) \
|
|
||||||
void jni_YGNodeStyleSet##name##Auto(jlong nativePointer) { \
|
|
||||||
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
|
|
||||||
javatype jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \
|
|
||||||
return (javatype) YGNodeStyleGet##name( \
|
|
||||||
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
void jni_YGNodeStyleSet##name( \
|
|
||||||
jlong nativePointer, jint edge, javatype value) { \
|
|
||||||
YGNodeStyleSet##name( \
|
|
||||||
_jlong2YGNodeRef(nativePointer), \
|
|
||||||
static_cast<YGEdge>(edge), \
|
|
||||||
static_cast<type>(value)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
|
||||||
jlong jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \
|
|
||||||
return YogaValue::asJavaLong(YGNodeStyleGet##name( \
|
|
||||||
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge))); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
void jni_YGNodeStyleSet##name( \
|
|
||||||
jlong nativePointer, jint edge, jfloat value) { \
|
|
||||||
YGNodeStyleSet##name( \
|
|
||||||
_jlong2YGNodeRef(nativePointer), \
|
|
||||||
static_cast<YGEdge>(edge), \
|
|
||||||
static_cast<float>(value)); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
void jni_YGNodeStyleSet##name##Percent( \
|
|
||||||
jlong nativePointer, jint edge, jfloat value) { \
|
|
||||||
YGNodeStyleSet##name##Percent( \
|
|
||||||
_jlong2YGNodeRef(nativePointer), \
|
|
||||||
static_cast<YGEdge>(edge), \
|
|
||||||
static_cast<float>(value)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(name) \
|
|
||||||
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
|
||||||
void jni_YGNodeStyleSet##name##Auto(jlong nativePointer, jint edge) { \
|
|
||||||
YGNodeStyleSet##name##Auto( \
|
|
||||||
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
|
|
||||||
YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
|
|
||||||
YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
|
|
||||||
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems);
|
|
||||||
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf);
|
|
||||||
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent);
|
|
||||||
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);
|
|
||||||
|
|
||||||
jfloat jni_YGNodeStyleGetFlex(jlong nativePointer) {
|
|
||||||
return YGNodeStyleGetFlex(_jlong2YGNodeRef(nativePointer));
|
|
||||||
}
|
|
||||||
void jni_YGNodeStyleSetFlex(jlong nativePointer, jfloat value) {
|
|
||||||
YGNodeStyleSetFlex(
|
|
||||||
_jlong2YGNodeRef(nativePointer), static_cast<float>(value));
|
|
||||||
}
|
|
||||||
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_EDGE_UNIT_PROP(Position);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
jlong jni_YGConfigNew(alias_ref<jclass>) {
|
|
||||||
return reinterpret_cast<jlong>(YGConfigNew());
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGConfigFree(alias_ref<jclass>, jlong nativePointer) {
|
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
||||||
// unique_ptr will destruct the underlying global_ref, if present.
|
|
||||||
auto context = std::unique_ptr<global_ref<JYogaLogger>>{
|
|
||||||
static_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config))};
|
|
||||||
YGConfigFree(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGConfigSetExperimentalFeatureEnabled(
|
|
||||||
alias_ref<jclass>,
|
|
||||||
jlong nativePointer,
|
|
||||||
jint feature,
|
|
||||||
jboolean enabled) {
|
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
||||||
YGConfigSetExperimentalFeatureEnabled(
|
|
||||||
config, static_cast<YGExperimentalFeature>(feature), enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
|
||||||
alias_ref<jclass>,
|
|
||||||
jlong nativePointer,
|
|
||||||
jboolean enabled) {
|
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
||||||
YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(config, enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGConfigSetUseWebDefaults(
|
|
||||||
alias_ref<jclass>,
|
|
||||||
jlong nativePointer,
|
|
||||||
jboolean useWebDefaults) {
|
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
||||||
YGConfigSetUseWebDefaults(config, useWebDefaults);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGConfigSetPrintTreeFlag(
|
|
||||||
alias_ref<jclass>,
|
|
||||||
jlong nativePointer,
|
|
||||||
jboolean enable) {
|
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
||||||
YGConfigSetPrintTreeFlag(config, enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGConfigSetPointScaleFactor(
|
|
||||||
alias_ref<jclass>,
|
|
||||||
jlong nativePointer,
|
|
||||||
jfloat pixelsInPoint) {
|
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
||||||
YGConfigSetPointScaleFactor(config, pixelsInPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGConfigSetUseLegacyStretchBehaviour(
|
|
||||||
alias_ref<jclass>,
|
|
||||||
jlong nativePointer,
|
|
||||||
jboolean useLegacyStretchBehaviour) {
|
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
||||||
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGConfigSetLogger(
|
|
||||||
alias_ref<jclass>,
|
|
||||||
jlong nativePointer,
|
|
||||||
alias_ref<jobject> logger) {
|
|
||||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
||||||
auto context =
|
|
||||||
reinterpret_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config));
|
|
||||||
|
|
||||||
if (logger) {
|
|
||||||
if (context == nullptr) {
|
|
||||||
context = new global_ref<JYogaLogger>{};
|
|
||||||
YGConfigSetContext(config, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
*context = make_global(static_ref_cast<JYogaLogger::javaobject>(logger));
|
|
||||||
config->setLogger(YGJNILogFunc);
|
|
||||||
} else {
|
|
||||||
if (context != nullptr) {
|
|
||||||
delete context;
|
|
||||||
YGConfigSetContext(config, nullptr);
|
|
||||||
}
|
|
||||||
config->setLogger(nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jlong jni_YGNodeStyleGetMargin(jlong nativePointer, jint edge) {
|
|
||||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
|
||||||
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::MARGIN)) {
|
|
||||||
return YogaValue::undefinedAsJavaLong();
|
|
||||||
}
|
|
||||||
return YogaValue::asJavaLong(
|
|
||||||
YGNodeStyleGetMargin(yogaNodeRef, static_cast<YGEdge>(edge)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeStyleSetMargin(jlong nativePointer, jint edge, jfloat margin) {
|
|
||||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
|
||||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
|
|
||||||
YGNodeStyleSetMargin(
|
|
||||||
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(margin));
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeStyleSetMarginPercent(
|
|
||||||
jlong nativePointer,
|
|
||||||
jint edge,
|
|
||||||
jfloat percent) {
|
|
||||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
|
||||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
|
|
||||||
YGNodeStyleSetMarginPercent(
|
|
||||||
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent));
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeStyleSetMarginAuto(jlong nativePointer, jint edge) {
|
|
||||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
|
||||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
|
|
||||||
YGNodeStyleSetMarginAuto(yogaNodeRef, static_cast<YGEdge>(edge));
|
|
||||||
}
|
|
||||||
|
|
||||||
jlong jni_YGNodeStyleGetPadding(jlong nativePointer, jint edge) {
|
|
||||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
|
||||||
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::PADDING)) {
|
|
||||||
return YogaValue::undefinedAsJavaLong();
|
|
||||||
}
|
|
||||||
return YogaValue::asJavaLong(
|
|
||||||
YGNodeStyleGetPadding(yogaNodeRef, static_cast<YGEdge>(edge)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeStyleSetPadding(jlong nativePointer, jint edge, jfloat padding) {
|
|
||||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
|
||||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::PADDING).setOn(yogaNodeRef);
|
|
||||||
YGNodeStyleSetPadding(
|
|
||||||
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(padding));
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeStyleSetPaddingPercent(
|
|
||||||
jlong nativePointer,
|
|
||||||
jint edge,
|
|
||||||
jfloat percent) {
|
|
||||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
|
||||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::PADDING).setOn(yogaNodeRef);
|
|
||||||
YGNodeStyleSetPaddingPercent(
|
|
||||||
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent));
|
|
||||||
}
|
|
||||||
|
|
||||||
jfloat jni_YGNodeStyleGetBorder(jlong nativePointer, jint edge) {
|
|
||||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
|
||||||
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::BORDER)) {
|
|
||||||
return (jfloat) YGUndefined;
|
|
||||||
}
|
|
||||||
return (jfloat) YGNodeStyleGetBorder(yogaNodeRef, static_cast<YGEdge>(edge));
|
|
||||||
}
|
|
||||||
|
|
||||||
void jni_YGNodeStyleSetBorder(jlong nativePointer, jint edge, jfloat border) {
|
|
||||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
|
||||||
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::BORDER).setOn(yogaNodeRef);
|
|
||||||
YGNodeStyleSetBorder(
|
|
||||||
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(border));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
|
|
||||||
#define YGMakeCriticalNativeMethod(name) \
|
|
||||||
makeCriticalNativeMethod_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(#name, name)
|
|
||||||
|
|
||||||
jint YGJNI::registerNativeMethods(JavaVM* vm) {
|
|
||||||
jint ret = initialize(vm, [] {
|
|
||||||
registerNatives(
|
|
||||||
"com/facebook/yoga/YogaNative",
|
|
||||||
{
|
|
||||||
YGMakeNativeMethod(jni_YGNodeNew),
|
|
||||||
YGMakeNativeMethod(jni_YGNodeNewWithConfig),
|
|
||||||
YGMakeNativeMethod(jni_YGNodeFree),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeReset),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeClearChildren),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeInsertChild),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeRemoveChild),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeSetIsReferenceBaseline),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeIsReferenceBaseline),
|
|
||||||
YGMakeNativeMethod(jni_YGNodeCalculateLayout),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeMarkDirty),
|
|
||||||
YGMakeCriticalNativeMethod(
|
|
||||||
jni_YGNodeMarkDirtyAndPropogateToDescendants),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeIsDirty),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeSetHasMeasureFunc),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeSetHasBaselineFunc),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeCopyStyle),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDirection),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDirection),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexDirection),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexDirection),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetJustifyContent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetJustifyContent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignItems),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignItems),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignSelf),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignSelf),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAlignContent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAlignContent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPositionType),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionType),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexWrap),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexWrap),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetOverflow),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetOverflow),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetDisplay),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetDisplay),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlex),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlex),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexGrow),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexGrow),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexShrink),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexShrink),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetFlexBasis),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasis),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisPercent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisAuto),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMargin),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMargin),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginPercent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginAuto),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPadding),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPadding),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPaddingPercent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetBorder),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetBorder),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetPosition),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPosition),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionPercent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetWidth),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidth),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthPercent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthAuto),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetHeight),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeight),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightPercent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightAuto),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMinWidth),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidth),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidthPercent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMinHeight),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeight),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeightPercent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMaxWidth),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidth),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidthPercent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetMaxHeight),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeight),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodePrint),
|
|
||||||
YGMakeNativeMethod(jni_YGNodeClone),
|
|
||||||
YGMakeNativeMethod(jni_YGConfigNew),
|
|
||||||
YGMakeNativeMethod(jni_YGConfigFree),
|
|
||||||
YGMakeNativeMethod(jni_YGConfigSetExperimentalFeatureEnabled),
|
|
||||||
YGMakeNativeMethod(jni_YGConfigSetUseWebDefaults),
|
|
||||||
YGMakeNativeMethod(jni_YGConfigSetPrintTreeFlag),
|
|
||||||
YGMakeNativeMethod(jni_YGConfigSetPointScaleFactor),
|
|
||||||
YGMakeNativeMethod(jni_YGConfigSetUseLegacyStretchBehaviour),
|
|
||||||
YGMakeNativeMethod(jni_YGConfigSetLogger),
|
|
||||||
YGMakeNativeMethod(
|
|
||||||
jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return ret;
|
|
||||||
}
|
|
@@ -5,6 +5,8 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "jni.h"
|
||||||
|
|
||||||
namespace YGJNIVanilla {
|
namespace YGJNIVanilla {
|
||||||
void registerNatives(JNIEnv* env);
|
void registerNatives(JNIEnv* env);
|
||||||
};
|
};
|
||||||
|
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "YGJTypes.h"
|
|
||||||
|
|
||||||
using facebook::jni::alias_ref;
|
|
||||||
using facebook::jni::local_ref;
|
|
||||||
|
|
||||||
jfloat JYogaNode::baseline(jfloat width, jfloat height) {
|
|
||||||
static auto javaMethod =
|
|
||||||
javaClassLocal()->getMethod<jfloat(jfloat, jfloat)>("baseline");
|
|
||||||
return javaMethod(self(), width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
jlong JYogaNode::measure(
|
|
||||||
jfloat width,
|
|
||||||
jint widthMode,
|
|
||||||
jfloat height,
|
|
||||||
jint heightMode) {
|
|
||||||
static auto javaMethod =
|
|
||||||
javaClassLocal()->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
|
|
||||||
return javaMethod(self(), width, widthMode, height, heightMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
facebook::jni::local_ref<JYogaLogLevel> JYogaLogLevel::fromInt(jint logLevel) {
|
|
||||||
static auto javaMethod =
|
|
||||||
javaClassStatic()->getStaticMethod<alias_ref<JYogaLogLevel>(jint)>(
|
|
||||||
"fromInt");
|
|
||||||
return javaMethod(javaClassStatic(), logLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void JYogaLogger::log(
|
|
||||||
facebook::jni::alias_ref<JYogaLogLevel> logLevel,
|
|
||||||
jstring message) {
|
|
||||||
static auto javaMethod =
|
|
||||||
javaClassLocal()->getMethod<void(alias_ref<JYogaLogLevel>, jstring)>(
|
|
||||||
"log");
|
|
||||||
javaMethod(self(), logLevel, message);
|
|
||||||
}
|
|
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fbjni/fbjni.h>
|
|
||||||
#include <yoga/YGValue.h>
|
|
||||||
#include <yoga/Yoga.h>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using namespace facebook::jni;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
struct JYogaNode : public facebook::jni::JavaClass<JYogaNode> {
|
|
||||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaNodeJNIBase;";
|
|
||||||
|
|
||||||
jfloat baseline(jfloat width, jfloat height);
|
|
||||||
jlong measure(jfloat width, jint widthMode, jfloat height, jint heightMode);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct JYogaLogLevel : public facebook::jni::JavaClass<JYogaLogLevel> {
|
|
||||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogLevel;";
|
|
||||||
|
|
||||||
static facebook::jni::local_ref<JYogaLogLevel> fromInt(jint);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct JYogaLogger : public facebook::jni::JavaClass<JYogaLogger> {
|
|
||||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogger;";
|
|
||||||
|
|
||||||
void log(facebook::jni::alias_ref<JYogaLogLevel>, jstring);
|
|
||||||
};
|
|
||||||
|
|
||||||
class PtrJNodeMap {
|
|
||||||
using JNodeArray = JArrayClass<JYogaNode::javaobject>;
|
|
||||||
std::map<YGNodeRef, size_t> ptrsToIdxs_;
|
|
||||||
alias_ref<JNodeArray> javaNodes_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
PtrJNodeMap() : ptrsToIdxs_{}, javaNodes_{} {}
|
|
||||||
PtrJNodeMap(
|
|
||||||
alias_ref<JArrayLong> nativePointers,
|
|
||||||
alias_ref<JNodeArray> javaNodes)
|
|
||||||
: javaNodes_{javaNodes} {
|
|
||||||
auto pin = nativePointers->pinCritical();
|
|
||||||
auto ptrs = pin.get();
|
|
||||||
for (size_t i = 0, n = pin.size(); i < n; ++i) {
|
|
||||||
ptrsToIdxs_[(YGNodeRef) ptrs[i]] = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local_ref<JYogaNode> ref(YGNodeRef node) {
|
|
||||||
auto idx = ptrsToIdxs_.find(node);
|
|
||||||
if (idx == ptrsToIdxs_.end()) {
|
|
||||||
return local_ref<JYogaNode>{};
|
|
||||||
} else {
|
|
||||||
return javaNodes_->getElement(idx->second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
@@ -4,20 +4,14 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "yogajni.h"
|
|
||||||
#include "YGJNIVanilla.h"
|
#include "YGJNIVanilla.h"
|
||||||
#include <fbjni/fbjni.h>
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
using namespace facebook::jni;
|
|
||||||
using namespace facebook::yoga;
|
using namespace facebook::yoga;
|
||||||
|
|
||||||
jint JNI_OnLoad(JavaVM* vm, void*) {
|
jint JNI_OnLoad(JavaVM* vm, void*) {
|
||||||
jint ret = YGJNI::registerNativeMethods(vm);
|
|
||||||
|
|
||||||
JNIEnv* env;
|
JNIEnv* env;
|
||||||
vanillajni::ensureInitialized(&env, vm);
|
jint ret = vanillajni::ensureInitialized(&env, vm);
|
||||||
YGJNIVanilla::registerNatives(env);
|
YGJNIVanilla::registerNatives(env);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fbjni/fbjni.h>
|
|
||||||
|
|
||||||
namespace YGJNI {
|
|
||||||
jint registerNativeMethods(JavaVM* vm);
|
|
||||||
};
|
|
@@ -28,25 +28,7 @@ public class TestParametrization {
|
|||||||
return "JNI";
|
return "JNI";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
return Arrays.asList(nodeFactory);
|
||||||
NodeFactory nodeFactoryUsingVanillaJNI = new NodeFactory() {
|
|
||||||
@Override
|
|
||||||
public YogaNode create() {
|
|
||||||
return YogaNodeFactory.create(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public YogaNode create(YogaConfig config) {
|
|
||||||
config.setUseVanillaJNI(true);
|
|
||||||
return YogaNodeFactory.create(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "VanillaJNI";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return Arrays.asList(nodeFactory, nodeFactoryUsingVanillaJNI);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user