mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-09 09:27:20 +00:00
+34
-4
@@ -23,6 +23,7 @@
|
||||
BOOL _transparent;
|
||||
RNSVGClipPath *_clipNode;
|
||||
CGPathRef _cachedClipPath;
|
||||
CGImageRef _clipMask;
|
||||
CGFloat canvasWidth;
|
||||
CGFloat canvasHeight;
|
||||
CGFloat canvasDiagonal;
|
||||
@@ -224,8 +225,10 @@ CGFloat const RNSVG_DEFAULT_FONT_SIZE = 12;
|
||||
return;
|
||||
}
|
||||
CGPathRelease(_cachedClipPath);
|
||||
CGImageRelease(_clipMask);
|
||||
_cachedClipPath = nil;
|
||||
_clipPath = clipPath;
|
||||
_clipMask = nil;
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
@@ -235,8 +238,10 @@ CGFloat const RNSVG_DEFAULT_FONT_SIZE = 12;
|
||||
return;
|
||||
}
|
||||
CGPathRelease(_cachedClipPath);
|
||||
CGImageRelease(_clipMask);
|
||||
_cachedClipPath = nil;
|
||||
_clipRule = clipRule;
|
||||
_clipMask = nil;
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
@@ -282,6 +287,24 @@ CGFloat const RNSVG_DEFAULT_FONT_SIZE = 12;
|
||||
CGPathRelease(_cachedClipPath);
|
||||
}
|
||||
_cachedClipPath = CGPathRetain([_clipNode getPath:context]);
|
||||
if (_clipMask) {
|
||||
CGImageRelease(_clipMask);
|
||||
}
|
||||
if ([_clipNode isSimpleClipPath]) {
|
||||
_clipMask = nil;
|
||||
} else {
|
||||
CGRect bounds = CGContextGetClipBoundingBox(context);
|
||||
CGSize size = bounds.size;
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
|
||||
CGContextRef newContext = UIGraphicsGetCurrentContext();
|
||||
CGContextTranslateCTM(newContext, 0.0, size.height);
|
||||
CGContextScaleCTM(newContext, 1.0, -1.0);
|
||||
|
||||
[_clipNode renderLayerTo:newContext rect:bounds];
|
||||
_clipMask = CGBitmapContextCreateImage(newContext);
|
||||
UIGraphicsEndImageContext();
|
||||
}
|
||||
}
|
||||
|
||||
return _cachedClipPath;
|
||||
@@ -292,11 +315,16 @@ CGFloat const RNSVG_DEFAULT_FONT_SIZE = 12;
|
||||
CGPathRef clipPath = [self getClipPath:context];
|
||||
|
||||
if (clipPath) {
|
||||
CGContextAddPath(context, clipPath);
|
||||
if (_clipNode.clipRule == kRNSVGCGFCRuleEvenodd) {
|
||||
CGContextEOClip(context);
|
||||
if (!_clipMask) {
|
||||
CGContextAddPath(context, clipPath);
|
||||
if (_clipNode.clipRule == kRNSVGCGFCRuleEvenodd) {
|
||||
CGContextEOClip(context);
|
||||
} else {
|
||||
CGContextClip(context);
|
||||
}
|
||||
} else {
|
||||
CGContextClip(context);
|
||||
CGRect bounds = CGContextGetClipBoundingBox(context);
|
||||
CGContextClipToMask(context, bounds, _clipMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,7 +551,9 @@ CGFloat const RNSVG_DEFAULT_FONT_SIZE = 12;
|
||||
{
|
||||
CGPathRelease(_cachedClipPath);
|
||||
CGPathRelease(_strokePath);
|
||||
CGImageRelease(_clipMask);
|
||||
CGPathRelease(_path);
|
||||
_clipMask = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user