mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Add an experimental "no-copy" renderer (#741)
* Add "ASGraphicsContext" to skip copying our rendered images * Zero the buffer before making a context * Update license header * Update dangerfile * Make it a runtime flag * Restore GState for good measure * Free buffer if end without image * Enable the experiment, and cut out the middle-man * Fix typo
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#import <AsyncDisplayKit/AsyncDisplayKit+Debug.h>
|
||||
#import <AsyncDisplayKit/ASAbstractLayoutController.h>
|
||||
#import <AsyncDisplayKit/ASGraphicsContext.h>
|
||||
#import <AsyncDisplayKit/ASLayout.h>
|
||||
#import <AsyncDisplayKit/ASWeakSet.h>
|
||||
#import <AsyncDisplayKit/UIImage+ASConvenience.h>
|
||||
@@ -148,7 +149,7 @@ static BOOL __enableHitTestDebug = NO;
|
||||
UIColor *clipsBorderColor = [UIColor colorWithRed:30/255.0 green:90/255.0 blue:50/255.0 alpha:0.7];
|
||||
CGRect imgRect = CGRectMake(0, 0, 2.0 * borderWidth + 1.0, 2.0 * borderWidth + 1.0);
|
||||
|
||||
UIGraphicsBeginImageContext(imgRect.size);
|
||||
ASGraphicsBeginImageContextWithOptions(imgRect.size, NO, 1);
|
||||
|
||||
[fillColor setFill];
|
||||
UIRectFill(imgRect);
|
||||
@@ -156,8 +157,7 @@ static BOOL __enableHitTestDebug = NO;
|
||||
[self drawEdgeIfClippedWithEdges:clippedEdges color:clipsBorderColor borderWidth:borderWidth imgRect:imgRect];
|
||||
[self drawEdgeIfClippedWithEdges:clipsToBoundsClippedEdges color:borderColor borderWidth:borderWidth imgRect:imgRect];
|
||||
|
||||
UIImage *debugHighlightImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
UIImage *debugHighlightImage = ASGraphicsGetImageAndEndCurrentContext();
|
||||
|
||||
UIEdgeInsets edgeInsets = UIEdgeInsetsMake(borderWidth, borderWidth, borderWidth, borderWidth);
|
||||
debugOverlay.image = [debugHighlightImage resizableImageWithCapInsets:edgeInsets resizingMode:UIImageResizingModeStretch];
|
||||
|
||||
Reference in New Issue
Block a user