Summary: Preserve floating point values when passing them across the JNI bridge. Differential Revision: D4366605 fbshipit-source-id: 0b94ee87a03a6ed918360dd9998930e780fc865d
35 lines
1013 B
Java
35 lines
1013 B
Java
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
package com.facebook.yoga;
|
|
|
|
/**
|
|
* Helpers for building measure output value.
|
|
*/
|
|
public class YogaMeasureOutput {
|
|
|
|
public static long make(float width, float 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 make((float) width, (float) height);
|
|
}
|
|
|
|
public static float getWidth(long measureOutput) {
|
|
return Float.intBitsToFloat((int) (0xFFFFFFFF & (measureOutput >> 32)));
|
|
}
|
|
|
|
public static float getHeight(long measureOutput) {
|
|
return Float.intBitsToFloat((int) (0xFFFFFFFF & measureOutput));
|
|
}
|
|
}
|