Added methods for pattern colour and alpha image composition.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@21436 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2005-07-08 23:51:49 +00:00
parent 4900027b36
commit d54180c5bb
5 changed files with 101 additions and 3 deletions

View file

@ -1,3 +1,12 @@
2005-07-09 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSGraphicsContext.h,
* Source/NSGraphicsContext.m: Added new methods
[-GScomposite:toPoint:fromRect:operation:fraction:] and
[-GSSetPatterColor:].
* Source/NSImage.m (-compositeToPoint:...fraction:): Implemented.
* Source/NSColor.m (GSPatternColor -set): Implemented.
2005-07-04 Adam Fedor <fedor@gnu.org> 2005-07-04 Adam Fedor <fedor@gnu.org>
* Documentation/ReleaseNotes.gsdoc: Update. * Documentation/ReleaseNotes.gsdoc: Update.

View file

@ -233,6 +233,8 @@ APPKIT_EXPORT NSGraphicsContext *GSCurrentContext(void);
- (void) DPSsethsbcolor: (float)h : (float)s : (float)b; - (void) DPSsethsbcolor: (float)h : (float)s : (float)b;
- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b; - (void) DPSsetrgbcolor: (float)r : (float)g : (float)b;
- (void) GSSetPatterColor: (NSImage*)image;
- (void) GSSetFillColorspace: (void *)spaceref; - (void) GSSetFillColorspace: (void *)spaceref;
- (void) GSSetStrokeColorspace: (void *)spaceref; - (void) GSSetStrokeColorspace: (void *)spaceref;
- (void) GSSetFillColor: (const float *)values; - (void) GSSetFillColor: (const float *)values;
@ -359,6 +361,11 @@ APPKIT_EXPORT NSGraphicsContext *GSCurrentContext(void);
- (void) DPSdissolve: (float)x : (float)y : (float)w : (float)h - (void) DPSdissolve: (float)x : (float)y : (float)w : (float)h
: (int)gstateNum : (float)dx : (float)dy : (float)delta; : (int)gstateNum : (float)dx : (float)dy : (float)delta;
- (void) GScomposite: (int)gstateNum
toPoint: (NSPoint)aPoint
fromRect: (NSRect)srcRect
operation: (NSCompositingOperation)op
fraction: (float)delta;
- (void) GSDrawImage: (NSRect)rect : (void *)imageref; - (void) GSDrawImage: (NSRect)rect : (void *)imageref;
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */

View file

@ -2743,7 +2743,7 @@ systemColorWithName(NSString *name)
- (void) set - (void) set
{ {
// FIXME: We need another PS command for this [GSCurrentContext() GSSetPatterColor: _pattern];
} }
// //

View file

@ -770,6 +770,11 @@ NSGraphicsContext *GSCurrentContext(void)
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
} }
- (void) GSSetPatterColor: (NSImage*)image
{
[self subclassResponsibility: _cmd];
}
/** /**
<p>Sets the colorspace for fill operations based on values in the supplied <p>Sets the colorspace for fill operations based on values in the supplied
dictionary dict.</p> dictionary dict.</p>
@ -1438,6 +1443,19 @@ NSGraphicsContext *GSCurrentContext(void)
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
} }
/*
As currently not all backends support mixed composite and dissolve operations,
this method is here to dispatch to the best suited one implemented
*/
- (void) GScomposite: (int)gstateNum
toPoint: (NSPoint)aPoint
fromRect: (NSRect)srcRect
operation: (NSCompositingOperation)op
fraction: (float)delta
{
[self subclassResponsibility: _cmd];
}
/** Generic method to draw an image into a rect. The image is defined /** Generic method to draw an image into a rect. The image is defined
by imageref, an opaque structure. Support for this method hasn't by imageref, an opaque structure. Support for this method hasn't
been implemented yet, so it should not be used anywhere. */ been implemented yet, so it should not be used anywhere. */

View file

@ -714,6 +714,12 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
fromRect: (NSRect)aRect fromRect: (NSRect)aRect
operation: (NSCompositingOperation)op operation: (NSCompositingOperation)op
{ {
#if 0
[self compositeToPoint: aPoint
fromRect: aRect
operation: op
fraction: 1.0];
#else
NSImageRep *rep = nil; NSImageRep *rep = nil;
NS_DURING NS_DURING
@ -762,6 +768,7 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
} }
} }
NS_ENDHANDLER NS_ENDHANDLER
#endif
} }
- (void) compositeToPoint: (NSPoint)aPoint - (void) compositeToPoint: (NSPoint)aPoint
@ -777,11 +784,61 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
} }
- (void) compositeToPoint: (NSPoint)aPoint - (void) compositeToPoint: (NSPoint)aPoint
fromRect: (NSRect)srcRect fromRect: (NSRect)aRect
operation: (NSCompositingOperation)op operation: (NSCompositingOperation)op
fraction: (float)delta fraction: (float)delta
{ {
// FIXME We need another PS command for this NSImageRep *rep = nil;
NS_DURING
{
if ([GSCurrentContext() isDrawingToScreen] == YES)
rep = [self _doImageCache];
if (rep
&&_cacheMode != NSImageCacheNever
&& [rep isKindOfClass: cachedClass])
{
NSRect rect;
rect = [(NSCachedImageRep *)rep rect];
NSDebugLLog(@"NSImage", @"composite rect %@ in %@",
NSStringFromRect(rect), NSStringFromRect(aRect));
// Move the drawing rectangle to the origin of the image rep
// and intersect the two rects.
aRect.origin.x += rect.origin.x;
aRect.origin.y += rect.origin.y;
rect = NSIntersectionRect(aRect, rect);
[GSCurrentContext() GScomposite: [[(NSCachedImageRep *)rep window] gState]
toPoint: aPoint
fromRect: rect
operation: op
fraction: delta];
}
else
{
NSRect rect;
rep = [self bestRepresentationForDevice: nil];
rect = NSMakeRect(aPoint.x, aPoint.y, _size.width, _size.height);
[self drawRepresentation: rep inRect: rect];
}
}
NS_HANDLER
{
NSLog(@"NSImage: compositeToPoint:fromRect:operation:fraction: failed due to %@: %@",
[localException name], [localException reason]);
if ([_delegate respondsToSelector: @selector(imageDidNotDraw:inRect:)])
{
NSImage *image = [_delegate imageDidNotDraw: self inRect: aRect];
if (image != nil)
[image compositeToPoint: aPoint
fromRect: aRect
operation: op
fraction: delta];
}
}
NS_ENDHANDLER
} }
- (void) dissolveToPoint: (NSPoint)aPoint fraction: (float)aFloat - (void) dissolveToPoint: (NSPoint)aPoint fraction: (float)aFloat
@ -797,6 +854,12 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
fromRect: (NSRect)aRect fromRect: (NSRect)aRect
fraction: (float)aFloat fraction: (float)aFloat
{ {
#if 0
[self compositeToPoint: aPoint
fromRect: aRect
operation: NSCompositeSourceOver
fraction: aFloat];
#else
NSImageRep *rep = nil; NSImageRep *rep = nil;
NS_DURING NS_DURING
@ -845,6 +908,7 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
} }
} }
NS_ENDHANDLER NS_ENDHANDLER
#endif
} }
- (BOOL) drawRepresentation: (NSImageRep *)imageRep inRect: (NSRect)aRect - (BOOL) drawRepresentation: (NSImageRep *)imageRep inRect: (NSRect)aRect