Revision: 5193
http://skim-app.svn.sourceforge.net/skim-app/?rev=5193&view=rev
Author: hofman
Date: 2009-02-06 17:29:22 +0000 (Fri, 06 Feb 2009)
Log Message:
-----------
Pass mirrored and flipped image drawing through a single implementation
Modified Paths:
--------------
trunk/NSImage_SKExtensions.h
trunk/NSImage_SKExtensions.m
Modified: trunk/NSImage_SKExtensions.h
===================================================================
--- trunk/NSImage_SKExtensions.h 2009-02-04 01:48:47 UTC (rev 5192)
+++ trunk/NSImage_SKExtensions.h 2009-02-06 17:29:22 UTC (rev 5193)
@@ -144,5 +144,6 @@
- (void)drawMirroredInRect:(NSRect)dstRect fromRect:(NSRect)srcRect
operation:(NSCompositingOperation)op fraction:(float)delta;
- (void)drawMirroredAndFlippedInRect:(NSRect)dstRect fromRect:(NSRect)srcRect
operation:(NSCompositingOperation)op fraction:(float)delta;
- (void)drawMirroredAndFlipped:(BOOL)isFlipped inRect:(NSRect)dstRect
fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op
fraction:(float)delta;
+- (void)drawMirrored:(BOOL)isMirrored andFlipped:(BOOL)isFlipped
inRect:(NSRect)dstRect fromRect:(NSRect)srcRect
operation:(NSCompositingOperation)op fraction:(float)delta;
@end
Modified: trunk/NSImage_SKExtensions.m
===================================================================
--- trunk/NSImage_SKExtensions.m 2009-02-04 01:48:47 UTC (rev 5192)
+++ trunk/NSImage_SKExtensions.m 2009-02-06 17:29:22 UTC (rev 5193)
@@ -1988,50 +1988,49 @@
}
- (void)drawFlippedInRect:(NSRect)dstRect fromRect:(NSRect)srcRect
operation:(NSCompositingOperation)op fraction:(float)delta {
- [NSGraphicsContext saveGraphicsState];
- NSAffineTransform *transform = [NSAffineTransform transform];
- [transform translateXBy:0.0 yBy:NSMaxY(dstRect)];
- [transform scaleXBy:1.0 yBy:-1.0];
- [transform translateXBy:0.0 yBy:-NSMinY(dstRect)];
- [transform concat];
- [self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
- [NSGraphicsContext restoreGraphicsState];
+ [self drawMirrored:NO andFlipped:YES inRect:dstRect fromRect:srcRect
operation:op fraction:delta];
}
- (void)drawFlipped:(BOOL)isFlipped inRect:(NSRect)dstRect
fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op
fraction:(float)delta {
- if (isFlipped)
- [self drawFlippedInRect:dstRect fromRect:srcRect operation:op
fraction:delta];
- else
- [self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
+ [self drawMirrored:NO andFlipped:isFlipped inRect:dstRect fromRect:srcRect
operation:op fraction:delta];
}
- (void)drawMirroredInRect:(NSRect)dstRect fromRect:(NSRect)srcRect
operation:(NSCompositingOperation)op fraction:(float)delta {
- [NSGraphicsContext saveGraphicsState];
- NSAffineTransform *transform = [NSAffineTransform transform];
- [transform translateXBy:NSMaxX(dstRect) yBy:0.0];
- [transform scaleXBy:-1.0 yBy:1.0];
- [transform translateXBy:-NSMinX(dstRect) yBy:0.0];
- [transform concat];
- [self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
- [NSGraphicsContext restoreGraphicsState];
+ [self drawMirrored:YES andFlipped:NO inRect:dstRect fromRect:srcRect
operation:op fraction:delta];
}
- (void)drawMirroredAndFlippedInRect:(NSRect)dstRect fromRect:(NSRect)srcRect
operation:(NSCompositingOperation)op fraction:(float)delta {
- [NSGraphicsContext saveGraphicsState];
- NSAffineTransform *transform = [NSAffineTransform transform];
- [transform translateXBy:NSMaxX(dstRect) yBy:NSMaxY(dstRect)];
- [transform scaleXBy:-1.0 yBy:-1.0];
- [transform translateXBy:-NSMinX(dstRect) yBy:-NSMinY(dstRect)];
- [transform concat];
- [self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
- [NSGraphicsContext restoreGraphicsState];
+ [self drawMirrored:YES andFlipped:YES inRect:dstRect fromRect:srcRect
operation:op fraction:delta];
}
- (void)drawMirroredAndFlipped:(BOOL)isFlipped inRect:(NSRect)dstRect
fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op
fraction:(float)delta {
- if (isFlipped)
- [self drawMirroredAndFlippedInRect:dstRect fromRect:srcRect
operation:op fraction:delta];
- else
- [self drawMirroredInRect:dstRect fromRect:srcRect operation:op
fraction:delta];
+ [self drawMirrored:YES andFlipped:isFlipped inRect:dstRect
fromRect:srcRect operation:op fraction:delta];
}
+- (void)drawMirrored:(BOOL)isMirrored andFlipped:(BOOL)isFlipped
inRect:(NSRect)dstRect fromRect:(NSRect)srcRect
operation:(NSCompositingOperation)op fraction:(float)delta {
+ if (isMirrored || isFlipped) {
+ float dx1 = 0.0, dx2 = 0.0, dy1 = 0.0, dy2 = 0.0, sx = 1.0, sy = 1.0;
+ if (isFlipped) {
+ sx = -1.0;
+ dx1 = NSMaxX(dstRect);
+ dx2 = -NSMinX(dstRect);
+ }
+ if (isMirrored) {
+ sy = -1.0;
+ dy1 = NSMaxY(dstRect);
+ dy2 = -NSMinY(dstRect);
+ }
+ [NSGraphicsContext saveGraphicsState];
+ NSAffineTransform *transform = [NSAffineTransform transform];
+ [transform translateXBy:dx1 yBy:dy1];
+ [transform scaleXBy:sx yBy:sy];
+ [transform translateXBy:dx2 yBy:dy2];
+ [transform concat];
+ [self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
+ [NSGraphicsContext restoreGraphicsState];
+ } else {
+ [self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
+ }
+}
+
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit