BREAKING - Change measure() api to remove need for MeasureOutput allocation

Summary: This is an API breaking change done to allow us to avoid an allocation during measurement. Instead we do the same trick as is done when passing measure results to C, we path them into a long.

Reviewed By: splhack

Differential Revision: D4081037

fbshipit-source-id: 28adbcdd160cbd3f59a0fdd4b9f1200ae18678f1
This commit is contained in:
Emil Sjolander
2016-10-27 10:52:09 -07:00
committed by Facebook Github Bot
parent c34299edc9
commit b59ce09109
10 changed files with 64 additions and 41 deletions

View File

@@ -10,10 +10,23 @@
package com.facebook.csslayout;
/**
* POJO to hold the output of the measure function.
* Helpers for building measure output value.
*/
public class MeasureOutput {
public float width;
public float height;
public static long make(float width, float height) {
return make((int) width, (int) height);
}
public static long make(int width, int height) {
return ((long) width) << 32 | ((long) height);
}
public static int getWidth(long measureOutput) {
return (int) (0xFFFFFFFF & (measureOutput >> 32));
}
public static int getHeight(long measureOutput) {
return (int) (0xFFFFFFFF & measureOutput);
}
}