Use floats to prevent double calculation + float casting on scale

Summary:
Use ```float``` for calculation, as we would calculate with ```double``` and cast to float afterwards otherwise. So this removes the warning.
Closes https://github.com/facebook/yoga/pull/450

Reviewed By: astreet

Differential Revision: D4642267

Pulled By: emilsjolander

fbshipit-source-id: 184ef24474f2b8a42654a71a8e98839296648b2b
This commit is contained in:
Lukas Wöhrl
2017-03-03 10:16:41 -08:00
committed by Facebook Github Bot
parent e7d2792009
commit b2a4e67fee

View File

@@ -3290,18 +3290,18 @@ bool YGLayoutNodeInternal(const YGNodeRef node,
static float gPointScaleFactor = 1.0; static float gPointScaleFactor = 1.0;
void YGSetPointScaleFactor(float pixelsInPoint) { void YGSetPointScaleFactor(float pixelsInPoint) {
YG_ASSERT(pixelsInPoint >= 0.0, "Scale factor should not be less than zero"); YG_ASSERT(pixelsInPoint >= 0.0f, "Scale factor should not be less than zero");
// We store points for Pixel as we will use it for rounding // We store points for Pixel as we will use it for rounding
if (pixelsInPoint == 0.0) { if (pixelsInPoint == 0.0f) {
// Zero is used to skip rounding // Zero is used to skip rounding
gPointScaleFactor = 0.0; gPointScaleFactor = 0.0f;
} else { } else {
gPointScaleFactor = 1.0 / pixelsInPoint; gPointScaleFactor = 1.0f / pixelsInPoint;
} }
} }
static void YGRoundToPixelGrid(const YGNodeRef node) { static void YGRoundToPixelGrid(const YGNodeRef node) {
if (gPointScaleFactor == 0.0) { if (gPointScaleFactor == 0.0f) {
return; return;
} }
const float nodeLeft = node->layout.position[YGEdgeLeft]; const float nodeLeft = node->layout.position[YGEdgeLeft];