moved all yoga node jni batching code to YogaNodeJNIBase and removed subclasses
Summary: Removed classes YogaNodeJNI and YogaNodeJNIBatching and all the logic have been moved to base class Reviewed By: davidaurelio Differential Revision: D16221484 fbshipit-source-id: 830819f5bc6010291b8bc0c6d90897cea991909f
This commit is contained in:
committed by
Facebook Github Bot
parent
838fc3f019
commit
d676d917e3
@@ -10,11 +10,11 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public abstract class YogaNode {
|
public abstract class YogaNode {
|
||||||
public static YogaNode create() {
|
public static YogaNode create() {
|
||||||
return new YogaNodeJNIBatching();
|
return new YogaNodeJNIBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static YogaNode create(YogaConfig config) {
|
public static YogaNode create(YogaConfig config) {
|
||||||
return new YogaNodeJNIBatching(config);
|
return new YogaNodeJNIBase(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void reset();
|
public abstract void reset();
|
||||||
|
@@ -1,186 +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.
|
|
||||||
*/
|
|
||||||
package com.facebook.yoga;
|
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
|
||||||
|
|
||||||
@DoNotStrip
|
|
||||||
public class YogaNodeJNI extends YogaNodeJNIBase {
|
|
||||||
|
|
||||||
@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;
|
|
||||||
|
|
||||||
public YogaNodeJNI() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public YogaNodeJNI(YogaConfig config) {
|
|
||||||
super(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset() {
|
|
||||||
super.reset();
|
|
||||||
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;
|
|
||||||
|
|
||||||
mDoesLegacyStretchFlagAffectsLayout = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNewLayout() {
|
|
||||||
return mHasNewLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void markLayoutSeen() {
|
|
||||||
mHasNewLayout = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutX() {
|
|
||||||
return mLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutY() {
|
|
||||||
return mTop;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutWidth() {
|
|
||||||
return mWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutHeight() {
|
|
||||||
return mHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getDoesLegacyStretchFlagAffectsLayout() {
|
|
||||||
return mDoesLegacyStretchFlagAffectsLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutMargin(YogaEdge 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutPadding(YogaEdge 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutBorder(YogaEdge 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public YogaDirection getLayoutDirection() {
|
|
||||||
return YogaDirection.fromInt(mLayoutDirection);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -12,7 +12,24 @@ import java.util.List;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@DoNotStrip
|
@DoNotStrip
|
||||||
public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
public class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||||
|
|
||||||
|
/* Those flags needs be in sync with YGJNI.cpp */
|
||||||
|
private static final byte MARGIN = 1;
|
||||||
|
private static final byte PADDING = 2;
|
||||||
|
private static final byte BORDER = 4;
|
||||||
|
private static final byte DOES_LEGACY_STRETCH_BEHAVIOUR = 8;
|
||||||
|
private static final byte HAS_NEW_LAYOUT = 16;
|
||||||
|
|
||||||
|
private static final byte LAYOUT_EDGE_SET_FLAG_INDEX = 0;
|
||||||
|
private static final byte LAYOUT_WIDTH_INDEX = 1;
|
||||||
|
private static final byte LAYOUT_HEIGHT_INDEX = 2;
|
||||||
|
private static final byte LAYOUT_LEFT_INDEX = 3;
|
||||||
|
private static final byte LAYOUT_TOP_INDEX = 4;
|
||||||
|
private static final byte LAYOUT_DIRECTION_INDEX = 5;
|
||||||
|
private static final byte LAYOUT_MARGIN_START_INDEX = 6;
|
||||||
|
private static final byte LAYOUT_PADDING_START_INDEX = 10;
|
||||||
|
private static final byte LAYOUT_BORDER_START_INDEX = 14;
|
||||||
|
|
||||||
@Nullable private YogaNodeJNIBase mOwner;
|
@Nullable private YogaNodeJNIBase mOwner;
|
||||||
@Nullable private List<YogaNodeJNIBase> mChildren;
|
@Nullable private List<YogaNodeJNIBase> mChildren;
|
||||||
@@ -21,6 +38,14 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
private long mNativePointer;
|
private long mNativePointer;
|
||||||
@Nullable private Object mData;
|
@Nullable private Object mData;
|
||||||
|
|
||||||
|
@DoNotStrip
|
||||||
|
private @Nullable float[] arr = null;
|
||||||
|
|
||||||
|
@DoNotStrip
|
||||||
|
private int mLayoutDirection = 0;
|
||||||
|
|
||||||
|
private boolean mHasNewLayout = true;
|
||||||
|
|
||||||
public YogaNodeJNIBase() {
|
public YogaNodeJNIBase() {
|
||||||
mNativePointer = YogaNative.jni_YGNodeNew();
|
mNativePointer = YogaNative.jni_YGNodeNew();
|
||||||
if (mNativePointer == 0) {
|
if (mNativePointer == 0) {
|
||||||
@@ -56,6 +81,9 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
mMeasureFunction = null;
|
mMeasureFunction = null;
|
||||||
mBaselineFunction = null;
|
mBaselineFunction = null;
|
||||||
mData = null;
|
mData = null;
|
||||||
|
arr = null;
|
||||||
|
mHasNewLayout = true;
|
||||||
|
mLayoutDirection = 0;
|
||||||
|
|
||||||
YogaNative.jni_YGNodeReset(mNativePointer);
|
YogaNative.jni_YGNodeReset(mNativePointer);
|
||||||
}
|
}
|
||||||
@@ -443,8 +471,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
YogaNative.jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
|
YogaNative.jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean getDoesLegacyStretchFlagAffectsLayout();
|
|
||||||
|
|
||||||
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
|
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
|
||||||
mMeasureFunction = measureFunction;
|
mMeasureFunction = measureFunction;
|
||||||
YogaNative.jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
|
YogaNative.jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
|
||||||
@@ -530,4 +556,124 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
private static YogaValue valueFromLong(long raw) {
|
private static YogaValue valueFromLong(long raw) {
|
||||||
return new YogaValue(Float.intBitsToFloat((int) raw), (int) (raw >> 32));
|
return new YogaValue(Float.intBitsToFloat((int) raw), (int) (raw >> 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getLayoutX() {
|
||||||
|
return arr != null ? arr[LAYOUT_LEFT_INDEX] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getLayoutY() {
|
||||||
|
return arr != null ? arr[LAYOUT_TOP_INDEX] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getLayoutWidth() {
|
||||||
|
return arr != null ? arr[LAYOUT_WIDTH_INDEX] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getLayoutHeight() {
|
||||||
|
return arr != null ? arr[LAYOUT_HEIGHT_INDEX] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getDoesLegacyStretchFlagAffectsLayout() {
|
||||||
|
return arr != null && (((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & DOES_LEGACY_STRETCH_BEHAVIOUR) == DOES_LEGACY_STRETCH_BEHAVIOUR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getLayoutMargin(YogaEdge edge) {
|
||||||
|
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) {
|
||||||
|
switch (edge) {
|
||||||
|
case LEFT:
|
||||||
|
return arr[LAYOUT_MARGIN_START_INDEX];
|
||||||
|
case TOP:
|
||||||
|
return arr[LAYOUT_MARGIN_START_INDEX + 1];
|
||||||
|
case RIGHT:
|
||||||
|
return arr[LAYOUT_MARGIN_START_INDEX + 2];
|
||||||
|
case BOTTOM:
|
||||||
|
return arr[LAYOUT_MARGIN_START_INDEX + 3];
|
||||||
|
case START:
|
||||||
|
return getLayoutDirection() == YogaDirection.RTL ? arr[LAYOUT_MARGIN_START_INDEX + 2] : arr[LAYOUT_MARGIN_START_INDEX];
|
||||||
|
case END:
|
||||||
|
return getLayoutDirection() == YogaDirection.RTL ? arr[LAYOUT_MARGIN_START_INDEX] : arr[LAYOUT_MARGIN_START_INDEX + 2];
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Cannot get layout margins of multi-edge shorthands");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getLayoutPadding(YogaEdge edge) {
|
||||||
|
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & PADDING) == PADDING) {
|
||||||
|
int paddingStartIndex = LAYOUT_PADDING_START_INDEX - ((((int)arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) ? 0 : 4);
|
||||||
|
switch (edge) {
|
||||||
|
case LEFT:
|
||||||
|
return arr[paddingStartIndex];
|
||||||
|
case TOP:
|
||||||
|
return arr[paddingStartIndex + 1];
|
||||||
|
case RIGHT:
|
||||||
|
return arr[paddingStartIndex + 2];
|
||||||
|
case BOTTOM:
|
||||||
|
return arr[paddingStartIndex + 3];
|
||||||
|
case START:
|
||||||
|
return getLayoutDirection() == YogaDirection.RTL ? arr[paddingStartIndex + 2] : arr[paddingStartIndex];
|
||||||
|
case END:
|
||||||
|
return getLayoutDirection() == YogaDirection.RTL ? arr[paddingStartIndex] : arr[paddingStartIndex + 2];
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Cannot get layout paddings of multi-edge shorthands");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getLayoutBorder(YogaEdge edge) {
|
||||||
|
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & BORDER) == BORDER) {
|
||||||
|
int borderStartIndex = LAYOUT_BORDER_START_INDEX - ((((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) ? 0 : 4) - ((((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & PADDING) == PADDING) ? 0 : 4);
|
||||||
|
switch (edge) {
|
||||||
|
case LEFT:
|
||||||
|
return arr[borderStartIndex];
|
||||||
|
case TOP:
|
||||||
|
return arr[borderStartIndex + 1];
|
||||||
|
case RIGHT:
|
||||||
|
return arr[borderStartIndex + 2];
|
||||||
|
case BOTTOM:
|
||||||
|
return arr[borderStartIndex + 3];
|
||||||
|
case START:
|
||||||
|
return getLayoutDirection() == YogaDirection.RTL ? arr[borderStartIndex + 2] : arr[borderStartIndex];
|
||||||
|
case END:
|
||||||
|
return getLayoutDirection() == YogaDirection.RTL ? arr[borderStartIndex] : arr[borderStartIndex + 2];
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Cannot get layout border of multi-edge shorthands");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public YogaDirection getLayoutDirection() {
|
||||||
|
return YogaDirection.fromInt(arr != null ? (int) arr[LAYOUT_DIRECTION_INDEX] : mLayoutDirection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNewLayout() {
|
||||||
|
if (arr != null) {
|
||||||
|
return (((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX]) & HAS_NEW_LAYOUT) == HAS_NEW_LAYOUT;
|
||||||
|
} else {
|
||||||
|
return mHasNewLayout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void markLayoutSeen() {
|
||||||
|
if (arr != null) {
|
||||||
|
arr[LAYOUT_EDGE_SET_FLAG_INDEX] = ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX]) & ~(HAS_NEW_LAYOUT);
|
||||||
|
}
|
||||||
|
mHasNewLayout = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,177 +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.
|
|
||||||
*/
|
|
||||||
package com.facebook.yoga;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
|
||||||
|
|
||||||
@DoNotStrip
|
|
||||||
public class YogaNodeJNIBatching extends YogaNodeJNIBase {
|
|
||||||
|
|
||||||
/* Those flags needs be in sync with YGJNI.cpp */
|
|
||||||
private static final byte MARGIN = 1;
|
|
||||||
private static final byte PADDING = 2;
|
|
||||||
private static final byte BORDER = 4;
|
|
||||||
private static final byte DOES_LEGACY_STRETCH_BEHAVIOUR = 8;
|
|
||||||
private static final byte HAS_NEW_LAYOUT = 16;
|
|
||||||
|
|
||||||
private static final byte LAYOUT_EDGE_SET_FLAG_INDEX = 0;
|
|
||||||
private static final byte LAYOUT_WIDTH_INDEX = 1;
|
|
||||||
private static final byte LAYOUT_HEIGHT_INDEX = 2;
|
|
||||||
private static final byte LAYOUT_LEFT_INDEX = 3;
|
|
||||||
private static final byte LAYOUT_TOP_INDEX = 4;
|
|
||||||
private static final byte LAYOUT_DIRECTION_INDEX = 5;
|
|
||||||
private static final byte LAYOUT_MARGIN_START_INDEX = 6;
|
|
||||||
private static final byte LAYOUT_PADDING_START_INDEX = 10;
|
|
||||||
private static final byte LAYOUT_BORDER_START_INDEX = 14;
|
|
||||||
|
|
||||||
@DoNotStrip
|
|
||||||
private @Nullable float[] arr = null;
|
|
||||||
|
|
||||||
@DoNotStrip
|
|
||||||
private int mLayoutDirection = 0;
|
|
||||||
|
|
||||||
private boolean mHasNewLayout = true;
|
|
||||||
|
|
||||||
public YogaNodeJNIBatching() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public YogaNodeJNIBatching(YogaConfig config) {
|
|
||||||
super(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset() {
|
|
||||||
super.reset();
|
|
||||||
arr = null;
|
|
||||||
mHasNewLayout = true;
|
|
||||||
mLayoutDirection = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutX() {
|
|
||||||
return arr != null ? arr[LAYOUT_LEFT_INDEX] : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutY() {
|
|
||||||
return arr != null ? arr[LAYOUT_TOP_INDEX] : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutWidth() {
|
|
||||||
return arr != null ? arr[LAYOUT_WIDTH_INDEX] : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutHeight() {
|
|
||||||
return arr != null ? arr[LAYOUT_HEIGHT_INDEX] : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getDoesLegacyStretchFlagAffectsLayout() {
|
|
||||||
return arr != null && (((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & DOES_LEGACY_STRETCH_BEHAVIOUR) == DOES_LEGACY_STRETCH_BEHAVIOUR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutMargin(YogaEdge edge) {
|
|
||||||
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) {
|
|
||||||
switch (edge) {
|
|
||||||
case LEFT:
|
|
||||||
return arr[LAYOUT_MARGIN_START_INDEX];
|
|
||||||
case TOP:
|
|
||||||
return arr[LAYOUT_MARGIN_START_INDEX + 1];
|
|
||||||
case RIGHT:
|
|
||||||
return arr[LAYOUT_MARGIN_START_INDEX + 2];
|
|
||||||
case BOTTOM:
|
|
||||||
return arr[LAYOUT_MARGIN_START_INDEX + 3];
|
|
||||||
case START:
|
|
||||||
return getLayoutDirection() == YogaDirection.RTL ? arr[LAYOUT_MARGIN_START_INDEX + 2] : arr[LAYOUT_MARGIN_START_INDEX];
|
|
||||||
case END:
|
|
||||||
return getLayoutDirection() == YogaDirection.RTL ? arr[LAYOUT_MARGIN_START_INDEX] : arr[LAYOUT_MARGIN_START_INDEX + 2];
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Cannot get layout margins of multi-edge shorthands");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutPadding(YogaEdge edge) {
|
|
||||||
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & PADDING) == PADDING) {
|
|
||||||
int paddingStartIndex = LAYOUT_PADDING_START_INDEX - ((((int)arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) ? 0 : 4);
|
|
||||||
switch (edge) {
|
|
||||||
case LEFT:
|
|
||||||
return arr[paddingStartIndex];
|
|
||||||
case TOP:
|
|
||||||
return arr[paddingStartIndex + 1];
|
|
||||||
case RIGHT:
|
|
||||||
return arr[paddingStartIndex + 2];
|
|
||||||
case BOTTOM:
|
|
||||||
return arr[paddingStartIndex + 3];
|
|
||||||
case START:
|
|
||||||
return getLayoutDirection() == YogaDirection.RTL ? arr[paddingStartIndex + 2] : arr[paddingStartIndex];
|
|
||||||
case END:
|
|
||||||
return getLayoutDirection() == YogaDirection.RTL ? arr[paddingStartIndex] : arr[paddingStartIndex + 2];
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Cannot get layout paddings of multi-edge shorthands");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getLayoutBorder(YogaEdge edge) {
|
|
||||||
if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & BORDER) == BORDER) {
|
|
||||||
int borderStartIndex = LAYOUT_BORDER_START_INDEX - ((((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) ? 0 : 4) - ((((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & PADDING) == PADDING) ? 0 : 4);
|
|
||||||
switch (edge) {
|
|
||||||
case LEFT:
|
|
||||||
return arr[borderStartIndex];
|
|
||||||
case TOP:
|
|
||||||
return arr[borderStartIndex + 1];
|
|
||||||
case RIGHT:
|
|
||||||
return arr[borderStartIndex + 2];
|
|
||||||
case BOTTOM:
|
|
||||||
return arr[borderStartIndex + 3];
|
|
||||||
case START:
|
|
||||||
return getLayoutDirection() == YogaDirection.RTL ? arr[borderStartIndex + 2] : arr[borderStartIndex];
|
|
||||||
case END:
|
|
||||||
return getLayoutDirection() == YogaDirection.RTL ? arr[borderStartIndex] : arr[borderStartIndex + 2];
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Cannot get layout border of multi-edge shorthands");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public YogaDirection getLayoutDirection() {
|
|
||||||
return YogaDirection.fromInt(arr != null ? (int) arr[LAYOUT_DIRECTION_INDEX] : mLayoutDirection);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNewLayout() {
|
|
||||||
if (arr != null) {
|
|
||||||
return (((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX]) & HAS_NEW_LAYOUT) == HAS_NEW_LAYOUT;
|
|
||||||
} else {
|
|
||||||
return mHasNewLayout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void markLayoutSeen() {
|
|
||||||
if (arr != null) {
|
|
||||||
arr[LAYOUT_EDGE_SET_FLAG_INDEX] = ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX]) & ~(HAS_NEW_LAYOUT);
|
|
||||||
}
|
|
||||||
mHasNewLayout = false;
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user