Summary: Migrate com.facebook.yoga.YogaMeasureOutput to Kotlin. Pull Request resolved: https://github.com/facebook/yoga/pull/1842 Test Plan: RN ```sh yarn android yarn test-android ``` Yoga ```sh ./gradlew :yoga:assembleDebug ``` Reviewed By: rshest Differential Revision: D79897681 Pulled By: cortinico fbshipit-source-id: 63280b6aed9bbeeb1e71458a1793c9647dcf0726
30 lines
949 B
Kotlin
30 lines
949 B
Kotlin
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
package com.facebook.yoga
|
|
|
|
/** Helpers for building measure output value. */
|
|
public object YogaMeasureOutput {
|
|
@JvmStatic
|
|
public fun make(width: Float, height: Float): Long {
|
|
val wBits = java.lang.Float.floatToRawIntBits(width)
|
|
val hBits = java.lang.Float.floatToRawIntBits(height)
|
|
return (wBits.toLong()) shl 32 or (hBits.toLong())
|
|
}
|
|
|
|
@JvmStatic
|
|
public fun make(width: Int, height: Int): Long = make(width.toFloat(), height.toFloat())
|
|
|
|
@JvmStatic
|
|
public fun getWidth(measureOutput: Long): Float =
|
|
java.lang.Float.intBitsToFloat((0xFFFFFFFFL and (measureOutput shr 32)).toInt())
|
|
|
|
@JvmStatic
|
|
public fun getHeight(measureOutput: Long): Float =
|
|
java.lang.Float.intBitsToFloat((0xFFFFFFFFL and measureOutput).toInt())
|
|
}
|