MCPcopy Create free account
hub / github.com/Snapchat/Valdi / populateRenderRequest

Function populateRenderRequest

valdi/test/benchmark/ViewNode_benchmark.cpp:100–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98};
99
100RawViewNodeId populateRenderRequest(RenderRequest& request, RenderState& state, const Element& element) {
101 auto elementId = ++state.elementId;
102 auto* createElement = request.appendCreateElement();
103 createElement->setElementId(elementId);
104 createElement->setViewClassName(element.name);
105
106 for (const auto& attribute : element.attributes) {
107 auto* setAttribute = request.appendSetElementAttribute();
108 setAttribute->setElementId(elementId);
109 setAttribute->setAttributeId(state.attributeIds.getIdForName(attribute.first));
110 setAttribute->setAttributeValue(attribute.second);
111 }
112
113 std::vector<RawViewNodeId> childrenIds;
114
115 for (const auto& child : element.children) {
116 auto childId = populateRenderRequest(request, state, child);
117 childrenIds.emplace_back(childId);
118 }
119
120 size_t i = 0;
121 for (const auto& childId : childrenIds) {
122 auto* moveElementToParent = request.appendMoveElementToParent();
123
124 moveElementToParent->setParentElementId(elementId);
125 moveElementToParent->setElementId(childId);
126 moveElementToParent->setParentIndex(i);
127 i++;
128 }
129
130 if (elementId == 1) {
131 request.appendSetRootElement()->setElementId(elementId);
132 }
133
134 return elementId;
135}
136
137static Element createElementTree() {
138 auto header =

Callers 2

InitialRenderFunction · 0.85
DestroyTreeFunction · 0.85

Calls 11

appendCreateElementMethod · 0.80
setViewClassNameMethod · 0.80
setAttributeIdMethod · 0.80
getIdForNameMethod · 0.80
setParentElementIdMethod · 0.80
setParentIndexMethod · 0.80
appendSetRootElementMethod · 0.80
setAttributeValueMethod · 0.65
setElementIdMethod · 0.45

Tested by

no test coverage detected