Used hasDirtyChildren tag for the optimization
Summary: More fine grained dirty marking Currently a node's dirty flag propagates to the root of the tree ensuring that when any node is invalidated its whole subtree will be re-calculated. This is often times not needed. There are many properties which only effects a node's children and would not need to propagate all the way to the root such as align-items. Also in cases where the style does change layout it may not need to propagate all the way to the root but can often stop at the nearest position: absolute parent. This change has the potential of greatly improving performance of re-calculating a tree. This might require adding a second dirty flag named hasDirtyDescendants ensuring that traversal still works even though a parent is not marked as dirty. Reviewed By: emilsjolander Differential Revision: D6134754 fbshipit-source-id: bbcfee14058140b946401de756a3f130de0f51cd
This commit is contained in:
committed by
Facebook Github Bot
parent
132b016bae
commit
c5182c4bf5
@@ -9,13 +9,11 @@
|
||||
|
||||
package com.facebook.yoga;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@DoNotStrip
|
||||
public class YogaNode {
|
||||
@@ -198,6 +196,12 @@ public class YogaNode {
|
||||
return jni_YGNodeIsDirty(mNativePointer);
|
||||
}
|
||||
|
||||
private native boolean jni_YGNodeHasDirtyDescendants(long nativePointer);
|
||||
|
||||
public boolean hasDirtyDescendants() {
|
||||
return jni_YGNodeHasDirtyDescendants(mNativePointer);
|
||||
}
|
||||
|
||||
private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
|
||||
public void copyStyle(YogaNode srcNode) {
|
||||
jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
|
||||
|
@@ -249,6 +249,10 @@ jboolean jni_YGNodeIsDirty(alias_ref<jobject>, jlong nativePointer) {
|
||||
return (jboolean) YGNodeIsDirty(_jlong2YGNodeRef(nativePointer));
|
||||
}
|
||||
|
||||
jboolean jni_YGNodeHasDirtyDescendants(alias_ref<jobject>, jlong nativePointer) {
|
||||
return (jboolean) YGNodeHasDirtyDescendants(_jlong2YGNodeRef(nativePointer));
|
||||
}
|
||||
|
||||
void jni_YGNodeSetHasMeasureFunc(alias_ref<jobject>, jlong nativePointer, jboolean hasMeasureFunc) {
|
||||
YGNodeSetMeasureFunc(_jlong2YGNodeRef(nativePointer), hasMeasureFunc ? YGJNIMeasureFunc : NULL);
|
||||
}
|
||||
@@ -453,6 +457,7 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
|
||||
YGMakeNativeMethod(jni_YGNodeCalculateLayout),
|
||||
YGMakeNativeMethod(jni_YGNodeMarkDirty),
|
||||
YGMakeNativeMethod(jni_YGNodeIsDirty),
|
||||
YGMakeNativeMethod(jni_YGNodeHasDirtyDescendants),
|
||||
YGMakeNativeMethod(jni_YGNodeSetHasMeasureFunc),
|
||||
YGMakeNativeMethod(jni_YGNodeSetHasBaselineFunc),
|
||||
YGMakeNativeMethod(jni_YGNodeCopyStyle),
|
||||
|
Reference in New Issue
Block a user