home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
x
/
xibm.zip
/
apa16
/
apa16PntA.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-12-30
|
10KB
|
329 lines
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/***********************************************************
Copyright IBM Corporation 1987,1988
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of IBM not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/***********************************************************
Copyright 1989 by the Massachusetts Institute of Technology
All rights reserved.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of the Massachusetts
Institute of Technology (M.I.T.) not be used in advertising or publicity
pertaining to distribution of the software without specific, written
prior permission.
M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
/* $Header: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/apa16/RCS/apa16PntA.c,v 5.0 1991/12/30 19:27:05 jfc Exp $ */
/* $Source: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/apa16/RCS/apa16PntA.c,v $ */
#ifndef lint
static char *rcsid = "$Header: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/apa16/RCS/apa16PntA.c,v 5.0 1991/12/30 19:27:05 jfc Exp $";
#endif
#include "X.h"
#include "windowstr.h"
#include "regionstr.h"
#include "pixmapstr.h"
#include "scrnintstr.h"
#include "gcstruct.h"
#include "mfb.h"
#include "maskbits.h"
#include "OScompiler.h"
#include "ibmTrace.h"
#include "apa16Hdwr.h"
/*
the solid fillers are called for rectangles and window backgrounds.
the boxes are already translated.
8/4/87 -- modified for RT/apa16 by erik
NOTE:
iy = ++iy < tileHeight ? iy : 0
is equivalent to iy%= tileheight, and saves a division.
*/
void
apa16SolidFillArea(pDraw, nbox, pbox, rrop, nop)
DrawablePtr pDraw;
int nbox;
BoxPtr pbox;
int rrop;
PixmapPtr nop;
{
if (rrop==RROP_NOP)
return;
if (pDraw->type != DRAWABLE_WINDOW)
{
if (rrop==RROP_BLACK)
mfbSolidBlackArea(pDraw,nbox,pbox,rrop,nop);
else if (rrop==RROP_WHITE)
mfbSolidWhiteArea(pDraw,nbox,pbox,rrop,nop);
else if (rrop==RROP_INVERT)
mfbSolidInvertArea(pDraw,nbox,pbox,rrop,nop);
return;
}
/* If the number of rectangles is less than the queue size, it
is only necessary to check the queue once. */
if (nbox * 5 < QUEUE_DANGER)
{
unsigned short cmd;
RESERVE_QUEUE(nbox * 5);
APA16_GET_CMD_FILL(rrop,cmd);
cmd |= EXEC_MASK;
while (nbox--)
{
register int w,h;
w = pbox->x2 - pbox->x1;
h = pbox->y2 - pbox->y1;
if (w > 0 && h > 0)
{
FILL_RECT_NOCHECK(cmd,pbox->x2,pbox->y2,w,h);
}
pbox++;
}
}
else
{
unsigned short cmd;
/* This contains an upper bound for the queue length:
it is initialized to the queue size and incremented every
time something is added to the queue. */
int queue_size = QUEUE_CNTR;
APA16_GET_CMD_FILL(rrop,cmd);
cmd |= EXEC_MASK;
while (nbox--)
{
register int w,h;
w = pbox->x2 - pbox->x1;
h = pbox->y2 - pbox->y1;
if (w > 0 && h > 0)
{
if (apa16Qoffset < 6)
{
/* Branch to top of queue. */
LOAD_QUEUE(QPTR_QUEUE_TOP,0);
apa16Qoffset= QUEUE_SIZE;
}
if (++queue_size >= QUEUE_DANGER)
queue_size = QUEUE_CNTR;
if (queue_size >= QUEUE_DANGER)
while (QUEUE_CNTR >= QUEUE_DANGER);
FILL_RECT_NOCHECK(cmd,pbox->x2,pbox->y2,w,h);
}
pbox++;
}
}
}
/* stipple a list of boxes
you can use the reduced rasterop for stipples. if rrop is
black, AND the destination with (not stipple pattern). if rrop is
white OR the destination with the stipple pattern. if rrop is invert,
XOR the destination with the stipple pattern.
*/
void
apa16StippleFillArea(pDraw, nbox, pbox, rrop, pstipple)
DrawablePtr pDraw;
int nbox;
BoxPtr pbox;
int rrop;
PixmapPtr pstipple;
{
register unsigned int *psrc;
/* pointer to bits in tile, if needed */
int tileHeight; /* height of the tile */
register unsigned int srcpix;
int w; /* width of current box */
register int h; /* height of current box */
int startmask;
int endmask; /* masks for reggedy bits at either end of line */
int nlwMiddle; /* number of longwords between sides of boxes */
register int nlwExtra;
/* to get from right of box to left of next span */
register int nlw; /* loop version of nlwMiddle */
register unsigned int *p; /* pointer to bits we're writing */
int iy; /* index of current scanline in tile */
if (pDraw->type != DRAWABLE_WINDOW)
{
if (rrop==RROP_WHITE)
mfbStippleWhiteArea(pDraw, nbox, pbox, rrop, pstipple);
else if (rrop==RROP_BLACK)
mfbStippleBlackArea(pDraw, nbox, pbox, rrop, pstipple);
else if (rrop==RROP_INVERT)
mfbStippleInvertArea(pDraw, nbox, pbox, rrop, pstipple);
return;
}
if (rrop == RROP_BLACK) { SET_MERGE_MODE(MERGE_BLACK); }
else if (rrop == RROP_WHITE) { SET_MERGE_MODE(MERGE_WHITE); }
else if (rrop == RROP_INVERT) { SET_MERGE_MODE(MERGE_INVERT); }
else if (rrop == RROP_NOP) return;
else {
ErrorF("Unexpected rrop %d in apa16StippleFillArea\n",rrop);
return;
}
tileHeight = pstipple->drawable.height;
psrc = (unsigned int *)(pstipple->devPrivate.ptr);
while (nbox--)
{
w = pbox->x2 - pbox->x1;
h = pbox->y2 - pbox->y1;
iy = pbox->y1 % tileHeight;
p = (unsigned int *)APA16_BASE + (pbox->y1 * (APA16_WIDTH / 32)) + (pbox->x1 >> 5);
if ( ((pbox->x1 & 0x1f) + w) < 32)
{
maskpartialbits(pbox->x1, w, startmask);
while (h--)
{
srcpix = psrc[iy];
if (++iy >= tileHeight)
iy = 0;
*p = (srcpix & startmask);
p += APA16_WIDTH / 32;
}
}
else
{
maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
nlwExtra = APA16_WIDTH / 32 - nlwMiddle;
if (startmask && endmask)
{
nlwExtra -= 1;
while (h--)
{
srcpix = psrc[iy];
if (++iy >= tileHeight)
iy = 0;
nlw = nlwMiddle;
*p = (srcpix & startmask);
p++;
Duff (nlw, *p++ = srcpix);
*p = (srcpix & endmask);
p += nlwExtra;
}
}
else if (startmask && !endmask)
{
nlwExtra -= 1;
while (h--)
{
srcpix = psrc[iy];
if (++iy >= tileHeight)
iy = 0;
nlw = nlwMiddle;
*p = (srcpix & startmask);
p++;
Duff (nlw, *p++ = srcpix);
p += nlwExtra;
}
}
else if (!startmask && endmask)
{
while (h--)
{
srcpix = psrc[iy];
if (++iy >= tileHeight)
iy = 0;
nlw = nlwMiddle;
Duff(nlw, *p++ = srcpix);
*p = (srcpix & endmask);
p += nlwExtra;
}
}
else /* no ragged bits at either end */
{
while (h--)
{
srcpix = psrc[iy];
if (++iy >= tileHeight)
iy = 0;
nlw = nlwMiddle;
Duff(nlw, *p++ = srcpix);
p += nlwExtra;
}
}
}
pbox++;
}
SET_MERGE_MODE(MERGE_COPY);
}