PageRenderTime 65ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/nx-3.5.0/nx-X11/programs/Xserver/afb/afbbresd.c

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