Skip to content

Commit

Permalink
Ensure full layout occurs when a system scale change occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
acoates-ms committed Jun 18, 2024
1 parent d8739e1 commit d04b1e5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ RootShadowNode::Unshared RootShadowNode::clone(
/* .props = */ props,
});

if (layoutConstraints != getConcreteProps().layoutConstraints) {
if (layoutConstraints != getConcreteProps().layoutConstraints ||
layoutContext.pointScaleFactor !=
getConcreteProps().layoutContext.pointScaleFactor) {
newRootShadowNode->dirtyLayout();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2140,7 +2140,8 @@ bool calculateLayoutInternal(

const bool needToVisitNode =
(node->isDirty() && layout->generationCount != generationCount) ||
layout->lastOwnerDirection != ownerDirection;
layout->lastOwnerDirection != ownerDirection ||
layout->lastScale != node->getConfig()->getPointScaleFactor();

if (needToVisitNode) {
// Invalidate the cached results.
Expand Down Expand Up @@ -2255,6 +2256,7 @@ bool calculateLayoutInternal(
reason);

layout->lastOwnerDirection = ownerDirection;
layout->lastScale = node->getConfig()->getPointScaleFactor();

if (cachedResults == nullptr) {
layoutMarkerData.maxMeasureCache = std::max(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bool LayoutResults::operator==(LayoutResults layout) const {
direction() == layout.direction() &&
hadOverflow() == layout.hadOverflow() &&
lastOwnerDirection == layout.lastOwnerDirection &&
lastScale == layout.lastScale &&
nextCachedMeasurementsIndex == layout.nextCachedMeasurementsIndex &&
cachedLayout == layout.cachedLayout &&
computedFlexBasis == layout.computedFlexBasis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct LayoutResults {
// information to break early when nothing changed
uint32_t generationCount = 0;
Direction lastOwnerDirection = Direction::Inherit;
float lastScale = 1.0f;

uint32_t nextCachedMeasurementsIndex = 0;
std::array<CachedMeasurement, MaxCachedMeasurements> cachedMeasurements = {};
Expand Down

0 comments on commit d04b1e5

Please sign in to comment.