shplanar8.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 4305b261ecSmrg/* 4405b261ecSmrg * Expose 8bpp depth 4 4505b261ecSmrg */ 4605b261ecSmrg 4705b261ecSmrg/* 4805b261ecSmrg * 32->8 conversion: 4905b261ecSmrg * 5005b261ecSmrg * 7 6 5 4 3 2 1 0 5105b261ecSmrg * A B C D E F G H 5205b261ecSmrg * 5305b261ecSmrg * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 5405b261ecSmrg * 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 5505b261ecSmrg * m1 D x x x x x x x C x x x x x x x B x x x x x x x A x x x x x x x sha[0] << (7-(p)) 5605b261ecSmrg * m2 x x x x H x x x x x x x G x x x x x x x F x x x x x x x E x x x sha[1] << (3-(p)) 5705b261ecSmrg * m3 D C B A m1 & 0x80808080 5805b261ecSmrg * m4 H G F E m2 & 0x08080808 5905b261ecSmrg * m5 D H C G B F A E m3 | m4 6005b261ecSmrg * m6 D H C G B F m5 >> 9 6105b261ecSmrg * m7 D H C D G H B C F G A B E F m5 | m6 6205b261ecSmrg * m8 D H C D G H m7 >> 18 6305b261ecSmrg * m9 D H C D G H B C D F G H A B C D E F G H m7 | m8 6405b261ecSmrg */ 6505b261ecSmrg 6605b261ecSmrg#define PL_SHIFT 8 6705b261ecSmrg#define PL_UNIT (1 << PL_SHIFT) 6805b261ecSmrg#define PL_MASK (PL_UNIT - 1) 6905b261ecSmrg 7005b261ecSmrg#if 0 7105b261ecSmrg#define GetBits(p,o,d) { \ 7205b261ecSmrg CARD32 m1,m2,m3,m4,m5,m6,m7,m8; \ 7305b261ecSmrg m1 = sha[o] << (7 - (p)); \ 7405b261ecSmrg m2 = sha[(o)+1] << (3 - (p)); \ 7505b261ecSmrg m3 = m1 & 0x80808080; \ 7605b261ecSmrg m4 = m2 & 0x08080808; \ 7705b261ecSmrg m5 = m3 | m4; \ 7805b261ecSmrg m6 = m5 >> 9; \ 7905b261ecSmrg m7 = m5 | m6; \ 8005b261ecSmrg m8 = m7 >> 18; \ 8105b261ecSmrg d = m7 | m8; \ 8205b261ecSmrg} 8305b261ecSmrg#else 8405b261ecSmrg#define GetBits(p,o,d) { \ 8505b261ecSmrg CARD32 m5,m7; \ 8605b261ecSmrg m5 = ((sha[o] << (7 - (p))) & 0x80808080) | ((sha[(o)+1] << (3 - (p))) & 0x08080808); \ 8705b261ecSmrg m7 = m5 | (m5 >> 9); \ 8805b261ecSmrg d = m7 | (m7 >> 18); \ 8905b261ecSmrg} 9005b261ecSmrg#endif 9105b261ecSmrg 9205b261ecSmrgvoid 9305b261ecSmrgshadowUpdatePlanar4x8 (ScreenPtr pScreen, 9405b261ecSmrg shadowBufPtr pBuf) 9505b261ecSmrg{ 9605b261ecSmrg RegionPtr damage = shadowDamage (pBuf); 9705b261ecSmrg PixmapPtr pShadow = pBuf->pPixmap; 9805b261ecSmrg int nbox = REGION_NUM_RECTS (damage); 9905b261ecSmrg BoxPtr pbox = REGION_RECTS (damage); 10005b261ecSmrg CARD32 *shaBase, *shaLine, *sha; 10105b261ecSmrg CARD8 s1, s2, s3, s4; 10205b261ecSmrg FbStride shaStride; 10305b261ecSmrg int scrBase, scrLine, scr; 10405b261ecSmrg int shaBpp; 10505b261ecSmrg int shaXoff, shaYoff; /* XXX assumed to be zero */ 10605b261ecSmrg int x, y, w, h, width; 10705b261ecSmrg int i; 10805b261ecSmrg CARD32 *winBase = NULL, *win; 10905b261ecSmrg CARD32 winSize; 11005b261ecSmrg int plane; 11105b261ecSmrg 11205b261ecSmrg fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); 11305b261ecSmrg while (nbox--) 11405b261ecSmrg { 11505b261ecSmrg x = pbox->x1 * shaBpp; 11605b261ecSmrg y = pbox->y1; 11705b261ecSmrg w = (pbox->x2 - pbox->x1) * shaBpp; 11805b261ecSmrg h = pbox->y2 - pbox->y1; 11905b261ecSmrg 12005b261ecSmrg w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT; 12105b261ecSmrg x &= ~PL_MASK; 12205b261ecSmrg 12305b261ecSmrg scrLine = (x >> PL_SHIFT); 12405b261ecSmrg shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); 12505b261ecSmrg 12605b261ecSmrg while (h--) 12705b261ecSmrg { 12805b261ecSmrg for (plane = 0; plane < 4; plane++) 12905b261ecSmrg { 13005b261ecSmrg width = w; 13105b261ecSmrg scr = scrLine; 13205b261ecSmrg sha = shaLine; 13305b261ecSmrg winSize = 0; 13405b261ecSmrg scrBase = 0; 13505b261ecSmrg while (width) { 13605b261ecSmrg /* how much remains in this window */ 13705b261ecSmrg i = scrBase + winSize - scr; 13805b261ecSmrg if (i <= 0 || scr < scrBase) 13905b261ecSmrg { 14005b261ecSmrg winBase = (CARD32 *) (*pBuf->window) (pScreen, 14105b261ecSmrg y, 14205b261ecSmrg (scr << 4) | (plane), 14305b261ecSmrg SHADOW_WINDOW_WRITE, 14405b261ecSmrg &winSize, 14505b261ecSmrg pBuf->closure); 14605b261ecSmrg if(!winBase) 14705b261ecSmrg return; 14805b261ecSmrg winSize >>= 2; 14905b261ecSmrg scrBase = scr; 15005b261ecSmrg i = winSize; 15105b261ecSmrg } 15205b261ecSmrg win = winBase + (scr - scrBase); 15305b261ecSmrg if (i > width) 15405b261ecSmrg i = width; 15505b261ecSmrg width -= i; 15605b261ecSmrg scr += i; 15705b261ecSmrg 15805b261ecSmrg while (i--) 15905b261ecSmrg { 16005b261ecSmrg GetBits(plane,0,s1); 16105b261ecSmrg GetBits(plane,2,s2); 16205b261ecSmrg GetBits(plane,4,s3); 16305b261ecSmrg GetBits(plane,6,s4); 16405b261ecSmrg *win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24); 16505b261ecSmrg sha += 8; 16605b261ecSmrg } 16705b261ecSmrg } 16805b261ecSmrg } 16905b261ecSmrg shaLine += shaStride; 17005b261ecSmrg y++; 17105b261ecSmrg } 17205b261ecSmrg pbox++; 17305b261ecSmrg } 17405b261ecSmrg} 17505b261ecSmrg 176