xserver

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

kshadow.c (2644B)


      1 /*
      2  * Copyright © 1999 Keith Packard
      3  *
      4  * Permission to use, copy, modify, distribute, and sell this software and its
      5  * documentation for any purpose is hereby granted without fee, provided that
      6  * the above copyright notice appear in all copies and that both that
      7  * copyright notice and this permission notice appear in supporting
      8  * documentation, and that the name of Keith Packard not be used in
      9  * advertising or publicity pertaining to distribution of the software without
     10  * specific, written prior permission.  Keith Packard makes no
     11  * representations about the suitability of this software for any purpose.  It
     12  * is provided "as is" without express or implied warranty.
     13  *
     14  * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
     15  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
     16  * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
     17  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
     18  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
     19  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
     20  * PERFORMANCE OF THIS SOFTWARE.
     21  */
     22 
     23 #ifdef HAVE_DIX_CONFIG_H
     24 #include <dix-config.h>
     25 #endif
     26 #include "kdrive.h"
     27 
     28 Bool
     29 KdShadowFbAlloc(KdScreenInfo * screen, Bool rotate)
     30 {
     31     int paddedWidth;
     32     void *buf;
     33     int width = rotate ? screen->height : screen->width;
     34     int height = rotate ? screen->width : screen->height;
     35     int bpp = screen->fb.bitsPerPixel;
     36 
     37     /* use fb computation for width */
     38     paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
     39     buf = xallocarray(paddedWidth, height);
     40     if (!buf)
     41         return FALSE;
     42     if (screen->fb.shadow)
     43         free(screen->fb.frameBuffer);
     44     screen->fb.shadow = TRUE;
     45     screen->fb.frameBuffer = buf;
     46     screen->fb.byteStride = paddedWidth;
     47     screen->fb.pixelStride = paddedWidth * 8 / bpp;
     48     return TRUE;
     49 }
     50 
     51 void
     52 KdShadowFbFree(KdScreenInfo * screen)
     53 {
     54     if (screen->fb.shadow) {
     55         free(screen->fb.frameBuffer);
     56         screen->fb.frameBuffer = 0;
     57         screen->fb.shadow = FALSE;
     58     }
     59 }
     60 
     61 Bool
     62 KdShadowSet(ScreenPtr pScreen, int randr, ShadowUpdateProc update,
     63             ShadowWindowProc window)
     64 {
     65     KdScreenPriv(pScreen);
     66     KdScreenInfo *screen = pScreenPriv->screen;
     67 
     68     shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
     69     if (screen->fb.shadow) {
     70         return shadowAdd(pScreen, pScreen->GetScreenPixmap(pScreen),
     71                          update, window, randr, 0);
     72     }
     73     return TRUE;
     74 }
     75 
     76 void
     77 KdShadowUnset(ScreenPtr pScreen)
     78 {
     79     shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
     80 }