move YGNode related methods to vanilla jni
Summary: This diff moves methods related to actions on YGNode like free node, reset node etc. to vanilla JNI Reviewed By: amir-shalem Differential Revision: D17668008 fbshipit-source-id: 03bfc51ec1fcf06569713400f984d551827e22fe
This commit is contained in:
committed by
Facebook Github Bot
parent
8975019269
commit
34b68cf1d2
@@ -114,6 +114,17 @@ public class YogaNative {
|
||||
|
||||
|
||||
// JNI methods that use Vanilla JNI
|
||||
static native void jni_YGNodeFreeJNI(long nativePointer);
|
||||
static native void jni_YGNodeResetJNI(long nativePointer);
|
||||
static native void jni_YGNodeInsertChildJNI(long nativePointer, long childPointer, int index);
|
||||
static native void jni_YGNodeSetIsReferenceBaselineJNI(long nativePointer, boolean isReferenceBaseline);
|
||||
static native boolean jni_YGNodeIsReferenceBaselineJNI(long nativePointer);
|
||||
static native void jni_YGNodeClearChildrenJNI(long nativePointer);
|
||||
static native void jni_YGNodeRemoveChildJNI(long nativePointer, long childPointer);
|
||||
static native void jni_YGNodeMarkDirtyJNI(long nativePointer);
|
||||
static native void jni_YGNodeMarkDirtyAndPropogateToDescendantsJNI(long nativePointer);
|
||||
static native boolean jni_YGNodeIsDirtyJNI(long nativePointer);
|
||||
static native void jni_YGNodeCopyStyleJNI(long dstNativePointer, long srcNativePointer);
|
||||
static native int jni_YGNodeStyleGetDirectionJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetDirectionJNI(long nativePointer, int direction);
|
||||
static native int jni_YGNodeStyleGetFlexDirectionJNI(long nativePointer);
|
||||
@@ -178,4 +189,7 @@ public class YogaNative {
|
||||
static native void jni_YGNodeStyleSetMaxHeightPercentJNI(long nativePointer, float percent);
|
||||
static native float jni_YGNodeStyleGetAspectRatioJNI(long nativePointer);
|
||||
static native void jni_YGNodeStyleSetAspectRatioJNI(long nativePointer, float aspectRatio);
|
||||
static native void jni_YGNodePrintJNI(long nativePointer);
|
||||
static native void jni_YGNodeSetStyleInputsJNI(long nativePointer, float[] styleInputsArray, int size);
|
||||
static native long jni_YGNodeCloneJNI(long nativePointer);
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
|
||||
private boolean mHasNewLayout = true;
|
||||
|
||||
private boolean useVanillaJNI = false;
|
||||
protected boolean useVanillaJNI = false;
|
||||
|
||||
private YogaNodeJNIBase(long nativePointer) {
|
||||
if (nativePointer == 0) {
|
||||
@@ -72,7 +72,10 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
mHasNewLayout = true;
|
||||
mLayoutDirection = 0;
|
||||
|
||||
YogaNative.jni_YGNodeReset(mNativePointer);
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeResetJNI(mNativePointer);
|
||||
else
|
||||
YogaNative.jni_YGNodeReset(mNativePointer);
|
||||
}
|
||||
|
||||
public int getChildCount() {
|
||||
@@ -97,22 +100,28 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
}
|
||||
mChildren.add(i, child);
|
||||
child.mOwner = this;
|
||||
YogaNative.jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeInsertChildJNI(mNativePointer, child.mNativePointer, i);
|
||||
else
|
||||
YogaNative.jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
|
||||
}
|
||||
|
||||
public void setIsReferenceBaseline(boolean isReferenceBaseline) {
|
||||
YogaNative.jni_YGNodeSetIsReferenceBaseline(mNativePointer, isReferenceBaseline);
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeSetIsReferenceBaselineJNI(mNativePointer, isReferenceBaseline);
|
||||
else
|
||||
YogaNative.jni_YGNodeSetIsReferenceBaseline(mNativePointer, isReferenceBaseline);
|
||||
}
|
||||
|
||||
public boolean isReferenceBaseline() {
|
||||
return YogaNative.jni_YGNodeIsReferenceBaseline(mNativePointer);
|
||||
return useVanillaJNI ? YogaNative.jni_YGNodeIsReferenceBaselineJNI(mNativePointer) : YogaNative.jni_YGNodeIsReferenceBaseline(mNativePointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YogaNodeJNIBase cloneWithoutChildren() {
|
||||
try {
|
||||
YogaNodeJNIBase clonedYogaNode = (YogaNodeJNIBase) super.clone();
|
||||
long clonedNativePointer = YogaNative.jni_YGNodeClone(mNativePointer);
|
||||
long clonedNativePointer = useVanillaJNI ? YogaNative.jni_YGNodeCloneJNI(mNativePointer) : YogaNative.jni_YGNodeClone(mNativePointer);;
|
||||
clonedYogaNode.mOwner = null;
|
||||
clonedYogaNode.mNativePointer = clonedNativePointer;
|
||||
clonedYogaNode.clearChildren();
|
||||
@@ -125,7 +134,10 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
|
||||
private void clearChildren() {
|
||||
mChildren = null;
|
||||
YogaNative.jni_YGNodeClearChildren(mNativePointer);
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeClearChildrenJNI(mNativePointer);
|
||||
else
|
||||
YogaNative.jni_YGNodeClearChildren(mNativePointer);
|
||||
}
|
||||
|
||||
public YogaNodeJNIBase removeChildAt(int i) {
|
||||
@@ -135,7 +147,10 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
}
|
||||
final YogaNodeJNIBase child = mChildren.remove(i);
|
||||
child.mOwner = null;
|
||||
YogaNative.jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeRemoveChildJNI(mNativePointer, child.mNativePointer);
|
||||
else
|
||||
YogaNative.jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -186,20 +201,29 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
}
|
||||
|
||||
public void dirty() {
|
||||
YogaNative.jni_YGNodeMarkDirty(mNativePointer);
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeMarkDirtyJNI(mNativePointer);
|
||||
else
|
||||
YogaNative.jni_YGNodeMarkDirty(mNativePointer);
|
||||
}
|
||||
|
||||
public void dirtyAllDescendants() {
|
||||
YogaNative.jni_YGNodeMarkDirtyAndPropogateToDescendants(mNativePointer);
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeMarkDirtyAndPropogateToDescendantsJNI(mNativePointer);
|
||||
else
|
||||
YogaNative.jni_YGNodeMarkDirtyAndPropogateToDescendants(mNativePointer);
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return YogaNative.jni_YGNodeIsDirty(mNativePointer);
|
||||
return useVanillaJNI ? YogaNative.jni_YGNodeIsDirtyJNI(mNativePointer) : YogaNative.jni_YGNodeIsDirty(mNativePointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyStyle(YogaNode srcNode) {
|
||||
YogaNative.jni_YGNodeCopyStyle(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeCopyStyleJNI(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
|
||||
else
|
||||
YogaNative.jni_YGNodeCopyStyle(mNativePointer, ((YogaNodeJNIBase) srcNode).mNativePointer);
|
||||
}
|
||||
|
||||
public YogaDirection getStyleDirection() {
|
||||
@@ -633,7 +657,10 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
* layout of the tree rooted at this node.
|
||||
*/
|
||||
public void print() {
|
||||
YogaNative.jni_YGNodePrint(mNativePointer);
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodePrintJNI(mNativePointer);
|
||||
else
|
||||
YogaNative.jni_YGNodePrint(mNativePointer);
|
||||
}
|
||||
|
||||
public void setStyleInputs(float[] styleInputsArray, int size) {
|
||||
|
@@ -28,7 +28,10 @@ public class YogaNodeJNIFinalizer extends YogaNodeJNIBase {
|
||||
if (mNativePointer != 0) {
|
||||
long nativePointer = mNativePointer;
|
||||
mNativePointer = 0;
|
||||
YogaNative.jni_YGNodeFree(nativePointer);
|
||||
if (useVanillaJNI)
|
||||
YogaNative.jni_YGNodeFreeJNI(nativePointer);
|
||||
else
|
||||
YogaNative.jni_YGNodeFree(nativePointer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user