diff --git a/Schemas/configuration.json b/Schemas/configuration.json index 925720f6a..71275e31e 100644 --- a/Schemas/configuration.json +++ b/Schemas/configuration.json @@ -23,7 +23,6 @@ "exp_skip_clear_data", "exp_did_enter_preload_skip_asm_layout", "exp_dispatch_apply", - "exp_text_drawing", "exp_oom_bg_dealloc_disable", "exp_transaction_operation_retain_cycle", "exp_remove_textkit_initialising_lock" diff --git a/Source/ASExperimentalFeatures.h b/Source/ASExperimentalFeatures.h index ef91628b3..0eed80034 100644 --- a/Source/ASExperimentalFeatures.h +++ b/Source/ASExperimentalFeatures.h @@ -27,11 +27,10 @@ typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) { ASExperimentalSkipClearData = 1 << 6, // exp_skip_clear_data ASExperimentalDidEnterPreloadSkipASMLayout = 1 << 7, // exp_did_enter_preload_skip_asm_layout ASExperimentalDispatchApply = 1 << 8, // exp_dispatch_apply - ASExperimentalTextDrawing = 1 << 9, // exp_text_drawing - ASExperimentalOOMBackgroundDeallocDisable = 1 << 10, // exp_oom_bg_dealloc_disable - ASExperimentalTransactionOperationRetainCycle = 1 << 11, // exp_transaction_operation_retain_cycle - ASExperimentalRemoveTextKitInitialisingLock = 1 << 12, // exp_remove_textkit_initialising_lock - ASExperimentalDrawingGlobal = 1 << 13, // exp_drawing_global + ASExperimentalOOMBackgroundDeallocDisable = 1 << 9, // exp_oom_bg_dealloc_disable + ASExperimentalTransactionOperationRetainCycle = 1 << 10, // exp_transaction_operation_retain_cycle + ASExperimentalRemoveTextKitInitialisingLock = 1 << 11, // exp_remove_textkit_initialising_lock + ASExperimentalDrawingGlobal = 1 << 12, // exp_drawing_global ASExperimentalFeatureAll = 0xFFFFFFFF }; diff --git a/Source/ASExperimentalFeatures.mm b/Source/ASExperimentalFeatures.mm index 9594a8f60..665db4e53 100644 --- a/Source/ASExperimentalFeatures.mm +++ b/Source/ASExperimentalFeatures.mm @@ -21,7 +21,6 @@ @"exp_skip_clear_data", @"exp_did_enter_preload_skip_asm_layout", @"exp_dispatch_apply", - @"exp_text_drawing", @"exp_oom_bg_dealloc_disable", @"exp_transaction_operation_retain_cycle", @"exp_remove_textkit_initialising_lock", diff --git a/Source/ASTextNode.mm b/Source/ASTextNode.mm index e2c458c44..636619447 100644 --- a/Source/ASTextNode.mm +++ b/Source/ASTextNode.mm @@ -25,6 +25,7 @@ #import #import #import +#import #import #import @@ -559,40 +560,12 @@ + (UIImage *)displayWithParameters:(id)parameters isCancelled:(NS_NOES if (drawParameter->_bounds.size.width <= 0 || drawParameter->_bounds.size.height <= 0) { return nil; } - - UIImage *result = nil; + UIColor *backgroundColor = drawParameter->_backgroundColor; UIEdgeInsets textContainerInsets = drawParameter ? drawParameter->_textContainerInsets : UIEdgeInsetsZero; ASTextKitRenderer *renderer = [drawParameter rendererForBounds:drawParameter->_bounds]; - BOOL renderedWithGraphicsRenderer = NO; - - if (AS_AVAILABLE_IOS_TVOS(10, 10)) { - if (ASActivateExperimentalFeature(ASExperimentalTextDrawing)) { - renderedWithGraphicsRenderer = YES; - UIGraphicsImageRenderer *graphicsRenderer = [[UIGraphicsImageRenderer alloc] initWithSize:CGSizeMake(drawParameter->_bounds.size.width, drawParameter->_bounds.size.height)]; - result = [graphicsRenderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) { - CGContextRef context = rendererContext.CGContext; - ASDisplayNodeAssert(context, @"This is no good without a context."); - - CGContextSaveGState(context); - CGContextTranslateCTM(context, textContainerInsets.left, textContainerInsets.top); - - // Fill background - if (backgroundColor != nil) { - [backgroundColor setFill]; - UIRectFillUsingBlendMode(CGContextGetClipBoundingBox(context), kCGBlendModeCopy); - } - - // Draw text - [renderer drawInContext:context bounds:drawParameter->_bounds]; - CGContextRestoreGState(context); - }]; - } - } - - if (!renderedWithGraphicsRenderer) { - UIGraphicsBeginImageContextWithOptions(CGSizeMake(drawParameter->_bounds.size.width, drawParameter->_bounds.size.height), drawParameter->_opaque, drawParameter->_contentScale); - + + UIImage *result = ASGraphicsCreateImageWithOptions(CGSizeMake(drawParameter->_bounds.size.width, drawParameter->_bounds.size.height), drawParameter->_opaque, drawParameter->_contentScale, nil, nil, ^{ CGContextRef context = UIGraphicsGetCurrentContext(); ASDisplayNodeAssert(context, @"This is no good without a context."); @@ -608,10 +581,7 @@ + (UIImage *)displayWithParameters:(id)parameters isCancelled:(NS_NOES // Draw text [renderer drawInContext:context bounds:drawParameter->_bounds]; CGContextRestoreGState(context); - - result = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - } + }); return result; } diff --git a/Tests/ASConfigurationTests.mm b/Tests/ASConfigurationTests.mm index 150360ea9..ce9a10bab 100644 --- a/Tests/ASConfigurationTests.mm +++ b/Tests/ASConfigurationTests.mm @@ -27,7 +27,6 @@ ASExperimentalSkipClearData, ASExperimentalDidEnterPreloadSkipASMLayout, ASExperimentalDispatchApply, - ASExperimentalTextDrawing, ASExperimentalOOMBackgroundDeallocDisable, ASExperimentalTransactionOperationRetainCycle, ASExperimentalRemoveTextKitInitialisingLock, @@ -53,7 +52,6 @@ + (NSArray *)names { @"exp_skip_clear_data", @"exp_did_enter_preload_skip_asm_layout", @"exp_dispatch_apply", - @"exp_text_drawing", @"exp_oom_bg_dealloc_disable", @"exp_transaction_operation_retain_cycle", @"exp_remove_textkit_initialising_lock",