mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-02 06:35:04 +00:00
merge master fix conflicts
This commit is contained in:
@@ -13,11 +13,10 @@
|
||||
|
||||
- (void)renderTo:(CGContextRef)context
|
||||
{
|
||||
for (RNSVGNode *node in self.subviews) {
|
||||
if ([node isKindOfClass:[RNSVGNode class]]) {
|
||||
[node saveDefinition];
|
||||
}
|
||||
}
|
||||
[self traverseSubviews:^(RNSVGNode *node) {
|
||||
[node saveDefinition];
|
||||
return YES;
|
||||
}];
|
||||
}
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
{
|
||||
RNSVGSvgView* svg = [self getSvgView];
|
||||
[self clip:context];
|
||||
|
||||
|
||||
CGContextConcatCTM(context, transform);
|
||||
[self traverseSubviews:^(RNSVGNode *node) {
|
||||
if (node.responsible && !svg.responsible) {
|
||||
@@ -28,11 +28,11 @@
|
||||
}
|
||||
return YES;
|
||||
}];
|
||||
|
||||
|
||||
[self traverseSubviews:^(RNSVGNode *node) {
|
||||
[node mergeProperties:self mergeList:self.ownedPropList inherited:YES];
|
||||
[node mergeProperties:self mergeList:self.attributeList inherited:YES];
|
||||
[node renderTo:context];
|
||||
|
||||
|
||||
if ([node isKindOfClass: [RNSVGRenderable class]]) {
|
||||
RNSVGRenderable *renderable = node;
|
||||
[self concatLayoutBoundingBox:[renderable getLayoutBoundingBox]];
|
||||
@@ -59,19 +59,19 @@
|
||||
CGPathAddPath(path, &transform, [node getPath:context]);
|
||||
return YES;
|
||||
}];
|
||||
|
||||
|
||||
return (CGPathRef)CFAutorelease(path);
|
||||
}
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event withTransform:(CGAffineTransform)transform
|
||||
{
|
||||
CGAffineTransform matrix = CGAffineTransformConcat(self.matrix, transform);
|
||||
|
||||
|
||||
CGPathRef clip = [self getComputedClipPath];
|
||||
if (clip && !CGPathContainsPoint(clip, nil, point, NO)) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
for (RNSVGNode *node in [self.subviews reverseObjectEnumerator]) {
|
||||
if ([node isKindOfClass:[RNSVGNode class]]) {
|
||||
if (event) {
|
||||
@@ -81,7 +81,7 @@
|
||||
}
|
||||
|
||||
UIView *view = [node hitTest: point withEvent:event withTransform:matrix];
|
||||
|
||||
|
||||
if (view) {
|
||||
node.active = YES;
|
||||
if (node.responsible || (node != view)) {
|
||||
@@ -101,20 +101,12 @@
|
||||
RNSVGSvgView* svg = [self getSvgView];
|
||||
[svg defineTemplate:self templateName:self.name];
|
||||
}
|
||||
|
||||
|
||||
[self traverseSubviews:^(RNSVGNode *node) {
|
||||
[node saveDefinition];
|
||||
return YES;
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)mergeProperties:(RNSVGNode *)target mergeList:(NSArray<NSString *> *)mergeList
|
||||
{
|
||||
[self traverseSubviews:^(RNSVGNode *node) {
|
||||
[node mergeProperties:target mergeList:mergeList];
|
||||
return YES;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)resetProperties
|
||||
@@ -125,16 +117,4 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)traverseSubviews:(BOOL (^)(__kindof RNSVGNode *node))block
|
||||
{
|
||||
for (RNSVGNode *node in self.subviews) {
|
||||
if ([node isKindOfClass:[RNSVGNode class]]) {
|
||||
if (!block(node)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
#import "RNSVGImage.h"
|
||||
#import "RCTImageSource.h"
|
||||
#import "RCTConvert+RNSVG.h"
|
||||
#import "RCTLog.h"
|
||||
#import <React/RCTImageSource.h>
|
||||
#import <React/RCTLog.h>
|
||||
#import "RNSVGViewBox.h"
|
||||
|
||||
@implementation RNSVGImage
|
||||
|
||||
+6
-102
@@ -15,116 +15,20 @@
|
||||
if (d == _d) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
[self invalidate];
|
||||
CGPathRelease(_d);
|
||||
_d = CGPathRetain(d);
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
CGPathRelease(_d);
|
||||
}
|
||||
|
||||
- (void)renderLayerTo:(CGContextRef)context
|
||||
{
|
||||
// todo: add detection if path has changed since last update.
|
||||
self.d = [self getPath:context];
|
||||
|
||||
CGPathRef path = self.d;
|
||||
[self setLayoutBoundingBox:CGPathGetBoundingBox(path)];
|
||||
|
||||
if ((!self.fill && !self.stroke) || !path) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ([self getSvgView].responsible) {
|
||||
// Add path to hitArea
|
||||
CGMutablePathRef hitAreaPath = CGPathCreateMutableCopy(path);
|
||||
if (self.stroke) {
|
||||
// Add stroke to hitArea
|
||||
CGPathRef strokePath = CGPathCreateCopyByStrokingPath(hitAreaPath, nil, self.strokeWidth, self.strokeLinecap, self.strokeLinejoin, self.strokeMiterlimit);
|
||||
CGPathAddPath(hitAreaPath, nil, strokePath);
|
||||
CGPathRelease(strokePath);
|
||||
}
|
||||
|
||||
CGAffineTransform transform = self.matrix;
|
||||
self.hitArea = CGPathCreateCopyByTransformingPath(hitAreaPath, &transform);
|
||||
CGPathRelease(hitAreaPath);
|
||||
}
|
||||
|
||||
if (self.opacity == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
CGPathDrawingMode mode = kCGPathStroke;
|
||||
BOOL fillColor = YES;
|
||||
|
||||
if (self.fill) {
|
||||
mode = self.fillRule == kRNSVGCGFCRuleEvenodd ? kCGPathEOFill : kCGPathFill;
|
||||
fillColor = [self.fill applyFillColor:context opacity:self.fillOpacity];
|
||||
|
||||
if (!fillColor) {
|
||||
[self clip:context];
|
||||
|
||||
CGContextSaveGState(context);
|
||||
CGContextAddPath(context, path);
|
||||
CGContextClip(context);
|
||||
RNSVGBrushConverter *brushConverter = [[self getSvgView] getDefinedBrushConverter:[self.fill brushRef]];
|
||||
[self.fill paint:context opacity:self.fillOpacity brushConverter:brushConverter];
|
||||
CGContextRestoreGState(context);
|
||||
if (!self.stroke) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self.stroke) {
|
||||
CGContextSetLineWidth(context, self.strokeWidth);
|
||||
CGContextSetLineCap(context, self.strokeLinecap);
|
||||
CGContextSetLineJoin(context, self.strokeLinejoin);
|
||||
RNSVGCGFloatArray dash = self.strokeDasharray;
|
||||
|
||||
if (dash.count) {
|
||||
CGContextSetLineDash(context, self.strokeDashoffset, dash.array, dash.count);
|
||||
}
|
||||
|
||||
if (!fillColor) {
|
||||
CGContextAddPath(context, path);
|
||||
CGContextReplacePathWithStrokedPath(context);
|
||||
CGContextClip(context);
|
||||
}
|
||||
|
||||
if ([self.stroke applyStrokeColor:context opacity:self.strokeOpacity]) {
|
||||
if (mode == kCGPathFill) {
|
||||
mode = kCGPathFillStroke;
|
||||
} else if (mode == kCGPathEOFill) {
|
||||
mode = kCGPathEOFillStroke;
|
||||
}
|
||||
} else {
|
||||
// draw fill
|
||||
[self clip:context];
|
||||
CGContextAddPath(context, path);
|
||||
CGContextDrawPath(context, mode);
|
||||
|
||||
// draw stroke
|
||||
CGContextAddPath(context, path);
|
||||
CGContextReplacePathWithStrokedPath(context);
|
||||
CGContextClip(context);
|
||||
RNSVGBrushConverter *brushConverter = [[self getSvgView] getDefinedBrushConverter:[self.stroke brushRef]];
|
||||
[self.stroke paint:context opacity:self.strokeOpacity brushConverter:brushConverter];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[self clip:context];
|
||||
CGContextAddPath(context, path);
|
||||
CGContextDrawPath(context, mode);
|
||||
}
|
||||
|
||||
- (CGPathRef)getPath:(CGContextRef)context
|
||||
{
|
||||
return self.d;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
CGPathRelease(_d);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#import "RNSVGSvgView.h"
|
||||
|
||||
#import "RNSVGNode.h"
|
||||
#import "RCTLog.h"
|
||||
#import <React/RCTLog.h>
|
||||
|
||||
@implementation RNSVGSvgView
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
#import "RNSVGUse.h"
|
||||
#import "RCTLog.h"
|
||||
#import <React/RCTLog.h>
|
||||
|
||||
@implementation RNSVGUse
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
if (template) {
|
||||
[self beginTransparencyLayer:context];
|
||||
[self clip:context];
|
||||
[template mergeProperties:self mergeList:self.ownedPropList];
|
||||
[template mergeProperties:self mergeList:self.attributeList inherited:YES];
|
||||
[template renderTo:context];
|
||||
[template resetProperties];
|
||||
[self endTransparencyLayer:context];
|
||||
|
||||
Reference in New Issue
Block a user