shpacked.c revision 05b261ec
105b261ecSmrg/*
205b261ecSmrg *
305b261ecSmrg * Copyright © 2000 Keith Packard
405b261ecSmrg *
505b261ecSmrg * Permission to use, copy, modify, distribute, and sell this software and its
605b261ecSmrg * documentation for any purpose is hereby granted without fee, provided that
705b261ecSmrg * the above copyright notice appear in all copies and that both that
805b261ecSmrg * copyright notice and this permission notice appear in supporting
905b261ecSmrg * documentation, and that the name of Keith Packard not be used in
1005b261ecSmrg * advertising or publicity pertaining to distribution of the software without
1105b261ecSmrg * specific, written prior permission.  Keith Packard makes no
1205b261ecSmrg * representations about the suitability of this software for any purpose.  It
1305b261ecSmrg * is provided "as is" without express or implied warranty.
1405b261ecSmrg *
1505b261ecSmrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1605b261ecSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
1705b261ecSmrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1805b261ecSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
1905b261ecSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
2005b261ecSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2105b261ecSmrg * PERFORMANCE OF THIS SOFTWARE.
2205b261ecSmrg */
2305b261ecSmrg
2405b261ecSmrg#ifdef HAVE_DIX_CONFIG_H
2505b261ecSmrg#include <dix-config.h>
2605b261ecSmrg#endif
2705b261ecSmrg
2805b261ecSmrg#include <stdlib.h>
2905b261ecSmrg
3005b261ecSmrg#include    <X11/X.h>
3105b261ecSmrg#include    "scrnintstr.h"
3205b261ecSmrg#include    "windowstr.h"
3305b261ecSmrg#include    <X11/fonts/font.h>
3405b261ecSmrg#include    "dixfontstr.h"
3505b261ecSmrg#include    <X11/fonts/fontstruct.h>
3605b261ecSmrg#include    "mi.h"
3705b261ecSmrg#include    "regionstr.h"
3805b261ecSmrg#include    "globals.h"
3905b261ecSmrg#include    "gcstruct.h"
4005b261ecSmrg#include    "shadow.h"
4105b261ecSmrg#include    "fb.h"
4205b261ecSmrg
4305b261ecSmrgvoid
4405b261ecSmrgshadowUpdatePacked (ScreenPtr	    pScreen,
4505b261ecSmrg		    shadowBufPtr    pBuf)
4605b261ecSmrg{
4705b261ecSmrg    RegionPtr	damage = shadowDamage (pBuf);
4805b261ecSmrg    PixmapPtr	pShadow = pBuf->pPixmap;
4905b261ecSmrg    int		nbox = REGION_NUM_RECTS (damage);
5005b261ecSmrg    BoxPtr	pbox = REGION_RECTS (damage);
5105b261ecSmrg    FbBits	*shaBase, *shaLine, *sha;
5205b261ecSmrg    FbStride	shaStride;
5305b261ecSmrg    int		scrBase, scrLine, scr;
5405b261ecSmrg    int		shaBpp;
5505b261ecSmrg    int		shaXoff, shaYoff; /* XXX assumed to be zero */
5605b261ecSmrg    int		x, y, w, h, width;
5705b261ecSmrg    int         i;
5805b261ecSmrg    FbBits	*winBase = NULL, *win;
5905b261ecSmrg    CARD32      winSize;
6005b261ecSmrg
6105b261ecSmrg    fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff);
6205b261ecSmrg    while (nbox--)
6305b261ecSmrg    {
6405b261ecSmrg	x = pbox->x1 * shaBpp;
6505b261ecSmrg	y = pbox->y1;
6605b261ecSmrg	w = (pbox->x2 - pbox->x1) * shaBpp;
6705b261ecSmrg	h = pbox->y2 - pbox->y1;
6805b261ecSmrg
6905b261ecSmrg	scrLine = (x >> FB_SHIFT);
7005b261ecSmrg	shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
7105b261ecSmrg
7205b261ecSmrg	x &= FB_MASK;
7305b261ecSmrg	w = (w + x + FB_MASK) >> FB_SHIFT;
7405b261ecSmrg
7505b261ecSmrg	while (h--)
7605b261ecSmrg	{
7705b261ecSmrg	    winSize = 0;
7805b261ecSmrg	    scrBase = 0;
7905b261ecSmrg	    width = w;
8005b261ecSmrg	    scr = scrLine;
8105b261ecSmrg	    sha = shaLine;
8205b261ecSmrg	    while (width) {
8305b261ecSmrg		/* how much remains in this window */
8405b261ecSmrg		i = scrBase + winSize - scr;
8505b261ecSmrg		if (i <= 0 || scr < scrBase)
8605b261ecSmrg		{
8705b261ecSmrg		    winBase = (FbBits *) (*pBuf->window) (pScreen,
8805b261ecSmrg							  y,
8905b261ecSmrg							  scr * sizeof (FbBits),
9005b261ecSmrg							  SHADOW_WINDOW_WRITE,
9105b261ecSmrg							  &winSize,
9205b261ecSmrg							  pBuf->closure);
9305b261ecSmrg		    if(!winBase)
9405b261ecSmrg			return;
9505b261ecSmrg		    scrBase = scr;
9605b261ecSmrg		    winSize /= sizeof (FbBits);
9705b261ecSmrg		    i = winSize;
9805b261ecSmrg		}
9905b261ecSmrg		win = winBase + (scr - scrBase);
10005b261ecSmrg		if (i > width)
10105b261ecSmrg		    i = width;
10205b261ecSmrg		width -= i;
10305b261ecSmrg		scr += i;
10405b261ecSmrg#define PickBit(a,i)	(((a) >> (i)) & 1)
10505b261ecSmrg		while (i--)
10605b261ecSmrg		    *win++ = *sha++;
10705b261ecSmrg	    }
10805b261ecSmrg	    shaLine += shaStride;
10905b261ecSmrg	    y++;
11005b261ecSmrg	}
11105b261ecSmrg	pbox++;
11205b261ecSmrg    }
11305b261ecSmrg}
11405b261ecSmrg
11505b261ecSmrgshadowUpdateProc shadowUpdatePackedWeak(void) { return shadowUpdatePacked; }
116