2018-04-10 19:46:20 +00:00
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <fabric/core/ComponentDescriptor.h>
|
|
|
|
#include <fabric/core/LayoutConstraints.h>
|
|
|
|
#include <fabric/uimanager/SchedulerDelegate.h>
|
|
|
|
#include <fabric/uimanager/UIManagerDelegate.h>
|
2018-05-09 05:56:16 +00:00
|
|
|
#include <fabric/uimanager/ShadowTree.h>
|
|
|
|
#include <fabric/uimanager/ShadowTreeDelegate.h>
|
2018-04-10 19:46:20 +00:00
|
|
|
#include <fabric/view/ViewShadowNode.h>
|
2018-05-09 05:56:14 +00:00
|
|
|
#include <fabric/view/RootShadowNode.h>
|
2018-04-10 19:46:20 +00:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
class FabricUIManager;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scheduler coordinates Shadow Tree updates and event flows.
|
|
|
|
*/
|
|
|
|
class Scheduler:
|
2018-05-09 05:56:16 +00:00
|
|
|
public UIManagerDelegate,
|
|
|
|
public ShadowTreeDelegate {
|
2018-04-10 19:46:20 +00:00
|
|
|
|
|
|
|
public:
|
2018-05-09 05:56:16 +00:00
|
|
|
|
2018-04-10 19:46:20 +00:00
|
|
|
Scheduler();
|
2018-05-09 05:56:16 +00:00
|
|
|
~Scheduler();
|
2018-04-10 19:46:20 +00:00
|
|
|
|
2018-05-09 05:56:16 +00:00
|
|
|
#pragma mark - Shadow Tree Management
|
2018-04-10 19:46:20 +00:00
|
|
|
|
|
|
|
void registerRootTag(Tag rootTag);
|
|
|
|
void unregisterRootTag(Tag rootTag);
|
|
|
|
|
2018-05-09 05:56:16 +00:00
|
|
|
Size measure(const Tag &rootTag, const LayoutConstraints &layoutConstraints, const LayoutContext &layoutContext) const;
|
|
|
|
void constraintLayout(const Tag &rootTag, const LayoutConstraints &layoutConstraints, const LayoutContext &layoutContext);
|
2018-04-10 19:46:20 +00:00
|
|
|
|
|
|
|
#pragma mark - Delegate
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sets and gets the Scheduler's delegate.
|
|
|
|
* The delegate is stored as a raw pointer, so the owner must null
|
|
|
|
* the pointer before being destroyed.
|
|
|
|
*/
|
|
|
|
void setDelegate(SchedulerDelegate *delegate);
|
2018-05-09 05:56:16 +00:00
|
|
|
SchedulerDelegate *getDelegate() const;
|
2018-04-10 19:46:20 +00:00
|
|
|
|
|
|
|
#pragma mark - UIManagerDelegate
|
|
|
|
|
|
|
|
void uiManagerDidFinishTransaction(Tag rootTag, const SharedShadowNodeUnsharedList &rootChildNodes) override;
|
|
|
|
void uiManagerDidCreateShadowNode(const SharedShadowNode &shadowNode) override;
|
|
|
|
|
2018-05-09 05:56:16 +00:00
|
|
|
#pragma mark - ShadowTreeDelegate
|
|
|
|
|
|
|
|
void shadowTreeDidCommit(const SharedShadowTree &shadowTree, const TreeMutationInstructionList &instructions) override;
|
|
|
|
|
2018-04-10 19:46:20 +00:00
|
|
|
#pragma mark - Deprecated
|
|
|
|
|
|
|
|
/*
|
|
|
|
* UIManager instance must be temporarily exposed for registration purposes.
|
|
|
|
*/
|
|
|
|
std::shared_ptr<FabricUIManager> getUIManager_DO_NOT_USE();
|
|
|
|
|
|
|
|
private:
|
2018-05-09 05:56:16 +00:00
|
|
|
|
2018-04-10 19:46:20 +00:00
|
|
|
SchedulerDelegate *delegate_;
|
|
|
|
std::shared_ptr<FabricUIManager> uiManager_;
|
2018-05-09 05:56:16 +00:00
|
|
|
std::unordered_map<Tag, SharedShadowTree> shadowTreeRegistry_;
|
2018-04-10 19:46:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|