Skip to content

Commit 24ead8f

Browse files
Bartlomiej Bloniarzfacebook-github-bot
authored andcommitted
Expose the backend via UIManager
Differential Revision: D81137954
1 parent 702ce5e commit 24ead8f

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

packages/react-native/ReactCommon/react/renderer/animated/NativeAnimatedNodesManagerProvider.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,17 @@ NativeAnimatedNodesManagerProvider::getOrCreate(
6666
};
6767

6868
if (ReactNativeFeatureFlags::useSharedAnimatedBackend()) {
69+
// TODO: this should be initialized outside of animated, but for now it
70+
// was convenient to do it here
6971
animationBackend_ = std::make_shared<AnimationBackend>(
7072
std::move(startOnRenderCallback_),
7173
std::move(stopOnRenderCallback_),
7274
std::move(directManipulationCallback));
7375

7476
nativeAnimatedNodesManager_ =
7577
std::make_shared<NativeAnimatedNodesManager>(animationBackend_);
78+
79+
uiManager->setAnimationBackend(animationBackend_);
7680
} else {
7781
nativeAnimatedNodesManager_ =
7882
std::make_shared<NativeAnimatedNodesManager>(

packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,15 @@ void UIManager::setNativeAnimatedDelegate(
678678
nativeAnimatedDelegate_ = delegate;
679679
}
680680

681+
void UIManager::setAnimationBackend(
682+
std::shared_ptr<AnimationBackend> animationBackend) {
683+
animationBackend_ = animationBackend;
684+
}
685+
686+
std::shared_ptr<AnimationBackend> UIManager::getAnimationBackend() {
687+
return animationBackend_;
688+
}
689+
681690
void UIManager::animationTick() const {
682691
if (animationDelegate_ != nullptr &&
683692
animationDelegate_->shouldAnimateFrame()) {

packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace facebook::react {
3636
class UIManagerBinding;
3737
class UIManagerCommitHook;
3838
class UIManagerMountHook;
39+
class AnimationBackend;
3940

4041
class UIManager final : public ShadowTreeDelegate {
4142
public:
@@ -55,13 +56,16 @@ class UIManager final : public ShadowTreeDelegate {
5556
*/
5657
void setDelegate(UIManagerDelegate* delegate);
5758
UIManagerDelegate* getDelegate();
59+
std::shared_ptr<AnimationBackend> animationBackend_;
5860

5961
/**
6062
* Sets and gets the UIManager's Animation APIs delegate.
6163
* The delegate is stored as a raw pointer, so the owner must null
6264
* the pointer before being destroyed.
6365
*/
6466
void setAnimationDelegate(UIManagerAnimationDelegate* delegate);
67+
void setAnimationBackend(std::shared_ptr<AnimationBackend> animationBackend);
68+
std::shared_ptr<AnimationBackend> getAnimationBackend();
6569

6670
/**
6771
* Execute stopSurface on any UIMAnagerAnimationDelegate.

0 commit comments

Comments
 (0)