diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index 1533893093..a9c3949903 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -2013,7 +2013,7 @@ ASDISPLAYNODE_INLINE BOOL nodeIsInRasterizedTree(ASDisplayNode *node) { ASDisplayNodeAssert(subnode, @"Cannot insert a nil subnode"); - // Don't add subnode if it's already if it's already a subnodes + // Don't add if it's already a subnode ASDisplayNode *oldParent = subnode.supernode; if (!subnode || subnode == self || oldParent == self) { return; @@ -3063,10 +3063,10 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) oldState = _interfaceState; _interfaceState = newState; } - - if ((newState & ASInterfaceStateMeasureLayout) != (oldState & ASInterfaceStateMeasureLayout)) { - // Trigger asynchronous measurement if it is not already cached or being calculated. - } + + // TODO: Trigger asynchronous measurement if it is not already cached or being calculated. + // if ((newState & ASInterfaceStateMeasureLayout) != (oldState & ASInterfaceStateMeasureLayout)) { + // } // For the Preload and Display ranges, we don't want to call -clear* if not being managed by a range controller. // Otherwise we get flashing behavior from normal UIKit manipulations like navigation controller push / pop. diff --git a/AsyncDisplayKit/ASImageNode.mm b/AsyncDisplayKit/ASImageNode.mm index 4604d906fd..b8ac7890de 100644 --- a/AsyncDisplayKit/ASImageNode.mm +++ b/AsyncDisplayKit/ASImageNode.mm @@ -273,35 +273,24 @@ struct ASImageNodeDrawParameters { return nil; } - CGRect drawParameterBounds = CGRectZero; - BOOL forceUpscaling = NO; - CGSize forcedSize = CGSizeZero; - BOOL cropEnabled = YES; - BOOL isOpaque = NO; - UIColor *backgroundColor = nil; - UIViewContentMode contentMode = UIViewContentModeScaleAspectFill; - CGFloat contentsScale = 0.0; - CGRect cropDisplayBounds = CGRectZero; - CGRect cropRect = CGRectZero; - asimagenode_modification_block_t imageModificationBlock; - + ASImageNodeDrawParameters drawParameter; { ASDN::MutexLocker l(__instanceLock__); - ASImageNodeDrawParameters drawParameter = _drawParameter; - - drawParameterBounds = drawParameter.bounds; - forceUpscaling = drawParameter.forceUpscaling; - forcedSize = drawParameter.forcedSize; - cropEnabled = drawParameter.cropEnabled; - isOpaque = drawParameter.opaque; - backgroundColor = drawParameter.backgroundColor; - contentMode = drawParameter.contentMode; - contentsScale = drawParameter.contentsScale; - cropDisplayBounds = drawParameter.cropDisplayBounds; - cropRect = drawParameter.cropRect; - imageModificationBlock = drawParameter.imageModificationBlock; + drawParameter = _drawParameter; } + CGRect drawParameterBounds = drawParameter.bounds; + BOOL forceUpscaling = drawParameter.forceUpscaling; + CGSize forcedSize = drawParameter.forcedSize; + BOOL cropEnabled = drawParameter.cropEnabled; + BOOL isOpaque = drawParameter.opaque; + UIColor *backgroundColor = drawParameter.backgroundColor; + UIViewContentMode contentMode = drawParameter.contentMode; + CGFloat contentsScale = drawParameter.contentsScale; + CGRect cropDisplayBounds = drawParameter.cropDisplayBounds; + CGRect cropRect = drawParameter.cropRect; + asimagenode_modification_block_t imageModificationBlock = drawParameter.imageModificationBlock; + BOOL hasValidCropBounds = cropEnabled && !CGRectIsEmpty(cropDisplayBounds); CGRect bounds = (hasValidCropBounds ? cropDisplayBounds : drawParameterBounds); @@ -374,26 +363,26 @@ struct ASImageNodeDrawParameters { return nil; } - ASImageNodeContentsKey *contentsKey = [[ASImageNodeContentsKey alloc] init]; - contentsKey.image = image; - contentsKey.backingSize = backingSize; - contentsKey.imageDrawRect = imageDrawRect; - contentsKey.isOpaque = isOpaque; - contentsKey.backgroundColor = backgroundColor; - contentsKey.preContextBlock = preContextBlock; - contentsKey.postContextBlock = postContextBlock; - contentsKey.imageModificationBlock = imageModificationBlock; + ASImageNodeContentsKey *contentsKey = [[ASImageNodeContentsKey alloc] init]; + contentsKey.image = image; + contentsKey.backingSize = backingSize; + contentsKey.imageDrawRect = imageDrawRect; + contentsKey.isOpaque = isOpaque; + contentsKey.backgroundColor = backgroundColor; + contentsKey.preContextBlock = preContextBlock; + contentsKey.postContextBlock = postContextBlock; + contentsKey.imageModificationBlock = imageModificationBlock; - if (isCancelled()) { - return nil; - } + if (isCancelled()) { + return nil; + } - ASWeakMapEntry *entry = [self.class contentsForkey:contentsKey isCancelled:(asdisplaynode_iscancelled_block_t)isCancelled]; - if (entry == nil) { // If nil, we were cancelled. - return nil; - } - _weakCacheEntry = entry; // Retain so that the entry remains in the weak cache - return entry.value; + ASWeakMapEntry *entry = [self.class contentsForkey:contentsKey isCancelled:(asdisplaynode_iscancelled_block_t)isCancelled]; + if (entry == nil) { // If nil, we were cancelled. + return nil; + } + _weakCacheEntry = entry; // Retain so that the entry remains in the weak cache + return entry.value; } static ASWeakMap *cache = nil;