This commit is contained in:
Horcrux 2016-07-27 16:22:31 +08:00
Родитель 8e0fb39a78
Коммит 0fd92e30ea
3 изменённых файлов: 45 добавлений и 44 удалений

Просмотреть файл

@ -29,7 +29,7 @@
{
CGMutablePathRef path = CGPathCreateMutable();
for (RNSVGNode *node in self.subviews) {
CGAffineTransform transform = node.matrix;
CGAffineTransform transform = node.transform;
CGPathAddPath(path, &transform, [node getPath:context]);
}
return (CGPathRef)CFAutorelease(path);

Просмотреть файл

@ -71,48 +71,10 @@
- (void)setMatrix:(CGAffineTransform)matrix
{
_matrix = matrix;
self.transform = matrix;
[self invalidate];
}
- (void)beginTransparencyLayer:(CGContextRef)context
{
if (_transparent) {
CGContextBeginTransparencyLayer(context, NULL);
}
}
- (void)endTransparencyLayer:(CGContextRef)context
{
if (_transparent) {
CGContextEndTransparencyLayer(context);
}
}
- (void)renderTo:(CGContextRef)context
{
float opacity = self.opacity;
// This needs to be painted on a layer before being composited.
CGContextSaveGState(context);
CGContextConcatCTM(context, self.matrix);
CGContextSetAlpha(context, opacity);
[self beginTransparencyLayer:context];
[self renderClip:context];
[self renderLayerTo:context];
[self endTransparencyLayer:context];
CGContextRestoreGState(context);
}
- (void)renderClip:(CGContextRef)context
{
if (self.clipPathRef) {
self.clipPath = [[[self getSvgView] getDefinedClipPath:self.clipPathRef] getPath:context];
}
}
- (void)setClipPath:(CGPathRef)clipPath
{
if (_clipPath == clipPath) {
@ -133,10 +95,42 @@
_clipPathRef = clipPathRef;
}
- (CGPathRef)getPath: (CGContextRef) context
- (void)beginTransparencyLayer:(CGContextRef)context
{
// abstract
return (CGPathRef)CFAutorelease(CGPathCreateMutable());
if (_transparent) {
CGContextBeginTransparencyLayer(context, NULL);
}
}
- (void)endTransparencyLayer:(CGContextRef)context
{
if (_transparent) {
CGContextEndTransparencyLayer(context);
}
}
- (void)renderTo:(CGContextRef)context
{
float opacity = self.opacity;
// This needs to be painted on a layer before being composited.
CGContextSaveGState(context);
CGContextConcatCTM(context, self.transform);
CGContextSetAlpha(context, opacity);
[self beginTransparencyLayer:context];
[self renderClip:context];
[self renderLayerTo:context];
[self endTransparencyLayer:context];
CGContextRestoreGState(context);
}
- (void)renderClip:(CGContextRef)context
{
if (self.clipPathRef) {
self.clipPath = [[[self getSvgView] getDefinedClipPath:self.clipPathRef] getPath:context];
}
}
- (void)clip:(CGContextRef)context
@ -153,6 +147,13 @@
}
}
- (CGPathRef)getPath: (CGContextRef) context
{
// abstract
return nil;
}
- (void)renderLayerTo:(CGContextRef)context
{
// abstract

Просмотреть файл

@ -121,7 +121,7 @@
// This is a terminal with only one painting. Therefore we don't need to paint this
// off-screen. We can just composite it straight onto the buffer.
CGContextSaveGState(context);
CGContextConcatCTM(context, self.matrix);
CGContextConcatCTM(context, self.transform);
CGContextSetAlpha(context, self.opacity);
[self renderClip:context];
[self renderLayerTo:context];