PageRenderTime 69ms CodeModel.GetById 38ms RepoModel.GetById 0ms app.codeStats 0ms

/nx-3.5.0/nx-X11/programs/Xserver/iplan2p4/iplbres.c

#
C | 186 lines | 120 code | 10 blank | 56 comment | 15 complexity | efce0a6138907f3d54fc01deb88217d8 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: iplbres.c,v 1.15 94/04/17 20:28:45 dpw Exp $ */
  39. /* Modified nov 94 by Martin Schaller (Martin_Schaller@maus.r.de) for use with
  40. interleaved planes */
  41. #ifdef HAVE_DIX_CONFIG_H
  42. #include <dix-config.h>
  43. #endif
  44. #include <X11/X.h>
  45. #include "misc.h"
  46. #include "ipl.h"
  47. #include "servermd.h"
  48. #include "miline.h"
  49. #include "iplmskbits.h"
  50. /* Solid bresenham line */
  51. /* NOTES
  52. e2 is used less often than e1, so it's not in a register
  53. */
  54. void
  55. iplBresS(rop, andp, xorp, addrg, ngwidth, signdx, signdy, axis, x1, y1, e, e1,
  56. e2, len)
  57. int rop;
  58. INTER_DECLARERRAX(andp);
  59. INTER_DECLARERRAX(xorp);
  60. INTER_DECLAREG(*addrg); /* pointer to base of bitmap */
  61. int ngwidth; /* width in longwords of bitmap */
  62. register int signdx;
  63. int signdy; /* signs of directions */
  64. int axis; /* major axis (Y_AXIS or X_AXIS) */
  65. int x1, y1; /* initial point */
  66. register int e; /* error accumulator */
  67. register int e1; /* bresenham increments */
  68. int e2;
  69. int len; /* length of line */
  70. {
  71. register int e3 = e2-e1;
  72. INTER_DECLAREG(bit);
  73. INTER_DECLAREG(leftbit);
  74. INTER_DECLAREG(rightbit);
  75. /* point to longword containing first point */
  76. addrg = addrg + y1 * ngwidth + (x1 >> INTER_PGSH) * INTER_PLANES;
  77. if (signdy < 0)
  78. ngwidth = -ngwidth;
  79. e = e-e1; /* to make looping easier */
  80. leftbit = iplmask[0];
  81. rightbit = iplmask[INTER_PPG-1];
  82. bit = iplmask[x1 & INTER_PIM];
  83. if (axis == X_AXIS)
  84. {
  85. if (signdx > 0)
  86. {
  87. while (len--)
  88. {
  89. INTER_DoMaskRRop(addrg, andp, xorp, bit, addrg);
  90. bit = bit >> 1;
  91. e += e1;
  92. if (e >= 0)
  93. {
  94. addrg += ngwidth;
  95. e += e3;
  96. }
  97. if (!bit)
  98. {
  99. bit = leftbit;
  100. addrg += INTER_PLANES;
  101. }
  102. }
  103. }
  104. else
  105. {
  106. while (len--)
  107. {
  108. INTER_DoMaskRRop(addrg, andp, xorp, bit, addrg);
  109. e += e1;
  110. bit = bit << 1;
  111. if (e >= 0)
  112. {
  113. addrg += ngwidth;
  114. e += e3;
  115. }
  116. if (!bit)
  117. {
  118. bit = rightbit;
  119. addrg -= INTER_PLANES;
  120. }
  121. }
  122. }
  123. } /* if X_AXIS */
  124. else
  125. {
  126. if (signdx > 0)
  127. {
  128. while(len--)
  129. {
  130. INTER_DoMaskRRop(addrg, andp, xorp, bit, addrg);
  131. e += e1;
  132. if (e >= 0)
  133. {
  134. bit = bit >> 1;
  135. if (!bit)
  136. {
  137. bit = leftbit;
  138. addrg += INTER_PLANES;
  139. }
  140. e += e3;
  141. }
  142. addrg += ngwidth;
  143. }
  144. }
  145. else
  146. {
  147. while(len--)
  148. {
  149. INTER_DoMaskRRop(addrg, andp, xorp, bit, addrg);
  150. e += e1;
  151. if (e >= 0)
  152. {
  153. bit = bit << 1;
  154. if (!bit)
  155. {
  156. bit = rightbit;
  157. addrg -= INTER_PLANES;
  158. }
  159. e += e3;
  160. }
  161. addrg += ngwidth;
  162. }
  163. }
  164. } /* else Y_AXIS */
  165. }