mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-20 21:29:00 +00:00
Merge pull request #1304 from garrettmoon/betterSkipClearContents
[ASDisplayNode] Coalesce -clearContents onto the next runloop, so it can be skipped if re-added to hierarchy in move operation.
This commit is contained in:
commit
47d2981487
@ -1227,7 +1227,7 @@ static bool disableNotificationsForMovingBetweenParents(ASDisplayNode *from, ASD
|
|||||||
if (isMovingEquivalentParents) {
|
if (isMovingEquivalentParents) {
|
||||||
[subnode __incrementVisibilityNotificationsDisabled];
|
[subnode __incrementVisibilityNotificationsDisabled];
|
||||||
}
|
}
|
||||||
[subnode removeFromSupernodeMovingBetweenNodes:YES];
|
[subnode removeFromSupernode];
|
||||||
|
|
||||||
if (!_subnodes)
|
if (!_subnodes)
|
||||||
_subnodes = [[NSMutableArray alloc] init];
|
_subnodes = [[NSMutableArray alloc] init];
|
||||||
@ -1497,11 +1497,6 @@ static NSInteger incrementIfFound(NSInteger i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeFromSupernode
|
- (void)removeFromSupernode
|
||||||
{
|
|
||||||
[self removeFromSupernodeMovingBetweenNodes:NO];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)removeFromSupernodeMovingBetweenNodes:(BOOL)movingBetweenNodes
|
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssertThreadAffinity(self);
|
ASDisplayNodeAssertThreadAffinity(self);
|
||||||
BOOL shouldRemoveFromSuperviewOrSuperlayer = NO;
|
BOOL shouldRemoveFromSuperviewOrSuperlayer = NO;
|
||||||
@ -1531,18 +1526,11 @@ static NSInteger incrementIfFound(NSInteger i) {
|
|||||||
if (shouldRemoveFromSuperviewOrSuperlayer) {
|
if (shouldRemoveFromSuperviewOrSuperlayer) {
|
||||||
ASPerformBlockOnMainThread(^{
|
ASPerformBlockOnMainThread(^{
|
||||||
ASDN::MutexLocker l(_propertyLock);
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
|
|
||||||
if (movingBetweenNodes) {
|
|
||||||
_flags.isMovingBetweenNodes = YES;
|
|
||||||
}
|
|
||||||
if (_flags.layerBacked) {
|
if (_flags.layerBacked) {
|
||||||
[_layer removeFromSuperlayer];
|
[_layer removeFromSuperlayer];
|
||||||
} else {
|
} else {
|
||||||
[_view removeFromSuperview];
|
[_view removeFromSuperview];
|
||||||
}
|
}
|
||||||
if (movingBetweenNodes) {
|
|
||||||
_flags.isMovingBetweenNodes = NO;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1982,14 +1970,6 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
|
|||||||
- (void)clearContents
|
- (void)clearContents
|
||||||
{
|
{
|
||||||
// No-op if these haven't been created yet, as that guarantees they don't have contents that needs to be released.
|
// No-op if these haven't been created yet, as that guarantees they don't have contents that needs to be released.
|
||||||
{
|
|
||||||
ASDN::MutexLocker l(_propertyLock);
|
|
||||||
//Do not clear contents if we're mearly moving between nodes
|
|
||||||
if (_flags.isMovingBetweenNodes) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_layer.contents = nil;
|
_layer.contents = nil;
|
||||||
_placeholderLayer.contents = nil;
|
_placeholderLayer.contents = nil;
|
||||||
_placeholderImage = nil;
|
_placeholderImage = nil;
|
||||||
@ -2103,8 +2083,14 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
|
|||||||
[self setDisplaySuspended:NO];
|
[self setDisplaySuspended:NO];
|
||||||
} else {
|
} else {
|
||||||
[self setDisplaySuspended:YES];
|
[self setDisplaySuspended:YES];
|
||||||
|
//schedule clear contents on next runloop
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
|
if (ASInterfaceStateIncludesDisplay(_interfaceState) == NO) {
|
||||||
[self clearContents];
|
[self clearContents];
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// NOTE: This case isn't currently supported as setInterfaceState: isn't exposed externally, and all
|
// NOTE: This case isn't currently supported as setInterfaceState: isn't exposed externally, and all
|
||||||
// internal use cases are range-managed. When a node is visible, don't mess with display - CA will start it.
|
// internal use cases are range-managed. When a node is visible, don't mess with display - CA will start it.
|
||||||
@ -2115,8 +2101,14 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
|
|||||||
[ASDisplayNode scheduleNodeForRecursiveDisplay:self];
|
[ASDisplayNode scheduleNodeForRecursiveDisplay:self];
|
||||||
} else {
|
} else {
|
||||||
[[self asyncLayer] cancelAsyncDisplay];
|
[[self asyncLayer] cancelAsyncDisplay];
|
||||||
|
//schedule clear contents on next runloop
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
|
if (ASInterfaceStateIncludesDisplay(_interfaceState) == NO) {
|
||||||
[self clearContents];
|
[self clearContents];
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,7 +82,6 @@ FOUNDATION_EXPORT NSString * const ASRenderingEngineDidDisplayNodesScheduledBefo
|
|||||||
unsigned isEnteringHierarchy:1;
|
unsigned isEnteringHierarchy:1;
|
||||||
unsigned isExitingHierarchy:1;
|
unsigned isExitingHierarchy:1;
|
||||||
unsigned isInHierarchy:1;
|
unsigned isInHierarchy:1;
|
||||||
unsigned isMovingBetweenNodes:1;
|
|
||||||
unsigned visibilityNotificationsDisabled:VISIBILITY_NOTIFICATIONS_DISABLED_BITS;
|
unsigned visibilityNotificationsDisabled:VISIBILITY_NOTIFICATIONS_DISABLED_BITS;
|
||||||
} _flags;
|
} _flags;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user