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
/
apa16Tile.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-12-30
|
7KB
|
247 lines
/***********************************************************
Copyright IBM Corporation 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,1991 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/apa16Tile.c,v 5.0 1991/12/30 19:22:51 jfc Exp $ */
/* $Source: /afs/athena.mit.edu/astaff/project/x11r5/src/athena/ibm/apa16/RCS/apa16Tile.c,v $ */
#ifndef lint
static char *rcsid = "$Id: apa16Tile.c,v 5.0 1991/12/30 19:22:51 jfc Exp $";
#endif
#include "X.h"
#include "windowstr.h"
#include "regionstr.h"
#include "pixmapstr.h"
#include "scrnintstr.h"
#include "OScompiler.h"
#include "mfb.h"
#include "maskbits.h"
#include "apa16Hdwr.h"
#include "ibmTrace.h"
/***====================================================================***/
/* This is globals so that other modules can invalidate off-screen
* scratch area
*/
unsigned int *apa16CurrentTileBits= NULL;
/* Store two adjacent copies of a 32 bit wide tile, so that the
routine which copies it onto the screen doesn't have to worry
about alignment. */
static void
apa16StageTile32( pTile )
PixmapPtr pTile;
{
register unsigned int *pDst;
register unsigned int *pSrc;
register int tileHeight;
TRACE(("apa16StageTile32( pTile= 0x%x )\n"));
pSrc = (unsigned int *)(pTile->devPrivate.ptr);
apa16CurrentTileBits= pSrc;
tileHeight = pTile->drawable.height;
pDst = (unsigned int *)SCREEN_ADDR(STAGE_X_OFFSET,STAGE_AREA_TOP);
QUEUE_WAIT();
while (tileHeight--) {
unsigned int tmp = *pSrc++;
pDst[0] = tmp;
pDst[1] = tmp;
pDst += APA16_WIDTH/32;
}
apa16replicateArea(STAGE_X_OFFSET, STAGE_AREA_TOP,
STAGE_WIDTH, STAGE_HEIGHT,
pTile->drawable.width,
pTile->drawable.height);
return;
}
/***====================================================================***/
/*
this code could be called by the paint window background stuff,
too; there would be some speed hit because of the different
parameters and the need to check for a rop when filling
with a tile.
the boxes are already translated.
NOTE:
iy = ++iy < tileHeight ? iy : 0
is equivalent to iy%= tileheight, and saves a division.
*/
/*
tile area with a 32 bit wide pixmap
*/
void
apa16TileArea32( pDraw, nbox, pbox, alu, ptile )
DrawablePtr pDraw;
int nbox;
register BoxPtr pbox;
int alu;
PixmapPtr ptile;
{
register unsigned int *psrc;
/* pointer to bits in tile, if needed */
unsigned short cmd;
int tileHeight; /* height of the tile */
int tileWidth; /* width of the tile */
int x;
int y;
int iy,ix; /* index of current scanline in tile */
int h1;
int w; /* width of current box */
int h; /* height of current box */
if ( !nbox )
return;
switch ( alu ) {
case GXclear: /* 0x0 Zero 0 */
case GXinvert: /* 0xa NOT dst */
case GXset: /* 0xf 1 */
apa16SolidFillArea( pDraw, nbox, pbox, alu, ptile );
case GXnoop: /* 0x5 dst */
return;
default:
break;
}
tileWidth = ptile->drawable.width;
if (pDraw->type != DRAWABLE_WINDOW)
{
mfbTileArea32(pDraw, nbox, pbox, alu, ptile);
return;
}
tileHeight = ptile->drawable.height;
psrc = (unsigned int *)(ptile->devPrivate.ptr);
for( ; nbox; pbox++, nbox--) {
x = pbox->x1;
w = pbox->x2 - x;
y = pbox->y1;
h = pbox->y2 - y;
if ( h > tileHeight || w > tileWidth ) { /* Special Iteration !! */
BoxRec tmpbox;
int currentHoriz, currentVert;
currentHoriz = MIN(w, tileWidth);
currentVert = MIN(h, tileHeight);
switch ( alu ) {
case GXcopy: /* 0x3 src */
case GXcopyInverted: /* 0xc NOT src */
/* Special Case Code */
/* Draw First Tile in place then blit-replicate
* until the entire box is filled
*/
tmpbox.x1 = x;
tmpbox.x2 = x + currentHoriz;
tmpbox.y1 = y;
tmpbox.y2 = y + currentVert;
apa16TileArea32(pDraw, 1, &tmpbox, alu, ptile);
apa16replicateArea(x, y, w, h,
currentHoriz, currentVert);
continue; /* There May Be Other Boxes ! */
/* Hard Cases Iterate over tile */
/* if possible for the easy cases use Hardware support */
case GXand: /* 0x1 src AND dst */
case GXnor: /* 0x8 NOT src AND NOT dst */
case GXandReverse: /* 0x2 src AND NOT dst */
case GXandInverted: /* 0x4 NOT src AND dst */
case GXequiv: /* 0x9 NOT src XOR dst */
case GXxor: /* 0x6 src XOR dst */
case GXor: /* 0x7 src OR dst */
case GXorInverted: /* 0xd NOT src OR dst */
case GXorReverse: /* 0xb src OR NOT dst */
case GXnand: /* 0xe NOT src OR NOT dst */
default:
ErrorF( "apa16TileArea: unexpected rrop" );
return;
}
/* Draw First Tile into the staging area ( off screen )
* then iterate-blit until entire box is filled
*/
}
/* One copy or less of source tile */
if (psrc != apa16CurrentTileBits)
apa16StageTile32(ptile);
iy = y % tileHeight;
ix = x % tileWidth;
h1 = MIN(tileHeight - iy, h);
RESERVE_QUEUE(14);
APA16_GET_CMD_COPY(ROP_RECT_COPY,alu,cmd);
cmd |= EXEC_MASK;
COPY_RECT_NOCHECK(cmd, x + w, y + h1,
APA16_STAGE_X + ix + w, APA16_STAGE_Y + iy + h1,
w, h1);
/* Copy lower part. */
if (h > h1)
{
COPY_RECT_NOCHECK(cmd, x + w, y + h,
APA16_STAGE_X + ix + w, APA16_STAGE_Y + h - h1,
w, h - h1);
}
}
return;
}