shpacked.c revision 05b261ec
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 43void 44shadowUpdatePacked (ScreenPtr pScreen, 45 shadowBufPtr pBuf) 46{ 47 RegionPtr damage = shadowDamage (pBuf); 48 PixmapPtr pShadow = pBuf->pPixmap; 49 int nbox = REGION_NUM_RECTS (damage); 50 BoxPtr pbox = REGION_RECTS (damage); 51 FbBits *shaBase, *shaLine, *sha; 52 FbStride shaStride; 53 int scrBase, scrLine, scr; 54 int shaBpp; 55 int shaXoff, shaYoff; /* XXX assumed to be zero */ 56 int x, y, w, h, width; 57 int i; 58 FbBits *winBase = NULL, *win; 59 CARD32 winSize; 60 61 fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); 62 while (nbox--) 63 { 64 x = pbox->x1 * shaBpp; 65 y = pbox->y1; 66 w = (pbox->x2 - pbox->x1) * shaBpp; 67 h = pbox->y2 - pbox->y1; 68 69 scrLine = (x >> FB_SHIFT); 70 shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); 71 72 x &= FB_MASK; 73 w = (w + x + FB_MASK) >> FB_SHIFT; 74 75 while (h--) 76 { 77 winSize = 0; 78 scrBase = 0; 79 width = w; 80 scr = scrLine; 81 sha = shaLine; 82 while (width) { 83 /* how much remains in this window */ 84 i = scrBase + winSize - scr; 85 if (i <= 0 || scr < scrBase) 86 { 87 winBase = (FbBits *) (*pBuf->window) (pScreen, 88 y, 89 scr * sizeof (FbBits), 90 SHADOW_WINDOW_WRITE, 91 &winSize, 92 pBuf->closure); 93 if(!winBase) 94 return; 95 scrBase = scr; 96 winSize /= sizeof (FbBits); 97 i = winSize; 98 } 99 win = winBase + (scr - scrBase); 100 if (i > width) 101 i = width; 102 width -= i; 103 scr += i; 104#define PickBit(a,i) (((a) >> (i)) & 1) 105 while (i--) 106 *win++ = *sha++; 107 } 108 shaLine += shaStride; 109 y++; 110 } 111 pbox++; 112 } 113} 114 115shadowUpdateProc shadowUpdatePackedWeak(void) { return shadowUpdatePacked; } 116