PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/nx-3.5.0/nx-X11/programs/Xserver/mfb/mfbbresd.c

#
C | 209 lines | 153 code | 6 blank | 50 comment | 50 complexity | bd1c30e25e188451d42f361bf862c46a MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0, LGPL-2.0
  1. /* $XFree86: xc/programs/Xserver/mfb/mfbbresd.c,v 1.4 2001/01/17 22:37:02 dawes Exp $ */
  2. /***********************************************************
  3. Copyright 1987, 1998 The Open Group
  4. Permission to use, copy, modify, distribute, and sell this software and its
  5. documentation for any purpose is hereby granted without fee, provided that
  6. the above copyright notice appear in all copies and that both that
  7. copyright notice and this permission notice appear in supporting
  8. documentation.
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  15. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. Except as contained in this notice, the name of The Open Group shall not be
  18. used in advertising or otherwise to promote the sale, use or other dealings
  19. in this Software without prior written authorization from The Open Group.
  20. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  21. All Rights Reserved
  22. Permission to use, copy, modify, and distribute this software and its
  23. documentation for any purpose and without fee is hereby granted,
  24. provided that the above copyright notice appear in all copies and that
  25. both that copyright notice and this permission notice appear in
  26. supporting documentation, and that the name of Digital not be
  27. used in advertising or publicity pertaining to distribution of the
  28. software without specific, written prior permission.
  29. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  30. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  31. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  32. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  33. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  34. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  35. SOFTWARE.
  36. ******************************************************************/
  37. /* $Xorg: mfbbresd.c,v 1.4 2001/02/09 02:05:18 xorgcvs Exp $ */
  38. #ifdef HAVE_DIX_CONFIG_H
  39. #include <dix-config.h>
  40. #endif
  41. #include <X11/X.h>
  42. #include "misc.h"
  43. #include "mfb.h"
  44. #include "maskbits.h"
  45. #include "miline.h"
  46. /* Dashed bresenham line */
  47. #define StepDash\
  48. if (!--dashRemaining) { \
  49. if (++ dashIndex == numInDashList) \
  50. dashIndex = 0; \
  51. dashRemaining = pDash[dashIndex]; \
  52. rop = fgrop; \
  53. if (dashIndex & 1) \
  54. rop = bgrop; \
  55. }
  56. void
  57. mfbBresD(fgrop, bgrop,
  58. pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash,
  59. addrlbase, nlwidth,
  60. signdx, signdy, axis, x1, y1, e, e1, e2, len)
  61. int fgrop, bgrop;
  62. int *pdashIndex; /* current dash */
  63. unsigned char *pDash; /* dash list */
  64. int numInDashList; /* total length of dash list */
  65. int *pdashOffset; /* offset into current dash */
  66. int isDoubleDash;
  67. PixelType *addrlbase; /* pointer to base of bitmap */
  68. int nlwidth; /* width in longwords of bitmap */
  69. int signdx, signdy; /* signs of directions */
  70. int axis; /* major axis (Y_AXIS or X_AXIS) */
  71. int x1, y1; /* initial point */
  72. register int e; /* error accumulator */
  73. register int e1; /* bresenham increments */
  74. int e2;
  75. int len; /* length of line */
  76. {
  77. register int yinc; /* increment to next scanline, in bytes */
  78. register PixelType *addrl;
  79. register int e3 = e2-e1;
  80. register MfbBits bit;
  81. PixelType leftbit = mask[0]; /* leftmost bit to process in new word */
  82. PixelType rightbit = mask[PPW-1]; /* rightmost bit to process in new word */
  83. int dashIndex;
  84. int dashOffset;
  85. int dashRemaining;
  86. int rop;
  87. dashOffset = *pdashOffset;
  88. dashIndex = *pdashIndex;
  89. dashRemaining = pDash[dashIndex] - dashOffset;
  90. rop = fgrop;
  91. if (!isDoubleDash)
  92. bgrop = -1;
  93. if (dashIndex & 1)
  94. rop = bgrop;
  95. /* point to longword containing first point */
  96. addrl = mfbScanline(addrlbase, x1, y1, nlwidth);
  97. yinc = signdy * nlwidth;
  98. e = e-e1; /* to make looping easier */
  99. bit = mask[x1 & PIM];
  100. if (axis == X_AXIS)
  101. {
  102. if (signdx > 0)
  103. {
  104. while(len--)
  105. {
  106. if (rop == RROP_BLACK)
  107. *addrl &= ~bit;
  108. else if (rop == RROP_WHITE)
  109. *addrl |= bit;
  110. else if (rop == RROP_INVERT)
  111. *addrl ^= bit;
  112. e += e1;
  113. if (e >= 0)
  114. {
  115. mfbScanlineInc(addrl, yinc);
  116. e += e3;
  117. }
  118. bit = SCRRIGHT(bit,1);
  119. if (!bit) { bit = leftbit;addrl ++; }
  120. StepDash
  121. }
  122. }
  123. else
  124. {
  125. while(len--)
  126. {
  127. if (rop == RROP_BLACK)
  128. *addrl &= ~bit;
  129. else if (rop == RROP_WHITE)
  130. *addrl |= bit;
  131. else if (rop == RROP_INVERT)
  132. *addrl ^= bit;
  133. e += e1;
  134. if (e >= 0)
  135. {
  136. mfbScanlineInc(addrl, yinc);
  137. e += e3;
  138. }
  139. bit = SCRLEFT(bit,1);
  140. if (!bit) { bit = rightbit;addrl --; }
  141. StepDash
  142. }
  143. }
  144. } /* if X_AXIS */
  145. else
  146. {
  147. if (signdx > 0)
  148. {
  149. while(len--)
  150. {
  151. if (rop == RROP_BLACK)
  152. *addrl &= ~bit;
  153. else if (rop == RROP_WHITE)
  154. *addrl |= bit;
  155. else if (rop == RROP_INVERT)
  156. *addrl ^= bit;
  157. e += e1;
  158. if (e >= 0)
  159. {
  160. bit = SCRRIGHT(bit,1);
  161. if (!bit) { bit = leftbit;addrl ++; }
  162. e += e3;
  163. }
  164. mfbScanlineInc(addrl, yinc);
  165. StepDash
  166. }
  167. }
  168. else
  169. {
  170. while(len--)
  171. {
  172. if (rop == RROP_BLACK)
  173. *addrl &= ~bit;
  174. else if (rop == RROP_WHITE)
  175. *addrl |= bit;
  176. else if (rop == RROP_INVERT)
  177. *addrl ^= bit;
  178. e += e1;
  179. if (e >= 0)
  180. {
  181. bit = SCRLEFT(bit,1);
  182. if (!bit) { bit = rightbit;addrl --; }
  183. e += e3;
  184. }
  185. mfbScanlineInc(addrl, yinc);
  186. StepDash
  187. }
  188. }
  189. } /* else Y_AXIS */
  190. *pdashIndex = dashIndex;
  191. *pdashOffset = pDash[dashIndex] - dashRemaining;
  192. }