diff --git a/ChangeLog b/ChangeLog index db43da38f..10f961bcd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +1999-05-18 Adam Fedor + + * Headers/gnustep/gui/DPSOperators: New graphics extensions + operators (composite, compositerect, disolve, etc). + * Headers/gnustep/gui/GSMethodTable.h: Likewise. + * Headers/gnustep/gui/NSGraphicsContext.h: Likewise. + * Headers/gnustep/gui/PSOperators.h: Likewise. + * Source/NSGraphicsContext.m: Likewise. + + * Source/NSImageRep.m: (-drawAtPoint:): Implement using DPS + operators. (-drawInRect:): Likewise. + Sun May 16 8:15:00 1999 Richard Frith-Macdonald * Source/NSView.m: Use new context lock/unlock operations. diff --git a/Headers/gnustep/gui/DPSOperators.h b/Headers/gnustep/gui/DPSOperators.h index 22dd3fd64..8a495b875 100644 --- a/Headers/gnustep/gui/DPSOperators.h +++ b/Headers/gnustep/gui/DPSOperators.h @@ -690,8 +690,32 @@ static inline void DPScapturegstate(GSCTXT *ctxt, int *gst) __attribute__((unused)); +/*-------------------------------------------------------------------------*/ +/* Graphics Extension Ops */ +/*-------------------------------------------------------------------------*/ +static inline void +DPScomposite(GSCTXT *ctxt, float x, float y, float w, float h, int gstateNum, float dx, float dy, int op) +__attribute__((unused)); +static inline void +DPScompositerect(GSCTXT *ctxt, float x, float y, float w, float h, int op) +__attribute__((unused)); +static inline void +DPSdissolve(GSCTXT *ctxt, float x, float y, float w, float h, int gstateNum, float dx, float dy, float delta) +__attribute__((unused)); + +static inline void +DPSreadimage(GSCTXT *ctxt) +__attribute__((unused)); + +static inline void +DPSsetalpha(GSCTXT *ctxt, float a) +__attribute__((unused)); + +static inline void +DPScurrentalpha(GSCTXT *ctxt, float *alpha) +__attribute__((unused)); /* ----------------------------------------------------------------------- */ /* Color operations */ @@ -1829,6 +1853,51 @@ DPScapturegstate(GSCTXT *ctxt, int *gst) (ctxt, @selector(DPScapturegstate:), gst); } +/*-------------------------------------------------------------------------*/ +/* Graphics Extensions Ops */ +/*-------------------------------------------------------------------------*/ +static inline void +DPScomposite(GSCTXT *ctxt, float x, float y, float w, float h, int gstateNum, float dx, float dy, int op) +{ + (ctxt->methods->DPScomposite________) + (ctxt, @selector(DPScomposite::::::::), x, y, w, h, gstateNum, dx, dy, op); +} + +static inline void +DPScompositerect(GSCTXT *ctxt, float x, float y, float w, float h, int op) +{ + (ctxt->methods->DPScompositerect_____) + (ctxt, @selector(DPScompositerect:::::), x, y, w, h, op); +} + +static inline void +DPSdissolve(GSCTXT *ctxt, float x, float y, float w, float h, int gstateNum, float dx, float dy, float delta) +{ + (ctxt->methods->DPSdissolve________) + (ctxt, @selector(DPSdissolve::::::::), x, y, w, h, gstateNum, dx, dy, delta); +} + +static inline void +DPSreadimage(GSCTXT *ctxt) +{ + (ctxt->methods->DPSreadimage) + (ctxt, @selector(DPSreadimage)); +} + +static inline void +DPSsetalpha(GSCTXT *ctxt, float a) +{ + (ctxt->methods->DPSsetalpha_) + (ctxt, @selector(DPSsetalpha:), a); +} + +static inline void +DPScurrentalpha(GSCTXT *ctxt, float *a) +{ + (ctxt->methods->DPScurrentalpha_) + (ctxt, @selector(DPScurrentalpha:), a); +} + /* ----------------------------------------------------------------------- */ /* GNUstep Event and other I/O extensions */ /* ----------------------------------------------------------------------- */ diff --git a/Headers/gnustep/gui/GSMethodTable.h b/Headers/gnustep/gui/GSMethodTable.h index a8f110a3b..71d5bfee3 100644 --- a/Headers/gnustep/gui/GSMethodTable.h +++ b/Headers/gnustep/gui/GSMethodTable.h @@ -379,6 +379,23 @@ typedef struct { (NSGraphicsContext*, SEL, double, double, double, int*); void (*DPScapturegstate_) (NSGraphicsContext*, SEL, int*); + +/*-------------------------------------------------------------------------*/ +/* Graphics Extensions Ops */ +/*-------------------------------------------------------------------------*/ + void (*DPScomposite________) + (NSGraphicsContext*, SEL, float, float, float, float, int, float, float, int); + void (*DPScompositerect_____) + (NSGraphicsContext*, SEL, float, float, float, float, int); + void (*DPSdissolve________) + (NSGraphicsContext*, SEL, float, float, float, float, int, float, float, float); + void (*DPSreadimage) + (NSGraphicsContext*, SEL); + void (*DPSsetalpha_) + (NSGraphicsContext*, SEL, float); + void (*DPScurrentalpha_) + (NSGraphicsContext*, SEL, float*); + /* ----------------------------------------------------------------------- */ /* GNUstep Event and other I/O extensions */ /* ----------------------------------------------------------------------- */ diff --git a/Headers/gnustep/gui/NSGraphicsContext.h b/Headers/gnustep/gui/NSGraphicsContext.h index ba31dbf11..a36111f51 100644 --- a/Headers/gnustep/gui/NSGraphicsContext.h +++ b/Headers/gnustep/gui/NSGraphicsContext.h @@ -330,6 +330,17 @@ NSGraphicsContext *GSCurrentContext(); - (void) DPSsetrgbactual: (double)r : (double)g : (double)b : (int *)success ; - (void) DPScapturegstate: (int *)gst ; +/*-------------------------------------------------------------------------*/ +/* Graphics Extensions Ops */ +/*-------------------------------------------------------------------------*/ +- (void) DPScomposite: (float)x : (float)y : (float)w : (float)h : (int)gstateNum : (float)dx : (float)dy : (int)op; +- (void) DPScompositerect: (float)x : (float)y : (float)w : (float)h : (int)op; +- (void) DPSdissolve: (float)x : (float)y : (float)w : (float)h : (int)gstateNum + : (float)dx : (float)dy : (float)delta; +- (void) DPSreadimage; +- (void) DPSsetalpha: (float)a; +- (void) DPScurrentalpha: (float *)a; + /* ----------------------------------------------------------------------- */ /* GNUstep Event and other I/O extensions */ /* ----------------------------------------------------------------------- */ diff --git a/Headers/gnustep/gui/PSOperators.h b/Headers/gnustep/gui/PSOperators.h index e08e30f58..0c0c21bd6 100644 --- a/Headers/gnustep/gui/PSOperators.h +++ b/Headers/gnustep/gui/PSOperators.h @@ -690,7 +690,33 @@ static inline void PScapturegstate(int *gst) __attribute__((unused)); +/*-------------------------------------------------------------------------*/ +/* Graphics Extension Ops */ +/*-------------------------------------------------------------------------*/ +static inline void +PScomposite(float x, float y, float w, float h, int gstateNum, float dx, float dy, int op) +__attribute__((unused)); + +static inline void +PScompositerect(float x, float y, float w, float h, int op) +__attribute__((unused)); + +static inline void +PSdissolve(float x, float y, float w, float h, int gstateNum, float dx, float dy, float delta) +__attribute__((unused)); + +static inline void +PSreadimage( void ) +__attribute__((unused)); + +static inline void +PSsetalpha(float a) +__attribute__((unused)); + +static inline void +PScurrentalpha(float *a) +__attribute__((unused)); /* ----------------------------------------------------------------------- */ /* Color operations */ @@ -1670,6 +1696,46 @@ PScapturegstate(int *gst) DPScapturegstate(DEFCTXT, gst); } +/*-------------------------------------------------------------------------*/ +/* Graphics Extension Ops */ +/*-------------------------------------------------------------------------*/ + +static inline void +PScomposite(float x, float y, float w, float h, int gstateNum, float dx, float dy, int op) +{ + DPScomposite(DEFCTXT, x, y, w, h, gstateNum, dx, dy, op); +} + +static inline void +PScompositerect(float x, float y, float w, float h, int op) +{ + DPScompositerect(DEFCTXT, x, y, w, h, op); +} + +static inline void +PSdissolve(float x, float y, float w, float h, int gstateNum, float dx, float dy, float delta) +{ + DPSdissolve(DEFCTXT, x, y, w, h, gstateNum, dx, dy, delta); +} + +static inline void +PSreadimage( void ) +{ + DPSreadimage(DEFCTXT); +} + +static inline void +PSsetalpha(float a) +{ + DPSsetalpha(DEFCTXT, a); +} + +static inline void +PScurrentalpha(float *a) +{ + DPScurrentalpha(DEFCTXT, a); +} + /* ----------------------------------------------------------------------- */ /* GNUstep Event and other I/O extensions */ /* ----------------------------------------------------------------------- */ diff --git a/Source/NSGraphicsContext.m b/Source/NSGraphicsContext.m index dab999250..dfcf7a299 100644 --- a/Source/NSGraphicsContext.m +++ b/Source/NSGraphicsContext.m @@ -619,6 +619,21 @@ struct NSWindow_struct GET_IMP(@selector(DPSsetrgbactual::::)); methodTable.DPScapturegstate_ = GET_IMP(@selector(DPScapturegstate:)); +/*-------------------------------------------------------------------------*/ +/* Graphics Extension Ops */ +/*-------------------------------------------------------------------------*/ + methodTable.DPScomposite________ = + GET_IMP(@selector(DPScomposite::::::::)); + methodTable.DPScompositerect_____ = + GET_IMP(@selector(DPScompositerect:::::)); + methodTable.DPSdissolve________ = + GET_IMP(@selector(DPSdissolve::::::::)); + methodTable.DPSreadimage = + GET_IMP(@selector(DPSreadimage)); + methodTable.DPSsetalpha_ = + GET_IMP(@selector(DPSsetalpha:)); + methodTable.DPScurrentalpha_ = + GET_IMP(@selector(DPScurrentalpha:)); mptr = NSZoneMalloc(_globalGSZone, sizeof(gsMethodTable)); memcpy(mptr, &methodTable, sizeof(gsMethodTable)); @@ -1476,6 +1491,40 @@ struct NSWindow_struct [self subclassResponsibility: _cmd]; } +/*-------------------------------------------------------------------------*/ +/* Graphics Extension Ops */ +/*-------------------------------------------------------------------------*/ +- (void) DPScomposite: (float)x : (float)y : (float)w : (float)h : (int)gstateNum : (float)dx : (float)dy : (int)op +{ + [self subclassResponsibility: _cmd]; +} + +- (void) DPScompositerect: (float)x : (float)y : (float)w : (float)h : (int)op +{ + [self subclassResponsibility: _cmd]; +} + +- (void) DPSdissolve: (float)x : (float)y : (float)w : (float)h : (int)gstateNum + : (float)dx : (float)dy : (float)delta +{ + [self subclassResponsibility: _cmd]; +} + +- (void) DPSreadimage +{ + [self subclassResponsibility: _cmd]; +} + +- (void) DPSsetalpha: (float)a +{ + [self subclassResponsibility: _cmd]; +} + +- (void) DPScurrentalpha: (float *)alpha +{ + [self subclassResponsibility: _cmd]; +} + /* ----------------------------------------------------------------------- */ /* GNUstep Event and other I/O extensions */ /* ----------------------------------------------------------------------- */ diff --git a/Source/NSImageRep.m b/Source/NSImageRep.m index f9e3d08e3..c0cb89d5f 100644 --- a/Source/NSImageRep.m +++ b/Source/NSImageRep.m @@ -35,13 +35,9 @@ #include #include #include - -/* Backend protocol - methods that must be implemented by the backend to - complete the class */ -@protocol NXImageRepBackend -- (BOOL) drawAtPoint: (NSPoint)aPoint; -- (BOOL) drawInRect: (NSRect)aRect; -@end +#include +#include +#include static NSMutableArray* imageReps = NULL; @@ -284,23 +280,51 @@ static NSMutableArray* imageReps = NULL; - (BOOL) drawAtPoint: (NSPoint)aPoint { - NSRect r; + BOOL ok, reset; + NSGraphicsContext *ctxt; - if (aPoint.x == 0 && aPoint.y == 0) - return [self draw]; - r.origin = aPoint; - r.size = size; - return [self drawInRect: r]; + if (size.width == 0 && size.height == 0) + return NO; + + NSDebugLLog(@"NSImage", @"Drawing at point %f %f\n", aPoint.x, aPoint.y); + reset = 0; + ctxt = GSCurrentContext(); + if (aPoint.x != 0 || aPoint.y != 0) + { + if ([[ctxt focusView] isFlipped]) + aPoint.y -= size.height; + DPSmatrix(ctxt); DPScurrentmatrix(ctxt); + DPStranslate(ctxt, aPoint.x, aPoint.y); + reset = 1; + } + ok = [self draw]; + if (reset) + DPSsetmatrix(ctxt); + return ok; } - (BOOL) drawInRect: (NSRect)aRect { - float x, y; + NSSize scale; + BOOL ok; + NSGraphicsContext *ctxt; - if (size.height == 0 || size.width == 0) + NSDebugLLog(@"NSImage", @"Drawing in rect (%f %f %f %f)\n", + NSMinX(aRect), NSMinY(aRect), NSWidth(aRect), NSHeight(aRect)); + if (size.width == 0 && size.height == 0) return NO; -/* FIXME - should scale and move as necessary. */ - return NO; + + ctxt = GSCurrentContext(); + scale = NSMakeSize(NSWidth(aRect) / size.width, + NSHeight(aRect) / size.height); + if ([[ctxt focusView] isFlipped]) + aRect.origin.y -= NSHeight(aRect); + DPSmatrix(ctxt); DPScurrentmatrix(ctxt); + DPStranslate(ctxt, NSMinX(aRect), NSMinY(aRect)); + DPSscale(ctxt, scale.width, scale.height); + ok = [self draw]; + DPSsetmatrix(ctxt); + return ok; } // Managing NSImageRep Subclasses diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 5f69b6b01..b06fe83e0 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -1800,6 +1800,7 @@ static Class responderClass; original_responder = nil; delegate = nil; window_num = 0; + gstate = 0; background_color = [[NSColor controlColor] retain]; represented_filename = @"Window"; miniaturized_title = @"Window";