Remove legacy layout diffing
Summary: This removes some unused flags which will cause Yoga to layout every tree twice, then diffing the tree, reporting whether the whole tree is different. This is too expensive to run outside of local experimentation, but we have more nuanced ways to implement the `YGNodeLayoutAffectedByQuirk` I am wanting to add. Changelog: [Internal] Reviewed By: lunaleaps Differential Revision: D42406917 fbshipit-source-id: b415ed02768f6b59de3a6fa90c60c750d56fd4b0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cac197f5a6
commit
9e1bcd8557
@@ -25,14 +25,6 @@ public abstract class YogaConfig {
|
||||
*/
|
||||
public abstract void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour);
|
||||
|
||||
/**
|
||||
* If this flag is set then yoga would diff the layout without legacy flag and would set a bool in
|
||||
* YogaNode(mDoesLegacyStretchFlagAffectsLayout) with true if the layouts were different and false
|
||||
* if not
|
||||
*/
|
||||
public abstract void setShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
boolean shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
||||
|
||||
public abstract void setLogger(YogaLogger logger);
|
||||
|
||||
public abstract YogaLogger getLogger();
|
||||
|
@@ -52,17 +52,6 @@ public abstract class YogaConfigJNIBase extends YogaConfig {
|
||||
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviourJNI(mNativePointer, useLegacyStretchBehaviour);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this flag is set then yoga would diff the layout without legacy flag and would set a bool in
|
||||
* YogaNode(mDoesLegacyStretchFlagAffectsLayout) with true if the layouts were different and false
|
||||
* if not
|
||||
*/
|
||||
public void setShouldDiffLayoutWithoutLegacyStretchBehaviour(
|
||||
boolean shouldDiffLayoutWithoutLegacyStretchBehaviour) {
|
||||
YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI(
|
||||
mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
||||
}
|
||||
|
||||
public void setLogger(YogaLogger logger) {
|
||||
mLogger = logger;
|
||||
YogaNative.jni_YGConfigSetLoggerJNI(mNativePointer, logger);
|
||||
|
@@ -25,7 +25,6 @@ public class YogaNative {
|
||||
static native void jni_YGConfigSetPrintTreeFlagJNI(long nativePointer, boolean enable);
|
||||
static native void jni_YGConfigSetPointScaleFactorJNI(long nativePointer, float pixelsInPoint);
|
||||
static native void jni_YGConfigSetUseLegacyStretchBehaviourJNI(long nativePointer, boolean useLegacyStretchBehaviour);
|
||||
static native void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI(long nativePointer, boolean shouldDiffLayoutWithoutLegacyStretchBehaviour);
|
||||
static native void jni_YGConfigSetLoggerJNI(long nativePointer, YogaLogger logger);
|
||||
|
||||
// YGNode related
|
||||
|
@@ -19,7 +19,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
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;
|
||||
@@ -606,12 +605,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
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) {
|
||||
|
@@ -17,7 +17,6 @@ const short int LAYOUT_BORDER_START_INDEX = 14;
|
||||
|
||||
namespace {
|
||||
|
||||
const int DOES_LEGACY_STRETCH_BEHAVIOUR = 8;
|
||||
const int HAS_NEW_LAYOUT = 16;
|
||||
|
||||
union YGNodeContext {
|
||||
|
@@ -57,15 +57,6 @@ static void jni_YGConfigSetExperimentalFeatureEnabledJNI(
|
||||
config, static_cast<YGExperimentalFeature>(feature), enabled);
|
||||
}
|
||||
|
||||
static void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI(
|
||||
JNIEnv* env,
|
||||
jobject obj,
|
||||
jlong nativePointer,
|
||||
jboolean enabled) {
|
||||
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
|
||||
YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(config, enabled);
|
||||
}
|
||||
|
||||
static void jni_YGConfigSetUseWebDefaultsJNI(
|
||||
JNIEnv* env,
|
||||
jobject obj,
|
||||
@@ -294,9 +285,6 @@ static void YGTransferLayoutOutputsRecursive(
|
||||
|
||||
int fieldFlags = edgesSet.get();
|
||||
fieldFlags |= HAS_NEW_LAYOUT;
|
||||
if (YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root)) {
|
||||
fieldFlags |= DOES_LEGACY_STRETCH_BEHAVIOUR;
|
||||
}
|
||||
|
||||
const int arrSize = 6 + (marginFieldSet ? 4 : 0) + (paddingFieldSet ? 4 : 0) +
|
||||
(borderFieldSet ? 4 : 0);
|
||||
@@ -776,9 +764,6 @@ static JNINativeMethod methods[] = {
|
||||
{"jni_YGConfigSetUseLegacyStretchBehaviourJNI",
|
||||
"(JZ)V",
|
||||
(void*) jni_YGConfigSetUseLegacyStretchBehaviourJNI},
|
||||
{"jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI",
|
||||
"(JZ)V",
|
||||
(void*) jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI},
|
||||
{"jni_YGConfigSetLoggerJNI",
|
||||
"(JLcom/facebook/yoga/YogaLogger;)V",
|
||||
(void*) jni_YGConfigSetLoggerJNI},
|
||||
|
@@ -233,29 +233,6 @@ public class YogaNodeTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlagShouldDiffLayoutWithoutLegacyStretchBehaviour() throws Exception {
|
||||
YogaConfig config = YogaConfigFactory.create();
|
||||
config.setShouldDiffLayoutWithoutLegacyStretchBehaviour(true);
|
||||
config.setUseLegacyStretchBehaviour(true);
|
||||
YogaNode root = createNode(config);
|
||||
root.setWidth(500);
|
||||
root.setHeight(500);
|
||||
YogaNode root_child0 = createNode(config);
|
||||
root_child0.setAlignItems(YogaAlign.FLEX_START);
|
||||
root.addChildAt(root_child0, 0);
|
||||
YogaNode root_child0_child0 = createNode(config);
|
||||
root_child0_child0.setFlexGrow(1);
|
||||
root_child0_child0.setFlexShrink(1);
|
||||
root_child0.addChildAt(root_child0_child0, 0);
|
||||
YogaNode root_child0_child0_child0 = createNode(config);
|
||||
root_child0_child0_child0.setFlexGrow(1);
|
||||
root_child0_child0_child0.setFlexShrink(1);
|
||||
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
assertTrue(((YogaNodeJNIBase) root).getDoesLegacyStretchFlagAffectsLayout());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initiallyHasNewLayout() {
|
||||
YogaNode root = createNode();
|
||||
@@ -315,7 +292,6 @@ public class YogaNodeTest {
|
||||
@Test
|
||||
public void testResetApiShouldResetAllLayoutOutputs() {
|
||||
YogaConfig config = YogaConfigFactory.create();
|
||||
config.setShouldDiffLayoutWithoutLegacyStretchBehaviour(true);
|
||||
config.setUseLegacyStretchBehaviour(true);
|
||||
YogaNode node = createNode(config);
|
||||
node.setWidth(100);
|
||||
@@ -371,7 +347,6 @@ public class YogaNodeTest {
|
||||
assertTrue(node.hasNewLayout());
|
||||
assertFalse(node.isMeasureDefined());
|
||||
assertFalse(node.isBaselineDefined());
|
||||
assertFalse(((YogaNodeJNIBase) node).getDoesLegacyStretchFlagAffectsLayout());
|
||||
assertEquals(null, node.getData());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user