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