1706f2543Smrg/* 2706f2543Smrg * 3706f2543Smrg * Copyright © 2000 Keith Packard 4706f2543Smrg * 5706f2543Smrg * Permission to use, copy, modify, distribute, and sell this software and its 6706f2543Smrg * documentation for any purpose is hereby granted without fee, provided that 7706f2543Smrg * the above copyright notice appear in all copies and that both that 8706f2543Smrg * copyright notice and this permission notice appear in supporting 9706f2543Smrg * documentation, and that the name of Keith Packard not be used in 10706f2543Smrg * advertising or publicity pertaining to distribution of the software without 11706f2543Smrg * specific, written prior permission. Keith Packard makes no 12706f2543Smrg * representations about the suitability of this software for any purpose. It 13706f2543Smrg * is provided "as is" without express or implied warranty. 14706f2543Smrg * 15706f2543Smrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16706f2543Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 17706f2543Smrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18706f2543Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 19706f2543Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 20706f2543Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 21706f2543Smrg * PERFORMANCE OF THIS SOFTWARE. 22706f2543Smrg */ 23706f2543Smrg 24706f2543Smrg#ifdef HAVE_DIX_CONFIG_H 25706f2543Smrg#include <dix-config.h> 26706f2543Smrg#endif 27706f2543Smrg 28706f2543Smrg#include <stdlib.h> 29706f2543Smrg 30706f2543Smrg#include <X11/X.h> 31706f2543Smrg#include "scrnintstr.h" 32706f2543Smrg#include "windowstr.h" 33706f2543Smrg#include <X11/fonts/font.h> 34706f2543Smrg#include "dixfontstr.h" 35706f2543Smrg#include <X11/fonts/fontstruct.h> 36706f2543Smrg#include "mi.h" 37706f2543Smrg#include "regionstr.h" 38706f2543Smrg#include "globals.h" 39706f2543Smrg#include "gcstruct.h" 40706f2543Smrg#include "shadow.h" 41706f2543Smrg#include "fb.h" 42706f2543Smrg 43706f2543Smrg/* 44706f2543Smrg * 32 4-bit pixels per write 45706f2543Smrg */ 46706f2543Smrg 47706f2543Smrg#define PL_SHIFT 7 48706f2543Smrg#define PL_UNIT (1 << PL_SHIFT) 49706f2543Smrg#define PL_MASK (PL_UNIT - 1) 50706f2543Smrg 51706f2543Smrg/* 52706f2543Smrg * 32->8 conversion: 53706f2543Smrg * 54706f2543Smrg * 7 6 5 4 3 2 1 0 55706f2543Smrg * A B C D E F G H 56706f2543Smrg * 57706f2543Smrg * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 58706f2543Smrg * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 59706f2543Smrg * m . . . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A 60706f2543Smrg * m1 G . . . F . . . E . . . D . . . C . . . B . . . A . . . . . . . m << (7 - (p)) 61706f2543Smrg * m2 . H . . . G . . . F . . . E . . . D . . . C . . . B . . . A . . (m >> (p)) << 2 62706f2543Smrg * m3 G E C A m1 & 0x80808080 63706f2543Smrg * m4 H F D B m2 & 0x40404040 64706f2543Smrg * m5 G H E F C D A B m3 | m4 65706f2543Smrg * m6 G H E F C D G H A B E F m5 | (m5 >> 20) 66706f2543Smrg * m7 G H E F C D G H A B C D E F G H m6 | (m6 >> 10) 67706f2543Smrg */ 68706f2543Smrg 69706f2543Smrg#if 0 70706f2543Smrg#define GetBits(p,o,d) {\ 71706f2543Smrg m = sha[o]; \ 72706f2543Smrg m1 = m << (7 - (p)); \ 73706f2543Smrg m2 = (m >> (p)) << 2; \ 74706f2543Smrg m3 = m1 & 0x80808080; \ 75706f2543Smrg m4 = m2 & 0x40404040; \ 76706f2543Smrg m5 = m3 | m4; \ 77706f2543Smrg m6 = m5 | (m5 >> 20); \ 78706f2543Smrg d = m6 | (m6 >> 10); \ 79706f2543Smrg} 80706f2543Smrg#else 81706f2543Smrg#define GetBits(p,o,d) {\ 82706f2543Smrg m = sha[o]; \ 83706f2543Smrg m5 = ((m << (7 - (p))) & 0x80808080) | (((m >> (p)) << 2) & 0x40404040); \ 84706f2543Smrg m6 = m5 | (m5 >> 20); \ 85706f2543Smrg d = m6 | (m6 >> 10); \ 86706f2543Smrg} 87706f2543Smrg#endif 88706f2543Smrg 89706f2543Smrgvoid 90706f2543SmrgshadowUpdatePlanar4 (ScreenPtr pScreen, 91706f2543Smrg shadowBufPtr pBuf) 92706f2543Smrg{ 93706f2543Smrg RegionPtr damage = shadowDamage (pBuf); 94706f2543Smrg PixmapPtr pShadow = pBuf->pPixmap; 95706f2543Smrg int nbox = RegionNumRects (damage); 96706f2543Smrg BoxPtr pbox = RegionRects (damage); 97706f2543Smrg CARD32 *shaBase, *shaLine, *sha; 98706f2543Smrg FbStride shaStride; 99706f2543Smrg int scrBase, scrLine, scr; 100706f2543Smrg int shaBpp; 101706f2543Smrg int shaXoff, shaYoff; /* XXX assumed to be zero */ 102706f2543Smrg int x, y, w, h, width; 103706f2543Smrg int i; 104706f2543Smrg CARD32 *winBase = NULL, *win; 105706f2543Smrg CARD32 winSize; 106706f2543Smrg int plane; 107706f2543Smrg CARD32 m,m5,m6; 108706f2543Smrg CARD8 s1, s2, s3, s4; 109706f2543Smrg 110706f2543Smrg fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); 111706f2543Smrg while (nbox--) 112706f2543Smrg { 113706f2543Smrg x = (pbox->x1) * shaBpp; 114706f2543Smrg y = (pbox->y1); 115706f2543Smrg w = (pbox->x2 - pbox->x1) * shaBpp; 116706f2543Smrg h = pbox->y2 - pbox->y1; 117706f2543Smrg 118706f2543Smrg w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT; 119706f2543Smrg x &= ~PL_MASK; 120706f2543Smrg 121706f2543Smrg scrLine = (x >> PL_SHIFT); 122706f2543Smrg shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); 123706f2543Smrg 124706f2543Smrg while (h--) 125706f2543Smrg { 126706f2543Smrg for (plane = 0; plane < 4; plane++) 127706f2543Smrg { 128706f2543Smrg width = w; 129706f2543Smrg scr = scrLine; 130706f2543Smrg sha = shaLine; 131706f2543Smrg winSize = 0; 132706f2543Smrg scrBase = 0; 133706f2543Smrg while (width) { 134706f2543Smrg /* how much remains in this window */ 135706f2543Smrg i = scrBase + winSize - scr; 136706f2543Smrg if (i <= 0 || scr < scrBase) 137706f2543Smrg { 138706f2543Smrg winBase = (CARD32 *) (*pBuf->window) (pScreen, 139706f2543Smrg y, 140706f2543Smrg (scr << 4) | (plane), 141706f2543Smrg SHADOW_WINDOW_WRITE, 142706f2543Smrg &winSize, 143706f2543Smrg pBuf->closure); 144706f2543Smrg if(!winBase) 145706f2543Smrg return; 146706f2543Smrg winSize >>= 2; 147706f2543Smrg scrBase = scr; 148706f2543Smrg i = winSize; 149706f2543Smrg } 150706f2543Smrg win = winBase + (scr - scrBase); 151706f2543Smrg if (i > width) 152706f2543Smrg i = width; 153706f2543Smrg width -= i; 154706f2543Smrg scr += i; 155706f2543Smrg 156706f2543Smrg while (i--) 157706f2543Smrg { 158706f2543Smrg GetBits(plane,0,s1); 159706f2543Smrg GetBits(plane,1,s2); 160706f2543Smrg GetBits(plane,2,s3); 161706f2543Smrg GetBits(plane,3,s4); 162706f2543Smrg *win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24); 163706f2543Smrg sha += 4; 164706f2543Smrg } 165706f2543Smrg } 166706f2543Smrg } 167706f2543Smrg shaLine += shaStride; 168706f2543Smrg y++; 169706f2543Smrg } 170706f2543Smrg pbox++; 171706f2543Smrg } 172706f2543Smrg} 173706f2543Smrg 174706f2543SmrgshadowUpdateProc shadowUpdatePlanar4Weak(void) { 175706f2543Smrg return shadowUpdatePlanar4; 176706f2543Smrg} 177706f2543Smrg 178706f2543SmrgshadowUpdateProc shadowUpdatePlanar4x8Weak(void) { 179706f2543Smrg return shadowUpdatePlanar4x8; 180706f2543Smrg} 181