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

Method calculateLayoutOnNodeIfNeeded

valdi/src/valdi/runtime/Context/ViewNode.cpp:2236–2280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2234 currentMeasureMetrics = &measureCount;
2235 facebook::yoga::calculateLayout(facebook::yoga::resolveRef(yogaNode), ownerWidth, ownerHeight, yogaDirection);
2236 currentMeasureMetrics = previousMeasureMetrics;
2237
2238 getYogaStyle(yogaNode).setMaxDimension(facebook::yoga::Dimension::Width, savedMaxWidth);
2239 getYogaStyle(yogaNode).setMaxDimension(facebook::yoga::Dimension::Height, savedMaxHeight);
2240}
2241
2242bool ViewNode::calculateLayoutOnNodeIfNeeded(YGNode* yogaNode,
2243 float width,
2244 MeasureMode widthMode,
2245 float height,
2246 MeasureMode heightMode,
2247 LayoutDirection direction,
2248 bool forceLayout,
2249 bool isFromLazyLayout) const {
2250 if (!resolveYogaNode(yogaNode)->isDirty() && !forceLayout) {
2251 return false;
2252 }
2253
2254 auto backendString = getBackendString(getBackend(_viewNodeTree));
2255 auto module = getModuleName();
2256
2257#if VALDI_DEBUG_TREE_UPDATES
2258 VALDI_TRACE_META("Valdi.calculateLayout", std::to_string(getRecursiveChildCount()));
2259#else
2260 VALDI_TRACE("Valdi.calculateLayout");
2261#endif
2262 auto metricsObj = getMetrics();
2263 ScopedMetrics metrics = isFromLazyLayout ?
2264 Metrics::scopedCalculateLazyLayoutLatency(metricsObj, module, backendString) :
2265 Metrics::scopedCalculateLayoutLatency(metricsObj, module, backendString);
2266
2267 MeasureMetrics measureCount;
2268 doCalculateLayoutOnNode(yogaNode, width, widthMode, height, heightMode, direction, measureCount);
2269
2270 if (measureCount.totalMeasure > 0) {
2271 if (isFromLazyLayout) {
2272 if (metricsObj != nullptr) {
2273 metricsObj->emitCalculateLazyLayoutLatencyMeasure(module, backendString, metrics.elapsed());
2274 }
2275 } else {
2276 if (metricsObj != nullptr) {
2277 metricsObj->emitCalculateLayoutLatencyMeasure(module, backendString, metrics.elapsed());
2278 }
2279 }
2280 }
2281
2282 if (Valdi::traceRenderingPerformance) {
2283 VALDI_INFO(getLogger(), "Calculated layout in {} from node {}", metrics.elapsed(), this->getDebugId());

Callers

nothing calls this directly

Calls 10

getDebugIdMethod · 0.95
resolveYogaNodeFunction · 0.85
getBackendFunction · 0.85
doCalculateLayoutOnNodeFunction · 0.85
getModuleNameFunction · 0.50
to_stringFunction · 0.50
isDirtyMethod · 0.45
elapsedMethod · 0.45

Tested by

no test coverage detected