forked from software-mansion/react-native-reanimated
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLayoutAnimationsUtils.cpp
More file actions
85 lines (71 loc) · 2.22 KB
/
Copy pathLayoutAnimationsUtils.cpp
File metadata and controls
85 lines (71 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifdef RCT_NEW_ARCH_ENABLED
#include <reanimated/LayoutAnimations/LayoutAnimationsUtils.h>
namespace reanimated {
std::unordered_map<Tag, UpdateValues> &SurfaceManager::getUpdateMap(
SurfaceId surfaceId) {
auto props = props_.find(surfaceId);
if (props != props_.end()) {
return *props->second;
}
auto newProps = std::make_shared<std::unordered_map<Tag, UpdateValues>>();
props_.insert_or_assign(surfaceId, newProps);
return *newProps;
}
void SurfaceManager::updateWindow(
const SurfaceId surfaceId,
const double windowWidth,
const double windowHeight) {
windows_.insert_or_assign(surfaceId, Rect{windowWidth, windowHeight});
}
Rect SurfaceManager::getWindow(SurfaceId surfaceId) {
auto windowIt = windows_.find(surfaceId);
if (windowIt != windows_.end()) {
return windowIt->second;
}
return Rect{0, 0};
}
void Node::applyMutationToIndices(ShadowViewMutation mutation) {
if (tag != mutation.parentTag) {
return;
}
int delta = mutation.type == ShadowViewMutation::Insert ? 1 : -1;
for (int i = children.size() - 1; i >= 0; i--) {
if (children[i]->mutation.index < mutation.index) {
return;
}
children[i]->mutation.index += delta;
}
}
// Should only be called on unflattened parents
void Node::removeChildFromUnflattenedTree(std::shared_ptr<MutationNode> child) {
for (int i = unflattenedChildren.size() - 1; i >= 0; i--) {
if (unflattenedChildren[i]->tag == child->tag) {
unflattenedChildren.erase(unflattenedChildren.begin() + i);
break;
}
}
auto &flattenedChildren = child->parent->children;
for (int i = flattenedChildren.size() - 1; i >= 0; i--) {
if (flattenedChildren[i]->tag == child->tag) {
flattenedChildren.erase(flattenedChildren.begin() + i);
return;
}
flattenedChildren[i]->mutation.index--;
}
}
void Node::insertChildren(
std::vector<std::shared_ptr<MutationNode>> &newChildren) {
mergeAndSwap(children, newChildren);
}
void Node::insertUnflattenedChildren(
std::vector<std::shared_ptr<MutationNode>> &newChildren) {
mergeAndSwap(unflattenedChildren, newChildren);
}
bool Node::isMutationMode() {
return false;
}
bool MutationNode::isMutationMode() {
return true;
}
} // namespace reanimated
#endif