Add YogaNodeProperties implementation with ByteBuffer based setters

Summary:
@public
Adds an implementation of `YogaNodeProperties` that sets style properties using a `ByteBuffer` rather than JNI calls.
We hope for a speed improvement.

Reviewed By: pasqualeanatriello

Differential Revision: D9042225

fbshipit-source-id: c7f2b24eaeddd1190755bec85a5034079bd2f492
This commit is contained in:
David Aurelio
2018-07-30 09:30:54 -07:00
committed by Facebook Github Bot
parent 3499e2e0ef
commit 78d6988461
5 changed files with 347 additions and 38 deletions

View File

@@ -21,6 +21,9 @@ public class YogaNode implements Cloneable {
SoLoader.loadLibrary("yoga");
}
public static final int BYTE_BUFFER = 1;
public static final int HYBRID = 2;
/** Get native instance count. Useful for testing only. */
static native int jni_YGNodeGetInstanceCount();
@@ -39,12 +42,30 @@ public class YogaNode implements Cloneable {
mDelegate = new YogaNodePropertiesJNI(this, config);
}
public YogaNode(boolean unsafeClownyUseByteBufferValueDoesNotMatter) {
mDelegate = new YogaNodePropertiesByteBuffer(this);
public YogaNode(int storageType) {
switch (storageType) {
case BYTE_BUFFER:
mDelegate = new YogaNodePropertiesByteBuffer(this);
break;
case HYBRID:
mDelegate = new YogaNodePropertiesHybrid(this);
break;
default:
mDelegate = new YogaNodePropertiesJNI(this);
}
}
public YogaNode(boolean unsafeClownyUseByteBufferValueDoesNotMatter, YogaConfig config) {
mDelegate = new YogaNodePropertiesByteBuffer(this, config);
public YogaNode(int storageType, YogaConfig config) {
switch (storageType) {
case BYTE_BUFFER:
mDelegate = new YogaNodePropertiesByteBuffer(this, config);
break;
case HYBRID:
mDelegate = new YogaNodePropertiesHybrid(this, config);
break;
default:
mDelegate = new YogaNodePropertiesJNI(this, config);
}
}
public long getNativePointer() {