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