#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#include "xf4bpp.h"
#include "OScompiler.h"
#include "ibmTrace.h"
static void
DrawFirstTile
(
WindowPtr pWin,
register PixmapPtr pTile,
register int x,
register int y,
int w,
int h,
int alu,
unsigned long int planes,
int xOffset,
int yOffset
)
{
register int htarget ;
register int vtarget ;
if ( xOffset ) {
if ( yOffset ) {
htarget = MIN( pTile->drawable.width - xOffset, w ),
vtarget = MIN( pTile->drawable.height - yOffset, h ),
yOffset *= pTile->devKind ;
xf4bppDrawColorImage( pWin,x, y,
htarget,
vtarget,
(unsigned char *)pTile->devPrivate.ptr + yOffset + xOffset,
pTile->devKind,
alu, planes ) ;
if ( w > htarget ) {
w = MIN( w, pTile->drawable.width ) ;
if ( h > vtarget ) {
h = MIN( h, pTile->drawable.height ) ;
xf4bppDrawColorImage( pWin, x, y + vtarget,
htarget,
h - vtarget,
(unsigned char *)pTile->devPrivate.ptr + xOffset,
pTile->devKind,
alu, planes ) ;
xf4bppDrawColorImage( pWin, x + htarget, y,
w - htarget,
vtarget,
(unsigned char *)pTile->devPrivate.ptr + yOffset,
pTile->devKind,
alu, planes ) ;
xf4bppDrawColorImage( pWin, x + htarget,
y + vtarget,
w - htarget,
h - vtarget,
pTile->devPrivate.ptr,
pTile->devKind,
alu, planes ) ;
}
else {
xf4bppDrawColorImage( pWin, x + htarget, y,
w - htarget,
vtarget,
(unsigned char *)pTile->devPrivate.ptr + yOffset,
pTile->devKind,
alu, planes ) ;
}
}
else if ( h > vtarget ) {
xf4bppDrawColorImage( pWin, x, y + vtarget,
htarget,
MIN( h, pTile->drawable.height ) - vtarget,
(unsigned char *)pTile->devPrivate.ptr + xOffset,
pTile->devKind,
alu, planes ) ;
vtarget = pTile->drawable.height ;
}
}
else {
xf4bppDrawColorImage( pWin, x, y,
htarget = MIN( pTile->drawable.width - xOffset, w ),
vtarget = MIN( pTile->drawable.height, h ),
(unsigned char *)pTile->devPrivate.ptr + xOffset,
pTile->devKind,
alu, planes ) ;
if ( w > htarget ) {
xf4bppDrawColorImage( pWin, x + htarget, y,
MIN( pTile->drawable.width, w ) - htarget,
vtarget,
pTile->devPrivate.ptr,
pTile->devKind,
alu, planes ) ;
}
}
}
else if ( yOffset ) {
xf4bppDrawColorImage( pWin, x, y,
htarget = MIN( pTile->drawable.width, w ),
vtarget = MIN( pTile->drawable.height - yOffset, h ),
(unsigned char *)pTile->devPrivate.ptr + ( yOffset * pTile->devKind ),
pTile->devKind,
alu, planes ) ;
if ( h > vtarget ) {
xf4bppDrawColorImage( pWin, x, y + vtarget,
htarget,
MIN( pTile->drawable.height, h ) - vtarget,
pTile->devPrivate.ptr,
pTile->devKind,
alu, planes ) ;
}
}
else {
xf4bppDrawColorImage( pWin, x, y,
htarget = MIN( pTile->drawable.width, w ),
vtarget = MIN( pTile->drawable.height, h ),
pTile->devPrivate.ptr,
pTile->devKind,
alu, planes ) ;
}
return ;
}
void
xf4bppTileRect( pWin, pTile, alu, planes, x0, y0, w, h, xSrc, ySrc )
WindowPtr pWin;
register PixmapPtr pTile ;
const int alu ;
const unsigned long int planes ;
register int x0, y0, w, h ;
int xSrc ;
int ySrc ;
{
int xOffset ;
int yOffset ;
int width, height;
TRACE( ( "xf4bppTileRect(pTile=x%x,alu=x%x,planes=x%02x,x0=%d,y0=%d,w=%d,h=%d,xSrc=%d,ySrc=%d\n",
pTile, alu, planes, x0, y0, w, h, xSrc, ySrc ) ) ;
switch ( alu ) {
case GXclear:
case GXinvert:
case GXset:
xf4bppFillSolid
( pWin, 0xFF, alu, planes, x0, y0, w, h ) ;
case GXnoop:
return ;
default:
break ;
}
width = pTile->drawable.width;
if ( ( xOffset = ( x0 - xSrc ) ) > 0 )
xOffset %= width ;
else
xOffset = width - (( - xOffset ) % width ) ;
if ( xOffset == width ) xOffset = 0;
height = pTile->drawable.height;
if ( ( yOffset = ( y0 - ySrc ) ) > 0 )
yOffset %= height ;
else
yOffset = height - (( - yOffset ) % height ) ;
if ( yOffset == height ) yOffset = 0;
switch ( alu ) {
case GXcopyInverted:
case GXcopy:
DrawFirstTile( pWin, pTile, x0, y0, w, h,
alu, planes, xOffset, yOffset ) ;
xf4bppReplicateArea( pWin, x0, y0, planes, w, h,
MIN( w, pTile->drawable.width ),
MIN( h, pTile->drawable.height ) ) ;
break ;
case GXnor:
case GXandReverse:
case GXorReverse:
case GXnand:
case GXandInverted:
case GXand:
case GXequiv:
case GXxor:
case GXorInverted:
case GXor:
default:
{
register unsigned char *data ;
register int hcount, vcount ;
int xcount, ycount;
int x1, y1;
int x2, y2;
int leftmgn, rightmgn, topmgn, botmgn;
int htarget, vtarget ;
data = pTile->devPrivate.ptr;
leftmgn = MIN( w, width - xOffset ) ;
x1 = x0 + leftmgn;
topmgn = MIN( h, height - yOffset ) ;
y1 = y0 + topmgn;
rightmgn = (w - leftmgn) % width;
hcount = (w - leftmgn) / width;
x2 = x0 + w - rightmgn;
botmgn = (h - topmgn) % height;
vcount = (h - topmgn) / height;
y2 = y0 + h - botmgn;
yOffset *= pTile->devKind;
if ( topmgn ) {
if ( leftmgn ) {
xf4bppDrawColorImage( pWin, x0, y0, leftmgn, topmgn,
data + yOffset + xOffset,
pTile->devKind, alu, planes ) ;
}
for ( xcount = hcount, htarget = x1;
xcount ;
xcount--, htarget += width )
{
xf4bppDrawColorImage( pWin, htarget, y0, width, topmgn,
data + yOffset,
pTile->devKind, alu, planes ) ;
}
if ( rightmgn ) {
xf4bppDrawColorImage( pWin, x2, y0, rightmgn, topmgn,
data + yOffset,
pTile->devKind, alu, planes ) ;
}
}
if ( botmgn ) {
if ( leftmgn ) {
xf4bppDrawColorImage( pWin, x0, y2, leftmgn, botmgn,
data + xOffset,
pTile->devKind, alu, planes ) ;
}
for ( xcount = hcount, htarget = x1;
xcount ;
xcount--, htarget += width )
{
xf4bppDrawColorImage( pWin, htarget, y2, width, botmgn,
data,
pTile->devKind, alu, planes ) ;
}
if ( rightmgn ) {
xf4bppDrawColorImage( pWin, x2, y2, rightmgn, botmgn,
data,
pTile->devKind, alu, planes ) ;
}
}
if ( leftmgn ) {
for ( ycount = vcount, vtarget = y1 ;
ycount ;
ycount--, vtarget += height )
{
xf4bppDrawColorImage( pWin, x0, vtarget, leftmgn, height,
data + xOffset,
pTile->devKind, alu, planes ) ;
}
}
if ( rightmgn ) {
for ( ycount = vcount, vtarget = y1 ;
ycount ;
ycount--, vtarget += height )
{
xf4bppDrawColorImage( pWin, x2, vtarget, rightmgn, height,
data,
pTile->devKind, alu, planes ) ;
}
}
for ( ycount = vcount, vtarget = y1 ;
ycount ;
ycount--, vtarget += height )
{
for ( xcount = hcount, htarget = x1 ;
xcount ;
xcount--, htarget += width )
{
xf4bppDrawColorImage( pWin, htarget, vtarget, width, height,
data,
pTile->devKind, alu, planes ) ;
}
}
} }
}