45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Copyright © 2004 Philip Blundell
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Permission to use, copy, modify, distribute, and sell this software and its
45e9809aff7304721fddb95654901b32195c9c7avboxsync * documentation for any purpose is hereby granted without fee, provided that
45e9809aff7304721fddb95654901b32195c9c7avboxsync * the above copyright notice appear in all copies and that both that
45e9809aff7304721fddb95654901b32195c9c7avboxsync * copyright notice and this permission notice appear in supporting
45e9809aff7304721fddb95654901b32195c9c7avboxsync * documentation, and that the name of Philip Blundell not be used in
45e9809aff7304721fddb95654901b32195c9c7avboxsync * advertising or publicity pertaining to distribution of the software without
45e9809aff7304721fddb95654901b32195c9c7avboxsync * specific, written prior permission. Philip Blundell makes no
45e9809aff7304721fddb95654901b32195c9c7avboxsync * representations about the suitability of this software for any purpose. It
45e9809aff7304721fddb95654901b32195c9c7avboxsync * is provided "as is" without express or implied warranty.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * PHILIP BLUNDELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
45e9809aff7304721fddb95654901b32195c9c7avboxsync * EVENT SHALL PHILIP BLUNDELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
45e9809aff7304721fddb95654901b32195c9c7avboxsync * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
45e9809aff7304721fddb95654901b32195c9c7avboxsync * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
45e9809aff7304721fddb95654901b32195c9c7avboxsync * PERFORMANCE OF THIS SOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <X11/X.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "scrnintstr.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "windowstr.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "dixfontstr.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "mi.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "regionstr.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "globals.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "gcstruct.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "shadow.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "fb.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#if ROTATE == 270
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define WINSTEPX(stride) (stride)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define WINSTART(x,y) (((pScreen->height - 1) - y) + (x * winStride))
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define WINSTEPY() -1
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#elif ROTATE == 90
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define WINSTEPX(stride) (-stride)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define WINSTEPY() 1
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define WINSTART(x,y) (((pScreen->width - 1 - x) * winStride) + y)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#else
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#error This rotation is not supported here
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifdef __arm__
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define PREFETCH
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncvoid
45e9809aff7304721fddb95654901b32195c9c7avboxsyncFUNC (ScreenPtr pScreen,
45e9809aff7304721fddb95654901b32195c9c7avboxsync shadowBufPtr pBuf);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncvoid
45e9809aff7304721fddb95654901b32195c9c7avboxsyncFUNC (ScreenPtr pScreen,
45e9809aff7304721fddb95654901b32195c9c7avboxsync shadowBufPtr pBuf)
45e9809aff7304721fddb95654901b32195c9c7avboxsync{
45e9809aff7304721fddb95654901b32195c9c7avboxsync RegionPtr damage = shadowDamage(pBuf);
45e9809aff7304721fddb95654901b32195c9c7avboxsync PixmapPtr pShadow = pBuf->pPixmap;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int nbox = REGION_NUM_RECTS (damage);
45e9809aff7304721fddb95654901b32195c9c7avboxsync BoxPtr pbox = REGION_RECTS (damage);
45e9809aff7304721fddb95654901b32195c9c7avboxsync FbBits *shaBits;
45e9809aff7304721fddb95654901b32195c9c7avboxsync Data *shaBase, *shaLine, *sha;
45e9809aff7304721fddb95654901b32195c9c7avboxsync FbStride shaStride, winStride;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int shaBpp;
45e9809aff7304721fddb95654901b32195c9c7avboxsync int shaXoff, shaYoff; /* XXX assumed to be zero */
45e9809aff7304721fddb95654901b32195c9c7avboxsync int x, y, w, h;
45e9809aff7304721fddb95654901b32195c9c7avboxsync Data *winBase, *win, *winLine;
45e9809aff7304721fddb95654901b32195c9c7avboxsync CARD32 winSize;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp, shaXoff, shaYoff);
45e9809aff7304721fddb95654901b32195c9c7avboxsync shaBase = (Data *) shaBits;
45e9809aff7304721fddb95654901b32195c9c7avboxsync shaStride = shaStride * sizeof (FbBits) / sizeof (Data);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync winBase = (Data *) (*pBuf->window) (pScreen, 0, 0,
45e9809aff7304721fddb95654901b32195c9c7avboxsync SHADOW_WINDOW_WRITE,
45e9809aff7304721fddb95654901b32195c9c7avboxsync &winSize, pBuf->closure);
45e9809aff7304721fddb95654901b32195c9c7avboxsync winStride = (Data *) (*pBuf->window) (pScreen, 1, 0,
45e9809aff7304721fddb95654901b32195c9c7avboxsync SHADOW_WINDOW_WRITE,
45e9809aff7304721fddb95654901b32195c9c7avboxsync &winSize, pBuf->closure) - winBase;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync while (nbox--)
45e9809aff7304721fddb95654901b32195c9c7avboxsync {
45e9809aff7304721fddb95654901b32195c9c7avboxsync x = pbox->x1;
45e9809aff7304721fddb95654901b32195c9c7avboxsync y = pbox->y1;
45e9809aff7304721fddb95654901b32195c9c7avboxsync w = (pbox->x2 - pbox->x1);
45e9809aff7304721fddb95654901b32195c9c7avboxsync h = pbox->y2 - pbox->y1;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync shaLine = shaBase + (y * shaStride) + x;
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifdef PREFETCH
45e9809aff7304721fddb95654901b32195c9c7avboxsync __builtin_prefetch (shaLine);
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync winLine = winBase + WINSTART(x, y);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync while (h--)
45e9809aff7304721fddb95654901b32195c9c7avboxsync {
45e9809aff7304721fddb95654901b32195c9c7avboxsync sha = shaLine;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win = winLine;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync while (sha < (shaLine + w - 16))
45e9809aff7304721fddb95654901b32195c9c7avboxsync {
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifdef PREFETCH
45e9809aff7304721fddb95654901b32195c9c7avboxsync __builtin_prefetch (sha + shaStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync while (sha < (shaLine + w))
45e9809aff7304721fddb95654901b32195c9c7avboxsync {
45e9809aff7304721fddb95654901b32195c9c7avboxsync *win = *sha++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync win += WINSTEPX(winStride);
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync y++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync shaLine += shaStride;
45e9809aff7304721fddb95654901b32195c9c7avboxsync winLine += WINSTEPY();
45e9809aff7304721fddb95654901b32195c9c7avboxsync }
45e9809aff7304721fddb95654901b32195c9c7avboxsync pbox++;
45e9809aff7304721fddb95654901b32195c9c7avboxsync } /* nbox */
45e9809aff7304721fddb95654901b32195c9c7avboxsync}