static char *rcsid_put_c
= "$Header: put.c,v 10.3 86/11/29 13:48:41 jg Rel $";
* The Sun X drivers are a product of Sun Microsystems, Inc. and are provided
* for unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify these drivers without charge, but are not authorized
* to license or distribute them to anyone else except as part of a product or
* program developed by the user.
* THE SUN X DRIVERS ARE PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND
* INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A
* PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE
* The Sun X Drivers are provided with no support and without any obligation
* on the part of Sun Microsystems, Inc. to assist in their use, correction,
* modification or enhancement.
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THE SUN X
* DRIVERS OR ANY PART THEREOF.
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
* Mountain View, California 94043
static char sccsid
[] = "@(#)put.c 2.1 86/01/28 Copyright 1986 Sun Micro";
* Copyright (c) 1986 by Sun Microsystems, Inc.
/* put.c Perform a raster operation with a source bitmap
* PixmapPut Puts a pixmap up on the screen
* PixmapBitsPut Puts a pixmap up on the screen
* BitmapBitsPut Puts a pixmap up on the screen
* XYColorPixmap putting & bitsputting
extern struct pixrect
*PixRect
;
PixmapPut (src
, srcx
, srcy
, width
, height
, dstx
, dsty
, clips
, clipcount
,
int srcx
, srcy
, width
, height
, dstx
, dsty
, clipcount
, zmask
;
int op
= SUN_FROM_X_OP(func
);
SetZmask(PixRect
, &zmask
);
BITMAP
*bm
= (BITMAP
*) src
->data
;
Src
= mem_point(bm
->width
, bm
->height
, 1, bm
->data
);
int cleft
, ctop
, cwidth
, cheight
;
GetNextClip(clips
, cleft
, ctop
, cwidth
, cheight
);
if (OverLap(cleft
, ctop
, cwidth
, cheight
, dstx
, dsty
, width
, height
)) {
int tleft
= (cleft
> dstx
? cleft
: dstx
);
int ttop
= (ctop
> dsty
? ctop
: dsty
);
int twidth
= (cleft
+ cwidth
< dstx
+ width
? cleft
+ cwidth
: dstx
+ width
) - tleft
;
int theight
= (ctop
+ cheight
< dsty
+ height
? ctop
+ cheight
: dsty
+ height
) - ttop
;
int sx
= (tleft
- dstx
) + srcx
;
int sy
= (ttop
- dsty
) + srcy
;
CheckCursor(tleft
, ttop
, twidth
, theight
);
CheckCursor(sx
, sy
, twidth
, theight
);
op
= SUN_FROM_X_OP_INVERT(func
);
pr_rop(PixRect
, tleft
, ttop
, twidth
, theight
, op
| PIX_DONTCLIP
, Src
, sx
, sy
);
} while (--clipcount
> 0);
/* spread constant from (dstx,dsty) by (width,height) */
int cleft
, ctop
, cwidth
, cheight
;
GetNextClip(clips
, cleft
, ctop
, cwidth
, cheight
);
if (OverLap(cleft
, ctop
, cwidth
, cheight
, dstx
, dsty
, width
, height
)) {
int tleft
= (cleft
> dstx
? cleft
: dstx
);
int ttop
= (ctop
> dsty
? ctop
: dsty
);
int twidth
= (cleft
+ cwidth
< dstx
+ width
? cleft
+ cwidth
: dstx
+ width
) - tleft
;
int theight
= (ctop
+ cheight
< dsty
+ height
? ctop
+ cheight
: dsty
+ height
) - ttop
;
CheckCursor(tleft
, ttop
, twidth
, theight
);
/* XXX - is this the right tile mode? */
pr_rop(PixRect
, tleft
, ttop
, twidth
, theight
, PIX_SRC
| PIX_COLOR(PINVERT(src
) ^ (int) src
->data
), NULL
, 0, 0);
} while (--clipcount
> 0);
Src
= mem_point(src
->width
, src
->height
, PixRect
->pr_depth
, src
->data
);
int cleft
, ctop
, cwidth
, cheight
;
GetNextClip(clips
, cleft
, ctop
, cwidth
, cheight
);
if (OverLap(cleft
, ctop
, cwidth
, cheight
, dstx
, dsty
, width
, height
)) {
int tleft
= (cleft
> dstx
? cleft
: dstx
);
int ttop
= (ctop
> dsty
? ctop
: dsty
);
int twidth
= (cleft
+ cwidth
< dstx
+ width
? cleft
+ cwidth
: dstx
+ width
) - tleft
;
int theight
= (ctop
+ cheight
< dsty
+ height
? ctop
+ cheight
: dsty
+ height
) - ttop
;
int sx
= (tleft
- dstx
) + srcx
;
int sy
= (ttop
- dsty
) + srcy
;
CheckCursor(tleft
, ttop
, twidth
, theight
);
CheckCursor(sx
, sy
, twidth
, theight
);
pr_rop(PixRect
, tleft
, ttop
, twidth
, theight
, op
| PIX_DONTCLIP
, Src
, sx
, sy
);
} while (--clipcount
> 0);
/* XXX - not yet implemented - do a plane at a time */
SetZmask(PixRect
, &allmask
);
PixmapBitsPut (width
, height
, format
, data
, xymask
, dstx
, dsty
,
clips
, clipcount
, func
, zmask
)
int width
, height
, format
, dstx
, dsty
, clipcount
, zmask
;
if (PixRect
->pr_depth
== 1)
BitsPut(width
, height
, data
, 1, 0, xymask
, dstx
, dsty
,
clips
, clipcount
, func
, zmask
, 1);
else if (PixRect
->pr_depth
<= 8)
register char *old
= data
, *new;
new = newdata
= (char *) Xalloc((width
+1)*height
);
for (i
= 0; i
< height
; i
++) {
BitsPut(width
, height
, newdata
, 1, 0, xymask
, dstx
, dsty
,
clips
, clipcount
, func
, zmask
, PixRect
->pr_depth
);
/* XXX - not yet supported - do one plane at a time */
BitmapBitsPut (width
, height
, data
, fore
, back
, xymask
, dstx
, dsty
,
clips
, clipcount
, func
, zmask
)
int width
, height
, fore
, back
, dstx
, dsty
, clipcount
, zmask
;
InvertPixelOrder((short *) data
, BitmapSize(width
, height
) >> 1);
BitsPut(width
, height
, data
, fore
, back
, xymask
, dstx
, dsty
,
clips
, clipcount
, func
, zmask
, 1);
BitsPut (width
, height
, data
, fore
, back
, xymask
, dstx
, dsty
,
clips
, clipcount
, func
, zmask
, srcdepth
)
int width
, height
, fore
, back
, dstx
, dsty
, clipcount
, zmask
;
if ((PixRect
->pr_depth
== 1) && !(zmask
& 1))
SetZmask(PixRect
, &zmask
);
op
= SUN_FROM_X_OP(func
);
Src
= mem_point(width
, height
, srcdepth
, data
);
int cleft
, ctop
, cwidth
, cheight
;
GetNextClip(clips
, cleft
, ctop
, cwidth
, cheight
);
if (OverLap(cleft
, ctop
, cwidth
, cheight
, dstx
, dsty
, width
, height
)) {
int tleft
= (cleft
> dstx
? cleft
: dstx
);
int ttop
= (ctop
> dsty
? ctop
: dsty
);
int twidth
= (cleft
+ cwidth
< dstx
+ width
? cleft
+ cwidth
: dstx
+ width
) - tleft
;
int theight
= (ctop
+ cheight
< dsty
+ height
? ctop
+ cheight
: dsty
+ height
) - ttop
;
CheckCursor(cleft
, ctop
, cwidth
, cheight
);
pr_rop(PixRect
, tleft
, ttop
, twidth
, theight
, op
| PIX_DONTCLIP
, Src
, sx
, sy
);
} while (--clipcount
> 0);
stencil
= mem_point(xymask
->width
, xymask
->height
, 1, xymask
->data
);
int cleft
, ctop
, cwidth
, cheight
;
GetNextClip(clips
, cleft
, ctop
, cwidth
, cheight
);
if (OverLap(cleft
, ctop
, cwidth
, cheight
, dstx
, dsty
, width
, height
)) {
CheckCursor(cleft
, ctop
, cwidth
, cheight
);
pr_stencil(PixRect
, dstx
, dsty
, width
, height
, op
,
stencil
, 0, 0, Src
, 0, 0);
} while (--clipcount
> 0);
SetZmask(PixRect
, &allmask
);