@react-native-ohos/react-native-reanimated 3.18.1-rc.6 → 3.18.2-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.OpenSource +10 -10
- package/README.md +10 -10
- package/harmony/reanimated/BuildProfile.ets +16 -16
- package/harmony/reanimated/build-profile.json5 +11 -11
- package/harmony/reanimated/oh-package.json5 +11 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +86 -86
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +68 -68
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.h +68 -68
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +101 -101
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +51 -51
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +96 -87
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +95 -95
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +9 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +232 -232
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +90 -90
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp +870 -870
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +147 -147
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +91 -91
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +176 -176
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +971 -971
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +252 -252
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +231 -231
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +109 -109
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +56 -56
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +70 -70
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +35 -35
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/CollectionUtils.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.cpp +5 -5
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.h +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +98 -98
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +135 -135
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +59 -59
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +27 -27
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -94
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.cpp +326 -326
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.h +345 -345
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.cpp +52 -52
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.h +35 -35
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/Defs.h +10 -10
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -342
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.h +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.cpp +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.cpp +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.h +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/PlatformLogger.h +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.cpp +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +199 -199
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.cpp +95 -95
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.h +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/SingleInstanceChecker.h +72 -72
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.cpp +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.cpp +112 -112
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h +127 -127
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -191
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +173 -155
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +90 -90
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +189 -182
- package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +22 -22
- package/harmony/reanimated/src/main/cpp/WorkletsModule.cpp +60 -60
- package/harmony/reanimated/src/main/cpp/patches/AnimatedSensor/AnimatedSensorModule.cpp +89 -89
- package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +7 -0
- package/harmony/reanimated/src/main/module.json5 +12 -12
- package/harmony/reanimated/src/main/resources/base/element/color.json +7 -7
- package/harmony/reanimated/src/main/resources/base/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -5
- package/harmony/reanimated/src/main/resources/en_US/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +15 -15
- package/harmony/reanimated/ts.ts +6 -6
- package/harmony/reanimated.har +0 -0
- package/package.json +50 -50
|
@@ -1,176 +1,176 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <reanimated/Fabric/PropsRegistry.h>
|
|
4
|
-
#include <reanimated/LayoutAnimations/LayoutAnimationsManager.h>
|
|
5
|
-
|
|
6
|
-
#include <react/renderer/mounting/MountingOverrideDelegate.h>
|
|
7
|
-
#include <react/renderer/mounting/ShadowView.h>
|
|
8
|
-
|
|
9
|
-
#include <memory>
|
|
10
|
-
#include <unordered_map>
|
|
11
|
-
#include <unordered_set>
|
|
12
|
-
#include <utility>
|
|
13
|
-
#include <vector>
|
|
14
|
-
|
|
15
|
-
namespace reanimated {
|
|
16
|
-
|
|
17
|
-
struct Rect {
|
|
18
|
-
double width, height;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
struct Frame {
|
|
22
|
-
std::optional<double> x, y, width, height;
|
|
23
|
-
Frame(jsi::Runtime &runtime, const jsi::Object &newStyle) {
|
|
24
|
-
if (newStyle.hasProperty(runtime, "originX")) {
|
|
25
|
-
x = newStyle.getProperty(runtime, "originX").asNumber();
|
|
26
|
-
}
|
|
27
|
-
if (newStyle.hasProperty(runtime, "originY")) {
|
|
28
|
-
y = newStyle.getProperty(runtime, "originY").asNumber();
|
|
29
|
-
}
|
|
30
|
-
if (newStyle.hasProperty(runtime, "width")) {
|
|
31
|
-
width = newStyle.getProperty(runtime, "width").asNumber();
|
|
32
|
-
}
|
|
33
|
-
if (newStyle.hasProperty(runtime, "height")) {
|
|
34
|
-
height = newStyle.getProperty(runtime, "height").asNumber();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
struct UpdateValues {
|
|
40
|
-
Props::Shared newProps;
|
|
41
|
-
Frame frame;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
struct Snapshot {
|
|
45
|
-
double x, y, width, height, windowWidth, windowHeight;
|
|
46
|
-
Snapshot(const ShadowView &shadowView, Rect window) {
|
|
47
|
-
const auto &frame = shadowView.layoutMetrics.frame;
|
|
48
|
-
x = frame.origin.x;
|
|
49
|
-
y = frame.origin.y;
|
|
50
|
-
width = frame.size.width;
|
|
51
|
-
height = frame.size.height;
|
|
52
|
-
windowWidth = window.width;
|
|
53
|
-
windowHeight = window.height;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
typedef enum ExitingState {
|
|
58
|
-
UNDEFINED = 1,
|
|
59
|
-
WAITING = 2,
|
|
60
|
-
ANIMATING = 4,
|
|
61
|
-
DEAD = 8,
|
|
62
|
-
MOVED = 16,
|
|
63
|
-
DELETED = 32,
|
|
64
|
-
} ExitingState;
|
|
65
|
-
|
|
66
|
-
struct MutationNode;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
Represents a view that was either removed or had a child removed from the
|
|
70
|
-
ShadowTree
|
|
71
|
-
*/
|
|
72
|
-
struct Node {
|
|
73
|
-
std::vector<std::shared_ptr<MutationNode>> children, unflattenedChildren;
|
|
74
|
-
std::shared_ptr<Node> parent, unflattenedParent;
|
|
75
|
-
Tag tag;
|
|
76
|
-
void removeChildFromUnflattenedTree(std::shared_ptr<MutationNode> child);
|
|
77
|
-
void applyMutationToIndices(ShadowViewMutation mutation);
|
|
78
|
-
void insertChildren(std::vector<std::shared_ptr<MutationNode>> &newChildren);
|
|
79
|
-
void insertUnflattenedChildren(
|
|
80
|
-
std::vector<std::shared_ptr<MutationNode>> &newChildren);
|
|
81
|
-
virtual bool isMutationMode();
|
|
82
|
-
explicit Node(const Tag tag) : tag(tag) {}
|
|
83
|
-
Node(Node &&node)
|
|
84
|
-
: children(std::move(node.children)),
|
|
85
|
-
unflattenedChildren(std::move(node.unflattenedChildren)),
|
|
86
|
-
tag(node.tag) {}
|
|
87
|
-
Node(Node &node)
|
|
88
|
-
: children(node.children),
|
|
89
|
-
unflattenedChildren(node.unflattenedChildren),
|
|
90
|
-
tag(node.tag) {}
|
|
91
|
-
virtual ~Node() = default;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
Represents a view that was removed from the ShadowTree
|
|
96
|
-
*/
|
|
97
|
-
struct MutationNode : public Node {
|
|
98
|
-
ShadowViewMutation mutation;
|
|
99
|
-
ExitingState state = UNDEFINED;
|
|
100
|
-
explicit MutationNode(ShadowViewMutation &mutation)
|
|
101
|
-
: Node(mutation.oldChildShadowView.tag), mutation(mutation) {}
|
|
102
|
-
MutationNode(ShadowViewMutation &mutation, Node &&node)
|
|
103
|
-
: Node(std::move(node)), mutation(mutation) {}
|
|
104
|
-
bool isMutationMode() override;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
struct SurfaceManager {
|
|
108
|
-
mutable std::unordered_map<
|
|
109
|
-
SurfaceId,
|
|
110
|
-
std::shared_ptr<std::unordered_map<Tag, UpdateValues>>>
|
|
111
|
-
props_;
|
|
112
|
-
mutable std::unordered_map<SurfaceId, Rect> windows_;
|
|
113
|
-
|
|
114
|
-
std::unordered_map<Tag, UpdateValues> &getUpdateMap(SurfaceId surfaceId);
|
|
115
|
-
void
|
|
116
|
-
updateWindow(SurfaceId surfaceId, double windowWidth, double windowHeight);
|
|
117
|
-
Rect getWindow(SurfaceId surfaceId);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
static inline void updateLayoutMetrics(
|
|
121
|
-
LayoutMetrics &layoutMetrics,
|
|
122
|
-
Frame &frame) {
|
|
123
|
-
// we use optional's here to avoid overwriting non-animated values
|
|
124
|
-
if (frame.width) {
|
|
125
|
-
layoutMetrics.frame.size.width = *frame.width;
|
|
126
|
-
}
|
|
127
|
-
if (frame.height) {
|
|
128
|
-
layoutMetrics.frame.size.height = *frame.height;
|
|
129
|
-
}
|
|
130
|
-
if (frame.x) {
|
|
131
|
-
layoutMetrics.frame.origin.x = *frame.x;
|
|
132
|
-
}
|
|
133
|
-
if (frame.y) {
|
|
134
|
-
layoutMetrics.frame.origin.y = *frame.y;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
static inline bool isRNSScreen(std::shared_ptr<MutationNode> node) {
|
|
139
|
-
return !std::strcmp(
|
|
140
|
-
node->mutation.oldChildShadowView.componentName,
|
|
141
|
-
"RNSScreenStack") ||
|
|
142
|
-
!std::strcmp(
|
|
143
|
-
node->mutation.oldChildShadowView.componentName, "RNSScreen");
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
static inline bool hasLayoutChanged(const ShadowViewMutation &mutation) {
|
|
147
|
-
return mutation.oldChildShadowView.layoutMetrics.frame !=
|
|
148
|
-
mutation.newChildShadowView.layoutMetrics.frame;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
static inline void mergeAndSwap(
|
|
152
|
-
std::vector<std::shared_ptr<MutationNode>> &A,
|
|
153
|
-
std::vector<std::shared_ptr<MutationNode>> &B) {
|
|
154
|
-
std::vector<std::shared_ptr<MutationNode>> merged;
|
|
155
|
-
auto it1 = A.begin(), it2 = B.begin();
|
|
156
|
-
while (it1 != A.end() && it2 != B.end()) {
|
|
157
|
-
if ((*it1)->mutation.index < (*it2)->mutation.index) {
|
|
158
|
-
merged.push_back(*it1);
|
|
159
|
-
it1++;
|
|
160
|
-
} else {
|
|
161
|
-
merged.push_back(*it2);
|
|
162
|
-
it2++;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
while (it1 != A.end()) {
|
|
166
|
-
merged.push_back(*it1);
|
|
167
|
-
it1++;
|
|
168
|
-
}
|
|
169
|
-
while (it2 != B.end()) {
|
|
170
|
-
merged.push_back(*it2);
|
|
171
|
-
it2++;
|
|
172
|
-
}
|
|
173
|
-
std::swap(A, merged);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
} // namespace reanimated
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <reanimated/Fabric/PropsRegistry.h>
|
|
4
|
+
#include <reanimated/LayoutAnimations/LayoutAnimationsManager.h>
|
|
5
|
+
|
|
6
|
+
#include <react/renderer/mounting/MountingOverrideDelegate.h>
|
|
7
|
+
#include <react/renderer/mounting/ShadowView.h>
|
|
8
|
+
|
|
9
|
+
#include <memory>
|
|
10
|
+
#include <unordered_map>
|
|
11
|
+
#include <unordered_set>
|
|
12
|
+
#include <utility>
|
|
13
|
+
#include <vector>
|
|
14
|
+
|
|
15
|
+
namespace reanimated {
|
|
16
|
+
|
|
17
|
+
struct Rect {
|
|
18
|
+
double width, height;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
struct Frame {
|
|
22
|
+
std::optional<double> x, y, width, height;
|
|
23
|
+
Frame(jsi::Runtime &runtime, const jsi::Object &newStyle) {
|
|
24
|
+
if (newStyle.hasProperty(runtime, "originX")) {
|
|
25
|
+
x = newStyle.getProperty(runtime, "originX").asNumber();
|
|
26
|
+
}
|
|
27
|
+
if (newStyle.hasProperty(runtime, "originY")) {
|
|
28
|
+
y = newStyle.getProperty(runtime, "originY").asNumber();
|
|
29
|
+
}
|
|
30
|
+
if (newStyle.hasProperty(runtime, "width")) {
|
|
31
|
+
width = newStyle.getProperty(runtime, "width").asNumber();
|
|
32
|
+
}
|
|
33
|
+
if (newStyle.hasProperty(runtime, "height")) {
|
|
34
|
+
height = newStyle.getProperty(runtime, "height").asNumber();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
struct UpdateValues {
|
|
40
|
+
Props::Shared newProps;
|
|
41
|
+
Frame frame;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
struct Snapshot {
|
|
45
|
+
double x, y, width, height, windowWidth, windowHeight;
|
|
46
|
+
Snapshot(const ShadowView &shadowView, Rect window) {
|
|
47
|
+
const auto &frame = shadowView.layoutMetrics.frame;
|
|
48
|
+
x = frame.origin.x;
|
|
49
|
+
y = frame.origin.y;
|
|
50
|
+
width = frame.size.width;
|
|
51
|
+
height = frame.size.height;
|
|
52
|
+
windowWidth = window.width;
|
|
53
|
+
windowHeight = window.height;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
typedef enum ExitingState {
|
|
58
|
+
UNDEFINED = 1,
|
|
59
|
+
WAITING = 2,
|
|
60
|
+
ANIMATING = 4,
|
|
61
|
+
DEAD = 8,
|
|
62
|
+
MOVED = 16,
|
|
63
|
+
DELETED = 32,
|
|
64
|
+
} ExitingState;
|
|
65
|
+
|
|
66
|
+
struct MutationNode;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
Represents a view that was either removed or had a child removed from the
|
|
70
|
+
ShadowTree
|
|
71
|
+
*/
|
|
72
|
+
struct Node {
|
|
73
|
+
std::vector<std::shared_ptr<MutationNode>> children, unflattenedChildren;
|
|
74
|
+
std::shared_ptr<Node> parent, unflattenedParent;
|
|
75
|
+
Tag tag;
|
|
76
|
+
void removeChildFromUnflattenedTree(std::shared_ptr<MutationNode> child);
|
|
77
|
+
void applyMutationToIndices(ShadowViewMutation mutation);
|
|
78
|
+
void insertChildren(std::vector<std::shared_ptr<MutationNode>> &newChildren);
|
|
79
|
+
void insertUnflattenedChildren(
|
|
80
|
+
std::vector<std::shared_ptr<MutationNode>> &newChildren);
|
|
81
|
+
virtual bool isMutationMode();
|
|
82
|
+
explicit Node(const Tag tag) : tag(tag) {}
|
|
83
|
+
Node(Node &&node)
|
|
84
|
+
: children(std::move(node.children)),
|
|
85
|
+
unflattenedChildren(std::move(node.unflattenedChildren)),
|
|
86
|
+
tag(node.tag) {}
|
|
87
|
+
Node(Node &node)
|
|
88
|
+
: children(node.children),
|
|
89
|
+
unflattenedChildren(node.unflattenedChildren),
|
|
90
|
+
tag(node.tag) {}
|
|
91
|
+
virtual ~Node() = default;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
Represents a view that was removed from the ShadowTree
|
|
96
|
+
*/
|
|
97
|
+
struct MutationNode : public Node {
|
|
98
|
+
ShadowViewMutation mutation;
|
|
99
|
+
ExitingState state = UNDEFINED;
|
|
100
|
+
explicit MutationNode(ShadowViewMutation &mutation)
|
|
101
|
+
: Node(mutation.oldChildShadowView.tag), mutation(mutation) {}
|
|
102
|
+
MutationNode(ShadowViewMutation &mutation, Node &&node)
|
|
103
|
+
: Node(std::move(node)), mutation(mutation) {}
|
|
104
|
+
bool isMutationMode() override;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
struct SurfaceManager {
|
|
108
|
+
mutable std::unordered_map<
|
|
109
|
+
SurfaceId,
|
|
110
|
+
std::shared_ptr<std::unordered_map<Tag, UpdateValues>>>
|
|
111
|
+
props_;
|
|
112
|
+
mutable std::unordered_map<SurfaceId, Rect> windows_;
|
|
113
|
+
|
|
114
|
+
std::unordered_map<Tag, UpdateValues> &getUpdateMap(SurfaceId surfaceId);
|
|
115
|
+
void
|
|
116
|
+
updateWindow(SurfaceId surfaceId, double windowWidth, double windowHeight);
|
|
117
|
+
Rect getWindow(SurfaceId surfaceId);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
static inline void updateLayoutMetrics(
|
|
121
|
+
LayoutMetrics &layoutMetrics,
|
|
122
|
+
Frame &frame) {
|
|
123
|
+
// we use optional's here to avoid overwriting non-animated values
|
|
124
|
+
if (frame.width) {
|
|
125
|
+
layoutMetrics.frame.size.width = *frame.width;
|
|
126
|
+
}
|
|
127
|
+
if (frame.height) {
|
|
128
|
+
layoutMetrics.frame.size.height = *frame.height;
|
|
129
|
+
}
|
|
130
|
+
if (frame.x) {
|
|
131
|
+
layoutMetrics.frame.origin.x = *frame.x;
|
|
132
|
+
}
|
|
133
|
+
if (frame.y) {
|
|
134
|
+
layoutMetrics.frame.origin.y = *frame.y;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
static inline bool isRNSScreen(std::shared_ptr<MutationNode> node) {
|
|
139
|
+
return !std::strcmp(
|
|
140
|
+
node->mutation.oldChildShadowView.componentName,
|
|
141
|
+
"RNSScreenStack") ||
|
|
142
|
+
!std::strcmp(
|
|
143
|
+
node->mutation.oldChildShadowView.componentName, "RNSScreen");
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static inline bool hasLayoutChanged(const ShadowViewMutation &mutation) {
|
|
147
|
+
return mutation.oldChildShadowView.layoutMetrics.frame !=
|
|
148
|
+
mutation.newChildShadowView.layoutMetrics.frame;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static inline void mergeAndSwap(
|
|
152
|
+
std::vector<std::shared_ptr<MutationNode>> &A,
|
|
153
|
+
std::vector<std::shared_ptr<MutationNode>> &B) {
|
|
154
|
+
std::vector<std::shared_ptr<MutationNode>> merged;
|
|
155
|
+
auto it1 = A.begin(), it2 = B.begin();
|
|
156
|
+
while (it1 != A.end() && it2 != B.end()) {
|
|
157
|
+
if ((*it1)->mutation.index < (*it2)->mutation.index) {
|
|
158
|
+
merged.push_back(*it1);
|
|
159
|
+
it1++;
|
|
160
|
+
} else {
|
|
161
|
+
merged.push_back(*it2);
|
|
162
|
+
it2++;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
while (it1 != A.end()) {
|
|
166
|
+
merged.push_back(*it1);
|
|
167
|
+
it1++;
|
|
168
|
+
}
|
|
169
|
+
while (it2 != B.end()) {
|
|
170
|
+
merged.push_back(*it2);
|
|
171
|
+
it2++;
|
|
172
|
+
}
|
|
173
|
+
std::swap(A, merged);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
} // namespace reanimated
|