Skip to content

Commit 68a5b32

Browse files
Merge pull request facebookarchive#140 from facebook/manual-display-part-deux
Update manual display logic
2 parents eb600b9 + 36cbea4 commit 68a5b32

4 files changed

Lines changed: 42 additions & 45 deletions

File tree

AsyncDisplayKit/ASDisplayNode.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -294,24 +294,6 @@
294294
*/
295295
@property (nonatomic, assign) BOOL shouldRasterizeDescendants;
296296

297-
/**
298-
* @abstract Calls -setNeedsDisplay and -displayIfNeeded on the node's backing store.
299-
*
300-
* @note This method must be called on the main thread but there are plans to allow this on any thread.
301-
*/
302-
- (void)display;
303-
304-
/**
305-
* @abstract Call -display on the node and recursively on all subnodes, forcing the entire node hierarchy to be
306-
* displayed.
307-
*/
308-
- (void)recursivelyDisplay;
309-
310-
/**
311-
* @abstract Display the node's view/layer immediately on the current thread, bypassing the background thread rendering.
312-
*/
313-
- (void)displayImmediately;
314-
315297
/**
316298
* @abstract Prevent the node's layer from displaying.
317299
*

AsyncDisplayKit/ASDisplayNode.mm

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -434,33 +434,6 @@ - (void)setContentsScaleForDisplay:(CGFloat)contentsScaleForDisplay
434434
_contentsScaleForDisplay = contentsScaleForDisplay;
435435
}
436436

437-
- (void)display
438-
{
439-
ASDisplayNodeAssertMainThread();
440-
ASDisplayNodeAssert(self.nodeLoaded, @"backing store must be loaded before calling -display");
441-
442-
// rendering a backing store requires a node be laid out
443-
[self __layout];
444-
445-
CALayer *layer = [self isLayerBacked] ? self.layer : self.view.layer;
446-
447-
if (layer.contents) {
448-
return;
449-
}
450-
451-
[layer setNeedsDisplay];
452-
[layer displayIfNeeded];
453-
}
454-
455-
- (void)recursivelyDisplay
456-
{
457-
for (ASDisplayNode *node in self.subnodes) {
458-
[node recursivelyDisplay];
459-
}
460-
461-
[self display];
462-
}
463-
464437
- (void)displayImmediately
465438
{
466439
ASDisplayNodeAssertMainThread();

AsyncDisplayKit/Details/ASRangeController.mm

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,45 @@
1313
#import "ASDisplayNodeInternal.h"
1414
#import "ASRangeControllerInternal.h"
1515

16+
@interface ASDisplayNode (ASRangeController)
17+
18+
- (void)display;
19+
- (void)recursivelyDisplay;
20+
21+
@end
22+
23+
@implementation ASDisplayNode (ASRangeController)
24+
25+
- (void)display
26+
{
27+
ASDisplayNodeAssertMainThread();
28+
ASDisplayNodeAssert(self.nodeLoaded, @"backing store must be loaded before calling -display");
29+
30+
CALayer *layer = self.layer;
31+
32+
// rendering a backing store requires a node be laid out
33+
[layer setNeedsLayout];
34+
[layer layoutIfNeeded];
35+
36+
if (layer.contents) {
37+
return;
38+
}
39+
40+
[layer setNeedsDisplay];
41+
[layer displayIfNeeded];
42+
}
43+
44+
- (void)recursivelyDisplay
45+
{
46+
for (ASDisplayNode *node in self.subnodes) {
47+
[node recursivelyDisplay];
48+
}
49+
50+
[self display];
51+
}
52+
53+
@end
54+
1655
@interface ASRangeController () {
1756
// index path -> node mapping
1857
NSMutableDictionary *_nodes;

AsyncDisplayKit/Private/ASDisplayNodeInternal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ void ASDisplayNodePerformBlockOnMainThread(void (^block)());
115115
// Call didExitHierarchy if necessary and set inHierarchy = NO if visibility notifications are enabled on all of its parents
116116
- (void)__exitHierarchy;
117117

118+
// Display the node's view/layer immediately on the current thread, bypassing the background thread rendering. Will be deprecated.
119+
- (void)displayImmediately;
120+
118121
// Returns the ancestor node that rasterizes descendants, or nil if none.
119122
- (ASDisplayNode *)__rasterizedContainerNode;
120123

0 commit comments

Comments
 (0)