Skip to content

Commit 9588692

Browse files
mikezuccnguyenhuy
authored andcommitted
Clean up timing of layout tree flattening/ copying of unflattened tree for Weaver (TextureGroup#1157)
* Simpler Huy fix for more efficient delayed flattening of the layout tree * Nit * Remove pbx changes * Update CHANGELOG.md * Add note about change in timing of _flattenedLayout capture
1 parent 5e05793 commit 9588692

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
- Optimize layout process by removing `ASRectMap`. [Adlai Holler](https://github.com/Adlai-Holler)
5252
- Remove necessity to use view to access rangeController in ASTableNode, ASCollectionNode. [Michael Schneider](https://github.com/maicki)
5353
- Remove display node's reliance on shared_ptr. [Adlai Holler](https://github.com/Adlai-Holler)
54+
- Clean up timing of layout tree flattening/ copying of unflattened tree for Weaver. [Michael Zuccarino](https://github.com/mikezucc) [#1157](https://github.com/TextureGroup/Texture/pull/1157)
5455

5556
## 2.7
5657
- Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877)

Source/ASDisplayNode+Layout.mm

-12
Original file line numberDiff line numberDiff line change
@@ -993,12 +993,6 @@ - (void)_pendingLayoutTransitionDidComplete
993993
_pendingLayoutTransition = nil;
994994
}
995995

996-
- (void)_setCalculatedDisplayNodeLayout:(const ASDisplayNodeLayout &)displayNodeLayout
997-
{
998-
ASDN::MutexLocker l(__instanceLock__);
999-
[self _locked_setCalculatedDisplayNodeLayout:displayNodeLayout];
1000-
}
1001-
1002996
- (void)_locked_setCalculatedDisplayNodeLayout:(const ASDisplayNodeLayout &)displayNodeLayout
1003997
{
1004998
ASAssertLocked(__instanceLock__);
@@ -1007,12 +1001,6 @@ - (void)_locked_setCalculatedDisplayNodeLayout:(const ASDisplayNodeLayout &)disp
10071001
ASDisplayNodeAssertTrue(displayNodeLayout.layout.size.height >= 0.0);
10081002

10091003
_calculatedDisplayNodeLayout = displayNodeLayout;
1010-
1011-
// Flatten the layout if it wasn't done before (@see -calculateLayoutThatFits:).
1012-
if ([ASDisplayNode shouldStoreUnflattenedLayouts]) {
1013-
_unflattenedLayout = _calculatedDisplayNodeLayout.layout;
1014-
_calculatedDisplayNodeLayout.layout = [_unflattenedLayout filteredNodeLayoutTree];
1015-
}
10161004
}
10171005

10181006
@end

Source/ASDisplayNode.mm

+4-4
Original file line numberDiff line numberDiff line change
@@ -1220,11 +1220,11 @@ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize
12201220
}
12211221
ASDisplayNodeLogEvent(self, @"computedLayout: %@", layout);
12221222

1223-
// Return the (original) unflattened layout if it needs to be stored. The layout will be flattened later on (@see _locked_setCalculatedDisplayNodeLayout:).
1224-
// Otherwise, flatten it right away.
1225-
if (! [ASDisplayNode shouldStoreUnflattenedLayouts]) {
1226-
layout = [layout filteredNodeLayoutTree];
1223+
// PR #1157: Reduces accuracy of _unflattenedLayout for debugging/Weaver
1224+
if ([ASDisplayNode shouldStoreUnflattenedLayouts]) {
1225+
_unflattenedLayout = layout;
12271226
}
1227+
layout = [layout filteredNodeLayoutTree];
12281228

12291229
return layout;
12301230
}

0 commit comments

Comments
 (0)