mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-09 01:25:01 +00:00
[iOS] Fix clipRule="evenodd"
https://github.com/react-native-community/react-native-svg/issues/983
This commit is contained in:
+4
-34
@@ -23,7 +23,6 @@
|
||||
BOOL _transparent;
|
||||
RNSVGClipPath *_clipNode;
|
||||
CGPathRef _cachedClipPath;
|
||||
CGImageRef _clipMask;
|
||||
CGFloat canvasWidth;
|
||||
CGFloat canvasHeight;
|
||||
CGFloat canvasDiagonal;
|
||||
@@ -225,10 +224,8 @@ CGFloat const RNSVG_DEFAULT_FONT_SIZE = 12;
|
||||
return;
|
||||
}
|
||||
CGPathRelease(_cachedClipPath);
|
||||
CGImageRelease(_clipMask);
|
||||
_cachedClipPath = nil;
|
||||
_clipPath = clipPath;
|
||||
_clipMask = nil;
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
@@ -238,10 +235,8 @@ CGFloat const RNSVG_DEFAULT_FONT_SIZE = 12;
|
||||
return;
|
||||
}
|
||||
CGPathRelease(_cachedClipPath);
|
||||
CGImageRelease(_clipMask);
|
||||
_cachedClipPath = nil;
|
||||
_clipRule = clipRule;
|
||||
_clipMask = nil;
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
@@ -287,24 +282,6 @@ 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;
|
||||
@@ -315,16 +292,11 @@ CGFloat const RNSVG_DEFAULT_FONT_SIZE = 12;
|
||||
CGPathRef clipPath = [self getClipPath:context];
|
||||
|
||||
if (clipPath) {
|
||||
if (!_clipMask) {
|
||||
CGContextAddPath(context, clipPath);
|
||||
if (_clipNode.clipRule == kRNSVGCGFCRuleEvenodd) {
|
||||
CGContextEOClip(context);
|
||||
} else {
|
||||
CGContextClip(context);
|
||||
}
|
||||
CGContextAddPath(context, clipPath);
|
||||
if (_clipNode.clipRule == kRNSVGCGFCRuleEvenodd) {
|
||||
CGContextEOClip(context);
|
||||
} else {
|
||||
CGRect bounds = CGContextGetClipBoundingBox(context);
|
||||
CGContextClipToMask(context, bounds, _clipMask);
|
||||
CGContextClip(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -551,9 +523,7 @@ 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