Add rounding to the pixel grid to Yoga
Summary: This diff adds rounding to the pixel grid feature to Yoga and appropriate property Reviewed By: emilsjolander Differential Revision: D4565980 fbshipit-source-id: 9700f6d6ed147f82b19f230fbff2e9ccbd625b25
This commit is contained in:
committed by
Facebook Github Bot
parent
3ad4d7dd6e
commit
37ec1774a7
@@ -39,13 +39,44 @@ TEST(YogaTest, rounding_feature_with_custom_measure_func_floor) {
|
||||
YGNodeSetMeasureFunc(root_child0, _measureFloor);
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
YGSetPointScaleFactor(0.0);
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(10.2, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(10.2, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGSetPointScaleFactor(1.0);
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGSetPointScaleFactor(2.0);
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGSetPointScaleFactor(4.0);
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(10.25, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(10.25, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGSetPointScaleFactor(1.0 / 3.0);
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(9.0, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(9.0, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetPointScaleFactor(1.0);
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
||||
@@ -58,6 +89,8 @@ TEST(YogaTest, rounding_feature_with_custom_measure_func_ceil) {
|
||||
YGNodeSetMeasureFunc(root_child0, _measureCeil);
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
YGSetPointScaleFactor(1.0);
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
ASSERT_FLOAT_EQ(11, YGNodeLayoutGetWidth(root_child0));
|
||||
@@ -65,5 +98,6 @@ TEST(YogaTest, rounding_feature_with_custom_measure_func_ceil) {
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGSetPointScaleFactor(1.0);
|
||||
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user