2018-11-29 11:35:34 -08:00
|
|
|
/**
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2016-12-03 04:40:18 -08:00
|
|
|
*
|
2018-11-29 11:35:34 -08:00
|
|
|
* This source code is licensed under the MIT license found in the LICENSE
|
|
|
|
* file in the root directory of this source tree.
|
2016-12-03 04:40:18 -08:00
|
|
|
*/
|
|
|
|
#include <fb/fbjni.h>
|
2017-12-19 11:18:00 -08:00
|
|
|
#include <yoga/YGNode.h>
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
#include <yoga/Yoga.h>
|
2019-02-19 09:54:45 -08:00
|
|
|
#include <yoga/log.h>
|
2019-03-20 08:39:34 -07:00
|
|
|
#include <cstdint>
|
2017-12-19 11:18:00 -08:00
|
|
|
#include <iostream>
|
2019-02-21 05:35:51 -08:00
|
|
|
#include <map>
|
2016-12-03 04:40:18 -08:00
|
|
|
|
2019-03-04 01:27:30 -08:00
|
|
|
#include "YGJTypes.h"
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
using namespace facebook::jni;
|
|
|
|
using namespace std;
|
2019-02-19 09:54:45 -08:00
|
|
|
using facebook::yoga::detail::Log;
|
2016-12-03 04:40:18 -08:00
|
|
|
|
2019-02-28 12:42:22 -08:00
|
|
|
enum YGStyleInput {
|
|
|
|
LayoutDirection,
|
|
|
|
FlexDirection,
|
|
|
|
Flex,
|
|
|
|
FlexGrow,
|
|
|
|
FlexShrink,
|
|
|
|
FlexBasis,
|
|
|
|
FlexBasisPercent,
|
|
|
|
FlexBasisAuto,
|
|
|
|
FlexWrap,
|
|
|
|
Width,
|
|
|
|
WidthPercent,
|
|
|
|
WidthAuto,
|
|
|
|
MinWidth,
|
|
|
|
MinWidthPercent,
|
|
|
|
MaxWidth,
|
|
|
|
MaxWidthPercent,
|
|
|
|
Height,
|
|
|
|
HeightPercent,
|
|
|
|
HeightAuto,
|
|
|
|
MinHeight,
|
|
|
|
MinHeightPercent,
|
|
|
|
MaxHeight,
|
|
|
|
MaxHeightPercent,
|
|
|
|
JustifyContent,
|
|
|
|
AlignItems,
|
|
|
|
AlignSelf,
|
|
|
|
AlignContent,
|
|
|
|
PositionType,
|
|
|
|
AspectRatio,
|
|
|
|
Overflow,
|
|
|
|
Display,
|
|
|
|
Margin,
|
|
|
|
MarginPercent,
|
|
|
|
MarginAuto,
|
|
|
|
Padding,
|
|
|
|
PaddingPercent,
|
|
|
|
Border,
|
|
|
|
Position,
|
|
|
|
PositionPercent,
|
|
|
|
IsReferenceBaseline,
|
|
|
|
};
|
|
|
|
|
2019-02-21 05:35:51 -08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-03-20 08:39:34 -07:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
union YGNodeContext {
|
|
|
|
uintptr_t edgesSet = 0;
|
|
|
|
void* asVoidPtr;
|
2019-02-28 12:42:22 -08:00
|
|
|
};
|
|
|
|
|
2019-03-20 08:39:34 -07:00
|
|
|
class YGNodeEdges {
|
|
|
|
uintptr_t edges_;
|
2019-02-28 12:42:22 -08:00
|
|
|
|
2019-03-20 08:39:34 -07:00
|
|
|
public:
|
|
|
|
enum Edge {
|
|
|
|
MARGIN = 1,
|
|
|
|
PADDING = 2,
|
|
|
|
BORDER = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
YGNodeEdges(YGNodeRef node) {
|
|
|
|
auto context = YGNodeContext{};
|
|
|
|
context.asVoidPtr = node->getContext();
|
|
|
|
edges_ = context.edgesSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setOn(YGNodeRef node) {
|
|
|
|
auto context = YGNodeContext{};
|
|
|
|
context.edgesSet = edges_;
|
|
|
|
node->setContext(context.asVoidPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool has(Edge edge) {
|
|
|
|
return (edges_ & edge) == edge;
|
|
|
|
}
|
|
|
|
|
|
|
|
YGNodeEdges& add(Edge edge) {
|
|
|
|
edges_ |= edge;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
2019-02-28 12:42:22 -08:00
|
|
|
|
2019-02-21 05:35:51 -08:00
|
|
|
static inline local_ref<JYogaNode> YGNodeJobject(
|
|
|
|
YGNodeRef node,
|
|
|
|
void* layoutContext) {
|
2019-03-12 12:59:58 -07:00
|
|
|
return reinterpret_cast<PtrJNodeMap*>(layoutContext)->ref(node);
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
static void YGTransferLayoutDirection(
|
|
|
|
YGNodeRef node,
|
2018-08-06 02:10:43 -07:00
|
|
|
alias_ref<jobject> javaNode) {
|
2018-07-11 04:09:39 -07:00
|
|
|
static auto layoutDirectionField =
|
2018-08-06 02:10:43 -07:00
|
|
|
javaNode->getClass()->getField<jint>("mLayoutDirection");
|
|
|
|
javaNode->setFieldValue(
|
2018-07-11 04:09:39 -07:00
|
|
|
layoutDirectionField, static_cast<jint>(YGNodeLayoutGetDirection(node)));
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
2019-02-21 05:35:51 -08:00
|
|
|
static void YGTransferLayoutOutputsRecursive(
|
|
|
|
YGNodeRef root,
|
|
|
|
void* layoutContext) {
|
2018-07-11 04:09:40 -07:00
|
|
|
if (!root->getHasNewLayout()) {
|
|
|
|
return;
|
|
|
|
}
|
2019-02-21 05:35:51 -08:00
|
|
|
auto obj = YGNodeJobject(root, layoutContext);
|
2018-07-11 04:09:40 -07:00
|
|
|
if (!obj) {
|
2019-02-19 09:54:45 -08:00
|
|
|
Log::log(
|
2018-07-11 04:09:40 -07:00
|
|
|
root,
|
|
|
|
YGLogLevelError,
|
2019-02-19 09:54:45 -08:00
|
|
|
nullptr,
|
2018-07-11 04:09:40 -07:00
|
|
|
"Java YGNode was GCed during layout calculation\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-20 08:39:34 -07:00
|
|
|
auto edgesSet = YGNodeEdges{root};
|
2019-02-28 12:42:22 -08:00
|
|
|
|
2018-07-11 04:09:40 -07:00
|
|
|
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
|
|
|
|
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
|
|
|
|
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
|
|
|
static auto topField = obj->getClass()->getField<jfloat>("mTop");
|
|
|
|
|
|
|
|
static auto marginLeftField =
|
|
|
|
obj->getClass()->getField<jfloat>("mMarginLeft");
|
|
|
|
static auto marginTopField = obj->getClass()->getField<jfloat>("mMarginTop");
|
|
|
|
static auto marginRightField =
|
|
|
|
obj->getClass()->getField<jfloat>("mMarginRight");
|
|
|
|
static auto marginBottomField =
|
|
|
|
obj->getClass()->getField<jfloat>("mMarginBottom");
|
|
|
|
|
|
|
|
static auto paddingLeftField =
|
|
|
|
obj->getClass()->getField<jfloat>("mPaddingLeft");
|
|
|
|
static auto paddingTopField =
|
|
|
|
obj->getClass()->getField<jfloat>("mPaddingTop");
|
|
|
|
static auto paddingRightField =
|
|
|
|
obj->getClass()->getField<jfloat>("mPaddingRight");
|
|
|
|
static auto paddingBottomField =
|
|
|
|
obj->getClass()->getField<jfloat>("mPaddingBottom");
|
|
|
|
|
|
|
|
static auto borderLeftField =
|
|
|
|
obj->getClass()->getField<jfloat>("mBorderLeft");
|
|
|
|
static auto borderTopField = obj->getClass()->getField<jfloat>("mBorderTop");
|
|
|
|
static auto borderRightField =
|
|
|
|
obj->getClass()->getField<jfloat>("mBorderRight");
|
|
|
|
static auto borderBottomField =
|
|
|
|
obj->getClass()->getField<jfloat>("mBorderBottom");
|
|
|
|
|
|
|
|
static auto hasNewLayoutField =
|
|
|
|
obj->getClass()->getField<jboolean>("mHasNewLayout");
|
|
|
|
static auto doesLegacyStretchBehaviour = obj->getClass()->getField<jboolean>(
|
|
|
|
"mDoesLegacyStretchFlagAffectsLayout");
|
|
|
|
|
|
|
|
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
|
|
|
|
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
|
|
|
|
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
|
|
|
|
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
|
|
|
|
obj->setFieldValue<jboolean>(
|
|
|
|
doesLegacyStretchBehaviour,
|
|
|
|
YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root));
|
2019-03-13 06:21:58 -07:00
|
|
|
obj->setFieldValue<jboolean>(hasNewLayoutField, true);
|
|
|
|
YGTransferLayoutDirection(root, obj);
|
2018-07-11 04:09:40 -07:00
|
|
|
|
2019-03-20 08:39:34 -07:00
|
|
|
if (edgesSet.has(YGNodeEdges::MARGIN)) {
|
2019-02-28 12:42:22 -08:00
|
|
|
obj->setFieldValue(
|
|
|
|
marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
|
|
|
|
obj->setFieldValue(marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
|
|
|
obj->setFieldValue(
|
|
|
|
marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
|
|
|
|
obj->setFieldValue(
|
|
|
|
marginBottomField, YGNodeLayoutGetMargin(root, YGEdgeBottom));
|
|
|
|
}
|
|
|
|
|
2019-03-20 08:39:34 -07:00
|
|
|
if (edgesSet.has(YGNodeEdges::PADDING)) {
|
2019-02-28 12:42:22 -08:00
|
|
|
obj->setFieldValue(
|
|
|
|
paddingLeftField, YGNodeLayoutGetPadding(root, YGEdgeLeft));
|
|
|
|
obj->setFieldValue(
|
|
|
|
paddingTopField, YGNodeLayoutGetPadding(root, YGEdgeTop));
|
|
|
|
obj->setFieldValue(
|
|
|
|
paddingRightField, YGNodeLayoutGetPadding(root, YGEdgeRight));
|
|
|
|
obj->setFieldValue(
|
|
|
|
paddingBottomField, YGNodeLayoutGetPadding(root, YGEdgeBottom));
|
|
|
|
}
|
2018-07-11 04:09:40 -07:00
|
|
|
|
2019-03-20 08:39:34 -07:00
|
|
|
if (edgesSet.has(YGNodeEdges::BORDER)) {
|
2019-02-28 12:42:22 -08:00
|
|
|
obj->setFieldValue(
|
|
|
|
borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
|
|
|
|
obj->setFieldValue(borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
|
|
|
obj->setFieldValue(
|
|
|
|
borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
|
|
|
|
obj->setFieldValue(
|
|
|
|
borderBottomField, YGNodeLayoutGetBorder(root, YGEdgeBottom));
|
|
|
|
}
|
2019-03-01 05:42:10 -08:00
|
|
|
|
2018-07-11 04:09:40 -07:00
|
|
|
root->setHasNewLayout(false);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
|
2019-02-21 05:35:51 -08:00
|
|
|
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i), layoutContext);
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-21 05:35:51 -08:00
|
|
|
static void YGPrint(YGNodeRef node, void* layoutContext) {
|
|
|
|
if (auto obj = YGNodeJobject(node, layoutContext)) {
|
2016-12-03 04:40:18 -08:00
|
|
|
cout << obj->toString() << endl;
|
|
|
|
} else {
|
2019-02-19 09:54:45 -08:00
|
|
|
Log::log(
|
2018-07-11 04:09:39 -07:00
|
|
|
node,
|
|
|
|
YGLogLevelError,
|
2019-02-19 09:54:45 -08:00
|
|
|
nullptr,
|
2018-07-11 04:09:39 -07:00
|
|
|
"Java YGNode was GCed during layout calculation\n");
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-21 05:35:51 -08:00
|
|
|
static float YGJNIBaselineFunc(
|
|
|
|
YGNodeRef node,
|
|
|
|
float width,
|
|
|
|
float height,
|
|
|
|
void* layoutContext) {
|
|
|
|
if (auto obj = YGNodeJobject(node, layoutContext)) {
|
2019-03-04 01:27:30 -08:00
|
|
|
return obj->baseline(width, height);
|
2017-01-10 07:03:56 -08:00
|
|
|
} else {
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-01 18:27:04 -07:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2018-02-14 09:31:10 -08:00
|
|
|
static YGSize YGJNIMeasureFunc(
|
|
|
|
YGNodeRef node,
|
|
|
|
float width,
|
|
|
|
YGMeasureMode widthMode,
|
|
|
|
float height,
|
2019-02-21 05:35:51 -08:00
|
|
|
YGMeasureMode heightMode,
|
|
|
|
void* layoutContext) {
|
|
|
|
if (auto obj = YGNodeJobject(node, layoutContext)) {
|
2018-08-06 02:10:43 -07:00
|
|
|
YGTransferLayoutDirection(node, obj);
|
2018-07-11 04:09:39 -07:00
|
|
|
const auto measureResult =
|
2019-03-04 01:27:30 -08:00
|
|
|
obj->measure(width, widthMode, height, heightMode);
|
2016-12-03 04:40:18 -08:00
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
static_assert(
|
|
|
|
sizeof(measureResult) == 8,
|
|
|
|
"Expected measureResult to be 8 bytes, or two 32 bit ints");
|
2016-12-03 04:40:18 -08:00
|
|
|
|
2016-12-29 04:52:20 -08:00
|
|
|
int32_t wBits = 0xFFFFFFFF & (measureResult >> 32);
|
|
|
|
int32_t hBits = 0xFFFFFFFF & measureResult;
|
2016-12-03 04:40:18 -08:00
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
const float* measuredWidth = reinterpret_cast<float*>(&wBits);
|
|
|
|
const float* measuredHeight = reinterpret_cast<float*>(&hBits);
|
2016-12-29 04:52:20 -08:00
|
|
|
|
|
|
|
return YGSize{*measuredWidth, *measuredHeight};
|
2016-12-03 04:40:18 -08:00
|
|
|
} else {
|
2019-02-19 09:54:45 -08:00
|
|
|
Log::log(
|
2018-07-11 04:09:39 -07:00
|
|
|
node,
|
|
|
|
YGLogLevelError,
|
2019-02-19 09:54:45 -08:00
|
|
|
nullptr,
|
2018-07-11 04:09:39 -07:00
|
|
|
"Java YGNode was GCed during layout calculation\n");
|
2016-12-03 04:40:18 -08:00
|
|
|
return YGSize{
|
|
|
|
widthMode == YGMeasureModeUndefined ? 0 : width,
|
|
|
|
heightMode == YGMeasureModeUndefined ? 0 : height,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
static int YGJNILogFunc(
|
|
|
|
const YGConfigRef config,
|
|
|
|
const YGNodeRef node,
|
|
|
|
YGLogLevel level,
|
2019-02-21 05:35:51 -08:00
|
|
|
void* layoutContext,
|
2018-07-11 04:09:39 -07:00
|
|
|
const char* format,
|
|
|
|
va_list args) {
|
2018-01-23 06:35:51 -08:00
|
|
|
int result = vsnprintf(NULL, 0, format, args);
|
|
|
|
std::vector<char> buffer(1 + result);
|
|
|
|
vsnprintf(buffer.data(), buffer.size(), format, args);
|
2016-12-03 04:40:18 -08:00
|
|
|
|
2019-03-01 05:42:10 -08:00
|
|
|
auto jloggerPtr =
|
2019-03-04 01:27:30 -08:00
|
|
|
static_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config));
|
2019-03-01 05:42:10 -08:00
|
|
|
if (jloggerPtr != nullptr) {
|
|
|
|
if (auto obj = YGNodeJobject(node, layoutContext)) {
|
2019-03-04 01:27:30 -08:00
|
|
|
(*jloggerPtr)
|
|
|
|
->log(
|
|
|
|
obj,
|
|
|
|
JYogaLogLevel::fromInt(level),
|
|
|
|
Environment::current()->NewStringUTF(buffer.data()));
|
2019-03-01 05:42:10 -08:00
|
|
|
}
|
2017-05-03 09:22:35 -07:00
|
|
|
}
|
2016-12-03 04:40:18 -08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-03-22 09:30:25 -07:00
|
|
|
jlong jni_YGNodeNew(alias_ref<jclass>) {
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef node = YGNodeNew();
|
2019-03-20 08:39:34 -07:00
|
|
|
node->setContext(YGNodeContext{}.asVoidPtr);
|
2017-12-19 11:18:00 -08:00
|
|
|
node->setPrintFunc(YGPrint);
|
2016-12-03 04:40:18 -08:00
|
|
|
return reinterpret_cast<jlong>(node);
|
|
|
|
}
|
|
|
|
|
2019-03-22 09:30:25 -07:00
|
|
|
jlong jni_YGNodeNewWithConfig(alias_ref<jclass>, jlong configPointer) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef node = YGNodeNewWithConfig(_jlong2YGConfigRef(configPointer));
|
2019-03-20 08:39:34 -07:00
|
|
|
node->setContext(YGNodeContext{}.asVoidPtr);
|
2017-03-01 09:19:55 -08:00
|
|
|
return reinterpret_cast<jlong>(node);
|
|
|
|
}
|
|
|
|
|
2019-02-22 08:56:40 -08:00
|
|
|
void jni_YGNodeFree(alias_ref<jclass>, jlong nativePointer) {
|
2018-08-02 03:50:15 -07:00
|
|
|
if (nativePointer == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
|
|
|
YGNodeFree(node);
|
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
void jni_YGNodeClearChildren(jlong nativePointer) {
|
2018-04-01 18:27:08 -07:00
|
|
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
|
|
|
node->clearChildren();
|
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
void jni_YGNodeReset(jlong nativePointer) {
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
2017-12-19 11:18:00 -08:00
|
|
|
void* context = node->getContext();
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeReset(node);
|
2017-12-19 11:18:00 -08:00
|
|
|
node->setContext(context);
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
void jni_YGNodePrint(jlong nativePointer) {
|
2019-03-13 07:25:13 -07:00
|
|
|
#ifdef DEBUG
|
2017-04-27 16:19:17 -07:00
|
|
|
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
|
2018-07-11 04:09:39 -07:00
|
|
|
YGNodePrint(
|
|
|
|
node,
|
|
|
|
(YGPrintOptions)(
|
|
|
|
YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren));
|
2019-03-13 07:25:13 -07:00
|
|
|
#endif
|
2017-04-27 16:19:17 -07:00
|
|
|
}
|
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
void jni_YGNodeInsertChild(
|
|
|
|
jlong nativePointer,
|
|
|
|
jlong childPointer,
|
|
|
|
jint index) {
|
|
|
|
YGNodeInsertChild(
|
|
|
|
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
void jni_YGNodeRemoveChild(jlong nativePointer, jlong childPointer) {
|
2018-07-11 04:09:39 -07:00
|
|
|
YGNodeRemoveChild(
|
|
|
|
_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
2018-11-14 02:49:27 -08:00
|
|
|
void jni_YGNodeSetIsReferenceBaseline(
|
|
|
|
jlong nativePointer,
|
|
|
|
jboolean isReferenceBaseline) {
|
|
|
|
YGNodeSetIsReferenceBaseline(
|
|
|
|
_jlong2YGNodeRef(nativePointer), isReferenceBaseline);
|
|
|
|
}
|
|
|
|
|
|
|
|
jboolean jni_YGNodeIsReferenceBaseline(jlong nativePointer) {
|
|
|
|
return YGNodeIsReferenceBaseline(_jlong2YGNodeRef(nativePointer));
|
|
|
|
}
|
|
|
|
|
2018-08-06 02:10:43 -07:00
|
|
|
void jni_YGNodeCalculateLayout(
|
2018-09-25 15:44:42 -07:00
|
|
|
alias_ref<jclass>,
|
2018-07-11 04:09:39 -07:00
|
|
|
jlong nativePointer,
|
|
|
|
jfloat width,
|
2019-02-21 05:35:51 -08:00
|
|
|
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 = ↦
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
const YGNodeRef root = _jlong2YGNodeRef(nativePointer);
|
2019-02-21 05:35:51 -08:00
|
|
|
YGNodeCalculateLayoutWithContext(
|
2018-07-11 04:09:39 -07:00
|
|
|
root,
|
|
|
|
static_cast<float>(width),
|
|
|
|
static_cast<float>(height),
|
2019-02-21 05:35:51 -08:00
|
|
|
YGNodeStyleGetDirection(_jlong2YGNodeRef(nativePointer)),
|
|
|
|
layoutContext);
|
|
|
|
YGTransferLayoutOutputsRecursive(root, layoutContext);
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
void jni_YGNodeMarkDirty(jlong nativePointer) {
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer));
|
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
void jni_YGNodeMarkDirtyAndPropogateToDescendants(jlong nativePointer) {
|
2018-02-08 04:51:12 -08:00
|
|
|
YGNodeMarkDirtyAndPropogateToDescendants(_jlong2YGNodeRef(nativePointer));
|
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
jboolean jni_YGNodeIsDirty(jlong nativePointer) {
|
2019-01-08 12:47:53 -08:00
|
|
|
return (jboolean) _jlong2YGNodeRef(nativePointer)->isDirty();
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
void jni_YGNodeSetHasMeasureFunc(jlong nativePointer, jboolean hasMeasureFunc) {
|
2017-12-19 11:18:00 -08:00
|
|
|
_jlong2YGNodeRef(nativePointer)
|
|
|
|
->setMeasureFunc(hasMeasureFunc ? YGJNIMeasureFunc : nullptr);
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
void jni_YGNodeSetHasBaselineFunc(
|
|
|
|
jlong nativePointer,
|
|
|
|
jboolean hasBaselineFunc) {
|
2017-12-19 11:18:00 -08:00
|
|
|
_jlong2YGNodeRef(nativePointer)
|
2019-02-21 05:35:52 -08:00
|
|
|
->setBaselineFunc(hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
|
2017-01-10 07:03:56 -08:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
void jni_YGNodeCopyStyle(jlong dstNativePointer, jlong srcNativePointer) {
|
2018-07-11 04:09:39 -07:00
|
|
|
YGNodeCopyStyle(
|
|
|
|
_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
2019-01-08 12:47:53 -08:00
|
|
|
#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)); \
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
#define YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
|
|
|
local_ref<jobject> jni_YGNodeStyleGet##name( \
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>, jlong nativePointer) { \
|
2018-09-25 15:44:42 -07:00
|
|
|
return JYogaValue::create( \
|
|
|
|
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)); \
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
}
|
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
#define YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(name) \
|
|
|
|
YG_NODE_JNI_STYLE_UNIT_PROP(name) \
|
2018-09-25 15:44:42 -07:00
|
|
|
void jni_YGNodeStyleSet##name##Auto(jlong nativePointer) { \
|
2018-07-11 04:09:39 -07:00
|
|
|
YGNodeStyleSet##name##Auto(_jlong2YGNodeRef(nativePointer)); \
|
2017-02-14 14:26:09 -08:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
|
|
|
|
javatype jni_YGNodeStyleGet##name(jlong nativePointer, jint edge) { \
|
2019-01-08 12:47:53 -08:00
|
|
|
return (javatype) YGNodeStyleGet##name( \
|
2018-09-25 15:44:42 -07:00
|
|
|
_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)); \
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
|
|
|
|
local_ref<jobject> jni_YGNodeStyleGet##name( \
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>, jlong nativePointer, jint edge) { \
|
2018-09-25 15:44:42 -07:00
|
|
|
return JYogaValue::create(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)); \
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
#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)); \
|
2017-02-14 14:26:09 -08:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
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);
|
2017-02-06 09:31:22 -08:00
|
|
|
YG_NODE_JNI_STYLE_PROP(jint, YGDisplay, Display);
|
2016-12-03 04:40:18 -08:00
|
|
|
|
2019-02-28 12:42:24 -08:00
|
|
|
jfloat jni_YGNodeStyleGetFlex(jlong nativePointer) {
|
|
|
|
return YGNodeStyleGetFlex(_jlong2YGNodeRef(nativePointer));
|
|
|
|
}
|
2018-09-25 15:44:42 -07:00
|
|
|
void jni_YGNodeStyleSetFlex(jlong nativePointer, jfloat value) {
|
2018-07-11 04:09:39 -07:00
|
|
|
YGNodeStyleSetFlex(
|
|
|
|
_jlong2YGNodeRef(nativePointer), static_cast<float>(value));
|
2016-12-03 04:40:18 -08:00
|
|
|
}
|
|
|
|
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
|
|
|
|
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
|
2017-02-14 14:26:09 -08:00
|
|
|
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(FlexBasis);
|
2016-12-03 04:40:18 -08:00
|
|
|
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(Position);
|
2016-12-03 04:40:18 -08:00
|
|
|
|
2017-02-14 14:26:09 -08:00
|
|
|
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Width);
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YG_NODE_JNI_STYLE_UNIT_PROP(MinWidth);
|
|
|
|
YG_NODE_JNI_STYLE_UNIT_PROP(MaxWidth);
|
2017-02-14 14:26:09 -08:00
|
|
|
YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Height);
|
Add feature to use percentage as value unit
Summary:
Adds the feature to use percentage as a value unit.
You can use the function ```YGPx(float)``` and ```YGPercent(float)``` for convenience.
I did some benchmarks:
```
Without Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.146683 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.490101 ms
Huge nested layout: median: 23.000000 ms, stddev: 0.928291 ms
Stack with flex: median: 0.000000 ms, stddev: 0.170587 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.143384 ms
Nested flex: median: 0.000000 ms, stddev: 0.477791 ms
Huge nested layout: median: 22.000000 ms, stddev: 2.129779 ms
With Percentage Feature - Release x86:
Stack with flex: median: 0.000000 ms, stddev: 0.132951 ms
Align stretch in undefined axis: median: 0.000000 ms, stddev: 0.136525 ms
Nested flex: median: 0.000000 ms, stddev: 0.489570 ms
Huge nested layout: median: 21.000000 ms, stddev: 1.390476 ms
Closes https://github.com/facebook/yoga/pull/258
Reviewed By: dshahidehpour
Differential Revision: D4361945
Pulled By: emilsjolander
fbshipit-source-id: a8f5bc63ad352eb9410d792729e56664468cd76a
2017-01-02 05:20:37 -08:00
|
|
|
YG_NODE_JNI_STYLE_UNIT_PROP(MinHeight);
|
|
|
|
YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
|
2016-12-03 04:40:18 -08:00
|
|
|
|
|
|
|
// Yoga specific properties, not compatible with flexbox specification
|
|
|
|
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
|
|
|
|
|
2019-03-22 09:30:25 -07:00
|
|
|
jlong jni_YGConfigNew(alias_ref<jclass>) {
|
2017-03-01 09:19:55 -08:00
|
|
|
return reinterpret_cast<jlong>(YGConfigNew());
|
|
|
|
}
|
|
|
|
|
2019-03-22 09:30:25 -07:00
|
|
|
void jni_YGConfigFree(alias_ref<jclass>, jlong nativePointer) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
2019-03-01 05:42:10 -08:00
|
|
|
// unique_ptr will destruct the underlying global_ref, if present.
|
2019-03-04 01:27:30 -08:00
|
|
|
auto context = std::unique_ptr<global_ref<JYogaLogger>>{
|
|
|
|
static_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config))};
|
2017-03-01 09:19:55 -08:00
|
|
|
YGConfigFree(config);
|
|
|
|
}
|
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
void jni_YGConfigSetExperimentalFeatureEnabled(
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>,
|
2018-07-11 04:09:39 -07:00
|
|
|
jlong nativePointer,
|
|
|
|
jint feature,
|
|
|
|
jboolean enabled) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
2018-07-11 04:09:39 -07:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(
|
|
|
|
config, static_cast<YGExperimentalFeature>(feature), enabled);
|
2017-03-01 09:19:55 -08:00
|
|
|
}
|
|
|
|
|
2018-03-14 08:37:55 -07:00
|
|
|
void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>,
|
2018-03-14 08:37:55 -07:00
|
|
|
jlong nativePointer,
|
|
|
|
jboolean enabled) {
|
|
|
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
|
|
YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(config, enabled);
|
|
|
|
}
|
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
void jni_YGConfigSetUseWebDefaults(
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>,
|
2018-07-11 04:09:39 -07:00
|
|
|
jlong nativePointer,
|
|
|
|
jboolean useWebDefaults) {
|
2017-03-29 03:06:17 -07:00
|
|
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
|
|
YGConfigSetUseWebDefaults(config, useWebDefaults);
|
|
|
|
}
|
|
|
|
|
2018-08-30 04:40:48 -07:00
|
|
|
void jni_YGConfigSetPrintTreeFlag(
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>,
|
2018-08-30 04:40:48 -07:00
|
|
|
jlong nativePointer,
|
|
|
|
jboolean enable) {
|
|
|
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
|
|
YGConfigSetPrintTreeFlag(config, enable);
|
|
|
|
}
|
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
void jni_YGConfigSetPointScaleFactor(
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>,
|
2018-07-11 04:09:39 -07:00
|
|
|
jlong nativePointer,
|
|
|
|
jfloat pixelsInPoint) {
|
2017-04-26 12:20:02 -07:00
|
|
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
|
|
YGConfigSetPointScaleFactor(config, pixelsInPoint);
|
|
|
|
}
|
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
void jni_YGConfigSetUseLegacyStretchBehaviour(
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>,
|
2018-07-11 04:09:39 -07:00
|
|
|
jlong nativePointer,
|
|
|
|
jboolean useLegacyStretchBehaviour) {
|
2017-04-28 06:13:51 -07:00
|
|
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
|
|
|
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
|
|
|
|
}
|
|
|
|
|
2018-02-14 09:31:10 -08:00
|
|
|
void jni_YGConfigSetLogger(
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>,
|
2018-02-14 09:31:10 -08:00
|
|
|
jlong nativePointer,
|
|
|
|
alias_ref<jobject> logger) {
|
|
|
|
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
2019-03-01 05:42:10 -08:00
|
|
|
auto context =
|
2019-03-04 01:27:30 -08:00
|
|
|
reinterpret_cast<global_ref<JYogaLogger>*>(YGConfigGetContext(config));
|
2017-05-03 09:22:35 -07:00
|
|
|
|
|
|
|
if (logger) {
|
2019-03-01 05:42:10 -08:00
|
|
|
if (context == nullptr) {
|
2019-03-04 01:27:30 -08:00
|
|
|
context = new global_ref<JYogaLogger>{};
|
2018-02-14 09:31:10 -08:00
|
|
|
YGConfigSetContext(config, context);
|
|
|
|
}
|
2019-03-04 01:27:30 -08:00
|
|
|
|
|
|
|
*context = make_global(static_ref_cast<JYogaLogger::javaobject>(logger));
|
2019-02-21 05:35:51 -08:00
|
|
|
config->setLogger(YGJNILogFunc);
|
2017-05-03 09:22:35 -07:00
|
|
|
} else {
|
2019-03-01 05:42:10 -08:00
|
|
|
if (context != nullptr) {
|
|
|
|
delete context;
|
|
|
|
YGConfigSetContext(config, nullptr);
|
|
|
|
}
|
2019-02-21 05:35:51 -08:00
|
|
|
config->setLogger(nullptr);
|
2017-05-03 09:22:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-28 12:42:22 -08:00
|
|
|
static void YGNodeSetStyleInputs(
|
|
|
|
const YGNodeRef node,
|
|
|
|
float* styleInputs,
|
|
|
|
int size) {
|
|
|
|
const auto end = styleInputs + size;
|
2019-03-20 08:39:34 -07:00
|
|
|
auto edgesSet = YGNodeEdges{node};
|
2019-02-28 12:42:22 -08:00
|
|
|
while (styleInputs < end) {
|
|
|
|
auto styleInputKey = static_cast<YGStyleInput>((int) *styleInputs++);
|
|
|
|
switch (styleInputKey) {
|
|
|
|
case LayoutDirection:
|
|
|
|
YGNodeStyleSetDirection(node, static_cast<YGDirection>(*styleInputs++));
|
|
|
|
break;
|
|
|
|
case FlexDirection:
|
|
|
|
YGNodeStyleSetFlexDirection(
|
|
|
|
node, static_cast<YGFlexDirection>(*styleInputs++));
|
|
|
|
break;
|
|
|
|
case Flex:
|
|
|
|
YGNodeStyleSetFlex(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case FlexGrow:
|
|
|
|
YGNodeStyleSetFlexGrow(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case FlexShrink:
|
|
|
|
YGNodeStyleSetFlexShrink(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case FlexBasis:
|
|
|
|
YGNodeStyleSetFlexBasis(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case FlexBasisPercent:
|
|
|
|
YGNodeStyleSetFlexBasisPercent(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case FlexBasisAuto:
|
|
|
|
YGNodeStyleSetFlexBasisAuto(node);
|
|
|
|
break;
|
|
|
|
case FlexWrap:
|
|
|
|
YGNodeStyleSetFlexWrap(node, static_cast<YGWrap>(*styleInputs++));
|
|
|
|
break;
|
|
|
|
case Width:
|
|
|
|
YGNodeStyleSetWidth(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case WidthPercent:
|
|
|
|
YGNodeStyleSetWidthPercent(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case WidthAuto:
|
|
|
|
YGNodeStyleSetWidthAuto(node);
|
|
|
|
break;
|
|
|
|
case MinWidth:
|
|
|
|
YGNodeStyleSetMinWidth(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case MinWidthPercent:
|
|
|
|
YGNodeStyleSetMinWidthPercent(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case MaxWidth:
|
|
|
|
YGNodeStyleSetMaxWidth(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case MaxWidthPercent:
|
|
|
|
YGNodeStyleSetMaxWidthPercent(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case Height:
|
|
|
|
YGNodeStyleSetHeight(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case HeightPercent:
|
|
|
|
YGNodeStyleSetHeightPercent(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case HeightAuto:
|
|
|
|
YGNodeStyleSetHeightAuto(node);
|
|
|
|
break;
|
|
|
|
case MinHeight:
|
|
|
|
YGNodeStyleSetMinHeight(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case MinHeightPercent:
|
|
|
|
YGNodeStyleSetMinHeightPercent(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case MaxHeight:
|
|
|
|
YGNodeStyleSetMaxHeight(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case MaxHeightPercent:
|
|
|
|
YGNodeStyleSetMaxHeightPercent(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case JustifyContent:
|
|
|
|
YGNodeStyleSetJustifyContent(
|
|
|
|
node, static_cast<YGJustify>(*styleInputs++));
|
|
|
|
break;
|
|
|
|
case AlignItems:
|
|
|
|
YGNodeStyleSetAlignItems(node, static_cast<YGAlign>(*styleInputs++));
|
|
|
|
break;
|
|
|
|
case AlignSelf:
|
|
|
|
YGNodeStyleSetAlignSelf(node, static_cast<YGAlign>(*styleInputs++));
|
|
|
|
break;
|
|
|
|
case AlignContent:
|
|
|
|
YGNodeStyleSetAlignContent(node, static_cast<YGAlign>(*styleInputs++));
|
|
|
|
break;
|
|
|
|
case PositionType:
|
|
|
|
YGNodeStyleSetPositionType(
|
|
|
|
node, static_cast<YGPositionType>(*styleInputs++));
|
|
|
|
break;
|
|
|
|
case AspectRatio:
|
|
|
|
YGNodeStyleSetAspectRatio(node, *styleInputs++);
|
|
|
|
break;
|
|
|
|
case Overflow:
|
|
|
|
YGNodeStyleSetOverflow(node, static_cast<YGOverflow>(*styleInputs++));
|
|
|
|
break;
|
|
|
|
case Display:
|
|
|
|
YGNodeStyleSetDisplay(node, static_cast<YGDisplay>(*styleInputs++));
|
|
|
|
break;
|
|
|
|
case Margin: {
|
2019-03-04 02:34:33 -08:00
|
|
|
auto edge = static_cast<YGEdge>(*styleInputs++);
|
2019-02-28 12:42:22 -08:00
|
|
|
float marginValue = *styleInputs++;
|
2019-03-20 08:39:34 -07:00
|
|
|
edgesSet.add(YGNodeEdges::MARGIN);
|
2019-03-04 02:34:33 -08:00
|
|
|
YGNodeStyleSetMargin(node, edge, marginValue);
|
2019-02-28 12:42:22 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MarginPercent: {
|
2019-03-04 02:34:33 -08:00
|
|
|
auto edge = static_cast<YGEdge>(*styleInputs++);
|
2019-02-28 12:42:22 -08:00
|
|
|
float marginPercent = *styleInputs++;
|
2019-03-20 08:39:34 -07:00
|
|
|
edgesSet.add(YGNodeEdges::MARGIN);
|
2019-03-04 02:34:33 -08:00
|
|
|
YGNodeStyleSetMarginPercent(node, edge, marginPercent);
|
2019-02-28 12:42:22 -08:00
|
|
|
break;
|
|
|
|
}
|
2019-02-28 12:42:24 -08:00
|
|
|
case MarginAuto: {
|
2019-03-20 08:39:34 -07:00
|
|
|
edgesSet.add(YGNodeEdges::MARGIN);
|
2019-02-28 12:42:22 -08:00
|
|
|
YGNodeStyleSetMarginAuto(node, static_cast<YGEdge>(*styleInputs++));
|
|
|
|
break;
|
2019-02-28 12:42:24 -08:00
|
|
|
}
|
2019-02-28 12:42:22 -08:00
|
|
|
case Padding: {
|
2019-03-04 02:34:33 -08:00
|
|
|
auto edge = static_cast<YGEdge>(*styleInputs++);
|
2019-02-28 12:42:22 -08:00
|
|
|
float paddingValue = *styleInputs++;
|
2019-03-20 08:39:34 -07:00
|
|
|
edgesSet.add(YGNodeEdges::PADDING);
|
2019-03-04 02:34:33 -08:00
|
|
|
YGNodeStyleSetPadding(node, edge, paddingValue);
|
2019-02-28 12:42:22 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PaddingPercent: {
|
2019-03-04 02:34:33 -08:00
|
|
|
auto edge = static_cast<YGEdge>(*styleInputs++);
|
2019-02-28 12:42:22 -08:00
|
|
|
float paddingPercent = *styleInputs++;
|
2019-03-20 08:39:34 -07:00
|
|
|
edgesSet.add(YGNodeEdges::PADDING);
|
2019-03-04 02:34:33 -08:00
|
|
|
YGNodeStyleSetPaddingPercent(node, edge, paddingPercent);
|
2019-02-28 12:42:22 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Border: {
|
2019-03-04 02:34:33 -08:00
|
|
|
auto edge = static_cast<YGEdge>(*styleInputs++);
|
2019-02-28 12:42:22 -08:00
|
|
|
float borderValue = *styleInputs++;
|
2019-03-20 08:39:34 -07:00
|
|
|
edgesSet.add(YGNodeEdges::BORDER);
|
2019-03-04 02:34:33 -08:00
|
|
|
YGNodeStyleSetBorder(node, edge, borderValue);
|
2019-02-28 12:42:22 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Position: {
|
2019-03-04 02:34:33 -08:00
|
|
|
auto edge = static_cast<YGEdge>(*styleInputs++);
|
2019-02-28 12:42:22 -08:00
|
|
|
float positionValue = *styleInputs++;
|
2019-03-04 02:34:33 -08:00
|
|
|
YGNodeStyleSetPosition(node, edge, positionValue);
|
2019-02-28 12:42:22 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PositionPercent: {
|
2019-03-04 02:34:33 -08:00
|
|
|
auto edge = static_cast<YGEdge>(*styleInputs++);
|
2019-02-28 12:42:22 -08:00
|
|
|
float positionPercent = *styleInputs++;
|
2019-03-04 02:34:33 -08:00
|
|
|
YGNodeStyleSetPositionPercent(node, edge, positionPercent);
|
2019-02-28 12:42:22 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IsReferenceBaseline: {
|
|
|
|
YGNodeSetIsReferenceBaseline(node, *styleInputs++ == 1 ? true : false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-03-20 08:39:34 -07:00
|
|
|
edgesSet.setOn(node);
|
2019-02-28 12:42:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void jni_YGNodeSetStyleInputs(
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>,
|
2019-02-28 12:42:22 -08:00
|
|
|
jlong nativePointer,
|
|
|
|
alias_ref<JArrayFloat> styleInputs,
|
|
|
|
jint size) {
|
|
|
|
float result[size];
|
|
|
|
styleInputs->getRegion(0, size, result);
|
|
|
|
YGNodeSetStyleInputs(_jlong2YGNodeRef(nativePointer), result, size);
|
|
|
|
}
|
|
|
|
|
2018-09-25 15:44:42 -07:00
|
|
|
jint jni_YGNodeGetInstanceCount() {
|
2017-03-01 09:19:55 -08:00
|
|
|
return YGNodeGetInstanceCount();
|
|
|
|
}
|
2018-08-05 16:36:09 -07:00
|
|
|
|
2019-02-28 12:42:22 -08:00
|
|
|
local_ref<jobject> jni_YGNodeStyleGetMargin(
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>,
|
2019-02-28 12:42:22 -08:00
|
|
|
jlong nativePointer,
|
|
|
|
jint edge) {
|
|
|
|
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
2019-03-20 08:39:34 -07:00
|
|
|
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::MARGIN)) {
|
2019-02-28 12:42:22 -08:00
|
|
|
return JYogaValue::create(YGValueUndefined);
|
|
|
|
}
|
|
|
|
return JYogaValue::create(
|
|
|
|
YGNodeStyleGetMargin(yogaNodeRef, static_cast<YGEdge>(edge)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void jni_YGNodeStyleSetMargin(jlong nativePointer, jint edge, jfloat margin) {
|
|
|
|
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
2019-03-20 08:39:34 -07:00
|
|
|
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
|
2019-02-28 12:42:22 -08:00
|
|
|
YGNodeStyleSetMargin(
|
|
|
|
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(margin));
|
|
|
|
}
|
|
|
|
|
|
|
|
void jni_YGNodeStyleSetMarginPercent(
|
|
|
|
jlong nativePointer,
|
|
|
|
jint edge,
|
|
|
|
jfloat percent) {
|
|
|
|
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
2019-03-20 08:39:34 -07:00
|
|
|
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
|
2019-02-28 12:42:22 -08:00
|
|
|
YGNodeStyleSetMarginPercent(
|
|
|
|
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent));
|
|
|
|
}
|
|
|
|
|
|
|
|
void jni_YGNodeStyleSetMarginAuto(jlong nativePointer, jint edge) {
|
|
|
|
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
2019-03-20 08:39:34 -07:00
|
|
|
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::MARGIN).setOn(yogaNodeRef);
|
2019-02-28 12:42:22 -08:00
|
|
|
YGNodeStyleSetMarginAuto(yogaNodeRef, static_cast<YGEdge>(edge));
|
|
|
|
}
|
|
|
|
|
|
|
|
local_ref<jobject> jni_YGNodeStyleGetPadding(
|
2019-03-22 09:30:25 -07:00
|
|
|
alias_ref<jclass>,
|
2019-02-28 12:42:22 -08:00
|
|
|
jlong nativePointer,
|
|
|
|
jint edge) {
|
|
|
|
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
2019-03-20 08:39:34 -07:00
|
|
|
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::PADDING)) {
|
2019-02-28 12:42:22 -08:00
|
|
|
return JYogaValue::create(YGValueUndefined);
|
|
|
|
}
|
|
|
|
return JYogaValue::create(
|
|
|
|
YGNodeStyleGetPadding(yogaNodeRef, static_cast<YGEdge>(edge)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void jni_YGNodeStyleSetPadding(jlong nativePointer, jint edge, jfloat padding) {
|
|
|
|
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
2019-03-20 08:39:34 -07:00
|
|
|
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::PADDING).setOn(yogaNodeRef);
|
2019-02-28 12:42:22 -08:00
|
|
|
YGNodeStyleSetPadding(
|
|
|
|
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(padding));
|
|
|
|
}
|
|
|
|
|
|
|
|
void jni_YGNodeStyleSetPaddingPercent(
|
|
|
|
jlong nativePointer,
|
|
|
|
jint edge,
|
|
|
|
jfloat percent) {
|
|
|
|
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
2019-03-20 08:39:34 -07:00
|
|
|
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::PADDING).setOn(yogaNodeRef);
|
2019-02-28 12:42:22 -08:00
|
|
|
YGNodeStyleSetPaddingPercent(
|
|
|
|
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(percent));
|
|
|
|
}
|
|
|
|
|
|
|
|
jfloat jni_YGNodeStyleGetBorder(jlong nativePointer, jint edge) {
|
|
|
|
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
2019-03-20 08:39:34 -07:00
|
|
|
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::BORDER)) {
|
2019-02-28 12:42:22 -08:00
|
|
|
return (jfloat) YGUndefined;
|
|
|
|
}
|
|
|
|
return (jfloat) YGNodeStyleGetBorder(yogaNodeRef, static_cast<YGEdge>(edge));
|
|
|
|
}
|
|
|
|
|
|
|
|
void jni_YGNodeStyleSetBorder(jlong nativePointer, jint edge, jfloat border) {
|
|
|
|
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
2019-03-20 08:39:34 -07:00
|
|
|
YGNodeEdges{yogaNodeRef}.add(YGNodeEdges::BORDER).setOn(yogaNodeRef);
|
2019-02-28 12:42:22 -08:00
|
|
|
YGNodeStyleSetBorder(
|
|
|
|
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(border));
|
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
|
2019-02-27 04:38:50 -08:00
|
|
|
#define YGMakeCriticalNativeMethod(name) \
|
|
|
|
makeCriticalNativeMethod_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(#name, name)
|
2018-09-25 15:44:40 -07:00
|
|
|
|
2018-07-11 04:09:39 -07:00
|
|
|
jint JNI_OnLoad(JavaVM* vm, void*) {
|
2016-12-03 04:40:18 -08:00
|
|
|
return initialize(vm, [] {
|
2018-11-22 03:59:22 -08:00
|
|
|
registerNatives(
|
2019-03-22 09:30:25 -07:00
|
|
|
"com/facebook/yoga/YogaNative",
|
2018-03-14 08:37:55 -07:00
|
|
|
{
|
2019-03-22 09:30:25 -07:00
|
|
|
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),
|
|
|
|
YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasis),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisPercent),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetFlexBasisAuto),
|
|
|
|
YGMakeNativeMethod(jni_YGNodeStyleGetMargin),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMargin),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginPercent),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMarginAuto),
|
|
|
|
YGMakeNativeMethod(jni_YGNodeStyleGetPadding),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPadding),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPaddingPercent),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetBorder),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetBorder),
|
|
|
|
YGMakeNativeMethod(jni_YGNodeStyleGetPosition),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPosition),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetPositionPercent),
|
|
|
|
YGMakeNativeMethod(jni_YGNodeStyleGetWidth),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidth),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthPercent),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetWidthAuto),
|
|
|
|
YGMakeNativeMethod(jni_YGNodeStyleGetHeight),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeight),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightPercent),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetHeightAuto),
|
|
|
|
YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidth),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinWidthPercent),
|
|
|
|
YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeight),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMinHeightPercent),
|
|
|
|
YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidth),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxWidthPercent),
|
|
|
|
YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeight),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodeGetInstanceCount),
|
|
|
|
YGMakeCriticalNativeMethod(jni_YGNodePrint),
|
|
|
|
YGMakeNativeMethod(jni_YGNodeSetStyleInputs),
|
2018-11-22 03:59:22 -08:00
|
|
|
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),
|
2018-03-14 08:37:55 -07:00
|
|
|
});
|
2016-12-03 04:40:18 -08:00
|
|
|
});
|
|
|
|
}
|