Allow decimal measurements on java
Differential Revision: D4366605 fbshipit-source-id: 0b94ee87a03a6ed918360dd9998930e780fc865d
This commit is contained in:
parent
573170699f
commit
c7c24dce84
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,10 +67,13 @@ static YGSize YGJNIMeasureFunc(YGNodeRef node,
|
|||
static_assert(sizeof(measureResult) == 8,
|
||||
"Expected measureResult to be 8 bytes, or two 32 bit ints");
|
||||
|
||||
const float measuredWidth = static_cast<float>(0xFFFFFFFF & (measureResult >> 32));
|
||||
const float measuredHeight = static_cast<float>(0xFFFFFFFF & measureResult);
|
||||
int32_t wBits = 0xFFFFFFFF & (measureResult >> 32);
|
||||
int32_t hBits = 0xFFFFFFFF & measureResult;
|
||||
|
||||
return YGSize{measuredWidth, measuredHeight};
|
||||
const float *measuredWidth = reinterpret_cast<float*>(&wBits);
|
||||
const float *measuredHeight = reinterpret_cast<float*>(&hBits);
|
||||
|
||||
return YGSize{*measuredWidth, *measuredHeight};
|
||||
} else {
|
||||
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
|
||||
return YGSize{
|
||||
|
|
Loading…
Reference in New Issue