Annotation of 43BSDTahoe/new/X/libibm/libsrc/copybits.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char *rcsid_copybits_c = "$Header: copybits.c,v 10.1 86/11/19 10:40:50 jg Exp $";
                      3: #endif lint
                      4: /* copybits.c -  Interface routine to bitblt()
                      5:  *
                      6:  *     CopyBits        Places "X" supplied data into blt structure before
                      7:  *                     calling bitblt() ounce for each clipping rectangle
                      8:  *                     in the cliplist.
                      9:  *
                     10:  *     Author:
                     11:  *             Scott Bates
                     12:  *             Brown University
                     13:  *             IRIS, Box 1946
                     14:  *             Providence, RI 02912
                     15:  *
                     16:  *
                     17:  *             Copyright (c) 1986 Brown University
                     18:  *
                     19:  * Permission to use, copy, modify and distribute this software and its
                     20:  * documentation for any purpose and without fee is hereby granted, provided
                     21:  * that the above copyright notice appear in all copies, and that both
                     22:  * that copyright notice and this permission notice appear in supporting
                     23:  * documentation, and that the name of Brown University not be used in
                     24:  * advertising or publicity pertaining to distribution of the software
                     25:  * without specific, written prior permission. Brown University makes no
                     26:  * representations about the suitability of this software for any purpose.
                     27:  * It is provided "as-is" without express or implied warranty.
                     28:  */
                     29: 
                     30: #include "private.h"
                     31: #include "bitblt.h"
                     32: 
                     33: /*
                     34:  * General interface routine to bitblt()
                     35:  */
                     36: 
                     37: CopyBits (srcbits, srcwidth, srcheight, srcrect, dstbits, dstwidth,
                     38:          dstheight, dstrect, maskbits, maskwidth, maskheight, rule,
                     39:          clipcount, cliplist)
                     40:        u_short *srcbits, *dstbits, *maskbits;
                     41:        register Blt_Rectangle *srcrect, *dstrect;
                     42:        int srcwidth, srcheight, dstwidth;
                     43:        int maskwidth, maskheight;
                     44:        int dstheight, rule;
                     45:        register clipcount;
                     46:        register CLIP *cliplist;
                     47: {
                     48:        register Blt *blt = &bltdata;
                     49:        register Blt_Bitmap *dstbitmap = &blt->dst_bitmap;
                     50:        register Blt_Rectangle *cliprect = &blt->clp_rect;
                     51: 
                     52: #ifdef FULL_TRACE_X
                     53:        fprintf(stderr, "In CopyBits\n");
                     54:        fflush(stderr);
                     55: #endif FULL_TRACE_X
                     56: 
                     57:        /*
                     58:         * Clear blt structure
                     59:         */
                     60: 
                     61:        bzero((char *) blt, sizeof(Blt));
                     62: 
                     63: #ifdef AED
                     64:        /*
                     65:         * If this is the AED make sure this blt
                     66:         * gets echoed
                     67:         */
                     68: 
                     69:        blt->blt_flags |= BLT_ECHO;
                     70: #endif AED
                     71: 
                     72:        /*
                     73:         * Set up source bitmap or tile
                     74:         */
                     75: 
                     76:        if(IS_RULE_TILE(rule)) {
                     77:                /*
                     78:                 * Srcbits is a tile
                     79:                 */
                     80: 
                     81:                blt->tile_ptr = (Blt_Tile *)srcbits;
                     82:        } else  {
                     83:                register Blt_Bitmap *srcbitmap = &blt->src_bitmap;
                     84: 
                     85:                /*
                     86:                 * Srcbits is a bitimage. Convert bitimage to bitmap
                     87:                 */
                     88: 
                     89:                BitimageToBitmap(srcbits, 0, 0, srcwidth, srcheight, srcbitmap);
                     90: 
                     91:                /*
                     92:                 * Copy source rectangle to blt structure
                     93:                 */
                     94: 
                     95:                blt->src_rect = *srcrect;
                     96:        }
                     97: 
                     98:        /*
                     99:         * Convert destination bitimage to a bitmap
                    100:         */
                    101: 
                    102:        BitimageToBitmap(dstbits, 0, 0, dstwidth, dstheight, dstbitmap);
                    103: 
                    104:        /*
                    105:         * Copy destination rectangle to blt structure
                    106:         */
                    107: 
                    108:        blt->dst_rect = *dstrect;
                    109: 
                    110:        /*
                    111:         * Set combination rule in blt structure
                    112:         */
                    113: 
                    114:        blt->comb_rule = rule;
                    115: 
                    116:        /*
                    117:         * Is there a clipping mask ?
                    118:         */
                    119: 
                    120:        if(maskbits) {
                    121:                register Blt_Bitmap *mskbitmap = &blt->msk_bitmap;
                    122: 
                    123:                /*
                    124:                 * Indicate that there is a mask
                    125:                 */
                    126: 
                    127:                blt->blt_flags |= BLT_MASKON;
                    128: 
                    129:                /*
                    130:                 * Convert mask bitimage to bitmap
                    131:                 *
                    132:                 * NOTE: The clipping mask has the same origin
                    133:                 *       as the destination rectangle but can
                    134:                 *       be larger in width and height.
                    135:                 */
                    136: 
                    137:                BitimageToBitmap(maskbits, dstrect->origin_x, dstrect->origin_y,                                 maskwidth, maskheight, mskbitmap);
                    138:        }
                    139: 
                    140:        /*
                    141:         * No X clips specified ?
                    142:         */
                    143: 
                    144:        if(clipcount == 0) {
                    145:                 /*
                    146:                  * Turn clipping off during this blt
                    147:                  */
                    148: 
                    149:                 blt->blt_flags &= ~BLT_CLIPON;
                    150: 
                    151:                 /*
                    152:                  * No X clips so blt and run
                    153:                  */
                    154: 
                    155:                 bitblt(blt);
                    156:                 return;
                    157:         }
                    158: 
                    159: 
                    160:        /*
                    161:         * Perform same blt for each X clip
                    162:         */
                    163: 
                    164:        for (;;) {
                    165: 
                    166:                /*
                    167:                 * Convert X clip to clipping rectangle
                    168:                 */
                    169: 
                    170:                ClipToRect(cliplist, cliprect);
                    171: 
                    172:                /*
                    173:                 * If destination lies inside of clipping rectangle
                    174:                 * turn off clipping flag during this blt otherwise 
                    175:                 * turn it on.
                    176:                 */
                    177: 
                    178:                if(InsideBounds(dstrect, cliprect)) {
                    179:                        blt->blt_flags &= ~BLT_CLIPON;
                    180:                } else  {
                    181:                        blt->blt_flags |= BLT_CLIPON;
                    182:                }
                    183: 
                    184:                /*
                    185:                 * Lets go do the blt
                    186:                 */
                    187: 
                    188:                bitblt(blt);
                    189: 
                    190:                /*
                    191:                 * Need to blt again ?
                    192:                 */
                    193: 
                    194:                if (--clipcount <= 0) {
                    195:                        /*
                    196:                         * No more clips so lets leave
                    197:                         */
                    198: 
                    199:                        break;
                    200:                }
                    201: 
                    202:                /*
                    203:                 * point to next X clip
                    204:                 */
                    205: 
                    206:                cliplist++;
                    207:        }
                    208: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.