mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-02-13 06:19:59 +00:00
Merge pull request #195 from facebook/text-context-passing
Safe calls in ASTextNodeRenderer
This commit is contained in:
@@ -338,7 +338,7 @@ ASDISPLAYNODE_INLINE CGFloat ceilPixelValue(CGFloat f)
|
||||
|
||||
// Draw text
|
||||
bounds.origin = parameters.textOrigin;
|
||||
[parameters.renderer drawInRect:bounds isRasterizing:isRasterizing];
|
||||
[parameters.renderer drawInRect:bounds inContext:context];
|
||||
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
|
||||
@@ -60,8 +60,7 @@ typedef NS_ENUM(NSUInteger, ASTextNodeRendererMeasureOption) {
|
||||
* Draw the renderer's text content into the bounds provided.
|
||||
*
|
||||
* @param bounds The rect in which to draw the contents of the renderer.
|
||||
* @param isRasterizing If YES, the renderer will not draw its background color
|
||||
* within the bounds.
|
||||
* @param context The CGContext in which to draw the contents of the renderer.
|
||||
*
|
||||
* @discussion Note that if a shadow is to be drawn, then the text will actually
|
||||
* draw inside a region that is inset from the bounds provided. Use
|
||||
@@ -72,7 +71,7 @@ typedef NS_ENUM(NSUInteger, ASTextNodeRendererMeasureOption) {
|
||||
* You may want to consider triggering this cost before hitting the draw method
|
||||
* if you are sensitive to this cost in drawInRect...
|
||||
*/
|
||||
- (void)drawInRect:(CGRect)bounds isRasterizing:(BOOL)isRasterizing;
|
||||
- (void)drawInRect:(CGRect)bounds inContext:(CGContextRef)context;
|
||||
|
||||
#pragma mark - Layout
|
||||
|
||||
|
||||
@@ -578,11 +578,10 @@ static const CGFloat ASTextNodeRendererTextCapHeightPadding = 1.3;
|
||||
|
||||
#pragma mark - Drawing
|
||||
|
||||
- (void)drawInRect:(CGRect)bounds isRasterizing:(BOOL)isRasterizing
|
||||
- (void)drawInRect:(CGRect)bounds inContext:(CGContextRef)context
|
||||
{
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
ASDisplayNodeAssert(context, @"This is no good without a context.");
|
||||
|
||||
UIGraphicsPushContext(context);
|
||||
CGContextSaveGState(context);
|
||||
|
||||
[self _initializeTextKitComponentsIfNeeded];
|
||||
@@ -594,6 +593,7 @@ static const CGFloat ASTextNodeRendererTextCapHeightPadding = 1.3;
|
||||
}
|
||||
|
||||
CGContextRestoreGState(context);
|
||||
UIGraphicsPopContext();
|
||||
}
|
||||
|
||||
#pragma mark - String Ranges
|
||||
|
||||
Reference in New Issue
Block a user