mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
[ASDisplayNode] Clarify logic around calling setNeedsDisplay (#2094)
This commit is contained in:
@@ -284,7 +284,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
_defaultLayoutTransitionOptions = UIViewAnimationOptionBeginFromCurrentState;
|
||||
|
||||
_flags.canClearContentsOfLayer = YES;
|
||||
_flags.canCallNeedsDisplayOfLayer = NO;
|
||||
_flags.canCallSetNeedsDisplayOfLayer = YES;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
@@ -454,12 +454,9 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
}
|
||||
|
||||
// Update flags related to special handling of UIImageView layers. More details on the flags
|
||||
if (_flags.synchronous) {
|
||||
if ([view isKindOfClass:[UIImageView class]]) {
|
||||
if (_flags.synchronous && [_viewClass isSubclassOfClass:[UIImageView class]]) {
|
||||
_flags.canClearContentsOfLayer = NO;
|
||||
} else {
|
||||
_flags.canCallNeedsDisplayOfLayer = YES;
|
||||
}
|
||||
_flags.canCallSetNeedsDisplayOfLayer = NO;
|
||||
}
|
||||
|
||||
return view;
|
||||
@@ -2056,11 +2053,11 @@ static NSInteger incrementIfFound(NSInteger i) {
|
||||
_flags.implementsInstanceDrawRect || _flags.implementsInstanceImageDisplay;
|
||||
}
|
||||
|
||||
// Helper method to determine if it's save to call setNeedsDisplay on a layer without throwing away the content.
|
||||
// For details look at the comment on the canCallNeedsDisplayOfLayer flag
|
||||
- (BOOL)__canCallNeedsDisplayOfLayer
|
||||
// Helper method to determine if it's safe to call setNeedsDisplay on a layer without throwing away the content.
|
||||
// For details look at the comment on the canCallSetNeedsDisplayOfLayer flag
|
||||
- (BOOL)__canCallSetNeedsDisplayOfLayer
|
||||
{
|
||||
return _flags.canCallNeedsDisplayOfLayer;
|
||||
return _flags.canCallSetNeedsDisplayOfLayer;
|
||||
}
|
||||
|
||||
- (BOOL)placeholderShouldPersist
|
||||
@@ -2111,9 +2108,10 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
|
||||
|
||||
ASDisplayNode *node = [layer asyncdisplaykit_node];
|
||||
|
||||
if ([node __canCallNeedsDisplayOfLayer]) {
|
||||
// Layers for UIKit components that are wrapped wtihin a node needs to be set to be displayed as the contents of
|
||||
// the layer get's cleared and would not be recreated otherwise
|
||||
if (node.isSynchronous && [node __canCallSetNeedsDisplayOfLayer]) {
|
||||
// Layers for UIKit components that are wrapped within a node needs to be set to be displayed as the contents of
|
||||
// the layer get's cleared and would not be recreated otherwise.
|
||||
// We do not call this for _ASDisplayLayer as an optimization.
|
||||
[layer setNeedsDisplay];
|
||||
}
|
||||
|
||||
|
||||
@@ -83,10 +83,10 @@ FOUNDATION_EXPORT NSString * const ASRenderingEngineDidDisplayNodesScheduledBefo
|
||||
|
||||
// Prevent calling setNeedsDisplay on a layer that backs a UIImageView. Usually calling setNeedsDisplay on a CALayer
|
||||
// triggers a recreation of the contents of layer unfortunately calling it on a CALayer that backs a UIImageView
|
||||
// it goes trough the normal flow to assign the contents to a layer via the CALayerDelegate methods. Unfortunately
|
||||
// it goes through the normal flow to assign the contents to a layer via the CALayerDelegate methods. Unfortunately
|
||||
// UIImageView does not do recreate the layer contents the usual way, it actually does not implement some of the
|
||||
// methods at all instead it throws away the contents of the layer and nothing will show up.
|
||||
unsigned canCallNeedsDisplayOfLayer:1;
|
||||
unsigned canCallSetNeedsDisplayOfLayer:1;
|
||||
|
||||
// whether custom drawing is enabled
|
||||
unsigned implementsInstanceDrawRect:1;
|
||||
|
||||
Reference in New Issue
Block a user