mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-29 20:07:38 +00:00
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:
parent
4900027b36
commit
d54180c5bb
5 changed files with 101 additions and 3 deletions
|
@ -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>
|
||||
|
||||
* Documentation/ReleaseNotes.gsdoc: Update.
|
||||
|
|
|
@ -233,6 +233,8 @@ APPKIT_EXPORT NSGraphicsContext *GSCurrentContext(void);
|
|||
- (void) DPSsethsbcolor: (float)h : (float)s : (float)b;
|
||||
- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b;
|
||||
|
||||
- (void) GSSetPatterColor: (NSImage*)image;
|
||||
|
||||
- (void) GSSetFillColorspace: (void *)spaceref;
|
||||
- (void) GSSetStrokeColorspace: (void *)spaceref;
|
||||
- (void) GSSetFillColor: (const float *)values;
|
||||
|
@ -359,6 +361,11 @@ APPKIT_EXPORT NSGraphicsContext *GSCurrentContext(void);
|
|||
- (void) DPSdissolve: (float)x : (float)y : (float)w : (float)h
|
||||
: (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;
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
|
|
@ -2743,7 +2743,7 @@ systemColorWithName(NSString *name)
|
|||
|
||||
- (void) set
|
||||
{
|
||||
// FIXME: We need another PS command for this
|
||||
[GSCurrentContext() GSSetPatterColor: _pattern];
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue