shpacked.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. *
  3. * Copyright © 2000 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 <stdlib.h>
  27. #include <X11/X.h>
  28. #include "scrnintstr.h"
  29. #include "windowstr.h"
  30. #include <X11/fonts/font.h>
  31. #include "dixfontstr.h"
  32. #include <X11/fonts/fontstruct.h>
  33. #include "mi.h"
  34. #include "regionstr.h"
  35. #include "globals.h"
  36. #include "gcstruct.h"
  37. #include "shadow.h"
  38. #include "fb.h"
  39. void
  40. shadowUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf)
  41. {
  42. RegionPtr damage = shadowDamage(pBuf);
  43. PixmapPtr pShadow = pBuf->pPixmap;
  44. int nbox = REGION_NUM_RECTS(damage);
  45. BoxPtr pbox = REGION_RECTS(damage);
  46. FbBits *shaBase, *shaLine, *sha;
  47. FbStride shaStride;
  48. int scrBase, scrLine, scr;
  49. int shaBpp;
  50. int shaXoff _X_UNUSED, shaYoff _X_UNUSED; /* XXX assumed to be zero */
  51. int x, y, w, h, width;
  52. int i;
  53. FbBits *winBase = NULL, *win;
  54. CARD32 winSize;
  55. fbGetDrawable(&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff,
  56. shaYoff);
  57. while (nbox--) {
  58. x = pbox->x1 * shaBpp;
  59. y = pbox->y1;
  60. w = (pbox->x2 - pbox->x1) * shaBpp;
  61. h = pbox->y2 - pbox->y1;
  62. scrLine = (x >> FB_SHIFT);
  63. shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
  64. x &= FB_MASK;
  65. w = (w + x + FB_MASK) >> FB_SHIFT;
  66. while (h--) {
  67. winSize = 0;
  68. scrBase = 0;
  69. width = w;
  70. scr = scrLine;
  71. sha = shaLine;
  72. while (width) {
  73. /* how much remains in this window */
  74. i = scrBase + winSize - scr;
  75. if (i <= 0 || scr < scrBase) {
  76. winBase = (FbBits *) (*pBuf->window) (pScreen,
  77. y,
  78. scr * sizeof(FbBits),
  79. SHADOW_WINDOW_WRITE,
  80. &winSize,
  81. pBuf->closure);
  82. if (!winBase)
  83. return;
  84. scrBase = scr;
  85. winSize /= sizeof(FbBits);
  86. i = winSize;
  87. }
  88. win = winBase + (scr - scrBase);
  89. if (i > width)
  90. i = width;
  91. width -= i;
  92. scr += i;
  93. while (i--)
  94. *win++ = *sha++;
  95. }
  96. shaLine += shaStride;
  97. y++;
  98. }
  99. pbox++;
  100. }
  101. }
  102. shadowUpdateProc
  103. shadowUpdatePackedWeak(void)
  104. {
  105. return shadowUpdatePacked;
  106. }