fix transform bug
This commit is contained in:
Родитель
8e0fb39a78
Коммит
0fd92e30ea
|
@ -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];
|
||||
|
|
Загрузка…
Ссылка в новой задаче