mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-03-29 08:39:00 +08:00
[ASDisplayNode] Add -displayWillStartAsynchronously: method to allow skipping synchronous image cache check.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user