mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 06:10:59 +00:00
Implement extended graphics ops (composite, etc).
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4262 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ed2acc2520
commit
95f1109ae7
8 changed files with 266 additions and 17 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
1999-05-18 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* 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 <richard@brainstorm.co.uk>
|
Sun May 16 8:15:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/NSView.m: Use new context lock/unlock operations.
|
* Source/NSView.m: Use new context lock/unlock operations.
|
||||||
|
|
|
@ -690,8 +690,32 @@ static inline void
|
||||||
DPScapturegstate(GSCTXT *ctxt, int *gst)
|
DPScapturegstate(GSCTXT *ctxt, int *gst)
|
||||||
__attribute__((unused));
|
__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 */
|
/* Color operations */
|
||||||
|
@ -1829,6 +1853,51 @@ DPScapturegstate(GSCTXT *ctxt, int *gst)
|
||||||
(ctxt, @selector(DPScapturegstate:), 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 */
|
/* GNUstep Event and other I/O extensions */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
|
@ -379,6 +379,23 @@ typedef struct {
|
||||||
(NSGraphicsContext*, SEL, double, double, double, int*);
|
(NSGraphicsContext*, SEL, double, double, double, int*);
|
||||||
void (*DPScapturegstate_)
|
void (*DPScapturegstate_)
|
||||||
(NSGraphicsContext*, SEL, int*);
|
(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 */
|
/* GNUstep Event and other I/O extensions */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
|
@ -330,6 +330,17 @@ NSGraphicsContext *GSCurrentContext();
|
||||||
- (void) DPSsetrgbactual: (double)r : (double)g : (double)b : (int *)success ;
|
- (void) DPSsetrgbactual: (double)r : (double)g : (double)b : (int *)success ;
|
||||||
- (void) DPScapturegstate: (int *)gst ;
|
- (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 */
|
/* GNUstep Event and other I/O extensions */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
|
@ -690,7 +690,33 @@ static inline void
|
||||||
PScapturegstate(int *gst)
|
PScapturegstate(int *gst)
|
||||||
__attribute__((unused));
|
__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 */
|
/* Color operations */
|
||||||
|
@ -1670,6 +1696,46 @@ PScapturegstate(int *gst)
|
||||||
DPScapturegstate(DEFCTXT, 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 */
|
/* GNUstep Event and other I/O extensions */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
|
@ -619,6 +619,21 @@ struct NSWindow_struct
|
||||||
GET_IMP(@selector(DPSsetrgbactual::::));
|
GET_IMP(@selector(DPSsetrgbactual::::));
|
||||||
methodTable.DPScapturegstate_ =
|
methodTable.DPScapturegstate_ =
|
||||||
GET_IMP(@selector(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));
|
mptr = NSZoneMalloc(_globalGSZone, sizeof(gsMethodTable));
|
||||||
memcpy(mptr, &methodTable, sizeof(gsMethodTable));
|
memcpy(mptr, &methodTable, sizeof(gsMethodTable));
|
||||||
|
@ -1476,6 +1491,40 @@ struct NSWindow_struct
|
||||||
[self subclassResponsibility: _cmd];
|
[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 */
|
/* GNUstep Event and other I/O extensions */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
|
@ -35,13 +35,9 @@
|
||||||
#include <AppKit/NSBitmapImageRep.h>
|
#include <AppKit/NSBitmapImageRep.h>
|
||||||
#include <AppKit/NSEPSImageRep.h>
|
#include <AppKit/NSEPSImageRep.h>
|
||||||
#include <AppKit/NSPasteboard.h>
|
#include <AppKit/NSPasteboard.h>
|
||||||
|
#include <AppKit/NSGraphicsContext.h>
|
||||||
/* Backend protocol - methods that must be implemented by the backend to
|
#include <AppKit/NSView.h>
|
||||||
complete the class */
|
#include <AppKit/DPSOperators.h>
|
||||||
@protocol NXImageRepBackend
|
|
||||||
- (BOOL) drawAtPoint: (NSPoint)aPoint;
|
|
||||||
- (BOOL) drawInRect: (NSRect)aRect;
|
|
||||||
@end
|
|
||||||
|
|
||||||
static NSMutableArray* imageReps = NULL;
|
static NSMutableArray* imageReps = NULL;
|
||||||
|
|
||||||
|
@ -284,23 +280,51 @@ static NSMutableArray* imageReps = NULL;
|
||||||
|
|
||||||
- (BOOL) drawAtPoint: (NSPoint)aPoint
|
- (BOOL) drawAtPoint: (NSPoint)aPoint
|
||||||
{
|
{
|
||||||
NSRect r;
|
BOOL ok, reset;
|
||||||
|
NSGraphicsContext *ctxt;
|
||||||
|
|
||||||
if (aPoint.x == 0 && aPoint.y == 0)
|
if (size.width == 0 && size.height == 0)
|
||||||
return [self draw];
|
return NO;
|
||||||
r.origin = aPoint;
|
|
||||||
r.size = size;
|
NSDebugLLog(@"NSImage", @"Drawing at point %f %f\n", aPoint.x, aPoint.y);
|
||||||
return [self drawInRect: r];
|
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
|
- (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",
|
||||||
return NO;
|
NSMinX(aRect), NSMinY(aRect), NSWidth(aRect), NSHeight(aRect));
|
||||||
/* FIXME - should scale and move as necessary. */
|
if (size.width == 0 && size.height == 0)
|
||||||
return NO;
|
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
|
// Managing NSImageRep Subclasses
|
||||||
|
|
|
@ -1800,6 +1800,7 @@ static Class responderClass;
|
||||||
original_responder = nil;
|
original_responder = nil;
|
||||||
delegate = nil;
|
delegate = nil;
|
||||||
window_num = 0;
|
window_num = 0;
|
||||||
|
gstate = 0;
|
||||||
background_color = [[NSColor controlColor] retain];
|
background_color = [[NSColor controlColor] retain];
|
||||||
represented_filename = @"Window";
|
represented_filename = @"Window";
|
||||||
miniaturized_title = @"Window";
|
miniaturized_title = @"Window";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue