mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-03 22:48:25 +08:00
Execute Animated.js declarative animation on UIThread on Android.
Summary:This is the first from the series of PRs I'm going to be sending shorty that would let Animated.js animations to run off the JS thread (for Android only). This PR introduce a new native module that will be used for offloading animations - NativeAnimatedModule. It has a simple API that allows for animated nodes management via methods like: create/drop animated node, connect/disconnect nodes, start animation of a value node, attach/detach animated from a native view. Similarly to how we handle UIManager view hierarchy updates we create a queue of animated graph operations that are then executed on the UI thread. This isolates us from problems that may be caused by concurrent updates of animated graph while UI thread is "executing" the animation. The most important class NativeAnimatedNodesManager.java implements a management interface for animated nodes graph as well as implements a graph traversal algorithm that is run for each animation frame. For each animation frame we visit animated nodes th Closes https://github.com/facebook/react-native/pull/6466 Differential Revision: D3092739 Pulled By: astreet fb-gh-sync-id: 665b49900b7367c91a93b9d8864f78fb90bb36ba shipit-source-id: 665b49900b7367c91a93b9d8864f78fb90bb36ba
This commit is contained in:
committed by
Facebook Github Bot 5
parent
bd8007300f
commit
65ccdffc8d
@@ -21,6 +21,7 @@ import com.facebook.react.bridge.Callback;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener;
|
||||
import com.facebook.react.uimanager.events.EventDispatcher;
|
||||
@@ -79,6 +80,10 @@ public class UIImplementation {
|
||||
return mViewManagers.get(className);
|
||||
}
|
||||
|
||||
/*package*/ UIViewOperationQueue getUIViewOperationQueue() {
|
||||
return mOperationsQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a root node with a given tag, size and ThemedReactContext
|
||||
* and adds it to a node registry.
|
||||
@@ -179,6 +184,17 @@ public class UIImplementation {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by native animated module to bypass the process of updating the values through the shadow
|
||||
* view hierarchy. This method will directly update native views, which means that updates for
|
||||
* layout-related propertied won't be handled properly.
|
||||
* Make sure you know what you're doing before calling this method :)
|
||||
*/
|
||||
public void synchronouslyUpdateViewOnUIThread(int tag, ReactStylesDiffMap props) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
mOperationsQueue.getNativeViewHierarchyManager().updateProperties(tag, props);
|
||||
}
|
||||
|
||||
protected void handleUpdateView(
|
||||
ReactShadowNode cssNode,
|
||||
String className,
|
||||
|
||||
Reference in New Issue
Block a user