Annotation of 43BSDTahoe/new/X/libibm/bitblt/bitblt_aed.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char *rcsid_bitblt_aed_c = "$Header: bitblt_aed.c,v 10.1 86/11/19 10:50:45 jg Exp $";
        !             3: #endif lint
        !             4: /* aed.c - AED display dependent routines
        !             5:  *
        !             6:  *     aed_echo_rect           Echos rectangular areas of shared memory to AED
        !             7:  *     aed_screen_copy         Does screen to screen copy
        !             8:  *     aed_draw_line           Draws lines directly on screen
        !             9:  *     UnionOfRects            Finds the union of two rectangles
        !            10:  *     AreaOfRect      `       Computes the area of a rectangle
        !            11:  *
        !            12:  *     Author:
        !            13:  *             Scott Bates
        !            14:  *             Brown University
        !            15:  *             IRIS, Box 1946
        !            16:  *             Providence, RI 02912
        !            17:  *
        !            18:  *
        !            19:  *             Copyright (c) 1986 Brown University
        !            20:  *
        !            21:  * Permission to use, copy, modify and distribute this software and its
        !            22:  * documentation for any purpose and without fee is hereby granted, provided
        !            23:  * that the above copyright notice appear in all copies, and that both
        !            24:  * that copyright notice and this permission notice appear in supporting
        !            25:  * documentation, and that the name of Brown University not be used in
        !            26:  * advertising or publicity pertaining to distribution of the software 
        !            27:  * without specific, written prior permission. Brown University makes no
        !            28:  * representations about the suitability of this software for any purpose.
        !            29:  * It is provided "as-is" without express or implied warranty.
        !            30:  */
        !            31: 
        !            32: #include "bitblt_int.h"
        !            33: #include "bitblt_aed.h"
        !            34: 
        !            35: /*
        !            36:  * Build echo rect command and place it on
        !            37:  * on command queue
        !            38:  */
        !            39: 
        !            40: aed_echo_rect(new_area)
        !            41:        register Blt_Rectangle *new_area;
        !            42: {
        !            43:         register i;
        !            44:         Blt_Rectangle merge_area;
        !            45:        register struct aed_cmd *cmd_queue = &AED_CMDQ[0];
        !            46: 
        !            47:         AED_CMDQ_SEMA = 1;
        !            48: 
        !            49:        for (i = AED_CMDQ_INDEX - 1; i >= 0; i--) {
        !            50:            if (cmd_queue[i].cmd == AED_ECHO_RECT) {
        !            51:                 UnionOfRects(new_area,(Blt_Rectangle *)&cmd_queue[i].ECHO_RECT,
        !            52:                             &merge_area);
        !            53:                 if (AreaOfRect(&merge_area) <= (AreaOfRect(new_area) +
        !            54:                    AreaOfRect((Blt_Rectangle *) &cmd_queue[i].ECHO_RECT)) * 2)
        !            55:                {
        !            56:                        cmd_queue[i].ECHO_RECT = 
        !            57:                                *((struct aed_echo_rect *) &merge_area);
        !            58:                                goto reset_sema;
        !            59:                 }
        !            60:            } else {
        !            61:                break;
        !            62:            }
        !            63:         }
        !            64: 
        !            65:         while (AED_CMDQ_INDEX == AED_MAX_CMDS) {
        !            66:                AED_CMDQ_SEMA = 0;
        !            67:         }
        !            68:         AED_CMDQ_SEMA = 1;
        !            69: 
        !            70:        cmd_queue[AED_CMDQ_INDEX].cmd = AED_ECHO_RECT;
        !            71:        cmd_queue[AED_CMDQ_INDEX].ECHO_RECT =
        !            72:                        *((struct aed_echo_rect *) new_area);
        !            73:        AED_CMDQ_INDEX++;
        !            74: 
        !            75: reset_sema:
        !            76:         AED_CMDQ_SEMA = 0;
        !            77: }
        !            78: 
        !            79: /*
        !            80:  * Build screen to screen copy command and 
        !            81:  * place it on command queue
        !            82:  */
        !            83: 
        !            84: aed_screen_copy(from_x, from_y, to_x, to_y, width, height, rule)
        !            85:        short from_x, from_y, to_x, to_y, width, height, rule;
        !            86: {
        !            87:        register struct aed_cmd *cmd_queue = &AED_CMDQ[0];
        !            88:        register struct aed_screen_copy *cmd;
        !            89:        register i;
        !            90: 
        !            91:        if (AED_CMDQ_INDEX != 0) {
        !            92:                for (i = 0; i < AED_CMDQ_INDEX; i++) {
        !            93:                        if (cmd_queue[i].cmd == AED_ECHO_RECT) {
        !            94:                                while (AED_CMDQ_INDEX != 0);
        !            95:                                break;
        !            96:                        }
        !            97:                }
        !            98:                while (AED_CMDQ_INDEX == AED_MAX_CMDS);
        !            99:        }
        !           100: 
        !           101:        AED_CMDQ_SEMA = 1;
        !           102: 
        !           103:        cmd_queue[AED_CMDQ_INDEX].cmd = AED_SCREEN_COPY;
        !           104:        cmd = &cmd_queue[AED_CMDQ_INDEX].SCREEN_COPY;
        !           105:        cmd->from_x = from_x;
        !           106:        cmd->from_y = from_y;
        !           107:        cmd->to_x = to_x;
        !           108:        cmd->to_y = to_y;
        !           109:        cmd->width = width;
        !           110:        cmd->height = height;
        !           111:        cmd->rule = AED_RULE(rule);
        !           112:        AED_CMDQ_INDEX++;
        !           113: 
        !           114:        AED_CMDQ_SEMA = 0;
        !           115: }
        !           116: 
        !           117: /*
        !           118:  * Build command to draw a line and place
        !           119:  * it on command queue
        !           120:  */
        !           121: 
        !           122: aed_draw_line(from_x, from_y, to_x, to_y, rule, width, color, pat, patlen, clip)
        !           123:        short from_x, from_y, to_x, to_y;
        !           124:        short rule, width, color;
        !           125:        u_short pat;
        !           126:        register short patlen;
        !           127:        Blt_Rectangle *clip;
        !           128: {
        !           129:        register struct aed_cmd *cmd_queue = &AED_CMDQ[0];
        !           130:        register struct aed_draw_line *cmd;
        !           131:        register u_short aed_pattern;
        !           132:        register i;
        !           133: 
        !           134:        if(patlen > 0 && patlen < 16) {
        !           135:                
        !           136:                /*
        !           137:                 * pattern must be left justified for AED microcode
        !           138:                 */
        !           139: 
        !           140:                aed_pattern = (pat <<= (16 - patlen));
        !           141: 
        !           142:                /*
        !           143:                 * make all patterns 16 bits long.
        !           144:                 * This is to get around microcode bug
        !           145:                 * (bug happens when pattern length < 16)
        !           146:                 */
        !           147: 
        !           148:                for(i = patlen; i < 16; i += patlen)
        !           149:                        pat |= (aed_pattern >> i);
        !           150:                patlen = 16;
        !           151:        }
        !           152: 
        !           153:        if (AED_CMDQ_INDEX != 0) {
        !           154:                for (i = 0; i < AED_CMDQ_INDEX; i++) {
        !           155:                        if (cmd_queue[i].cmd == AED_ECHO_RECT) {
        !           156:                                while (AED_CMDQ_INDEX != 0);
        !           157:                                break;
        !           158:                        }
        !           159:                }
        !           160:                while (AED_CMDQ_INDEX == AED_MAX_CMDS);
        !           161:        }
        !           162: 
        !           163:        AED_CMDQ_SEMA = 1;
        !           164: 
        !           165:        cmd_queue[AED_CMDQ_INDEX].cmd = AED_DRAW_LINE;
        !           166:        cmd = &cmd_queue[AED_CMDQ_INDEX].DRAW_LINE;
        !           167:        cmd->from_x = from_x;
        !           168:        cmd->from_y = from_y;
        !           169:        cmd->to_x = to_x;
        !           170:        cmd->to_y = to_y;
        !           171:        cmd->rule = AED_RULE(rule);
        !           172:        cmd->width = width;
        !           173:        cmd->color = color;
        !           174:        cmd->pat = pat;
        !           175:        cmd->patlen = patlen;
        !           176:        cmd->top = clip->origin_y;
        !           177:        cmd->left = clip->origin_x;
        !           178:        cmd->bottom = clip->corner_y - 1;
        !           179:        cmd->right = clip->corner_x - 1;
        !           180:        AED_CMDQ_INDEX++;
        !           181: 
        !           182:        AED_CMDQ_SEMA = 0;
        !           183: }
        !           184: 
        !           185: /*
        !           186:  * Find union to two rectangles
        !           187:  */
        !           188: 
        !           189: static
        !           190: UnionOfRects(rectA,rectB,dstrect)
        !           191:        register Blt_Rectangle *rectA, *rectB, *dstrect;
        !           192: {
        !           193:        if (rectA->origin_y >= rectA->corner_y ||
        !           194:            rectA->origin_x >= rectA->corner_x)
        !           195:                *dstrect = *rectB;
        !           196:        else if (rectB->origin_y >= rectB->corner_y ||
        !           197:            rectB->origin_x >= rectB->corner_x)
        !           198:                *dstrect = *rectA;
        !           199:        else {
        !           200:                dstrect->origin_y = MIN(rectA->origin_y, rectB->origin_y);
        !           201:                dstrect->corner_y = MAX(rectA->corner_y, rectB->corner_y);
        !           202:                dstrect->origin_x = MIN(rectA->origin_x, rectB->origin_x);
        !           203:                dstrect->corner_x = MAX(rectA->corner_x, rectB->corner_x);
        !           204:        }
        !           205: }
        !           206: 
        !           207: /*
        !           208:  * Compute area of a rectangle
        !           209:  */
        !           210: 
        !           211: static
        !           212: AreaOfRect(r)
        !           213:        register Blt_Rectangle *r;
        !           214: {
        !           215:         return ((r->corner_x - r->origin_x) * (r->corner_y - r->origin_y));
        !           216: }

unix.superglobalmegacorp.com

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