Back to JNI storage

Summary:
@public

This reverts the Yoga/Java storage experiment. I will follow up with any learnings.

Reviewed By: pasqualeanatriello

Differential Revision: D9168405

fbshipit-source-id: fb227fb9353bd4c4e3bebbe9b04eec1132e532e8
This commit is contained in:
David Aurelio
2018-08-06 02:10:43 -07:00
committed by Facebook Github Bot
parent be78bfbd8c
commit 78cdf3cadc
14 changed files with 369 additions and 2780 deletions

View File

@@ -21,74 +21,132 @@ public class YogaNode implements Cloneable {
SoLoader.loadLibrary("yoga");
}
public static final int BYTE_BUFFER = 1;
public static final int HYBRID = 2;
public static final int UNSAFE = 3;
/** Get native instance count. Useful for testing only. */
/**
* Get native instance count. Useful for testing only.
*/
static native int jni_YGNodeGetInstanceCount();
private YogaNodeProperties mDelegate;
private YogaNode mOwner;
@Nullable private List<YogaNode> mChildren;
private YogaMeasureFunction mMeasureFunction;
private YogaBaselineFunction mBaselineFunction;
private long mNativePointer;
private Object mData;
/* Those flags needs be in sync with YGJNI.cpp */
private static final int MARGIN = 1;
private static final int PADDING = 2;
private static final int BORDER = 4;
@DoNotStrip
private int mEdgeSetFlag = 0;
private boolean mHasSetPosition = false;
@DoNotStrip
private float mWidth = YogaConstants.UNDEFINED;
@DoNotStrip
private float mHeight = YogaConstants.UNDEFINED;
@DoNotStrip
private float mTop = YogaConstants.UNDEFINED;
@DoNotStrip
private float mLeft = YogaConstants.UNDEFINED;
@DoNotStrip
private float mMarginLeft = 0;
@DoNotStrip
private float mMarginTop = 0;
@DoNotStrip
private float mMarginRight = 0;
@DoNotStrip
private float mMarginBottom = 0;
@DoNotStrip
private float mPaddingLeft = 0;
@DoNotStrip
private float mPaddingTop = 0;
@DoNotStrip
private float mPaddingRight = 0;
@DoNotStrip
private float mPaddingBottom = 0;
@DoNotStrip
private float mBorderLeft = 0;
@DoNotStrip
private float mBorderTop = 0;
@DoNotStrip
private float mBorderRight = 0;
@DoNotStrip
private float mBorderBottom = 0;
@DoNotStrip
private int mLayoutDirection = 0;
@DoNotStrip
private boolean mHasNewLayout = true;
@DoNotStrip private boolean mDoesLegacyStretchFlagAffectsLayout = false;
private native long jni_YGNodeNew();
public YogaNode() {
mDelegate = new YogaNodePropertiesJNI(this);
mNativePointer = jni_YGNodeNew();
if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
}
}
private native long jni_YGNodeNewWithConfig(long configPointer);
public YogaNode(YogaConfig config) {
mDelegate = new YogaNodePropertiesJNI(this, config);
}
public YogaNode(int storageType) {
switch (storageType) {
case BYTE_BUFFER:
mDelegate = new YogaNodePropertiesByteBuffer(this);
break;
case HYBRID:
mDelegate = new YogaNodePropertiesHybrid(this);
break;
case UNSAFE:
mDelegate = new YogaNodePropertiesUnsafe(this);
break;
default:
mDelegate = new YogaNodePropertiesJNI(this);
mNativePointer = jni_YGNodeNewWithConfig(config.mNativePointer);
if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
}
}
public YogaNode(int storageType, YogaConfig config) {
switch (storageType) {
case BYTE_BUFFER:
mDelegate = new YogaNodePropertiesByteBuffer(this, config);
break;
case HYBRID:
mDelegate = new YogaNodePropertiesHybrid(this, config);
break;
case UNSAFE:
mDelegate = new YogaNodePropertiesUnsafe(this, config);
break;
default:
mDelegate = new YogaNodePropertiesJNI(this, config);
@Override
protected void finalize() throws Throwable {
try {
freeNatives();
} finally {
super.finalize();
}
}
public long getNativePointer() {
return mDelegate.getNativePointer();
}
private static native void jni_YGNodeFree(long nativePointer);
/* frees the native underlying YGNode. Useful for testing. */
public void freeNatives() {
mDelegate.freeNatives();
if (mNativePointer > 0) {
long nativePointer = mNativePointer;
mNativePointer = 0;
jni_YGNodeFree(nativePointer);
}
}
private native void jni_YGNodeReset(long nativePointer);
public void reset() {
mEdgeSetFlag = 0;
mHasSetPosition = false;
mHasNewLayout = true;
mWidth = YogaConstants.UNDEFINED;
mHeight = YogaConstants.UNDEFINED;
mTop = YogaConstants.UNDEFINED;
mLeft = YogaConstants.UNDEFINED;
mMarginLeft = 0;
mMarginTop = 0;
mMarginRight = 0;
mMarginBottom = 0;
mPaddingLeft = 0;
mPaddingTop = 0;
mPaddingRight = 0;
mPaddingBottom = 0;
mBorderLeft = 0;
mBorderTop = 0;
mBorderRight = 0;
mBorderBottom = 0;
mLayoutDirection = 0;
mMeasureFunction = null;
mBaselineFunction = null;
mData = null;
mDelegate.reset();
mDoesLegacyStretchFlagAffectsLayout = false;
jni_YGNodeReset(mNativePointer);
}
public int getChildCount() {
@@ -113,7 +171,7 @@ public class YogaNode implements Cloneable {
}
mChildren.add(i, child);
child.mOwner = this;
jni_YGNodeInsertChild(getNativePointer(), child.getNativePointer(), i);
jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
}
private native void jni_YGNodeInsertSharedChild(long nativePointer, long childPointer, int index);
@@ -124,24 +182,27 @@ public class YogaNode implements Cloneable {
}
mChildren.add(i, child);
child.mOwner = null;
jni_YGNodeInsertSharedChild(getNativePointer(), child.getNativePointer(), i);
jni_YGNodeInsertSharedChild(mNativePointer, child.mNativePointer, i);
}
private native void jni_YGNodeSetOwner(long nativePointer, long newOwnerNativePointer);
private native long jni_YGNodeClone(long nativePointer, Object newNode);
@Override
public YogaNode clone() {
try {
YogaNode clonedYogaNode = (YogaNode) super.clone();
long clonedNativePointer = jni_YGNodeClone(mNativePointer, clonedYogaNode);
if (mChildren != null) {
for (YogaNode child : mChildren) {
child.jni_YGNodeSetOwner(child.getNativePointer(), 0);
child.jni_YGNodeSetOwner(child.mNativePointer, 0);
child.mOwner = null;
}
}
clonedYogaNode.mDelegate = mDelegate.clone(clonedYogaNode);
clonedYogaNode.mNativePointer = clonedNativePointer;
clonedYogaNode.mOwner = null;
clonedYogaNode.mChildren =
mChildren != null ? (List<YogaNode>) ((ArrayList) mChildren).clone() : null;
@@ -160,8 +221,9 @@ public class YogaNode implements Cloneable {
public YogaNode cloneWithNewChildren() {
try {
YogaNode clonedYogaNode = (YogaNode) super.clone();
clonedYogaNode.mDelegate = mDelegate.clone(clonedYogaNode);
long clonedNativePointer = jni_YGNodeClone(mNativePointer, clonedYogaNode);
clonedYogaNode.mOwner = null;
clonedYogaNode.mNativePointer = clonedNativePointer;
clonedYogaNode.clearChildren();
return clonedYogaNode;
} catch (CloneNotSupportedException ex) {
@@ -174,7 +236,7 @@ public class YogaNode implements Cloneable {
private void clearChildren() {
mChildren = null;
jni_YGNodeClearChildren(getNativePointer());
jni_YGNodeClearChildren(mNativePointer);
}
private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
@@ -185,7 +247,7 @@ public class YogaNode implements Cloneable {
}
final YogaNode child = mChildren.remove(i);
child.mOwner = null;
jni_YGNodeRemoveChild(getNativePointer(), child.getNativePointer());
jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
return child;
}
@@ -213,329 +275,455 @@ public class YogaNode implements Cloneable {
return mChildren == null ? -1 : mChildren.indexOf(child);
}
private native boolean jni_YGNodeCalculateLayout(long nativePointer, float width, float height);
private native void jni_YGNodeCalculateLayout(long nativePointer, float width, float height);
public void calculateLayout(float width, float height) {
boolean hasNewLayout = jni_YGNodeCalculateLayout(getNativePointer(), width, height);
mDelegate.onAfterCalculateLayout(hasNewLayout);
jni_YGNodeCalculateLayout(mNativePointer, width, height);
}
public boolean hasNewLayout() {
return mDelegate.hasNewLayout();
return mHasNewLayout;
}
private native void jni_YGNodeMarkDirty(long nativePointer);
public void dirty() {
jni_YGNodeMarkDirty(getNativePointer());
jni_YGNodeMarkDirty(mNativePointer);
}
private native void jni_YGNodeMarkDirtyAndPropogateToDescendants(long nativePointer);
public void dirtyAllDescendants() {
jni_YGNodeMarkDirtyAndPropogateToDescendants(getNativePointer());
jni_YGNodeMarkDirtyAndPropogateToDescendants(mNativePointer);
}
private native boolean jni_YGNodeIsDirty(long nativePointer);
public boolean isDirty() {
return mDelegate.isDirty();
return jni_YGNodeIsDirty(mNativePointer);
}
private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
public void copyStyle(YogaNode srcNode) {
jni_YGNodeCopyStyle(getNativePointer(), srcNode.getNativePointer());
jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
}
public void markLayoutSeen() {
mDelegate.markLayoutSeen();
mHasNewLayout = false;
}
private native int jni_YGNodeStyleGetDirection(long nativePointer);
public YogaDirection getStyleDirection() {
return mDelegate.getStyleDirection();
return YogaDirection.fromInt(jni_YGNodeStyleGetDirection(mNativePointer));
}
private native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
public void setDirection(YogaDirection direction) {
mDelegate.setDirection(direction);
jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
}
private native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
public YogaFlexDirection getFlexDirection() {
return mDelegate.getFlexDirection();
return YogaFlexDirection.fromInt(jni_YGNodeStyleGetFlexDirection(mNativePointer));
}
private native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
public void setFlexDirection(YogaFlexDirection flexDirection) {
mDelegate.setFlexDirection(flexDirection);
jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
}
private native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
public YogaJustify getJustifyContent() {
return mDelegate.getJustifyContent();
return YogaJustify.fromInt(jni_YGNodeStyleGetJustifyContent(mNativePointer));
}
private native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
public void setJustifyContent(YogaJustify justifyContent) {
mDelegate.setJustifyContent(justifyContent);
jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
}
private native int jni_YGNodeStyleGetAlignItems(long nativePointer);
public YogaAlign getAlignItems() {
return mDelegate.getAlignItems();
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignItems(mNativePointer));
}
private native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
public void setAlignItems(YogaAlign alignItems) {
mDelegate.setAlignItems(alignItems);
jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
}
private native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
public YogaAlign getAlignSelf() {
return mDelegate.getAlignSelf();
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignSelf(mNativePointer));
}
private native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
public void setAlignSelf(YogaAlign alignSelf) {
mDelegate.setAlignSelf(alignSelf);
jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
}
private native int jni_YGNodeStyleGetAlignContent(long nativePointer);
public YogaAlign getAlignContent() {
return mDelegate.getAlignContent();
return YogaAlign.fromInt(jni_YGNodeStyleGetAlignContent(mNativePointer));
}
private native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
public void setAlignContent(YogaAlign alignContent) {
mDelegate.setAlignContent(alignContent);
jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
}
private native int jni_YGNodeStyleGetPositionType(long nativePointer);
public YogaPositionType getPositionType() {
return mDelegate.getPositionType();
return YogaPositionType.fromInt(jni_YGNodeStyleGetPositionType(mNativePointer));
}
private native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
public void setPositionType(YogaPositionType positionType) {
mDelegate.setPositionType(positionType);
jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
}
private native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
public void setWrap(YogaWrap flexWrap) {
mDelegate.setWrap(flexWrap);
jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
}
private native int jni_YGNodeStyleGetOverflow(long nativePointer);
public YogaOverflow getOverflow() {
return mDelegate.getOverflow();
return YogaOverflow.fromInt(jni_YGNodeStyleGetOverflow(mNativePointer));
}
private native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
public void setOverflow(YogaOverflow overflow) {
mDelegate.setOverflow(overflow);
jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
}
private native int jni_YGNodeStyleGetDisplay(long nativePointer);
public YogaDisplay getDisplay() {
return mDelegate.getDisplay();
return YogaDisplay.fromInt(jni_YGNodeStyleGetDisplay(mNativePointer));
}
private native void jni_YGNodeStyleSetDisplay(long nativePointer, int display);
public void setDisplay(YogaDisplay display) {
mDelegate.setDisplay(display);
jni_YGNodeStyleSetDisplay(mNativePointer, display.intValue());
}
private native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
public void setFlex(float flex) {
mDelegate.setFlex(flex);
jni_YGNodeStyleSetFlex(mNativePointer, flex);
}
private native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
public float getFlexGrow() {
return mDelegate.getFlexGrow();
return jni_YGNodeStyleGetFlexGrow(mNativePointer);
}
private native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
public void setFlexGrow(float flexGrow) {
mDelegate.setFlexGrow(flexGrow);
jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
}
private native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
public float getFlexShrink() {
return mDelegate.getFlexShrink();
return jni_YGNodeStyleGetFlexShrink(mNativePointer);
}
private native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
public void setFlexShrink(float flexShrink) {
mDelegate.setFlexShrink(flexShrink);
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
}
private native Object jni_YGNodeStyleGetFlexBasis(long nativePointer);
public YogaValue getFlexBasis() {
return mDelegate.getFlexBasis();
return (YogaValue) jni_YGNodeStyleGetFlexBasis(mNativePointer);
}
private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
public void setFlexBasis(float flexBasis) {
mDelegate.setFlexBasis(flexBasis);
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
}
private native void jni_YGNodeStyleSetFlexBasisPercent(long nativePointer, float percent);
public void setFlexBasisPercent(float percent) {
mDelegate.setFlexBasisPercent(percent);
jni_YGNodeStyleSetFlexBasisPercent(mNativePointer, percent);
}
private native void jni_YGNodeStyleSetFlexBasisAuto(long nativePointer);
public void setFlexBasisAuto() {
mDelegate.setFlexBasisAuto();
jni_YGNodeStyleSetFlexBasisAuto(mNativePointer);
}
private native Object jni_YGNodeStyleGetMargin(long nativePointer, int edge);
public YogaValue getMargin(YogaEdge edge) {
return mDelegate.getMargin(edge);
if (!((mEdgeSetFlag & MARGIN) == MARGIN)) {
return YogaValue.UNDEFINED;
}
return (YogaValue) jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
}
private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
public void setMargin(YogaEdge edge, float margin) {
mDelegate.setMargin(edge, margin);
mEdgeSetFlag |= MARGIN;
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
}
private native void jni_YGNodeStyleSetMarginPercent(long nativePointer, int edge, float percent);
public void setMarginPercent(YogaEdge edge, float percent) {
mDelegate.setMarginPercent(edge, percent);
mEdgeSetFlag |= MARGIN;
jni_YGNodeStyleSetMarginPercent(mNativePointer, edge.intValue(), percent);
}
private native void jni_YGNodeStyleSetMarginAuto(long nativePointer, int edge);
public void setMarginAuto(YogaEdge edge) {
mDelegate.setMarginAuto(edge);
mEdgeSetFlag |= MARGIN;
jni_YGNodeStyleSetMarginAuto(mNativePointer, edge.intValue());
}
private native Object jni_YGNodeStyleGetPadding(long nativePointer, int edge);
public YogaValue getPadding(YogaEdge edge) {
return mDelegate.getPadding(edge);
if (!((mEdgeSetFlag & PADDING) == PADDING)) {
return YogaValue.UNDEFINED;
}
return (YogaValue) jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
}
private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
public void setPadding(YogaEdge edge, float padding) {
mDelegate.setPadding(edge, padding);
mEdgeSetFlag |= PADDING;
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
}
private native void jni_YGNodeStyleSetPaddingPercent(long nativePointer, int edge, float percent);
public void setPaddingPercent(YogaEdge edge, float percent) {
mDelegate.setPaddingPercent(edge, percent);
mEdgeSetFlag |= PADDING;
jni_YGNodeStyleSetPaddingPercent(mNativePointer, edge.intValue(), percent);
}
private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
public float getBorder(YogaEdge edge) {
return mDelegate.getBorder(edge);
if (!((mEdgeSetFlag & BORDER) == BORDER)) {
return YogaConstants.UNDEFINED;
}
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
}
private native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
public void setBorder(YogaEdge edge, float border) {
mDelegate.setBorder(edge, border);
mEdgeSetFlag |= BORDER;
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
}
private native Object jni_YGNodeStyleGetPosition(long nativePointer, int edge);
public YogaValue getPosition(YogaEdge edge) {
return mDelegate.getPosition(edge);
if (!mHasSetPosition) {
return YogaValue.UNDEFINED;
}
return (YogaValue) jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue());
}
private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
public void setPosition(YogaEdge edge, float position) {
mDelegate.setPosition(edge, position);
mHasSetPosition = true;
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
}
private native void jni_YGNodeStyleSetPositionPercent(long nativePointer, int edge, float percent);
public void setPositionPercent(YogaEdge edge, float percent) {
mDelegate.setPositionPercent(edge, percent);
mHasSetPosition = true;
jni_YGNodeStyleSetPositionPercent(mNativePointer, edge.intValue(), percent);
}
private native Object jni_YGNodeStyleGetWidth(long nativePointer);
public YogaValue getWidth() {
return mDelegate.getWidth();
return (YogaValue) jni_YGNodeStyleGetWidth(mNativePointer);
}
private native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
public void setWidth(float width) {
mDelegate.setWidth(width);
jni_YGNodeStyleSetWidth(mNativePointer, width);
}
private native void jni_YGNodeStyleSetWidthPercent(long nativePointer, float percent);
public void setWidthPercent(float percent) {
mDelegate.setWidthPercent(percent);
jni_YGNodeStyleSetWidthPercent(mNativePointer, percent);
}
private native void jni_YGNodeStyleSetWidthAuto(long nativePointer);
public void setWidthAuto() {
mDelegate.setWidthAuto();
jni_YGNodeStyleSetWidthAuto(mNativePointer);
}
private native Object jni_YGNodeStyleGetHeight(long nativePointer);
public YogaValue getHeight() {
return mDelegate.getHeight();
return (YogaValue) jni_YGNodeStyleGetHeight(mNativePointer);
}
private native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
public void setHeight(float height) {
mDelegate.setHeight(height);
jni_YGNodeStyleSetHeight(mNativePointer, height);
}
private native void jni_YGNodeStyleSetHeightPercent(long nativePointer, float percent);
public void setHeightPercent(float percent) {
mDelegate.setHeightPercent(percent);
jni_YGNodeStyleSetHeightPercent(mNativePointer, percent);
}
private native void jni_YGNodeStyleSetHeightAuto(long nativePointer);
public void setHeightAuto() {
mDelegate.setHeightAuto();
jni_YGNodeStyleSetHeightAuto(mNativePointer);
}
private native Object jni_YGNodeStyleGetMinWidth(long nativePointer);
public YogaValue getMinWidth() {
return mDelegate.getMinWidth();
return (YogaValue) jni_YGNodeStyleGetMinWidth(mNativePointer);
}
private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
public void setMinWidth(float minWidth) {
mDelegate.setMinWidth(minWidth);
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
}
private native void jni_YGNodeStyleSetMinWidthPercent(long nativePointer, float percent);
public void setMinWidthPercent(float percent) {
mDelegate.setMinWidthPercent(percent);
jni_YGNodeStyleSetMinWidthPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMinHeight(long nativePointer);
public YogaValue getMinHeight() {
return mDelegate.getMinHeight();
return (YogaValue) jni_YGNodeStyleGetMinHeight(mNativePointer);
}
private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
public void setMinHeight(float minHeight) {
mDelegate.setMinHeight(minHeight);
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
}
private native void jni_YGNodeStyleSetMinHeightPercent(long nativePointer, float percent);
public void setMinHeightPercent(float percent) {
mDelegate.setMinHeightPercent(percent);
jni_YGNodeStyleSetMinHeightPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMaxWidth(long nativePointer);
public YogaValue getMaxWidth() {
return mDelegate.getMaxWidth();
return (YogaValue) jni_YGNodeStyleGetMaxWidth(mNativePointer);
}
private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
public void setMaxWidth(float maxWidth) {
mDelegate.setMaxWidth(maxWidth);
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
}
private native void jni_YGNodeStyleSetMaxWidthPercent(long nativePointer, float percent);
public void setMaxWidthPercent(float percent) {
mDelegate.setMaxWidthPercent(percent);
jni_YGNodeStyleSetMaxWidthPercent(mNativePointer, percent);
}
private native Object jni_YGNodeStyleGetMaxHeight(long nativePointer);
public YogaValue getMaxHeight() {
return mDelegate.getMaxHeight();
return (YogaValue) jni_YGNodeStyleGetMaxHeight(mNativePointer);
}
private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
public void setMaxHeight(float maxheight) {
mDelegate.setMaxHeight(maxheight);
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
}
private native void jni_YGNodeStyleSetMaxHeightPercent(long nativePointer, float percent);
public void setMaxHeightPercent(float percent) {
mDelegate.setMaxHeightPercent(percent);
jni_YGNodeStyleSetMaxHeightPercent(mNativePointer, percent);
}
private native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
public float getAspectRatio() {
return mDelegate.getAspectRatio();
return jni_YGNodeStyleGetAspectRatio(mNativePointer);
}
private native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
public void setAspectRatio(float aspectRatio) {
mDelegate.setAspectRatio(aspectRatio);
jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
}
public float getLayoutX() {
return mDelegate.getLayoutX();
return mLeft;
}
public float getLayoutY() {
return mDelegate.getLayoutY();
return mTop;
}
public float getLayoutWidth() {
return mDelegate.getLayoutWidth();
return mWidth;
}
public float getLayoutHeight() {
return mDelegate.getLayoutHeight();
return mHeight;
}
public boolean getDoesLegacyStretchFlagAffectsLayout() {
return mDelegate.getDoesLegacyStretchFlagAffectsLayout();
return mDoesLegacyStretchFlagAffectsLayout;
}
public float getLayoutMargin(YogaEdge edge) {
return mDelegate.getLayoutMargin(edge);
switch (edge) {
case LEFT:
return mMarginLeft;
case TOP:
return mMarginTop;
case RIGHT:
return mMarginRight;
case BOTTOM:
return mMarginBottom;
case START:
return getLayoutDirection() == YogaDirection.RTL ? mMarginRight : mMarginLeft;
case END:
return getLayoutDirection() == YogaDirection.RTL ? mMarginLeft : mMarginRight;
default:
throw new IllegalArgumentException("Cannot get layout margins of multi-edge shorthands");
}
}
public float getLayoutPadding(YogaEdge edge) {
return mDelegate.getLayoutPadding(edge);
switch (edge) {
case LEFT:
return mPaddingLeft;
case TOP:
return mPaddingTop;
case RIGHT:
return mPaddingRight;
case BOTTOM:
return mPaddingBottom;
case START:
return getLayoutDirection() == YogaDirection.RTL ? mPaddingRight : mPaddingLeft;
case END:
return getLayoutDirection() == YogaDirection.RTL ? mPaddingLeft : mPaddingRight;
default:
throw new IllegalArgumentException("Cannot get layout paddings of multi-edge shorthands");
}
}
public float getLayoutBorder(YogaEdge edge) {
return mDelegate.getLayoutBorder(edge);
switch (edge) {
case LEFT:
return mBorderLeft;
case TOP:
return mBorderTop;
case RIGHT:
return mBorderRight;
case BOTTOM:
return mBorderBottom;
case START:
return getLayoutDirection() == YogaDirection.RTL ? mBorderRight : mBorderLeft;
case END:
return getLayoutDirection() == YogaDirection.RTL ? mBorderLeft : mBorderRight;
default:
throw new IllegalArgumentException("Cannot get layout border of multi-edge shorthands");
}
}
public YogaDirection getLayoutDirection() {
return mDelegate.getLayoutDirection();
return YogaDirection.fromInt(mLayoutDirection);
}
private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
mMeasureFunction = measureFunction;
jni_YGNodeSetHasMeasureFunc(getNativePointer(), measureFunction != null);
jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
}
// Implementation Note: Why this method needs to stay final
@@ -560,7 +748,7 @@ public class YogaNode implements Cloneable {
private native void jni_YGNodeSetHasBaselineFunc(long nativePointer, boolean hasMeasureFunc);
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
mBaselineFunction = baselineFunction;
jni_YGNodeSetHasBaselineFunc(getNativePointer(), baselineFunction != null);
jni_YGNodeSetHasBaselineFunc(mNativePointer, baselineFunction != null);
}
@DoNotStrip
@@ -587,7 +775,7 @@ public class YogaNode implements Cloneable {
* layout of the tree rooted at this node.
*/
public void print() {
jni_YGNodePrint(getNativePointer());
jni_YGNodePrint(mNativePointer);
}
/**
@@ -605,6 +793,6 @@ public class YogaNode implements Cloneable {
mChildren.remove(childIndex);
mChildren.add(childIndex, newNode);
newNode.mOwner = this;
return newNode.getNativePointer();
return newNode.mNativePointer;
}
}