2007-02-13 03:41:55 +00:00
|
|
|
/* Copyright (c) 2007 Christopher J. W. Lloyd
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
|
|
|
|
#import "KGContext.h"
|
2009-10-07 17:19:32 +00:00
|
|
|
#import "KGBitmapContext.h"
|
2008-04-17 16:59:58 +00:00
|
|
|
#import "KGGraphicsState.h"
|
2009-08-06 20:02:33 +00:00
|
|
|
#import "O2Color.h"
|
2009-09-04 16:36:13 +00:00
|
|
|
#import "O2ColorSpace.h"
|
2009-08-03 20:52:42 +00:00
|
|
|
#import "O2MutablePath.h"
|
2007-03-11 19:28:02 +00:00
|
|
|
#import "KGLayer.h"
|
|
|
|
#import "KGPDFPage.h"
|
2008-02-29 17:56:38 +00:00
|
|
|
#import "KGClipPhase.h"
|
2008-04-17 16:59:58 +00:00
|
|
|
#import "KGExceptions.h"
|
|
|
|
#import <Foundation/NSBundle.h>
|
|
|
|
#import <Foundation/NSArray.h>
|
2007-02-13 03:41:55 +00:00
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
@implementation O2Context
|
2007-02-13 03:41:55 +00:00
|
|
|
|
2008-02-29 17:56:38 +00:00
|
|
|
static NSMutableArray *possibleContextClasses=nil;
|
|
|
|
|
|
|
|
+(void)initialize {
|
|
|
|
if(possibleContextClasses==nil){
|
|
|
|
possibleContextClasses=[NSMutableArray new];
|
|
|
|
|
|
|
|
[possibleContextClasses addObject:@"KGContext_gdi"];
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
[possibleContextClasses addObject:@"KGContext_builtin"];
|
2008-06-27 17:35:48 +00:00
|
|
|
[possibleContextClasses addObject:@"KGContext_builtin_gdi"];
|
2008-02-29 17:56:38 +00:00
|
|
|
|
|
|
|
NSArray *allPaths=[[NSBundle bundleForClass:self] pathsForResourcesOfType:@"cgContext" inDirectory:nil];
|
|
|
|
int i,count=[allPaths count];
|
|
|
|
|
|
|
|
for(i=0;i<count;i++){
|
|
|
|
NSString *path=[allPaths objectAtIndex:i];
|
|
|
|
NSBundle *check=[NSBundle bundleWithPath:path];
|
|
|
|
Class cls=[check principalClass];
|
|
|
|
|
|
|
|
if(cls!=Nil)
|
|
|
|
[possibleContextClasses addObject:NSStringFromClass([check principalClass])];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-02 03:31:21 +00:00
|
|
|
+(NSArray *)allContextClasses {
|
|
|
|
NSMutableArray *result=[NSMutableArray array];
|
2008-02-29 17:56:38 +00:00
|
|
|
int i,count=[possibleContextClasses count];
|
2008-01-02 03:31:21 +00:00
|
|
|
|
2008-02-29 17:56:38 +00:00
|
|
|
for(i=0;i<count;i++){
|
|
|
|
Class check=NSClassFromString([possibleContextClasses objectAtIndex:i]);
|
2008-01-02 03:31:21 +00:00
|
|
|
|
2008-08-12 16:16:19 +00:00
|
|
|
if(check!=Nil)
|
2008-01-02 03:31:21 +00:00
|
|
|
[result addObject:check];
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
+(O2Context *)createContextWithSize:(CGSize)size window:(CGWindow *)window {
|
2008-01-02 03:31:21 +00:00
|
|
|
NSArray *array=[self allContextClasses];
|
|
|
|
int count=[array count];
|
|
|
|
|
|
|
|
while(--count>=0){
|
|
|
|
Class check=[array objectAtIndex:count];
|
|
|
|
|
2008-02-29 17:56:38 +00:00
|
|
|
if([check canInitWithWindow:window]){
|
2009-10-06 16:02:46 +00:00
|
|
|
O2Context *result=[[check alloc] initWithSize:size window:window];
|
2008-02-29 17:56:38 +00:00
|
|
|
|
|
|
|
if(result!=nil)
|
|
|
|
return result;
|
|
|
|
}
|
2008-01-02 03:31:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
+(O2Context *)createBackingContextWithSize:(CGSize)size context:(O2Context *)context deviceDictionary:(NSDictionary *)deviceDictionary {
|
2008-01-02 03:31:21 +00:00
|
|
|
NSArray *array=[self allContextClasses];
|
|
|
|
int count=[array count];
|
|
|
|
|
|
|
|
while(--count>=0){
|
|
|
|
Class check=[array objectAtIndex:count];
|
|
|
|
|
2008-08-12 16:16:19 +00:00
|
|
|
if([check canInitBackingWithContext:context deviceDictionary:deviceDictionary]){
|
2009-10-06 16:02:46 +00:00
|
|
|
O2Context *result=[[check alloc] initWithSize:size context:context];
|
2008-02-29 17:56:38 +00:00
|
|
|
|
|
|
|
if(result!=nil)
|
|
|
|
return result;
|
|
|
|
}
|
2008-01-02 03:31:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
+(O2Context *)createWithBytes:(void *)bytes width:(size_t)width height:(size_t)height bitsPerComponent:(size_t)bitsPerComponent bytesPerRow:(size_t)bytesPerRow colorSpace:(O2ColorSpaceRef)colorSpace bitmapInfo:(CGBitmapInfo)bitmapInfo {
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
NSArray *array=[self allContextClasses];
|
|
|
|
int count=[array count];
|
|
|
|
|
|
|
|
while(--count>=0){
|
|
|
|
Class check=[array objectAtIndex:count];
|
|
|
|
|
|
|
|
if([check canInitBitmap]){
|
2009-10-06 16:02:46 +00:00
|
|
|
O2Context *result=[[check alloc] initWithBytes:bytes width:width height:height bitsPerComponent:bitsPerComponent bytesPerRow:bytesPerRow colorSpace:colorSpace bitmapInfo:bitmapInfo flipped:NO];
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
|
|
|
|
if(result!=nil)
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2008-01-02 03:31:21 +00:00
|
|
|
+(BOOL)canInitWithWindow:(CGWindow *)window {
|
2008-02-29 17:56:38 +00:00
|
|
|
return NO;
|
2008-01-02 03:31:21 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
+(BOOL)canInitBackingWithContext:(O2Context *)context deviceDictionary:(NSDictionary *)deviceDictionary {
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
+(BOOL)canInitBitmap {
|
2008-02-29 17:56:38 +00:00
|
|
|
return NO;
|
2008-01-02 03:31:21 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-initWithSize:(CGSize)size window:(CGWindow *)window {
|
|
|
|
KGInvalidAbstractInvocation();
|
2008-01-02 03:31:21 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
-initWithSize:(CGSize)size context:(O2Context *)context {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2008-01-02 03:31:21 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
-initWithGraphicsState:(O2GState *)state {
|
2008-02-29 17:56:38 +00:00
|
|
|
_userToDeviceTransform=[state userSpaceToDeviceSpaceTransform];
|
2007-03-11 19:28:02 +00:00
|
|
|
_layerStack=[NSMutableArray new];
|
|
|
|
_stateStack=[NSMutableArray new];
|
|
|
|
[_stateStack addObject:state];
|
2009-08-03 20:52:42 +00:00
|
|
|
_path=[[O2MutablePath alloc] init];
|
2007-03-11 19:28:02 +00:00
|
|
|
_allowsAntialiasing=YES;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2007-10-15 18:08:57 +00:00
|
|
|
-init {
|
2009-10-06 16:02:46 +00:00
|
|
|
return [self initWithGraphicsState:[[[O2GState alloc] init] autorelease]];
|
2007-10-15 18:08:57 +00:00
|
|
|
}
|
|
|
|
|
2007-03-11 19:28:02 +00:00
|
|
|
-(void)dealloc {
|
|
|
|
[_layerStack release];
|
|
|
|
[_stateStack release];
|
|
|
|
[_path release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
static inline O2GState *currentState(O2Context *self){
|
2007-03-11 19:28:02 +00:00
|
|
|
return [self->_stateStack lastObject];
|
|
|
|
}
|
|
|
|
|
2008-06-27 17:35:48 +00:00
|
|
|
-(KGSurface *)surface {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(KGSurface *)createSurfaceWithWidth:(size_t)width height:(size_t)height {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2007-03-11 19:28:02 +00:00
|
|
|
-(void)setAllowsAntialiasing:(BOOL)yesOrNo {
|
|
|
|
_allowsAntialiasing=yesOrNo;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)beginTransparencyLayerWithInfo:(NSDictionary *)unused {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGUnimplementedMethod();
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)endTransparencyLayer {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGUnimplementedMethod();
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(BOOL)pathIsEmpty {
|
2009-08-03 20:52:42 +00:00
|
|
|
return (_path==nil)?YES:O2PathIsEmpty(_path);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(CGPoint)pathCurrentPoint {
|
2009-08-03 20:52:42 +00:00
|
|
|
return (_path==nil)?CGPointZero:O2PathGetCurrentPoint(_path);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(CGRect)pathBoundingBox {
|
2009-08-03 20:52:42 +00:00
|
|
|
return (_path==nil)?CGRectZero:O2PathGetBoundingBox(_path);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(BOOL)pathContainsPoint:(CGPoint)point drawingMode:(int)pathMode {
|
2008-02-29 17:56:38 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceToDeviceSpaceTransform];
|
2007-03-11 19:28:02 +00:00
|
|
|
|
|
|
|
// FIX evenOdd
|
2009-08-03 20:52:42 +00:00
|
|
|
return O2PathContainsPoint(_path,&ctm,point,NO);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)beginPath {
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathReset(_path);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)closePath {
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathCloseSubpath(_path);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-07-08 15:59:34 +00:00
|
|
|
/* Path building is affected by the CTM, we transform them here into base coordinates (first quadrant, no transformation)
|
|
|
|
|
|
|
|
A backend can then convert them to where it needs them, base, current, or device space.
|
|
|
|
*/
|
|
|
|
|
2008-06-30 16:18:49 +00:00
|
|
|
-(void)moveToPoint:(float)x:(float)y {
|
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathMoveToPoint(_path,&ctm,x,y);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)addLineToPoint:(float)x:(float)y {
|
2008-06-30 16:18:49 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathAddLineToPoint(_path,&ctm,x,y);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)addCurveToPoint:(float)cx1:(float)cy1:(float)cx2:(float)cy2:(float)x:(float)y {
|
2008-06-30 16:18:49 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathAddCurveToPoint(_path,&ctm,cx1,cy1,cx2,cy2,x,y);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)addQuadCurveToPoint:(float)cx1:(float)cy1:(float)x:(float)y {
|
2008-06-30 16:18:49 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathAddQuadCurveToPoint(_path,&ctm,cx1,cy1,x,y);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
-(void)addLinesWithPoints:(CGPoint *)points count:(unsigned)count {
|
2008-06-30 16:18:49 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathAddLines(_path,&ctm,points,count);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)addRect:(CGRect)rect {
|
2009-08-03 20:52:42 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
|
|
|
O2PathAddRect(_path,&ctm,rect);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
-(void)addRects:(const CGRect *)rects count:(unsigned)count {
|
2008-06-30 16:18:49 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathAddRects(_path,&ctm,rects,count);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)addArc:(float)x:(float)y:(float)radius:(float)startRadian:(float)endRadian:(int)clockwise {
|
2008-06-30 16:18:49 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathAddArc(_path,&ctm,x,y,radius,startRadian,endRadian,clockwise);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)addArcToPoint:(float)x1:(float)y1:(float)x2:(float)y2:(float)radius {
|
2008-06-30 16:18:49 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathAddArcToPoint(_path,&ctm,x1,y1,x2,y2,radius);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)addEllipseInRect:(CGRect)rect {
|
2008-06-30 16:18:49 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathAddEllipseInRect(_path,&ctm,rect);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
-(void)addPath:(O2Path *)path {
|
2008-06-30 16:18:49 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathAddPath(_path,&ctm,path);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)replacePathWithStrokedPath {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGUnimplementedMethod();
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
-(O2GState *)currentState {
|
2008-02-29 17:56:38 +00:00
|
|
|
return currentState(self);
|
|
|
|
}
|
|
|
|
|
2007-03-11 19:28:02 +00:00
|
|
|
-(void)saveGState {
|
2009-10-06 16:02:46 +00:00
|
|
|
O2GState *current=currentState(self),*next;
|
2007-03-11 19:28:02 +00:00
|
|
|
|
|
|
|
next=[current copy];
|
|
|
|
[_stateStack addObject:next];
|
|
|
|
[next release];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)restoreGState {
|
|
|
|
[_stateStack removeLastObject];
|
2008-02-29 17:56:38 +00:00
|
|
|
|
|
|
|
NSArray *phases=[[self currentState] clipPhases];
|
|
|
|
int i,count=[phases count];
|
|
|
|
|
|
|
|
[self deviceClipReset];
|
|
|
|
|
|
|
|
for(i=0;i<count;i++){
|
2009-10-06 16:02:46 +00:00
|
|
|
O2ClipPhase *phase=[phases objectAtIndex:i];
|
2008-02-29 17:56:38 +00:00
|
|
|
|
|
|
|
switch([phase phaseType]){
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
case O2ClipPhaseNonZeroPath:{
|
2009-08-03 20:52:42 +00:00
|
|
|
O2Path *path=[phase object];
|
2008-02-29 17:56:38 +00:00
|
|
|
[self deviceClipToNonZeroPath:path];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
case O2ClipPhaseEOPath:{
|
2009-08-03 20:52:42 +00:00
|
|
|
O2Path *path=[phase object];
|
2008-02-29 17:56:38 +00:00
|
|
|
[self deviceClipToEvenOddPath:path];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
case O2ClipPhaseMask:
|
2008-02-29 17:56:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(CGAffineTransform)userSpaceToDeviceSpaceTransform {
|
2007-11-08 15:58:54 +00:00
|
|
|
return [currentState(self) userSpaceToDeviceSpaceTransform];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(CGAffineTransform)ctm {
|
2008-02-29 17:56:38 +00:00
|
|
|
return [currentState(self) userSpaceTransform];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(CGRect)clipBoundingBox {
|
2007-11-08 15:58:54 +00:00
|
|
|
return [currentState(self) clipBoundingBox];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(CGAffineTransform)textMatrix {
|
|
|
|
return [currentState(self) textMatrix];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(int)interpolationQuality {
|
|
|
|
return [currentState(self) interpolationQuality];
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(CGPoint)textPosition {
|
2007-03-11 19:28:02 +00:00
|
|
|
return [currentState(self) textPosition];
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(CGPoint)convertPointToDeviceSpace:(CGPoint)point {
|
2007-03-11 19:28:02 +00:00
|
|
|
return [currentState(self) convertPointToDeviceSpace:point];
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(CGPoint)convertPointToUserSpace:(CGPoint)point {
|
2007-03-11 19:28:02 +00:00
|
|
|
return [currentState(self) convertPointToUserSpace:point];
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(CGSize)convertSizeToDeviceSpace:(CGSize)size {
|
2007-03-11 19:28:02 +00:00
|
|
|
return [currentState(self) convertSizeToDeviceSpace:size];
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(CGSize)convertSizeToUserSpace:(CGSize)size {
|
2007-03-11 19:28:02 +00:00
|
|
|
return [currentState(self) convertSizeToUserSpace:size];
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(CGRect)convertRectToDeviceSpace:(CGRect)rect {
|
2007-03-11 19:28:02 +00:00
|
|
|
return [currentState(self) convertRectToDeviceSpace:rect];
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(CGRect)convertRectToUserSpace:(CGRect)rect {
|
2007-03-11 19:28:02 +00:00
|
|
|
return [currentState(self) convertRectToUserSpace:rect];
|
|
|
|
}
|
|
|
|
|
2007-11-08 15:58:54 +00:00
|
|
|
-(void)setCTM:(CGAffineTransform)matrix {
|
2008-02-29 17:56:38 +00:00
|
|
|
CGAffineTransform deviceTransform=_userToDeviceTransform;
|
|
|
|
|
2008-06-30 16:18:49 +00:00
|
|
|
deviceTransform=CGAffineTransformConcat(matrix,deviceTransform);
|
2008-01-02 03:31:21 +00:00
|
|
|
|
2008-02-29 17:56:38 +00:00
|
|
|
[currentState(self) setDeviceSpaceCTM:deviceTransform];
|
|
|
|
|
|
|
|
[currentState(self) setUserSpaceCTM:matrix];
|
2007-11-08 15:58:54 +00:00
|
|
|
}
|
|
|
|
|
2007-03-11 19:28:02 +00:00
|
|
|
-(void)concatCTM:(CGAffineTransform)transform {
|
|
|
|
[currentState(self) concatCTM:transform];
|
|
|
|
}
|
|
|
|
|
2007-10-15 18:08:57 +00:00
|
|
|
-(void)translateCTM:(float)translatex:(float)translatey {
|
|
|
|
[self concatCTM:CGAffineTransformMakeTranslation(translatex,translatey)];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)scaleCTM:(float)scalex:(float)scaley {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self concatCTM:CGAffineTransformMakeScale(scalex,scaley)];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)rotateCTM:(float)radians {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self concatCTM:CGAffineTransformMakeRotation(radians)];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)clipToPath {
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
if([_path numberOfElements]==0)
|
2007-07-11 23:27:46 +00:00
|
|
|
return;
|
2008-02-29 17:56:38 +00:00
|
|
|
|
|
|
|
[currentState(self) addClipToPath:_path];
|
|
|
|
[self deviceClipToNonZeroPath:_path];
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathReset(_path);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)evenOddClipToPath {
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
if([_path numberOfElements]==0)
|
2007-07-11 23:27:46 +00:00
|
|
|
return;
|
|
|
|
|
2008-02-29 17:56:38 +00:00
|
|
|
[currentState(self) addEvenOddClipToPath:_path];
|
|
|
|
[self deviceClipToEvenOddPath:_path];
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathReset(_path);
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
-(void)clipToMask:(O2Image *)image inRect:(CGRect)rect {
|
2008-02-29 17:56:38 +00:00
|
|
|
[currentState(self) addClipToMask:image inRect:rect];
|
|
|
|
[self deviceClipToMask:image inRect:rect];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)clipToRect:(CGRect)rect {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self clipToRects:&rect count:1];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
-(void)clipToRects:(const CGRect *)rects count:(unsigned)count {
|
2008-06-30 16:18:49 +00:00
|
|
|
CGAffineTransform ctm=[currentState(self) userSpaceTransform];
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
O2PathReset(_path);
|
|
|
|
O2PathAddRects(_path,&ctm,rects,count);
|
2008-02-29 17:56:38 +00:00
|
|
|
[self clipToPath];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 20:02:33 +00:00
|
|
|
-(O2Color *)strokeColor {
|
2007-06-23 04:08:45 +00:00
|
|
|
return [currentState(self) strokeColor];
|
|
|
|
}
|
|
|
|
|
2009-08-06 20:02:33 +00:00
|
|
|
-(O2Color *)fillColor {
|
2007-06-23 04:08:45 +00:00
|
|
|
return [currentState(self) fillColor];
|
|
|
|
}
|
|
|
|
|
2009-09-04 16:36:13 +00:00
|
|
|
-(void)setStrokeColorSpace:(O2ColorSpaceRef)colorSpace {
|
|
|
|
int i,length=[colorSpace numberOfComponents];
|
|
|
|
CGFloat components[length+1];
|
|
|
|
|
|
|
|
for(i=0;i<length;i++)
|
|
|
|
components[i]=0;
|
|
|
|
components[i]=1;
|
|
|
|
|
|
|
|
O2Color *color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
|
|
|
[self setStrokeColor:color];
|
|
|
|
|
|
|
|
[color release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-09-04 16:36:13 +00:00
|
|
|
-(void)setFillColorSpace:(O2ColorSpaceRef)colorSpace {
|
|
|
|
int i,length=[colorSpace numberOfComponents];
|
|
|
|
CGFloat components[length+1];
|
|
|
|
|
|
|
|
for(i=0;i<length;i++)
|
|
|
|
components[i]=0;
|
|
|
|
components[i]=1;
|
|
|
|
|
|
|
|
O2Color *color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
|
|
|
[self setFillColor:color];
|
|
|
|
|
|
|
|
[color release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setStrokeColorWithComponents:(const float *)components {
|
2009-09-04 16:36:13 +00:00
|
|
|
O2ColorSpaceRef colorSpace=O2ColorGetColorSpace([self strokeColor]);
|
|
|
|
O2Color *color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
|
|
|
[self setStrokeColor:color];
|
|
|
|
|
|
|
|
[color release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 20:02:33 +00:00
|
|
|
-(void)setStrokeColor:(O2Color *)color {
|
2007-03-11 19:28:02 +00:00
|
|
|
[currentState(self) setStrokeColor:color];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setGrayStrokeColor:(float)gray:(float)alpha {
|
2009-09-04 16:36:13 +00:00
|
|
|
O2ColorSpaceRef colorSpace=[[O2ColorSpace alloc] initWithDeviceGray];
|
2007-10-15 18:08:57 +00:00
|
|
|
float components[2]={gray,alpha};
|
2009-09-04 16:36:13 +00:00
|
|
|
O2Color *color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
|
|
|
[self setStrokeColor:color];
|
|
|
|
|
|
|
|
[color release];
|
|
|
|
[colorSpace release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setRGBStrokeColor:(float)r:(float)g:(float)b:(float)alpha {
|
2009-09-04 16:36:13 +00:00
|
|
|
O2ColorSpaceRef colorSpace=[[O2ColorSpace alloc] initWithDeviceRGB];
|
2007-10-15 18:08:57 +00:00
|
|
|
float components[4]={r,g,b,alpha};
|
2009-09-04 16:36:13 +00:00
|
|
|
O2Color *color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
|
|
|
[self setStrokeColor:color];
|
|
|
|
|
|
|
|
[color release];
|
|
|
|
[colorSpace release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setCMYKStrokeColor:(float)c:(float)m:(float)y:(float)k:(float)alpha {
|
2009-09-04 16:36:13 +00:00
|
|
|
O2ColorSpaceRef colorSpace=[[O2ColorSpace alloc] initWithDeviceCMYK];
|
2007-10-15 18:08:57 +00:00
|
|
|
float components[5]={c,m,y,k,alpha};
|
2009-09-04 16:36:13 +00:00
|
|
|
O2Color *color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
|
|
|
[self setStrokeColor:color];
|
|
|
|
|
|
|
|
[color release];
|
|
|
|
[colorSpace release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setFillColorWithComponents:(const float *)components {
|
2009-09-04 16:36:13 +00:00
|
|
|
O2ColorSpaceRef colorSpace=O2ColorGetColorSpace([self fillColor]);
|
|
|
|
O2Color *color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
|
|
|
[self setFillColor:color];
|
|
|
|
|
|
|
|
[color release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 20:02:33 +00:00
|
|
|
-(void)setFillColor:(O2Color *)color {
|
2007-03-11 19:28:02 +00:00
|
|
|
[currentState(self) setFillColor:color];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setGrayFillColor:(float)gray:(float)alpha {
|
2009-09-04 16:36:13 +00:00
|
|
|
O2ColorSpaceRef colorSpace=[[O2ColorSpace alloc] initWithDeviceGray];
|
2007-10-15 18:08:57 +00:00
|
|
|
float components[2]={gray,alpha};
|
2009-09-04 16:36:13 +00:00
|
|
|
O2Color *color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
|
|
|
[self setFillColor:color];
|
|
|
|
|
|
|
|
[color release];
|
|
|
|
[colorSpace release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setRGBFillColor:(float)r:(float)g:(float)b:(float)alpha {
|
2009-09-04 16:36:13 +00:00
|
|
|
O2ColorSpaceRef colorSpace=[[O2ColorSpace alloc] initWithDeviceRGB];
|
2007-10-15 18:08:57 +00:00
|
|
|
float components[4]={r,g,b,alpha};
|
2009-09-04 16:36:13 +00:00
|
|
|
O2Color *color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
|
|
|
[self setFillColor:color];
|
|
|
|
|
|
|
|
[color release];
|
|
|
|
[colorSpace release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setCMYKFillColor:(float)c:(float)m:(float)y:(float)k:(float)alpha {
|
2009-09-04 16:36:13 +00:00
|
|
|
O2ColorSpaceRef colorSpace=[[O2ColorSpace alloc] initWithDeviceCMYK];
|
2007-10-15 18:08:57 +00:00
|
|
|
float components[5]={c,m,y,k,alpha};
|
2009-09-04 16:36:13 +00:00
|
|
|
O2Color *color=O2ColorCreate(colorSpace,components);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
|
|
|
[self setFillColor:color];
|
|
|
|
|
|
|
|
[color release];
|
|
|
|
[colorSpace release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setStrokeAndFillAlpha:(float)alpha {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self setStrokeAlpha:alpha];
|
|
|
|
[self setFillAlpha:alpha];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setStrokeAlpha:(float)alpha {
|
2009-09-04 16:36:13 +00:00
|
|
|
O2Color *color=O2ColorCreateCopyWithAlpha([self strokeColor],alpha);
|
2007-10-15 18:08:57 +00:00
|
|
|
[self setStrokeColor:color];
|
|
|
|
[color release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setGrayStrokeColor:(float)gray {
|
2009-09-04 16:36:13 +00:00
|
|
|
float alpha=O2ColorGetAlpha([self strokeColor]);
|
2007-10-15 18:08:57 +00:00
|
|
|
|
|
|
|
[self setGrayStrokeColor:gray:alpha];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setRGBStrokeColor:(float)r:(float)g:(float)b {
|
2009-09-04 16:36:13 +00:00
|
|
|
float alpha=O2ColorGetAlpha([self strokeColor]);
|
2007-10-15 18:08:57 +00:00
|
|
|
[self setRGBStrokeColor:r:g:b:alpha];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setCMYKStrokeColor:(float)c:(float)m:(float)y:(float)k {
|
2009-09-04 16:36:13 +00:00
|
|
|
float alpha=O2ColorGetAlpha([self strokeColor]);
|
2007-10-15 18:08:57 +00:00
|
|
|
[self setCMYKStrokeColor:c:m:y:k:alpha];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setFillAlpha:(float)alpha {
|
2009-09-04 16:36:13 +00:00
|
|
|
O2Color *color=O2ColorCreateCopyWithAlpha([self fillColor],alpha);
|
2007-10-15 18:08:57 +00:00
|
|
|
[self setFillColor:color];
|
|
|
|
[color release];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setGrayFillColor:(float)gray {
|
2009-09-04 16:36:13 +00:00
|
|
|
float alpha=O2ColorGetAlpha([self fillColor]);
|
2007-10-15 18:08:57 +00:00
|
|
|
[self setGrayFillColor:gray:alpha];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setRGBFillColor:(float)r:(float)g:(float)b {
|
2009-09-04 16:36:13 +00:00
|
|
|
float alpha=O2ColorGetAlpha([self fillColor]);
|
2007-10-15 18:08:57 +00:00
|
|
|
[self setRGBFillColor:r:g:b:alpha];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setCMYKFillColor:(float)c:(float)m:(float)y:(float)k {
|
2009-09-04 16:36:13 +00:00
|
|
|
float alpha=O2ColorGetAlpha([self fillColor]);
|
2007-10-15 18:08:57 +00:00
|
|
|
[self setCMYKFillColor:c:m:y:k:alpha];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)setPatternPhase:(CGSize)phase {
|
2007-03-11 19:28:02 +00:00
|
|
|
[currentState(self) setPatternPhase:phase];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setStrokePattern:(KGPattern *)pattern components:(const float *)components {
|
|
|
|
[currentState(self) setStrokePattern:pattern components:components];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setFillPattern:(KGPattern *)pattern components:(const float *)components {
|
|
|
|
[currentState(self) setFillPattern:pattern components:components];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setTextMatrix:(CGAffineTransform)transform {
|
|
|
|
[currentState(self) setTextMatrix:transform];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setTextPosition:(float)x:(float)y {
|
|
|
|
[currentState(self) setTextPosition:x:y];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setCharacterSpacing:(float)spacing {
|
|
|
|
[currentState(self) setCharacterSpacing:spacing];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setTextDrawingMode:(int)textMode {
|
|
|
|
[currentState(self) setTextDrawingMode:textMode];
|
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
-(void)setFont:(O2Font *)font {
|
2008-12-03 21:17:06 +00:00
|
|
|
[currentState(self) setFont:font];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setFontSize:(float)size {
|
2008-12-03 21:17:06 +00:00
|
|
|
[currentState(self) setFontSize:size];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-07-02 19:28:33 +00:00
|
|
|
-(void)selectFontWithName:(const char *)name size:(float)size encoding:(CGTextEncoding)encoding {
|
2008-12-03 21:17:06 +00:00
|
|
|
[currentState(self) selectFontWithName:name size:size encoding:encoding];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setShouldSmoothFonts:(BOOL)yesOrNo {
|
|
|
|
[currentState(self) setShouldSmoothFonts:yesOrNo];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setLineWidth:(float)width {
|
|
|
|
[currentState(self) setLineWidth:width];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setLineCap:(int)lineCap {
|
|
|
|
[currentState(self) setLineCap:lineCap];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setLineJoin:(int)lineJoin {
|
|
|
|
[currentState(self) setLineJoin:lineJoin];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setMiterLimit:(float)limit {
|
|
|
|
[currentState(self) setMiterLimit:limit];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setLineDashPhase:(float)phase lengths:(const float *)lengths count:(unsigned)count {
|
|
|
|
[currentState(self) setLineDashPhase:phase lengths:lengths count:count];
|
|
|
|
}
|
|
|
|
|
2007-10-15 18:08:57 +00:00
|
|
|
-(void)setRenderingIntent:(CGColorRenderingIntent)intent {
|
2007-03-11 19:28:02 +00:00
|
|
|
[currentState(self) setRenderingIntent:intent];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setBlendMode:(int)mode {
|
|
|
|
[currentState(self) setBlendMode:mode];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setFlatness:(float)flatness {
|
|
|
|
[currentState(self) setFlatness:flatness];
|
|
|
|
}
|
|
|
|
|
2007-10-15 18:08:57 +00:00
|
|
|
-(void)setInterpolationQuality:(CGInterpolationQuality)quality {
|
2007-03-11 19:28:02 +00:00
|
|
|
[currentState(self) setInterpolationQuality:quality];
|
|
|
|
}
|
|
|
|
|
2009-08-06 20:02:33 +00:00
|
|
|
-(void)setShadowOffset:(CGSize)offset blur:(float)blur color:(O2Color *)color {
|
2007-03-11 19:28:02 +00:00
|
|
|
[currentState(self) setShadowOffset:offset blur:blur color:color];
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)setShadowOffset:(CGSize)offset blur:(float)blur {
|
2007-03-11 19:28:02 +00:00
|
|
|
[currentState(self) setShadowOffset:offset blur:blur];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setShouldAntialias:(BOOL)flag {
|
|
|
|
[currentState(self) setShouldAntialias:flag];
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)strokeLineSegmentsWithPoints:(CGPoint *)points count:(unsigned)count {
|
2007-10-15 18:08:57 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
[self beginPath];
|
|
|
|
for(i=0;i<count;i+=2){
|
|
|
|
[self moveToPoint:points[i].x:points[i].y];
|
|
|
|
[self addLineToPoint:points[i+1].x:points[i+1].y];
|
|
|
|
}
|
|
|
|
[self strokePath];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)strokeRect:(CGRect)rect {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self beginPath];
|
|
|
|
[self addRect:rect];
|
|
|
|
[self strokePath];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)strokeRect:(CGRect)rect width:(float)width {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self saveGState];
|
|
|
|
[self setLineWidth:width];
|
|
|
|
[self beginPath];
|
|
|
|
[self addRect:rect];
|
|
|
|
[self strokePath];
|
|
|
|
[self restoreGState];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)strokeEllipseInRect:(CGRect)rect {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self beginPath];
|
|
|
|
[self addEllipseInRect:rect];
|
|
|
|
[self strokePath];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)fillRect:(CGRect)rect {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self fillRects:&rect count:1];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)fillRects:(const CGRect *)rects count:(unsigned)count {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self beginPath];
|
|
|
|
[self addRects:rects count:count];
|
|
|
|
[self fillPath];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)fillEllipseInRect:(CGRect)rect {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self beginPath];
|
|
|
|
[self addEllipseInRect:rect];
|
|
|
|
[self fillPath];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2007-10-15 18:08:57 +00:00
|
|
|
-(void)drawPath:(CGPathDrawingMode)pathMode {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2007-10-15 18:08:57 +00:00
|
|
|
// reset path in subclass
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)strokePath {
|
2008-02-29 17:56:38 +00:00
|
|
|
[self drawPath:kCGPathStroke];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)fillPath {
|
2008-02-29 17:56:38 +00:00
|
|
|
[self drawPath:kCGPathFill];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)evenOddFillPath {
|
2008-02-29 17:56:38 +00:00
|
|
|
[self drawPath:kCGPathEOFill];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)fillAndStrokePath {
|
2008-02-29 17:56:38 +00:00
|
|
|
[self drawPath:kCGPathFillStroke];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)evenOddFillAndStrokePath {
|
2008-02-29 17:56:38 +00:00
|
|
|
[self drawPath:kCGPathEOFillStroke];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)clearRect:(CGRect)rect {
|
2008-05-26 18:06:53 +00:00
|
|
|
// doc.s are not clear. tests say CGContextClearRect resets the path and does not affect gstate color
|
2007-10-22 19:00:18 +00:00
|
|
|
[self saveGState];
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
[self setBlendMode:kCGBlendModeCopy]; // does it set the blend mode?
|
2007-10-22 19:00:18 +00:00
|
|
|
[self setGrayFillColor:0:0];
|
|
|
|
[self fillRect:rect];
|
|
|
|
[self restoreGState];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)showGlyphs:(const CGGlyph *)glyphs count:(unsigned)count {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)showGlyphs:(const CGGlyph *)glyphs count:(unsigned)count atPoint:(float)x:(float)y {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self setTextPosition:x:y];
|
|
|
|
[self showGlyphs:glyphs count:count];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)showGlyphs:(const CGGlyph *)glyphs count:(unsigned)count advances:(const CGSize *)advances {
|
2007-10-15 18:08:57 +00:00
|
|
|
CGAffineTransform textMatrix=[currentState(self) textMatrix];
|
|
|
|
float x=textMatrix.tx;
|
|
|
|
float y=textMatrix.ty;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0;i<count;i++){
|
|
|
|
[self showGlyphs:glyphs+i count:1];
|
|
|
|
|
|
|
|
x+=advances[i].width;
|
|
|
|
y+=advances[i].height;
|
|
|
|
[self setTextPosition:x:y];
|
|
|
|
}
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)showText:(const char *)text length:(unsigned)length {
|
2008-12-03 22:21:32 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)showText:(const char *)text length:(unsigned)length atPoint:(float)x:(float)y {
|
2007-10-15 18:08:57 +00:00
|
|
|
[self setTextPosition:x:y];
|
|
|
|
[self showText:text length:length];
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)drawShading:(KGShading *)shading {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
-(void)drawImage:(O2Image *)image inRect:(CGRect)rect {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)drawLayer:(KGLayer *)layer atPoint:(CGPoint)point {
|
|
|
|
CGSize size=[layer size];
|
|
|
|
CGRect rect={point,size};
|
2007-03-11 19:28:02 +00:00
|
|
|
|
|
|
|
[self drawLayer:layer inRect:rect];
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)drawLayer:(KGLayer *)layer inRect:(CGRect)rect {
|
|
|
|
KGInvalidAbstractInvocation();
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
-(void)drawPDFPage:(O2PDFPage *)page {
|
2007-03-11 19:28:02 +00:00
|
|
|
[page drawInContext:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)flush {
|
2007-10-15 18:08:57 +00:00
|
|
|
// do nothing
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)synchronize {
|
2007-10-15 18:08:57 +00:00
|
|
|
// do nothing
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)beginPage:(const CGRect *)mediaBox {
|
2007-10-15 18:08:57 +00:00
|
|
|
// do nothing
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)endPage {
|
2007-10-15 18:08:57 +00:00
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
2009-06-05 03:16:46 +00:00
|
|
|
-(void)close {
|
|
|
|
// do nothing
|
2007-10-15 18:08:57 +00:00
|
|
|
}
|
|
|
|
|
2009-06-05 03:16:46 +00:00
|
|
|
-(KGLayer *)layerWithSize:(CGSize)size unused:(NSDictionary *)unused {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2009-06-05 03:16:46 +00:00
|
|
|
return nil;
|
2007-10-15 18:08:57 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(BOOL)getImageableRect:(CGRect *)rect {
|
2007-10-22 19:00:18 +00:00
|
|
|
return NO;
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
// bitmap context
|
|
|
|
|
2008-07-08 15:59:34 +00:00
|
|
|
-(NSData *)pixelData {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void *)pixelBytes {
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(size_t)width {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(size_t)height {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(size_t)bitsPerComponent {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(size_t)bytesPerRow {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-04 16:36:13 +00:00
|
|
|
-(O2ColorSpaceRef)colorSpace {
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(CGBitmapInfo)bitmapInfo {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(size_t)bitsPerPixel {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(CGImageAlphaInfo)alphaInfo {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
-(O2Image *)createImage {
|
- Issue #84 fix in NSDocumentController, NSDocumentController was referring to a NSMenu's itemArray while the array was changing due to KVC & -[NSMenu _setItemArray:]
- Added NSIntegerMapKeyCallBacks
- Added variety of CGBitmapContext, CGImage, CGDataProvider, CGGeometry, CGPath, CGPattern, CGColor C interfaces to the .h's in ApplicationServices and underlying implementation in AppKit.
- Consolidated KGPath/VGPath more. Consolidated KGImage/KGSurface(VGImage) more into read-only and read-write images.
- Moved some KG classes from SWRender to AppKit
- SWRender overhaul to use the whole KG interface (context,color,path,etc.) directly using the C CoreGraphics interface and a common test template for both CG and KG using the C interface.
2008-04-23 17:52:06 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2007-03-11 19:28:02 +00:00
|
|
|
// temporary
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
-(void)drawBackingContext:(O2Context *)other size:(CGSize)size {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2008-01-02 03:31:21 +00:00
|
|
|
}
|
|
|
|
|
2007-06-26 03:07:44 +00:00
|
|
|
-(void)resetClip {
|
2008-02-29 17:56:38 +00:00
|
|
|
[[self currentState] removeAllClipPhases];
|
|
|
|
[self deviceClipReset];
|
2007-06-26 03:07:44 +00:00
|
|
|
}
|
|
|
|
|
2008-06-23 18:58:30 +00:00
|
|
|
-(void)setAntialiasingQuality:(int)value {
|
|
|
|
[currentState(self) setAntialiasingQuality:value];
|
|
|
|
}
|
|
|
|
|
2007-03-11 19:28:02 +00:00
|
|
|
-(void)setWordSpacing:(float)spacing {
|
|
|
|
[currentState(self) setWordSpacing:spacing];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setTextLeading:(float)leading {
|
|
|
|
[currentState(self) setTextLeading:leading];
|
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(void)copyBitsInRect:(CGRect)rect toPoint:(CGPoint)point gState:(int)gState {
|
|
|
|
KGInvalidAbstractInvocation();
|
2007-03-11 19:28:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:59:58 +00:00
|
|
|
-(NSData *)captureBitmapInRect:(CGRect)rect {
|
|
|
|
KGInvalidAbstractInvocation();
|
2008-02-16 20:27:01 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2009-01-31 14:56:04 +00:00
|
|
|
/*
|
|
|
|
Notes: OSX generates a clip mask at fill time using the current aliasing setting. Once the fill is complete the clip mask persists with the next clip/fill. This means you can turn off AA, create a clip path, fill, turn on AA, create another clip path, fill, and edges from the first path will be aliased, and ones from the second will not. PDF does not dictate aliasing behavior, so while this is not really expected behavior, it is not a bug.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2008-02-29 17:56:38 +00:00
|
|
|
-(void)deviceClipReset {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2008-02-29 17:56:38 +00:00
|
|
|
}
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
-(void)deviceClipToNonZeroPath:(O2Path *)path {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2008-02-29 17:56:38 +00:00
|
|
|
}
|
|
|
|
|
2009-08-03 20:52:42 +00:00
|
|
|
-(void)deviceClipToEvenOddPath:(O2Path *)path {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2008-02-29 17:56:38 +00:00
|
|
|
}
|
|
|
|
|
2009-10-06 16:02:46 +00:00
|
|
|
-(void)deviceClipToMask:(O2Image *)mask inRect:(CGRect)rect {
|
2008-04-17 16:59:58 +00:00
|
|
|
KGInvalidAbstractInvocation();
|
2008-02-29 17:56:38 +00:00
|
|
|
}
|
|
|
|
|
2007-02-13 03:41:55 +00:00
|
|
|
@end
|