[ASDisplayNode] Add -displayWillStartAsynchronously: method to allow skipping synchronous image cache check.

This commit is contained in:
Scott Goodson
2016-10-04 20:30:25 -07:00
parent 07f0b5b02c
commit 5aa5dc591a
5 changed files with 13 additions and 9 deletions

View File

@@ -216,6 +216,7 @@ NS_ASSUME_NONNULL_BEGIN
* @note Called on the main thread only
*/
- (void)displayWillStart ASDISPLAYNODE_REQUIRES_SUPER;
- (void)displayWillStartAsynchronously:(BOOL)asynchronously ASDISPLAYNODE_REQUIRES_SUPER;
/**
* @abstract Indicates that the receiver has finished displaying.

View File

@@ -1542,10 +1542,11 @@ static inline CATransform3D _calculateTransformFromReferenceToTarget(ASDisplayNo
#pragma mark - _ASDisplayLayerDelegate
- (void)willDisplayAsyncLayer:(_ASDisplayLayer *)layer
- (void)willDisplayAsyncLayer:(_ASDisplayLayer *)layer asynchronously:(BOOL)asynchronously
{
// Subclass hook.
[self displayWillStart];
[self displayWillStartAsynchronously:asynchronously];
}
- (void)didDisplayAsyncLayer:(_ASDisplayLayer *)layer
@@ -2914,13 +2915,15 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
#pragma mark - Display
- (void)displayWillStart
- (void)displayWillStart {}
- (void)displayWillStartAsynchronously:(BOOL)asynchronously
{
[self displayWillStart]; // Subclass override
ASDisplayNodeAssertMainThread();
// in case current node takes longer to display than it's subnodes, treat it as a dependent node
[self _pendingNodeWillDisplay:self];
[_supernode subnodeDisplayWillStart:self];
}

View File

@@ -249,11 +249,11 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
/* displayWillStart in ASMultiplexImageNode has a very similar implementation. Changes here are likely necessary
in ASMultiplexImageNode as well. */
- (void)displayWillStart
- (void)displayWillStartAsynchronously:(BOOL)asynchronously
{
[super displayWillStart];
[super displayWillStartAsynchronously:asynchronously];
if (_cacheFlags.cacheSupportsSynchronousFetch) {
if (asynchronously == NO && _cacheFlags.cacheSupportsSynchronousFetch) {
ASDN::MutexLocker l(__instanceLock__);
if (_imageLoaded == NO && _URL && _downloadIdentifier == nil) {
UIImage *result = [[_cache synchronouslyFetchedCachedImageWithURL:_URL] asdk_image];

View File

@@ -132,7 +132,7 @@ typedef BOOL(^asdisplaynode_iscancelled_block_t)(void);
/**
@summary Delegate override for willDisplay
*/
- (void)willDisplayAsyncLayer:(_ASDisplayLayer *)layer;
- (void)willDisplayAsyncLayer:(_ASDisplayLayer *)layer asynchronously:(BOOL)asynchronously;
/**
@summary Delegate override for didDisplay

View File

@@ -304,7 +304,7 @@
};
// Call willDisplay immediately in either case
[self willDisplayAsyncLayer:self.asyncLayer];
[self willDisplayAsyncLayer:self.asyncLayer asynchronously:asynchronously];
if (asynchronously) {
// Async rendering operations are contained by a transaction, which allows them to proceed and concurrently