diff --git a/ChangeLog b/ChangeLog index b7dfcf4..94bc86a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-10-03 Fred Kiefer + + * Headers/gsc/GSGState.h + * Source/gsc/GSContext.m + * Source/gsc/GSGState.m + * Source/cairo/CairoGState.m + Implement per gstate methods for antialias, patternPhase and + compositingOperation. + 2015-09-20 Fred Kiefer * Source/cairo/CairoGState.m: Preliminary support for anti alias diff --git a/Headers/gsc/GSGState.h b/Headers/gsc/GSGState.h index 59668b1..0ca0b0b 100644 --- a/Headers/gsc/GSGState.h +++ b/Headers/gsc/GSGState.h @@ -69,6 +69,9 @@ typedef enum { NSAffineTransform *textCtm; /* Text transform - concat with ctm */ GSTextDrawingMode textMode; BOOL viewIsFlipped; + BOOL _antialias; + NSPoint _patternPhase; + NSCompositingOperation _compositingOperation; } - initWithDrawContext: (GSContext *)context; @@ -80,6 +83,13 @@ typedef enum { - (void) setColor: (device_color_t *)color state: (color_state_t)cState; - (void) GSSetPatterColor: (NSImage*)image; +- (void) setShouldAntialias: (BOOL)antialias; +- (BOOL) shouldAntialias; +- (NSPoint) patternPhase; +- (void) setPatternPhase: (NSPoint)phase; +- (NSCompositingOperation) compositingOperation; +- (void) setCompositingOperation:(NSCompositingOperation) operation; + - (void) compositeGState: (GSGState *)source fromRect: (NSRect)aRect toPoint: (NSPoint)aPoint diff --git a/Source/cairo/CairoGState.m b/Source/cairo/CairoGState.m index be7a1e4..b3e7262 100644 --- a/Source/cairo/CairoGState.m +++ b/Source/cairo/CairoGState.m @@ -723,8 +723,7 @@ static inline cairo_filter_t cairoFilterFromNSImageInterpolation(NSImageInterpol break; } } - // FIXME: Should be part of the state - cairo_set_antialias(_ct, [drawcontext shouldAntialias] ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE); + cairo_set_antialias(_ct, [self shouldAntialias] ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE); } - (void) DPSclip diff --git a/Source/gsc/GSContext.m b/Source/gsc/GSContext.m index e7cdaa7..d8d1db9 100644 --- a/Source/gsc/GSContext.m +++ b/Source/gsc/GSContext.m @@ -254,6 +254,36 @@ static NSMapTable *gtable; return gstate; } +- (void) setShouldAntialias: (BOOL)antialias +{ + [gstate setShouldAntialias: antialias]; +} + +- (BOOL) shouldAntialias +{ + return [gstate shouldAntialias]; +} + +- (NSPoint) patternPhase +{ + return [gstate patternPhase]; +} + +- (void) setPatternPhase: (NSPoint)phase +{ + [gstate setPatternPhase: phase]; +} + +- (NSCompositingOperation) compositingOperation +{ + return [gstate compositingOperation]; +} + +- (void) setCompositingOperation: (NSCompositingOperation)operation +{ + [gstate setCompositingOperation: operation]; +} + @end @implementation GSContext (Ops) diff --git a/Source/gsc/GSGState.m b/Source/gsc/GSGState.m index ec67e42..d477f18 100644 --- a/Source/gsc/GSGState.m +++ b/Source/gsc/GSGState.m @@ -143,6 +143,36 @@ ASSIGN(pattern, image); } +- (void) setShouldAntialias: (BOOL)antialias +{ + _antialias = antialias; +} + +- (BOOL) shouldAntialias +{ + return _antialias; +} + +- (NSPoint) patternPhase +{ + return _patternPhase; +} + +- (void) setPatternPhase: (NSPoint)phase +{ + _patternPhase = phase; +} + +- (NSCompositingOperation) compositingOperation +{ + return _compositingOperation; +} + +- (void) setCompositingOperation: (NSCompositingOperation)operation +{ + _compositingOperation = operation; +} + // This is only a fall back, the method should not be called any more. - (void) compositeGState: (GSGState *)source fromRect: (NSRect)aRect @@ -1285,7 +1315,7 @@ typedef enum { [ictm invert]; size = [color_pattern size]; - patternPhase = [drawcontext patternPhase]; + patternPhase = [self patternPhase]; if (!NSEqualPoints(patternPhase, NSZeroPoint)) {