xserver

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

shiplan2p8.c (4104B)


      1 /*
      2  *  Copyright © 2013 Geert Uytterhoeven
      3  *
      4  *  Permission is hereby granted, free of charge, to any person obtaining a
      5  *  copy of this software and associated documentation files (the "Software"),
      6  *  to deal in the Software without restriction, including without limitation
      7  *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8  *  and/or sell copies of the Software, and to permit persons to whom the
      9  *  Software is furnished to do so, subject to the following conditions:
     10  *
     11  *  The above copyright notice and this permission notice (including the next
     12  *  paragraph) shall be included in all copies or substantial portions of the
     13  *  Software.
     14  *
     15  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     18  *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     20  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     21  *  DEALINGS IN THE SOFTWARE.
     22  *
     23  *  Based on shpacked.c, which is Copyright © 2000 Keith Packard
     24  */
     25 
     26 #ifdef HAVE_DIX_CONFIG_H
     27 #include <dix-config.h>
     28 #endif
     29 
     30 #include <stdlib.h>
     31 
     32 #include    <X11/X.h>
     33 #include    "scrnintstr.h"
     34 #include    "windowstr.h"
     35 #include    <X11/fonts/font.h>
     36 #include    "dixfontstr.h"
     37 #include    <X11/fonts/fontstruct.h>
     38 #include    "mi.h"
     39 #include    "regionstr.h"
     40 #include    "globals.h"
     41 #include    "gcstruct.h"
     42 #include    "shadow.h"
     43 #include    "fb.h"
     44 #include    "c2p_core.h"
     45 
     46 
     47     /*
     48      *  Perform a full C2P step on 16 8-bit pixels, stored in 4 32-bit words
     49      *  containing
     50      *    - 16 8-bit chunky pixels on input
     51      *    - permutated planar data (2 planes per 32-bit word) on output
     52      */
     53 
     54 static void c2p_16x8(CARD32 d[4])
     55 {
     56     transp4(d, 8, 2);
     57     transp4(d, 1, 2);
     58     transp4x(d, 16, 2);
     59     transp4x(d, 2, 2);
     60     transp4(d, 4, 1);
     61 }
     62 
     63 
     64     /*
     65      *  Store a full block of permutated iplan2p8 data after c2p conversion
     66      */
     67 
     68 static inline void store_iplan2p8(void *dst, const CARD32 d[4])
     69 {
     70     CARD32 *p = dst;
     71 
     72     *p++ = d[1];
     73     *p++ = d[3];
     74     *p++ = d[0];
     75     *p++ = d[2];
     76 }
     77 
     78 
     79 void
     80 shadowUpdateIplan2p8(ScreenPtr pScreen, shadowBufPtr pBuf)
     81 {
     82     RegionPtr damage = DamageRegion(pBuf->pDamage);
     83     PixmapPtr pShadow = pBuf->pPixmap;
     84     int nbox = RegionNumRects(damage);
     85     BoxPtr pbox = RegionRects(damage);
     86     FbBits *shaBase;
     87     CARD16 *shaLine, *sha;
     88     FbStride shaStride;
     89     int scrLine;
     90     _X_UNUSED int shaBpp, shaXoff, shaYoff;
     91     int x, y, w, h;
     92     int i, n;
     93     CARD16 *win;
     94     _X_UNUSED CARD32 winSize;
     95     union {
     96         CARD8 bytes[16];
     97         CARD32 words[4];
     98     } d;
     99 
    100     fbGetDrawable(&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff,
    101                   shaYoff);
    102     shaStride *= sizeof(FbBits) / sizeof(CARD16);
    103 
    104     while (nbox--) {
    105         x = pbox->x1;
    106         y = pbox->y1;
    107         w = pbox->x2 - pbox->x1;
    108         h = pbox->y2 - pbox->y1;
    109 
    110         scrLine = x & -16;
    111         shaLine = (CARD16 *)shaBase + y * shaStride + scrLine / sizeof(CARD16);
    112 
    113         n = ((x & 15) + w + 15) / 16;   /* number of c2p units in scanline */
    114 
    115         while (h--) {
    116             sha = shaLine;
    117             win = (CARD16 *) (*pBuf->window) (pScreen,
    118                                               y,
    119                                               scrLine,
    120                                               SHADOW_WINDOW_WRITE,
    121                                               &winSize,
    122                                               pBuf->closure);
    123             if (!win)
    124                 return;
    125             for (i = 0; i < n; i++) {
    126                 memcpy(d.bytes, sha, sizeof(d.bytes));
    127                 c2p_16x8(d.words);
    128                 store_iplan2p8(win, d.words);
    129                 sha += sizeof(d.bytes) / sizeof(*sha);
    130                 win += sizeof(d.bytes) / sizeof(*win);
    131             }
    132             shaLine += shaStride;
    133             y++;
    134         }
    135         pbox++;
    136     }
    137 }