Rounding error in width/height fixed
Summary: If the width has an exact dimension, while the left and right edges have a decimal part, that means the decimal part is equal and we can round both down instead of rounding left down and right up. Same for top and bottom. Reviewed By: emilsjolander Differential Revision: D5209073 Tags: accept2ship fbshipit-source-id: a3a6a43767aa707ebfa5eee62a83adcdd88d7ce6
This commit is contained in:
committed by
Facebook Github Bot
parent
a20bde8444
commit
ca483cae00
15
yoga/Yoga.c
15
yoga/Yoga.c
@@ -3456,11 +3456,22 @@ static void YGRoundToPixelGrid(const YGNodeRef node,
|
||||
node->layout.position[YGEdgeTop] =
|
||||
YGRoundValueToPixelGrid(nodeTop, pointScaleFactor, false, textRounding);
|
||||
|
||||
const bool hasFractionalWidth = !YGFloatsEqual(fmodf(nodeWidth, 1.0), 0);
|
||||
const bool hasFractionalHeight = !YGFloatsEqual(fmodf(nodeHeight, 1.0), 0);
|
||||
|
||||
node->layout.dimensions[YGDimensionWidth] =
|
||||
YGRoundValueToPixelGrid(absoluteNodeRight, pointScaleFactor, textRounding, false) -
|
||||
YGRoundValueToPixelGrid(
|
||||
absoluteNodeRight,
|
||||
pointScaleFactor,
|
||||
(textRounding && hasFractionalWidth),
|
||||
(textRounding && !hasFractionalWidth)) -
|
||||
YGRoundValueToPixelGrid(absoluteNodeLeft, pointScaleFactor, false, textRounding);
|
||||
node->layout.dimensions[YGDimensionHeight] =
|
||||
YGRoundValueToPixelGrid(absoluteNodeBottom, pointScaleFactor, textRounding, false) -
|
||||
YGRoundValueToPixelGrid(
|
||||
absoluteNodeBottom,
|
||||
pointScaleFactor,
|
||||
(textRounding && hasFractionalHeight),
|
||||
(textRounding && !hasFractionalHeight)) -
|
||||
YGRoundValueToPixelGrid(absoluteNodeTop, pointScaleFactor, false, textRounding);
|
||||
|
||||
const uint32_t childCount = YGNodeListCount(node->children);
|
||||
|
Reference in New Issue
Block a user