-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Adds support for disabling and re-enabling should rasterize. #711
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -331,6 +331,40 @@ - (void)dealloc | |
|
||
#pragma mark - Core | ||
|
||
- (void)__tearDown:(BOOL)tearDown subnodesOfNode:(ASDisplayNode *)node | ||
{ | ||
for (ASDisplayNode *subnode in node.subnodes) { | ||
if (tearDown) { | ||
[subnode __unloadNode]; | ||
} else { | ||
[subnode __loadNode]; | ||
} | ||
} | ||
} | ||
|
||
- (void)__unloadNode | ||
{ | ||
ASDisplayNodeAssertThreadAffinity(self); | ||
ASDN::MutexLocker l(_propertyLock); | ||
|
||
if (_flags.layerBacked) | ||
_pendingViewState = [_ASPendingState pendingViewStateFromLayer:_layer]; | ||
else | ||
_pendingViewState = [_ASPendingState pendingViewStateFromView:_view]; | ||
|
||
[_view removeFromSuperview]; | ||
_view = nil; | ||
if (_flags.layerBacked) | ||
_layer.delegate = nil; | ||
[_layer removeFromSuperlayer]; | ||
_layer = nil; | ||
} | ||
|
||
- (void)__loadNode | ||
{ | ||
[self layer]; | ||
} | ||
|
||
- (ASDisplayNode *)__rasterizedContainerNode | ||
{ | ||
ASDisplayNode *node = self.supernode; | ||
|
@@ -340,7 +374,7 @@ - (ASDisplayNode *)__rasterizedContainerNode | |
} | ||
node = node.supernode; | ||
} | ||
|
||
return nil; | ||
} | ||
|
||
|
@@ -619,11 +653,22 @@ - (void)setShouldRasterizeDescendants:(BOOL)flag | |
{ | ||
ASDisplayNodeAssertThreadAffinity(self); | ||
ASDN::MutexLocker l(_propertyLock); | ||
|
||
if (_flags.shouldRasterizeDescendants == flag) | ||
return; | ||
|
||
_flags.shouldRasterizeDescendants = flag; | ||
|
||
if (self.isNodeLoaded) { | ||
//recursively tear down or build up subnodes | ||
[self recursivelyClearContents]; | ||
[self __tearDown:flag subnodesOfNode:self]; | ||
if (flag == NO) { | ||
[self _addSubnodeViewsAndLayers]; | ||
} | ||
|
||
[self recursivelyDisplayImmediately]; | ||
} | ||
} | ||
|
||
- (CGFloat)contentsScaleForDisplay | ||
|
@@ -653,6 +698,15 @@ - (void)displayImmediately | |
[[self asyncLayer] displayImmediately]; | ||
} | ||
|
||
- (void)recursivelyDisplayImmediately | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check out -recursivelyEnsureDisplay; will it do what you need? If so (I am not confident with this quick review), it would be notably faster. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I replace recursivelyDisplayImmediately with recursivelySetNeedsDisplay and recursivelyEnsureDisplay it doesn’t seem to complete synchronously, resulting in the UI flashing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, that's exceedingly odd. I'm OK with landing this approach, but will consider it a followup for me to debug that issue and consolidate the display mechanisms. Thank you for trying it. |
||
{ | ||
ASDN::MutexLocker l(_propertyLock); | ||
for (ASDisplayNode *child in _subnodes) { | ||
[child recursivelyDisplayImmediately]; | ||
} | ||
[self displayImmediately]; | ||
} | ||
|
||
- (void)__setNeedsLayout | ||
{ | ||
ASDisplayNodeAssertThreadAffinity(self); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a little sparse, but smart :). Multiple loads and unloads of a node is a first for the public ASDK, something we had some challenges implementing a while back when building prototypes of view reuse. I assume each time will use layerBlock or viewBlock accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears so.