Skip to content

Commit 0bee1b2

Browse files
Bartlomiej Bloniarzfacebook-github-bot
authored andcommitted
Expose the backend via UIManager
Differential Revision: D81137954
1 parent d740def commit 0bee1b2

3 files changed

Lines changed: 18 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::weak_ptr<AnimationBackend> animationBackend) {
683+
animationBackend_ = animationBackend;
684+
}
685+
686+
std::weak_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: 5 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:
@@ -62,6 +63,8 @@ class UIManager final : public ShadowTreeDelegate {
6263
* the pointer before being destroyed.
6364
*/
6465
void setAnimationDelegate(UIManagerAnimationDelegate* delegate);
66+
void setAnimationBackend(std::weak_ptr<AnimationBackend> animationBackend);
67+
std::weak_ptr<AnimationBackend> getAnimationBackend();
6568

6669
/**
6770
* Execute stopSurface on any UIMAnagerAnimationDelegate.
@@ -258,6 +261,8 @@ class UIManager final : public ShadowTreeDelegate {
258261

259262
std::unique_ptr<LazyShadowTreeRevisionConsistencyManager>
260263
lazyShadowTreeRevisionConsistencyManager_;
264+
265+
std::weak_ptr<AnimationBackend> animationBackend_;
261266
};
262267

263268
} // namespace facebook::react

0 commit comments

Comments
 (0)