Skip to content

Move rncxx scheduler to oss #50535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.

#include "SchedulerDelegateImpl.h"

namespace facebook::react {

SchedulerDelegateImpl::SchedulerDelegateImpl(
std::shared_ptr<IMountingManager> mountingManager) noexcept
: mountingManager_(std::move(mountingManager)) {}

void SchedulerDelegateImpl::schedulerDidFinishTransaction(
const std::shared_ptr<const MountingCoordinator>& /*mountingCoordinator*/) {
// no-op, we will flush the transaction from schedulerShouldRenderTransactions
}

void SchedulerDelegateImpl::schedulerShouldRenderTransactions(
const std::shared_ptr<const MountingCoordinator>& mountingCoordinator) {
auto surfaceId = mountingCoordinator->getSurfaceId();
if (auto transaction = mountingCoordinator->pullTransaction();
transaction.has_value()) {
if (auto& transactionValue = transaction.value();
!transactionValue.getMutations().empty()) {
mountingManager_->executeMount(surfaceId, std::move(transactionValue));
}
}
}

void SchedulerDelegateImpl::schedulerDidRequestPreliminaryViewAllocation(
const ShadowNode& shadowNode) {}

void SchedulerDelegateImpl::schedulerDidDispatchCommand(
const ShadowView& shadowView,
const std::string& commandName,
const folly::dynamic& args) {
mountingManager_->dispatchCommand(shadowView, commandName, args);
}

void SchedulerDelegateImpl::schedulerDidSetIsJSResponder(
const ShadowView& shadowView,
bool isJSResponder,
bool blockNativeResponder) {
mountingManager_->setIsJSResponder(
shadowView, isJSResponder, blockNativeResponder);
}

void SchedulerDelegateImpl::schedulerDidSendAccessibilityEvent(
const ShadowView& shadowView,
const std::string& eventType) {}

void SchedulerDelegateImpl::schedulerShouldSynchronouslyUpdateViewOnUIThread(
Tag tag,
const folly::dynamic& props) {
mountingManager_->synchronouslyUpdateViewOnUIThread(tag, props);
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.

#pragma once

#include <react/renderer/scheduler/SchedulerDelegate.h>
#include <react/renderer/uimanager/IMountingManager.h>

namespace facebook::react {

class IMountingManager;

class SchedulerDelegateImpl : public SchedulerDelegate {
public:
SchedulerDelegateImpl(
std::shared_ptr<IMountingManager> mountingManager) noexcept;

~SchedulerDelegateImpl() noexcept override = default;

SchedulerDelegateImpl(SchedulerDelegateImpl&&) noexcept = default;
SchedulerDelegateImpl& operator=(SchedulerDelegateImpl&&) noexcept = default;
SchedulerDelegateImpl(const SchedulerDelegateImpl&) = delete;
SchedulerDelegateImpl& operator=(const SchedulerDelegateImpl&) = delete;

private:
void schedulerDidFinishTransaction(
const std::shared_ptr<const MountingCoordinator>& mountingCoordinator)
override;

void schedulerShouldRenderTransactions(
const std::shared_ptr<const MountingCoordinator>& mountingCoordinator)
override;

void schedulerDidRequestPreliminaryViewAllocation(
const ShadowNode& shadowNode) override;

void schedulerDidDispatchCommand(
const ShadowView& shadowView,
const std::string& commandName,
const folly::dynamic& args) override;

void schedulerDidSetIsJSResponder(
const ShadowView& shadowView,
bool isJSResponder,
bool blockNativeResponder) override;

void schedulerDidSendAccessibilityEvent(
const ShadowView& shadowView,
const std::string& eventType) override;

void schedulerShouldSynchronouslyUpdateViewOnUIThread(
Tag tag,
const folly::dynamic& props) override;

std::shared_ptr<IMountingManager> mountingManager_;
};

}; // namespace facebook::react
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.

#pragma once

#include <string>

namespace facebook::react {
/**
* Interface for handling a surface in React Native. Each platform can have
* custom logic to show/hide.
* Inspired by
* xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/SurfaceDelegate.java
*/
class SurfaceDelegate {
public:
virtual ~SurfaceDelegate() = default;

/**
* Create the React content view that uses the appKey as the React application
* name
*/
virtual void createContentView(std::string appKey) = 0;

/**
* Check if the content view is created and ready to be shown
*/
virtual bool isContentViewReady() = 0;

/** Destroy the React content view to avoid memory leak */
virtual void destroyContentView() = 0;

/** Show the surface containing the React content view */
virtual void show() = 0;

/** Hide the surface containing the React content view */
virtual void hide() = 0;

/** Check if the surface is currently showing */
virtual bool isShowing() = 0;
};
} // namespace facebook::react
Loading