fbfillsp.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. *
  3. * Copyright © 1998 Keith Packard
  4. *
  5. * Permission to use, copy, modify, distribute, and sell this software and its
  6. * documentation for any purpose is hereby granted without fee, provided that
  7. * the above copyright notice appear in all copies and that both that
  8. * copyright notice and this permission notice appear in supporting
  9. * documentation, and that the name of Keith Packard not be used in
  10. * advertising or publicity pertaining to distribution of the software without
  11. * specific, written prior permission. Keith Packard makes no
  12. * representations about the suitability of this software for any purpose. It
  13. * is provided "as is" without express or implied warranty.
  14. *
  15. * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  16. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  17. * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  18. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  19. * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  20. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  21. * PERFORMANCE OF THIS SOFTWARE.
  22. */
  23. #ifdef HAVE_DIX_CONFIG_H
  24. #include <dix-config.h>
  25. #endif
  26. #include "fb.h"
  27. void
  28. fbFillSpans(DrawablePtr pDrawable,
  29. GCPtr pGC, int n, DDXPointPtr ppt, int *pwidth, int fSorted)
  30. {
  31. RegionPtr pClip = fbGetCompositeClip(pGC);
  32. BoxPtr pextent, pbox;
  33. int nbox;
  34. int extentX1, extentX2, extentY1, extentY2;
  35. int fullX1, fullX2, fullY1;
  36. int partX1, partX2;
  37. pextent = REGION_EXTENTS(pClip);
  38. extentX1 = pextent->x1;
  39. extentY1 = pextent->y1;
  40. extentX2 = pextent->x2;
  41. extentY2 = pextent->y2;
  42. while (n--) {
  43. fullX1 = ppt->x;
  44. fullY1 = ppt->y;
  45. fullX2 = fullX1 + (int) *pwidth;
  46. ppt++;
  47. pwidth++;
  48. if (fullY1 < extentY1 || extentY2 <= fullY1)
  49. continue;
  50. if (fullX1 < extentX1)
  51. fullX1 = extentX1;
  52. if (fullX2 > extentX2)
  53. fullX2 = extentX2;
  54. if (fullX1 >= fullX2)
  55. continue;
  56. nbox = REGION_NUM_RECTS(pClip);
  57. if (nbox == 1) {
  58. fbFill(pDrawable, pGC, fullX1, fullY1, fullX2 - fullX1, 1);
  59. }
  60. else {
  61. pbox = REGION_RECTS(pClip);
  62. while (nbox--) {
  63. if (pbox->y1 <= fullY1 && fullY1 < pbox->y2) {
  64. partX1 = pbox->x1;
  65. if (partX1 < fullX1)
  66. partX1 = fullX1;
  67. partX2 = pbox->x2;
  68. if (partX2 > fullX2)
  69. partX2 = fullX2;
  70. if (partX2 > partX1) {
  71. fbFill(pDrawable, pGC,
  72. partX1, fullY1, partX2 - partX1, 1);
  73. }
  74. }
  75. pbox++;
  76. }
  77. }
  78. }
  79. }