Allow decimal measurements on java

Summary: Preserve floating point values when passing them across the JNI bridge.

Differential Revision: D4366605

fbshipit-source-id: 0b94ee87a03a6ed918360dd9998930e780fc865d
This commit is contained in:
Emil Sjolander
2016-12-29 04:52:20 -08:00
committed by Facebook Github Bot
parent f2080e520f
commit 352f592767
3 changed files with 68 additions and 9 deletions

View File

@@ -15,18 +15,20 @@ package com.facebook.yoga;
public class YogaMeasureOutput {
public static long make(float width, float height) {
return make((int) width, (int) height);
final int wBits = Float.floatToRawIntBits(width);
final int hBits = Float.floatToRawIntBits(height);
return ((long) wBits) << 32 | ((long) hBits);
}
public static long make(int width, int height) {
return ((long) width) << 32 | ((long) height);
return make((float) width, (float) height);
}
public static int getWidth(long measureOutput) {
return (int) (0xFFFFFFFF & (measureOutput >> 32));
public static float getWidth(long measureOutput) {
return Float.intBitsToFloat((int) (0xFFFFFFFF & (measureOutput >> 32)));
}
public static int getHeight(long measureOutput) {
return (int) (0xFFFFFFFF & measureOutput);
public static float getHeight(long measureOutput) {
return Float.intBitsToFloat((int) (0xFFFFFFFF & measureOutput));
}
}