xserver

xserver with xephyr scale patch
git clone https://git.neptards.moe/u3shit/xserver.git
Log | Files | Refs | README | LICENSE

shplanar8.c (5918B)


      1 /*
      2  *
      3  * Copyright © 2000 Keith Packard
      4  *
      5  * Permission to use, copy, modify, distribute, and sell this software and its
      6  * documentation for any purpose is hereby granted without fee, provided that
      7  * the above copyright notice appear in all copies and that both that
      8  * copyright notice and this permission notice appear in supporting
      9  * documentation, and that the name of Keith Packard not be used in
     10  * advertising or publicity pertaining to distribution of the software without
     11  * specific, written prior permission.  Keith Packard makes no
     12  * representations about the suitability of this software for any purpose.  It
     13  * is provided "as is" without express or implied warranty.
     14  *
     15  * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
     16  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
     17  * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
     18  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
     19  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
     20  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
     21  * PERFORMANCE OF THIS SOFTWARE.
     22  */
     23 
     24 #ifdef HAVE_DIX_CONFIG_H
     25 #include <dix-config.h>
     26 #endif
     27 
     28 #include <stdlib.h>
     29 
     30 #include    <X11/X.h>
     31 #include    "scrnintstr.h"
     32 #include    "windowstr.h"
     33 #include    <X11/fonts/font.h>
     34 #include    "dixfontstr.h"
     35 #include    <X11/fonts/fontstruct.h>
     36 #include    "mi.h"
     37 #include    "regionstr.h"
     38 #include    "globals.h"
     39 #include    "gcstruct.h"
     40 #include    "shadow.h"
     41 #include    "fb.h"
     42 
     43 /*
     44  * Expose 8bpp depth 4
     45  */
     46 
     47 /*
     48  *  32->8 conversion:
     49  *
     50  *      7 6 5 4 3 2 1 0
     51  *      A B C D E F G H
     52  *
     53  *      3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
     54  *      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
     55  * 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))
     56  * 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))
     57  * m3   D               C               B               A                   m1 & 0x80808080
     58  * m4           H               G               F               E           m2 & 0x08080808
     59  * m5   D       H       C       G       B       F       A       E	    m3 | m4
     60  * m6                     D       H       C       G       B       F         m5 >> 9
     61  * m7   D       H       C D     G H     B C     F G     A B     E F         m5 | m6
     62  * m8                                       D       H       C D     G H     m7 >> 18
     63  * m9   D       H       C D     G H     B C D   F G H   A B C D E F G H     m7 | m8
     64  */
     65 
     66 #define PL_SHIFT    8
     67 #define PL_UNIT	    (1 << PL_SHIFT)
     68 #define PL_MASK	    (PL_UNIT - 1)
     69 
     70 #if 0
     71 #define GetBits(p,o,d) { \
     72     CARD32	m1,m2,m3,m4,m5,m6,m7,m8; \
     73     m1 = sha[o] << (7 - (p)); \
     74     m2 = sha[(o)+1] << (3 - (p)); \
     75     m3 = m1 & 0x80808080; \
     76     m4 = m2 & 0x08080808; \
     77     m5 = m3 | m4; \
     78     m6 = m5 >> 9; \
     79     m7 = m5 | m6; \
     80     m8 = m7 >> 18; \
     81     d = m7 | m8; \
     82 }
     83 #else
     84 #define GetBits(p,o,d) { \
     85     CARD32	m5,m7; \
     86     m5 = ((sha[o] << (7 - (p))) & 0x80808080) | ((sha[(o)+1] << (3 - (p))) & 0x08080808); \
     87     m7 = m5 | (m5 >> 9); \
     88     d = m7 | (m7 >> 18); \
     89 }
     90 #endif
     91 
     92 void
     93 shadowUpdatePlanar4x8(ScreenPtr pScreen, shadowBufPtr pBuf)
     94 {
     95     RegionPtr damage = DamageRegion(pBuf->pDamage);
     96     PixmapPtr pShadow = pBuf->pPixmap;
     97     int nbox = RegionNumRects(damage);
     98     BoxPtr pbox = RegionRects(damage);
     99     CARD32 *shaBase, *shaLine, *sha;
    100     CARD8 s1, s2, s3, s4;
    101     FbStride shaStride;
    102     int scrBase, scrLine, scr;
    103     int shaBpp;
    104     _X_UNUSED int shaXoff, shaYoff;
    105     int x, y, w, h, width;
    106     int i;
    107     CARD32 *winBase = NULL, *win;
    108     CARD32 winSize;
    109     int plane;
    110 
    111     fbGetStipDrawable(&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff,
    112                       shaYoff);
    113     while (nbox--) {
    114         x = pbox->x1 * shaBpp;
    115         y = pbox->y1;
    116         w = (pbox->x2 - pbox->x1) * shaBpp;
    117         h = pbox->y2 - pbox->y1;
    118 
    119         w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT;
    120         x &= ~PL_MASK;
    121 
    122         scrLine = (x >> PL_SHIFT);
    123         shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
    124 
    125         while (h--) {
    126             for (plane = 0; plane < 4; plane++) {
    127                 width = w;
    128                 scr = scrLine;
    129                 sha = shaLine;
    130                 winSize = 0;
    131                 scrBase = 0;
    132                 while (width) {
    133                     /* how much remains in this window */
    134                     i = scrBase + winSize - scr;
    135                     if (i <= 0 || scr < scrBase) {
    136                         winBase = (CARD32 *) (*pBuf->window) (pScreen,
    137                                                               y,
    138                                                               (scr << 4) |
    139                                                               (plane),
    140                                                               SHADOW_WINDOW_WRITE,
    141                                                               &winSize,
    142                                                               pBuf->closure);
    143                         if (!winBase)
    144                             return;
    145                         winSize >>= 2;
    146                         scrBase = scr;
    147                         i = winSize;
    148                     }
    149                     win = winBase + (scr - scrBase);
    150                     if (i > width)
    151                         i = width;
    152                     width -= i;
    153                     scr += i;
    154 
    155                     while (i--) {
    156                         GetBits(plane, 0, s1);
    157                         GetBits(plane, 2, s2);
    158                         GetBits(plane, 4, s3);
    159                         GetBits(plane, 6, s4);
    160                         *win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
    161                         sha += 8;
    162                     }
    163                 }
    164             }
    165             shaLine += shaStride;
    166             y++;
    167         }
    168         pbox++;
    169     }
    170 }