Subject: Blitting: a prototype
To: None <amiga-x@sun-lamp.cs.berkeley.edu>
From: Eduardo E. Horvath eeh@btr.com <eeh@btr.btr.com>
List: amiga-x
Date: 03/25/1994 16:25:20
I'm getting this feeling of deja-vu.  Seems like I have deleted the
same messages from my mailbox 5 times already.  Anybody else have the
feeling that the amiga-x mailing list is corrupt?

Anyway, not for the main point.  I extended the prorotypes in
grfioctl.h to something that I think will fully cover the
functionality of the current blitter.  I re-used the same structure so
we wouldn't have a half dozen very similar structures polluting the
name space and taking up room in the kernel.  If you really think it's
necessary, different structures can be created for each ioctl.

The other point is that the functionality maps almost directly to the
amiga blitter, especially the area fill routines.  This way they are
extremely easy to implement and no state needs to be saved in the
kernel.  If this is incompatible with other rendering systems, we
could always switch to a system closer to the rom kernel routines with
begin_area, and area_end, however that means that the kernel will need
to store the endpoints of each line in the area fill, something I
would prefer not to do.

Clipping is done in the server, period.

Arcs are best done in the server with the CPU.  All arcs except
zero-width arcs must conform to very strict constraints, and just
optimizing zero-width arcs and filled arcs does not seem worth while.
(And the blitter doesn't support arcs)


Here it is:


/* support for a BitBlt operation. The op-codes are identical
   to X11 GCs */
#define	GRFBBOPclear		0x0	/* 0 */
#define GRFBBOPand		0x1	/* src AND dst */
#define GRFBBOPandReverse	0x2	/* src AND NOT dst */
#define GRFBBOPcopy		0x3	/* src */
#define GRFBBOPandInverted	0x4	/* NOT src AND dst */
#define	GRFBBOPnoop		0x5	/* dst */
#define GRFBBOPxor		0x6	/* src XOR dst */
#define GRFBBOPor		0x7	/* src OR dst */
#define GRFBBOPnor		0x8	/* NOT src AND NOT dst */
#define GRFBBOPequiv		0x9	/* NOT src XOR dst */
#define GRFBBOPinvert		0xa	/* NOT dst */
#define GRFBBOPorReverse	0xb	/* src OR NOT dst */
#define GRFBBOPcopyInverted	0xc	/* NOT src */
#define GRFBBOPorInverted	0xd	/* NOT src OR dst */
#define GRFBBOPnand		0xe	/* NOT src OR NOT dst */
#define GRFBBOPset		0xf	/* 1 */

#define GRFLDOPnormal		0x0	/* Normal line */
#define GRFLDOPfill		0xf0	/* Area fill line */

struct grf_bitblt {
  int     drawable1;	/* What to draw from (only used when copying from pixmap) */
  int     drawable2;	/* What to draw on */
  u_short op;		/* see above */
  u_short x1, y1;	/* upper left corner of source-region or start of line*/
  u_short x2, y2;	/* upper left corner of dest-region or end of line */
  u_short w, h;		/* width, height of region */
  int 	  mask;		/* bitmask to apply */
  u_char* image;	/* Pointer to image buffer (if used) */
};

#define GRFIOCBITBLT	_IOR('G', 57, struct grf_bitblt) /* Do a bit-blit */
/* Use	:
 *				
 * drawable1 	= 	source pixmap (0 is screen)
 * drawable2 	= 	dest pixmap (0 is screen)
 * op 		= 	rendering mode (see above)
 * x1, y1 	=	upper left of source
 * x2, y2 	= 	upper left of dest
 * w,  h  	=	width and height of blit
 * mask		=	bitplanes to render into (remeber, we may go 24 bit
 * image  	=	unused
 */
#define GRFIOCLINE	_IOR('G', 58, struct grf_bitblt) /* Draw a line */
/* Use	:
 *				
 * drawable1 	= 	set to -1 for area fill lines
 * drawable2 	= 	dest pixmap (0 is screen)
 * op 		= 	rendering mode (see above)
 * x1, y1 	=	start of line
 * x2, y2 	= 	end of line
 * w,  h  	=	unused
 * mask		=	bitplanes to render into (ignored by area fill lines)
 * image  	=	unused
 */
#define GRFIOCFILL	_IOR('G', 59, struct grf_bitblt) /* Area fill */
/* Use	:
 *				
 * drawable1 	= 	set to 0 to erase fill plane after fill
 * drawable2 	= 	dest pixmap (0 is screen)
 * op 		= 	rendering mode (see above)
 * x1, y1 	=	start of fill
 * x2, y2 	= 	unused
 * w,  h  	=	size of fill
 * mask		=	bitplanes to render into
 * image  	=	unused
 */
#define GRFIOCALOCMAP	_IOR('G', 60, struct grf_bitblt) /* Allocate a pixmap */
/*Use	: returns -1 on falure, or pixmap id
 *				
 * drawable1 	= 	unused
 * drawable2 	= 	unused
 * op 		= 	unused
 * x1, y1 	=	unused
 * x2, y2 	= 	unused
 * w,  h  	=	size of pixmap
 * mask		=	number of planes to allocate
 * image  	=	unused
 */
#define GRFIOCFREEMAP	_IOR('G', 61, int) /* Free a pixmap */
/*
 * Deallocate a pixmap
 */
#define GRFIOCSYNC	_IOR('G', 62, void) /* Wait till blitter's free */

#define GRFIOCGETMAP	_IOR('G', 63, struct grf_bitblt) /* Read contents of pixmap into buffer */
/*Use	:
 *				
 * drawable1 	= 	source pixmap (0 is screen)
 * drawable2 	= 	unused
 * op 		= 	unused
 * x1, y1 	=	starting position in pixmap
 * x2, y2 	= 	unused
 * w,  h  	=	size of area to move
 * mask		=	planes to use
 * image  	=	where to store data
 */
#define GRFIOCSETMAP	_IOR('G', 64, struct grf_bitblt) /* Put buffer into pixmap */
/*Use	:
 *				
 * drawable1 	= 	source pixmap (0 is screen)
 * drawable2 	= 	unused
 * op 		= 	unused
 * x1, y1 	=	starting position in pixmap
 * x2, y2 	= 	unused
 * w,  h  	=	size of area to move
 * mask		=	planes to use
 * image  	=	where to read data
 */


------------------------------------------------------------------------------