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

@ -2743,7 +2743,7 @@ systemColorWithName(NSString *name)
- (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];
}
- (void) GSSetPatterColor: (NSImage*)image
{
[self subclassResponsibility: _cmd];
}
/**
<p>Sets the colorspace for fill operations based on values in the supplied
dictionary dict.</p>
@ -1438,6 +1443,19 @@ NSGraphicsContext *GSCurrentContext(void)
[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
by imageref, an opaque structure. Support for this method hasn't
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
operation: (NSCompositingOperation)op
{
#if 0
[self compositeToPoint: aPoint
fromRect: aRect
operation: op
fraction: 1.0];
#else
NSImageRep *rep = nil;
NS_DURING
@ -762,6 +768,7 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
}
}
NS_ENDHANDLER
#endif
}
- (void) compositeToPoint: (NSPoint)aPoint
@ -777,11 +784,61 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
}
- (void) compositeToPoint: (NSPoint)aPoint
fromRect: (NSRect)srcRect
fromRect: (NSRect)aRect
operation: (NSCompositingOperation)op
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
@ -797,6 +854,12 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
fromRect: (NSRect)aRect
fraction: (float)aFloat
{
#if 0
[self compositeToPoint: aPoint
fromRect: aRect
operation: NSCompositeSourceOver
fraction: aFloat];
#else
NSImageRep *rep = nil;
NS_DURING
@ -845,6 +908,7 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
}
}
NS_ENDHANDLER
#endif
}
- (BOOL) drawRepresentation: (NSImageRep *)imageRep inRect: (NSRect)aRect