fbsetsp.c 2.9 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. fbSetSpans(DrawablePtr pDrawable,
  29. GCPtr pGC,
  30. char *src, DDXPointPtr ppt, int *pwidth, int nspans, int fSorted)
  31. {
  32. FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
  33. RegionPtr pClip = fbGetCompositeClip(pGC);
  34. FbBits *dst, *d, *s;
  35. FbStride dstStride;
  36. int dstBpp;
  37. int dstXoff, dstYoff;
  38. BoxPtr pbox;
  39. int n;
  40. int xoff;
  41. int x1, x2;
  42. if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth)) {
  43. fb24_32SetSpans(pDrawable, pGC, src, ppt, pwidth, nspans, fSorted);
  44. return;
  45. }
  46. fbGetDrawable(pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
  47. while (nspans--) {
  48. d = dst + (ppt->y + dstYoff) * dstStride;
  49. xoff = (int) (((long) src) & (FB_MASK >> 3));
  50. s = (FbBits *) (src - xoff);
  51. xoff <<= 3;
  52. n = REGION_NUM_RECTS(pClip);
  53. pbox = REGION_RECTS(pClip);
  54. while (n--) {
  55. if (pbox->y1 > ppt->y)
  56. break;
  57. if (pbox->y2 > ppt->y) {
  58. x1 = ppt->x;
  59. x2 = x1 + *pwidth;
  60. if (pbox->x1 > x1)
  61. x1 = pbox->x1;
  62. if (pbox->x2 < x2)
  63. x2 = pbox->x2;
  64. if (x1 < x2)
  65. fbBlt((FbBits *) s,
  66. 0,
  67. (x1 - ppt->x) * dstBpp + xoff,
  68. d,
  69. dstStride,
  70. (x1 + dstXoff) * dstBpp,
  71. (x2 - x1) * dstBpp,
  72. 1, pGC->alu, pPriv->pm, dstBpp, FALSE, FALSE);
  73. }
  74. }
  75. src += PixmapBytePad(*pwidth, pDrawable->depth);
  76. ppt++;
  77. pwidth++;
  78. }
  79. fbValidateDrawable(pDrawable);
  80. }