1: #ifndef lint
   2: static char *rcsid_draw_c = "$Header: draw.c,v 10.2 86/02/01 16:20:44 tony Rel $";
   3: #endif	lint
   4: #ifdef  sun
   5: /*
   6:  * The Sun X drivers are a product of Sun Microsystems, Inc. and are provided
   7:  * for unrestricted use provided that this legend is included on all tape
   8:  * media and as a part of the software program in whole or part.  Users
   9:  * may copy or modify these drivers without charge, but are not authorized
  10:  * to license or distribute them to anyone else except as part of a product or
  11:  * program developed by the user.
  12:  *
  13:  * THE SUN X DRIVERS ARE PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND
  14:  * INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A
  15:  * PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE
  16:  * PRACTICE.
  17:  *
  18:  * The Sun X Drivers are provided with no support and without any obligation
  19:  * on the part of Sun Microsystems, Inc. to assist in their use, correction,
  20:  * modification or enhancement.
  21:  *
  22:  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  23:  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THE SUN X
  24:  * DRIVERS OR ANY PART THEREOF.
  25:  *
  26:  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  27:  * or profits or other special, indirect and consequential damages, even if
  28:  * Sun has been advised of the possibility of such damages.
  29:  *
  30:  * Sun Microsystems, Inc.
  31:  * 2550 Garcia Avenue
  32:  * Mountain View, California  94043
  33:  */
  34: 
  35: #ifndef lint
  36: static char sccsid[] = "@(#)draw.c 2.2 86/01/29 Copyright 1986 Sun Micro";
  37: #endif
  38: 
  39: /*-
  40:  * Copyright (c) 1986 by Sun Microsystems,  Inc.
  41:  */
  42: 
  43: /* draw.c	Draw lines, curves, and polygons on the screen
  44:  *
  45:  *	DrawCurve	Draw a generalized line/polygon/combination
  46:  *
  47:  */
  48: 
  49: /*
  50:  *	ToDo:
  51:  *		Brush shapes
  52:  *		Dash/Pattern
  53:  *		Curves
  54:  */
  55: 
  56: #include "Xsun.h"
  57: 
  58: extern struct pixrect *PixRect;
  59: 
  60: static
  61: Draw_Solid(srcpix, xbase, ybase, op, vertcount, verts, clipcount, clips, zmask)
  62:     int srcpix; /* Pixel value to write */
  63:     int xbase, ybase;   /* Origin of curve */
  64:     int op;     /* Opcode */
  65:     int vertcount;  /* Length of Vertex array */
  66:     Vertex *verts;  /* Vertices */
  67:     int clipcount;  /* Length of clip array */
  68:     CLIP *clips;    /* clipping rectangles */
  69:     int zmask;
  70: {
  71:     int allmask = -1;
  72: 
  73:     SetZmask(PixRect, &zmask);
  74:     do {
  75:     struct pixrect *region;
  76:     int         cleft, ctop, cwidth, cheight;
  77:     register int xp, yp;
  78:     register Vertex *v = verts;
  79:     register int vc = vertcount;
  80: 
  81:     GetNextClip(clips, cleft, ctop, cwidth, cheight);
  82:     CheckCursor(cleft, ctop, cwidth, cheight);
  83:     do {
  84:         register    xo = xp, yo = yp;
  85: 
  86:         if (v->flags & VertexRelative) {
  87:         xp += v->x;
  88:         yp += v->y;
  89:         }
  90:         else {
  91:         xp = v->x + xbase;
  92:         yp = v->y + ybase;
  93:         }
  94:         /* XXX - ignore VertexCurved for now */
  95:         /* XXX - ignore VertexDrawLastPoint for now */
  96:         if (!(v->flags & VertexDontDraw)) {
  97:         register int xmin, ymin, xsize, ysize;
  98: 
  99:         xmin = imin(xo, xp);
 100:         ymin = imin(yo, yp),
 101:             xsize = imax(xo, xp) - imin(xo, xp) + 1;
 102:         ysize = imax(yo, yp) - imin(yo, yp) + 1;
 103:         if (OverLap(xmin, ymin, xsize, ysize, cleft, ctop, cwidth, cheight)) {
 104:             /* Its at least partly visible */
 105:             if (xmin < cleft || ymin < ctop
 106:             || (xmin + xsize) > (cleft + cwidth)
 107:             || (ymin + ysize) > (ctop + cheight)) {
 108:             /* Its clipped - we lose */
 109:             region = pr_region(PixRect, cleft, ctop, cwidth, cheight);  /* XXX - slow!!! */
 110:             pr_vector(region, xo - cleft, yo - ctop, xp - cleft, yp - ctop, op, srcpix);
 111:             pr_destroy(region);
 112:             }
 113:             else {
 114:             /* It isnt clipped */
 115:             pr_vector(PixRect, xo, yo, xp, yp, op, srcpix);
 116:             }
 117:         }
 118:         }
 119:         v++;
 120:     } while (--vc > 0);
 121:     } while (--clipcount > 0);
 122:     RestoreCursor();
 123:     SetZmask(PixRect, &allmask);
 124: }
 125: 
 126: DrawCurve (verts, vertcount, xbase, ybase, srcpix, altpix, mode,
 127:        bwidth, bheight, pat, patlen, patmul, clips, clipcount, func, zmask)
 128:     Vertex *verts;
 129:     int vertcount, xbase, ybase, srcpix, altpix, mode, bwidth, bheight;
 130:     int pat, patlen, patmul, clipcount, zmask;
 131:     register int func;
 132:     CLIP *clips;
 133: {
 134:     int op = SUN_FROM_X_OP(func);
 135:     if (bwidth == 1 && bheight == 1)
 136:     switch (mode) {
 137:         /* XXX - ignores dash/pattern for now */
 138:     case DrawSolidLine:
 139:         Draw_Solid(srcpix, xbase, ybase, op,
 140:                vertcount, verts, clipcount, clips, zmask);
 141:         break;
 142:     case DrawDashedLine:
 143:         Draw_Solid(srcpix, xbase, ybase, op,
 144:                vertcount, verts, clipcount, clips, zmask);
 145:         break;
 146:     case DrawPatternedLine:
 147:         Draw_Solid(srcpix, xbase, ybase, op,
 148:                vertcount, verts, clipcount, clips, zmask);
 149:         break;
 150:     }
 151:     else
 152:     switch (mode) {
 153:         /* XXX - ignores brush specification for now */
 154:     case DrawSolidLine:
 155:         Draw_Solid(srcpix, xbase, ybase, op,
 156:                vertcount, verts, clipcount, clips, zmask);
 157:         break;
 158:     case DrawDashedLine:
 159:         Draw_Solid(srcpix, xbase, ybase, op,
 160:                vertcount, verts, clipcount, clips, zmask);
 161:         break;
 162:     case DrawPatternedLine:
 163:         Draw_Solid(srcpix, xbase, ybase, op,
 164:                vertcount, verts, clipcount, clips, zmask);
 165:         break;
 166:     }
 167: }
 168: #endif	sun

Defined functions

DrawCurve defined in line 126; never used
Draw_Solid defined in line 60; used 6 times

Defined variables

rcsid_draw_c defined in line 2; never used
sccsid defined in line 36; never used
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 952
Valid CSS Valid XHTML 1.0 Strict