Gather command and node region information off the UI thread.

Summary: This optimizes node region searches in clipping cases, and does position calculation for drawCommands off of the UI thread.

Reviewed By: ahmedre

Differential Revision: D3665301
This commit is contained in:
Seth Kirby
2016-08-08 16:05:36 -07:00
committed by Ahmed El-Helw
parent ca79e6cf30
commit 192c99a4f6
13 changed files with 598 additions and 105 deletions

View File

@@ -15,7 +15,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import android.graphics.Rect;
import android.util.SparseIntArray;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
@@ -82,6 +82,55 @@ import com.facebook.react.uimanager.ViewManagerRegistry;
}
}
/**
* Updates DrawCommands and AttachDetachListeners of a clipping FlatViewGroup specified by a
* reactTag.
*
* @param reactTag The react tag to lookup FlatViewGroup by.
* @param drawCommands If non-null, new draw commands to execute during the drawing.
* @param drawViewIndexMap Mapping of react tags to the index of the corresponding DrawView
* command in the draw command array.
* @param commandMaxBot At each index i, the maximum bottom value (or right value in the case of
* horizontal clipping) value of all draw commands at or below i.
* @param commandMinTop At each index i, the minimum top value (or left value in the case of
* horizontal clipping) value of all draw commands at or below i.
* @param listeners If non-null, new attach-detach listeners.
* @param nodeRegions Node regions to mount.
* @param regionMaxBot At each index i, the maximum bottom value (or right value in the case of
* horizontal clipping) value of all node regions at or below i.
* @param regionMinTop At each index i, the minimum top value (or left value in the case of
* horizontal clipping) value of all draw commands at or below i.
* @param willMountViews Whether we are going to also send a mountViews command in this state
* cycle.
*/
/* package */ void updateClippingMountState(
int reactTag,
@Nullable DrawCommand[] drawCommands,
SparseIntArray drawViewIndexMap,
float[] commandMaxBot,
float[] commandMinTop,
@Nullable AttachDetachListener[] listeners,
@Nullable NodeRegion[] nodeRegions,
float[] regionMaxBot,
float[] regionMinTop,
boolean willMountViews) {
FlatViewGroup view = (FlatViewGroup) resolveView(reactTag);
if (drawCommands != null) {
view.mountClippingDrawCommands(
drawCommands,
drawViewIndexMap,
commandMaxBot,
commandMinTop,
willMountViews);
}
if (listeners != null) {
view.mountAttachDetachListeners(listeners);
}
if (nodeRegions != null) {
view.mountClippingNodeRegions(nodeRegions, regionMaxBot, regionMinTop);
}
}
/* package */ void updateViewGroup(int reactTag, int[] viewsToAdd, int[] viewsToDetach) {
View view = resolveView(reactTag);
if (view instanceof FlatViewGroup) {