File tree 5 files changed +50
-0
lines changed
packages/react-native/ReactCommon/react/renderer
5 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -336,6 +336,13 @@ void Scheduler::uiManagerShouldRemoveEventListener(
336
336
removeEventListener (listener);
337
337
}
338
338
339
+ void Scheduler::uiManagerDidStartSurface (const ShadowTree& shadowTree) {
340
+ std::shared_lock lock (onSurfaceStartCallbackMutex_);
341
+ if (onSurfaceStartCallback_) {
342
+ onSurfaceStartCallback_ (shadowTree);
343
+ }
344
+ }
345
+
339
346
void Scheduler::reportMount (SurfaceId surfaceId) const {
340
347
uiManager_->reportMount (surfaceId);
341
348
}
@@ -362,4 +369,10 @@ void Scheduler::removeEventListener(
362
369
}
363
370
}
364
371
372
+ void Scheduler::uiManagerShouldSetOnSurfaceStartCallback (
373
+ OnSurfaceStartCallback&& callback) {
374
+ std::shared_lock lock (onSurfaceStartCallbackMutex_);
375
+ onSurfaceStartCallback_ = std::move (callback);
376
+ }
377
+
365
378
} // namespace facebook::react
Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ class Scheduler final : public UIManagerDelegate {
101
101
std::shared_ptr<const EventListener> listener) final ;
102
102
void uiManagerShouldRemoveEventListener (
103
103
const std::shared_ptr<const EventListener>& listener) final ;
104
+ void uiManagerDidStartSurface (const ShadowTree& shadowTree) override ;
104
105
105
106
#pragma mark - ContextContainer
106
107
ContextContainer::Shared getContextContainer () const ;
@@ -115,6 +116,10 @@ class Scheduler final : public UIManagerDelegate {
115
116
void removeEventListener (
116
117
const std::shared_ptr<const EventListener>& listener);
117
118
119
+ #pragma mark - Surface start callback
120
+ void uiManagerShouldSetOnSurfaceStartCallback (
121
+ OnSurfaceStartCallback&& callback) override ;
122
+
118
123
private:
119
124
friend class SurfaceHandler ;
120
125
@@ -144,6 +149,9 @@ class Scheduler final : public UIManagerDelegate {
144
149
ContextContainer::Shared contextContainer_;
145
150
146
151
RuntimeScheduler* runtimeScheduler_{nullptr };
152
+
153
+ mutable std::shared_mutex onSurfaceStartCallbackMutex_;
154
+ OnSurfaceStartCallback onSurfaceStartCallback_;
147
155
};
148
156
149
157
} // namespace facebook::react
Original file line number Diff line number Diff line change @@ -227,6 +227,13 @@ void UIManager::startSurface(
227
227
auto surfaceId = shadowTree->getSurfaceId ();
228
228
shadowTreeRegistry_.add (std::move (shadowTree));
229
229
230
+ shadowTreeRegistry_.visit (
231
+ surfaceId, [delegate = delegate_](const ShadowTree& shadowTree) {
232
+ if (delegate != nullptr ) {
233
+ delegate->uiManagerDidStartSurface (shadowTree);
234
+ }
235
+ });
236
+
230
237
runtimeExecutor_ ([=](jsi::Runtime& runtime) {
231
238
TraceSection s (" UIManager::startSurface::onRuntime" );
232
239
AppRegistryBinding::startSurface (
@@ -706,4 +713,11 @@ void UIManager::removeEventListener(
706
713
}
707
714
}
708
715
716
+ void UIManager::setOnSurfaceStartCallback (
717
+ UIManagerDelegate::OnSurfaceStartCallback&& callback) {
718
+ if (delegate_ != nullptr ) {
719
+ delegate_->uiManagerShouldSetOnSurfaceStartCallback (std::move (callback));
720
+ }
721
+ }
722
+
709
723
} // namespace facebook::react
Original file line number Diff line number Diff line change @@ -216,6 +216,10 @@ class UIManager final : public ShadowTreeDelegate {
216
216
void removeEventListener (
217
217
const std::shared_ptr<const EventListener>& listener);
218
218
219
+ #pragma mark - Set on surface start callback
220
+ void setOnSurfaceStartCallback (
221
+ UIManagerDelegate::OnSurfaceStartCallback&& callback);
222
+
219
223
private:
220
224
friend class UIManagerBinding ;
221
225
friend class Scheduler ;
Original file line number Diff line number Diff line change 10
10
#include < react/renderer/core/ReactPrimitives.h>
11
11
#include < react/renderer/core/ShadowNode.h>
12
12
#include < react/renderer/mounting/MountingCoordinator.h>
13
+ #include < react/renderer/mounting/ShadowTree.h>
13
14
14
15
namespace facebook ::react {
15
16
@@ -77,6 +78,16 @@ class UIManagerDelegate {
77
78
virtual void uiManagerShouldRemoveEventListener (
78
79
const std::shared_ptr<const EventListener>& listener) = 0;
79
80
81
+ /*
82
+ * Start surface.
83
+ */
84
+ virtual void uiManagerDidStartSurface (const ShadowTree& shadowTree) = 0;
85
+
86
+ using OnSurfaceStartCallback =
87
+ std::function<void (const ShadowTree& shadowTree)>;
88
+ virtual void uiManagerShouldSetOnSurfaceStartCallback (
89
+ OnSurfaceStartCallback&& callback) = 0;
90
+
80
91
virtual ~UIManagerDelegate () noexcept = default ;
81
92
};
82
93
You can’t perform that action at this time.
0 commit comments