clipPathId => clipPathRef

This commit is contained in:
Horcrux
2016-07-19 09:34:27 +08:00
parent efa7363b6f
commit d610729208
10 changed files with 34 additions and 34 deletions

View File

@@ -87,16 +87,16 @@ public class RNSVGSvgViewShadowNode extends LayoutShadowNode {
return viewTag;
}
public void defineClipPath(Path clipPath, String clipPathId) {
mDefinedClipPaths.put(clipPathId, clipPath);
public void defineClipPath(Path clipPath, String clipPathRef) {
mDefinedClipPaths.put(clipPathRef, clipPath);
}
// TODO: remove unmounted clipPath
public void removeClipPath(String clipPathId) {
mDefinedClipPaths.remove(clipPathId);
public void removeClipPath(String clipPathRef) {
mDefinedClipPaths.remove(clipPathRef);
}
public Path getDefinedClipPath(String clipPathId) {
return mDefinedClipPaths.get(clipPathId);
public Path getDefinedClipPath(String clipPathRef) {
return mDefinedClipPaths.get(clipPathRef);
}
}

View File

@@ -111,9 +111,9 @@ public abstract class RNSVGVirtualNode extends LayoutShadowNode {
markUpdated();
}
@ReactProp(name = "clipPathId")
public void setClipPathId(String clipPathId) {
mClipPathId = clipPathId;
@ReactProp(name = "clipPathRef")
public void setClipPathId(String clipPathRef) {
mClipPathId = clipPathRef;
markUpdated();
}

View File

@@ -12,7 +12,7 @@
- (void)renderLayerTo:(CGContextRef)context
{
[[self getSvgView] defineClipPath:[self getPath:context] clipPathId:self.name];
[[self getSvgView] defineClipPath:[self getPath:context] clipPathRef:self.name];
}
// hitTest delagate

View File

@@ -17,10 +17,10 @@
/**
* define <ClipPath></ClipPath> content as clipPath template.
*/
- (void)defineClipPath:(CGPathRef)clipPath clipPathId:(NSString *)clipPathId;
- (void)defineClipPath:(CGPathRef)clipPath clipPathRef:(NSString *)clipPathId;
- (void)removeClipPath:(NSString *)clipPathId;
- (void)removeClipPath:(NSString *)clipPathRef;
- (CGPathRef)getDefinedClipPath:(NSString *)clipPathId;
- (CGPathRef)getDefinedClipPath:(NSString *)clipPathRef;
@end

View File

@@ -42,10 +42,10 @@
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
for (RNSVGNode *node in self.subviews) {
[node renderTo:context];
if (node.responsible && !self.responsible) {
self.responsible = YES;
}
@@ -62,24 +62,24 @@
return self.responsible ? [super hitTest:point withEvent:event] : nil;
}
- (void)defineClipPath:(CGPathRef)clipPath clipPathId:(NSString *)clipPathId
- (void)defineClipPath:(CGPathRef)clipPath clipPathRef:(NSString *)clipPathRef
{
if (clipPaths == NULL) {
clipPaths = [[NSMutableDictionary alloc] init];
}
[clipPaths setValue:[NSValue valueWithPointer:clipPath] forKey:clipPathId];
[clipPaths setValue:[NSValue valueWithPointer:clipPath] forKey:clipPathRef];
}
- (void)removeClipPath:(NSString *)clipPathId
- (void)removeClipPath:(NSString *)clipPathRef
{
if (clipPaths != NULL) {
[clipPaths removeObjectForKey:clipPathId];
[clipPaths removeObjectForKey:clipPathRef];
}
}
- (CGPathRef)getDefinedClipPath:(NSString *)clipPathId
- (CGPathRef)getDefinedClipPath:(NSString *)clipPathRef
{
return [[clipPaths valueForKey:clipPathId] pointerValue];
return [[clipPaths valueForKey:clipPathRef] pointerValue];
}
@end

View File

@@ -22,7 +22,7 @@
@property (nonatomic, assign) CGFloat opacity;
@property (nonatomic, assign) RNSVGCGFCRule clipRule;
@property (nonatomic, assign) CGPathRef clipPath; // convert clipPath="M0,0 L0,10 L10,10z" into path
@property (nonatomic, strong) NSString *clipPathId; // use clipPath="url(#clip)" as ClipPath
@property (nonatomic, strong) NSString *clipPathRef; // use clipPath="url(#clip)" as ClipPath
@property (nonatomic, assign) BOOL responsible;
- (void)invalidate;

View File

@@ -35,13 +35,13 @@
if (opacity == _opacity) {
return;
}
if (opacity < 0) {
opacity = 0;
} else if (opacity > 1) {
opacity = 1;
}
[self invalidate];
_opacity = opacity;
}
@@ -63,7 +63,7 @@
float opacity = self.opacity;
BOOL transparent = opacity < 1;
// This needs to be painted on a layer before being composited.
CGContextSaveGState(context);
CGContextConcatCTM(context, self.transform);
@@ -97,20 +97,20 @@
- (CGPathRef)getClipPath
{
CGPathRef clipPath = nil;
if (self.clipPath) {
clipPath = self.clipPath;
} else if (self.clipPathId) {
clipPath = [[self getSvgView] getDefinedClipPath:self.clipPathId];
} else if (self.clipPathRef) {
clipPath = [[self getSvgView] getDefinedClipPath:self.clipPathRef];
}
return clipPath;
}
- (void)clip:(CGContextRef)context
{
CGPathRef clipPath = [self getClipPath];
if (clipPath != NULL) {
CGContextAddPath(context, [self getClipPath]);
if (self.clipRule == kRNSVGCGFCRuleEvenodd) {
@@ -138,7 +138,7 @@
while ([parent class] != [RNSVGSvgView class]) {
parent = parent.superview;
}
return (RNSVGSvgView *)parent;
}

View File

@@ -31,7 +31,7 @@ RCT_EXPORT_MODULE()
RCT_EXPORT_VIEW_PROPERTY(opacity, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(trans, CGAffineTransform)
RCT_EXPORT_VIEW_PROPERTY(clipPathId, NSString)
RCT_EXPORT_VIEW_PROPERTY(clipPathRef, NSString)
RCT_EXPORT_VIEW_PROPERTY(responsible, BOOL)
@end

View File

@@ -46,7 +46,7 @@ const NodeAttributes = {
diff: arrayDiffer
},
opacity: true,
clipPathId: true,
clipPathRef: true,
responsible: true
};

View File

@@ -29,7 +29,7 @@ export default function (props) {
let patternName = `${matched[1]}:${props.svgId}`;
let pattern = clipPatterns[patternName];
if (pattern) {
clippingProps.clipPathId = pattern;
clippingProps.clipPathRef = pattern;
} else {
clippingProps = null;
// TODO: warn