2018-05-31 22:31:03 +00:00
|
|
|
// Copyright (c) 2004-present, Facebook, Inc.
|
|
|
|
|
|
|
|
// This source code is licensed under the MIT license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree.
|
2018-04-10 19:46:20 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <fabric/core/ComponentDescriptor.h>
|
|
|
|
#include <fabric/core/LayoutConstraints.h>
|
2018-06-22 14:28:34 +00:00
|
|
|
#include <fabric/uimanager/ContextContainer.h>
|
2018-04-10 19:46:20 +00:00
|
|
|
#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
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
class FabricUIManager;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scheduler coordinates Shadow Tree updates and event flows.
|
|
|
|
*/
|
2018-05-10 22:00:30 +00:00
|
|
|
class Scheduler final:
|
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-06-22 14:28:34 +00:00
|
|
|
Scheduler(const SharedContextContainer &contextContainer);
|
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-06-01 16:36:25 +00:00
|
|
|
SharedSchedulerEventDispatcher eventDispatcher_;
|
2018-06-22 14:28:34 +00:00
|
|
|
SharedContextContainer contextContainer_;
|
2018-04-10 19:46:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|