home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mi / miwideline.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-19  |  3.5 KB  |  130 lines

  1. /*
  2.  * $XConsortium: miwideline.h,v 1.7 90/11/19 15:16:41 keith Exp $
  3.  *
  4.  * Copyright 1988 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software and its
  7.  * documentation for any purpose and without fee is hereby granted, provided
  8.  * that the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * Author:  Keith Packard, MIT X Consortium
  17.  */
  18.  
  19. #include "mispans.h"
  20.  
  21. /* 
  22.  * interface data to span-merging polygon filler
  23.  */
  24.  
  25. typedef struct _SpanData {
  26.     SpanGroup    fgGroup, bgGroup;
  27. } SpanDataRec, *SpanDataPtr;
  28.  
  29. extern SpanDataPtr  miSetupSpanData ();
  30.  
  31. /*
  32.  * Polygon edge description for integer wide-line routines
  33.  */
  34.  
  35. typedef struct _PolyEdge {
  36.     int        height;    /* number of scanlines to process */
  37.     int        x;        /* starting x coordinate */
  38.     int        stepx;    /* fixed integral dx */
  39.     int        signdx;    /* variable dx sign */
  40.     int        e;        /* initial error term */
  41.     int        dy;
  42.     int        dx;
  43. } PolyEdgeRec, *PolyEdgePtr;
  44.  
  45. #define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - miter limit constant */
  46.  
  47. /*
  48.  * types for general polygon routines
  49.  */
  50.  
  51. typedef struct _PolyVertex {
  52.     double  x, y;
  53. } PolyVertexRec, *PolyVertexPtr;
  54.  
  55. typedef struct _PolySlope {
  56.     int        dx, dy;
  57.     double  k;        /* x0 * dy - y0 * dx */
  58. } PolySlopeRec, *PolySlopePtr;
  59.  
  60. /*
  61.  * Line face description for caps/joins
  62.  */
  63.  
  64. typedef struct _LineFace {
  65.     double  xa, ya;
  66.     int        dx, dy;
  67.     int        x, y;
  68.     double  k;
  69. } LineFaceRec, *LineFacePtr;
  70.  
  71. /*
  72.  * macros for polygon fillers
  73.  */
  74.  
  75. #define MIPOLYRELOADLEFT    if (!left_height && left_count) { \
  76.                             left_height = left->height; \
  77.                             left_x = left->x; \
  78.                             left_stepx = left->stepx; \
  79.                             left_signdx = left->signdx; \
  80.                             left_e = left->e; \
  81.                             left_dy = left->dy; \
  82.                             left_dx = left->dx; \
  83.                             --left_count; \
  84.                             ++left; \
  85.                 }
  86.  
  87. #define MIPOLYRELOADRIGHT   if (!right_height && right_count) { \
  88.                             right_height = right->height; \
  89.                             right_x = right->x; \
  90.                             right_stepx = right->stepx; \
  91.                             right_signdx = right->signdx; \
  92.                             right_e = right->e; \
  93.                             right_dy = right->dy; \
  94.                             right_dx = right->dx; \
  95.                             --right_count; \
  96.                             ++right; \
  97.             }
  98.  
  99. #define MIPOLYSTEPLEFT  left_x += left_stepx; \
  100.                         left_e += left_dx; \
  101.                         if (left_e > 0) \
  102.                         { \
  103.                         left_x += left_signdx; \
  104.                         left_e -= left_dy; \
  105.                         }
  106.  
  107. #define MIPOLYSTEPRIGHT right_x += right_stepx; \
  108.                         right_e += right_dx; \
  109.                         if (right_e > 0) \
  110.                         { \
  111.                         right_x += right_signdx; \
  112.                         right_e -= right_dy; \
  113.                         }
  114.  
  115. #ifdef NOINLINEICEIL
  116. #define ICEIL(x) ((int)ceil(x))
  117. #else
  118. #ifdef __GNUC__
  119. static __inline int ICEIL(x)
  120.     double x;
  121. {
  122.     int _cTmp = x;
  123.     return ((x == _cTmp) || (x < 0.0)) ? _cTmp : _cTmp+1;
  124. }
  125. #else
  126. #define ICEIL(x) ((((x) == (_cTmp = (x))) || ((x) < 0.0)) ? _cTmp : _cTmp+1)
  127. #define ICEILTEMPDECL static int _cTmp;
  128. #endif
  129. #endif
  130.