Merge remote-tracking branch 'facebook/master'

This commit is contained in:
Hannah Troisi 2016-06-16 22:23:35 -07:00
commit d96beb29de
6 changed files with 24 additions and 7 deletions

View File

@ -192,8 +192,7 @@
{
ASTextKitComponents *displayedComponents = [self isDisplayingPlaceholder] ? _placeholderTextKitComponents : _textKitComponents;
CGSize textSize = [displayedComponents sizeForConstrainedWidth:constrainedSize.width];
textSize = ceilSizeValue(textSize);
return CGSizeMake(fminf(textSize.width, constrainedSize.width), fminf(textSize.height, constrainedSize.height));
return CGSizeMake(fminf(ceilf(textSize.width), constrainedSize.width), fminf(ceilf(textSize.height), constrainedSize.height));
}
- (void)layout

View File

@ -531,7 +531,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
BOOL shouldReleaseImageOnBackgroundThread = imageSize.width > kMinReleaseImageOnBackgroundSize.width ||
imageSize.height > kMinReleaseImageOnBackgroundSize.height;
if (shouldReleaseImageOnBackgroundThread) {
ASPerformBlockOnBackgroundThread(^{
ASPerformBlockOnDeallocationQueue(^{
image = nil;
});
}

View File

@ -378,7 +378,7 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
BOOL shouldReleaseImageOnBackgroundThread = imageSize.width > kMinReleaseImageOnBackgroundSize.width ||
imageSize.height > kMinReleaseImageOnBackgroundSize.height;
if (shouldReleaseImageOnBackgroundThread) {
ASPerformBlockOnBackgroundThread(^{
ASPerformBlockOnDeallocationQueue(^{
image = nil;
});
}

View File

@ -260,7 +260,7 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
// actually dealloc.
__block ASTextKitRenderer *renderer = _renderer;
ASPerformBlockOnBackgroundThread(^{
ASPerformBlockOnDeallocationQueue(^{
renderer = nil;
});
_renderer = nil;
@ -619,7 +619,7 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
if (_activeHighlightLayer) {
if (animated) {
__unsafe_unretained CALayer *weakHighlightLayer = _activeHighlightLayer;
__weak CALayer *weakHighlightLayer = _activeHighlightLayer;
_activeHighlightLayer = nil;
weakHighlightLayer.opacity = 0.0;

View File

@ -17,9 +17,16 @@ ASDISPLAYNODE_EXTERN_C_BEGIN
BOOL ASSubclassOverridesSelector(Class superclass, Class subclass, SEL selector);
BOOL ASSubclassOverridesClassSelector(Class superclass, Class subclass, SEL selector);
/// Dispatches the given block to the main queue if not already running on the main thread
void ASPerformBlockOnMainThread(void (^block)());
/// Dispatches the given block to a background queue with priority of DISPATCH_QUEUE_PRIORITY_DEFAULT if not already run on a background queue
void ASPerformBlockOnBackgroundThread(void (^block)()); // DISPATCH_QUEUE_PRIORITY_DEFAULT
/// Dispatches a block on to a serial queue that's main purpose is for deallocation of objects on a background thread
void ASPerformBlockOnDeallocationQueue(void (^block)());
CGFloat ASScreenScale();
CGFloat ASFloorPixelValue(CGFloat f);

View File

@ -52,6 +52,17 @@ void ASPerformBlockOnBackgroundThread(void (^block)())
}
}
void ASPerformBlockOnDeallocationQueue(void (^block)())
{
static dispatch_queue_t queue;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
queue = dispatch_queue_create("org.AsyncDisplayKit.deallocationQueue", DISPATCH_QUEUE_SERIAL);
});
dispatch_async(queue, block);
}
CGFloat ASScreenScale()
{
static CGFloat __scale = 0.0;