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

Function canUseCachedMeasurement

third-party/yoga/src/yoga/algorithm/Cache.cpp:45–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45bool canUseCachedMeasurement(
46 const SizingMode widthMode,
47 const float availableWidth,
48 const SizingMode heightMode,
49 const float availableHeight,
50 const SizingMode lastWidthMode,
51 const float lastAvailableWidth,
52 const SizingMode lastHeightMode,
53 const float lastAvailableHeight,
54 const float lastComputedWidth,
55 const float lastComputedHeight,
56 const float marginRow,
57 const float marginColumn,
58 const yoga::Config* const config) {
59 if ((yoga::isDefined(lastComputedHeight) && lastComputedHeight < 0) ||
60 ((yoga::isDefined(lastComputedWidth)) && lastComputedWidth < 0)) {
61 return false;
62 }
63
64 const float pointScaleFactor = config->getPointScaleFactor();
65
66 bool useRoundedComparison = config != nullptr && pointScaleFactor != 0;
67 const float effectiveWidth = useRoundedComparison
68 ? roundValueToPixelGrid(availableWidth, pointScaleFactor, false, false)
69 : availableWidth;
70 const float effectiveHeight = useRoundedComparison
71 ? roundValueToPixelGrid(availableHeight, pointScaleFactor, false, false)
72 : availableHeight;
73 const float effectiveLastWidth = useRoundedComparison
74 ? roundValueToPixelGrid(
75 lastAvailableWidth, pointScaleFactor, false, false)
76 : lastAvailableWidth;
77 const float effectiveLastHeight = useRoundedComparison
78 ? roundValueToPixelGrid(
79 lastAvailableHeight, pointScaleFactor, false, false)
80 : lastAvailableHeight;
81
82 const bool hasSameWidthSpec = lastWidthMode == widthMode &&
83 yoga::inexactEquals(effectiveLastWidth, effectiveWidth);
84 const bool hasSameHeightSpec = lastHeightMode == heightMode &&
85 yoga::inexactEquals(effectiveLastHeight, effectiveHeight);
86
87 const bool widthIsCompatible =
88 hasSameWidthSpec ||
89 sizeIsExactAndMatchesOldMeasuredSize(
90 widthMode, availableWidth - marginRow, lastComputedWidth) ||
91 oldSizeIsMaxContentAndStillFits(
92 widthMode,
93 availableWidth - marginRow,
94 lastWidthMode,
95 lastComputedWidth) ||
96 newSizeIsStricterAndStillValid(
97 widthMode,
98 availableWidth - marginRow,
99 lastWidthMode,
100 lastAvailableWidth,
101 lastComputedWidth);
102

Callers 2

calculateLayoutInternalFunction · 0.85

Calls 7

roundValueToPixelGridFunction · 0.85
getPointScaleFactorMethod · 0.80
isDefinedFunction · 0.50
inexactEqualsFunction · 0.50

Tested by

no test coverage detected