Fix caching of text

This commit is contained in:
Mikael Sand
2018-08-25 00:17:36 +03:00
parent ce602c1d62
commit d0a9cbaceb
2 changed files with 12 additions and 7 deletions
+1
View File
@@ -60,6 +60,7 @@ static double RNSVGTSpan_radToDeg = 180 / M_PI;
{ {
CGPathRelease(_cache); CGPathRelease(_cache);
_cache = nil; _cache = nil;
self.path = nil;
} }
- (void)dealloc - (void)dealloc
+11 -7
View File
@@ -18,6 +18,12 @@
RNSVGGlyphContext *_glyphContext; RNSVGGlyphContext *_glyphContext;
} }
- (void)invalidate
{
[super invalidate];
[self releaseCachedPath];
}
- (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect - (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect
{ {
[self clip:context]; [self clip:context];
@@ -26,7 +32,6 @@
CGPathRef path = [self getGroupPath:context]; CGPathRef path = [self getGroupPath:context];
[self renderGroupTo:context rect:rect]; [self renderGroupTo:context rect:rect];
[self releaseCachedPath];
CGContextRestoreGState(context); CGContextRestoreGState(context);
CGPathRef transformedPath = CGPathCreateCopyByTransformingPath(path, &CGAffineTransformIdentity); CGPathRef transformedPath = CGPathCreateCopyByTransformingPath(path, &CGAffineTransformIdentity);
@@ -63,7 +68,6 @@
{ {
[self setupGlyphContext:context]; [self setupGlyphContext:context];
CGPathRef groupPath = [self getGroupPath:context]; CGPathRef groupPath = [self getGroupPath:context];
[self releaseCachedPath];
return (CGPathRef)CFAutorelease(CGPathCreateCopyByTransformingPath(groupPath, &CGAffineTransformIdentity)); return (CGPathRef)CFAutorelease(CGPathCreateCopyByTransformingPath(groupPath, &CGAffineTransformIdentity));
} }
@@ -95,7 +99,7 @@
if (_alignmentBaseline != nil) { if (_alignmentBaseline != nil) {
return _alignmentBaseline; return _alignmentBaseline;
} }
UIView* parent = self.superview; UIView* parent = self.superview;
while (parent != nil) { while (parent != nil) {
if ([parent isKindOfClass:[RNSVGText class]]) { if ([parent isKindOfClass:[RNSVGText class]]) {
@@ -108,7 +112,7 @@
} }
parent = [parent superview]; parent = [parent superview];
} }
if (_alignmentBaseline == nil) { if (_alignmentBaseline == nil) {
_alignmentBaseline = RNSVGAlignmentBaselineStrings[0]; _alignmentBaseline = RNSVGAlignmentBaselineStrings[0];
} }
@@ -120,7 +124,7 @@
if (_baselineShift != nil) { if (_baselineShift != nil) {
return _baselineShift; return _baselineShift;
} }
UIView* parent = [self superview]; UIView* parent = [self superview];
while (parent != nil) { while (parent != nil) {
if ([parent isKindOfClass:[RNSVGText class]]) { if ([parent isKindOfClass:[RNSVGText class]]) {
@@ -133,10 +137,10 @@
} }
parent = [parent superview]; parent = [parent superview];
} }
// set default value // set default value
_baselineShift = @""; _baselineShift = @"";
return _baselineShift; return _baselineShift;
} }