mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-04 15:44:24 +00:00
Fix caching of text
This commit is contained in:
@@ -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
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user