xserver

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

fbwindow.c (5394B)


      1 /*
      2  * Copyright © 1998 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 
     27 #include <stdlib.h>
     28 
     29 #include "fb.h"
     30 
     31 Bool
     32 fbCreateWindow(WindowPtr pWin)
     33 {
     34     dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(pWin),
     35                   fbGetScreenPixmap(pWin->drawable.pScreen));
     36     return TRUE;
     37 }
     38 
     39 Bool
     40 fbDestroyWindow(WindowPtr pWin)
     41 {
     42     return TRUE;
     43 }
     44 
     45 Bool
     46 fbRealizeWindow(WindowPtr pWindow)
     47 {
     48     return TRUE;
     49 }
     50 
     51 Bool
     52 fbPositionWindow(WindowPtr pWin, int x, int y)
     53 {
     54     return TRUE;
     55 }
     56 
     57 Bool
     58 fbUnrealizeWindow(WindowPtr pWindow)
     59 {
     60     return TRUE;
     61 }
     62 
     63 void
     64 fbCopyWindowProc(DrawablePtr pSrcDrawable,
     65                  DrawablePtr pDstDrawable,
     66                  GCPtr pGC,
     67                  BoxPtr pbox,
     68                  int nbox,
     69                  int dx,
     70                  int dy,
     71                  Bool reverse, Bool upsidedown, Pixel bitplane, void *closure)
     72 {
     73     FbBits *src;
     74     FbStride srcStride;
     75     int srcBpp;
     76     int srcXoff, srcYoff;
     77     FbBits *dst;
     78     FbStride dstStride;
     79     int dstBpp;
     80     int dstXoff, dstYoff;
     81 
     82     fbGetDrawable(pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
     83     fbGetDrawable(pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
     84 
     85     while (nbox--) {
     86         fbBlt(src + (pbox->y1 + dy + srcYoff) * srcStride,
     87               srcStride,
     88               (pbox->x1 + dx + srcXoff) * srcBpp,
     89               dst + (pbox->y1 + dstYoff) * dstStride,
     90               dstStride,
     91               (pbox->x1 + dstXoff) * dstBpp,
     92               (pbox->x2 - pbox->x1) * dstBpp,
     93               (pbox->y2 - pbox->y1),
     94               GXcopy, FB_ALLONES, dstBpp, reverse, upsidedown);
     95         pbox++;
     96     }
     97 
     98     fbFinishAccess(pDstDrawable);
     99     fbFinishAccess(pSrcDrawable);
    100 }
    101 
    102 void
    103 fbCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
    104 {
    105     RegionRec rgnDst;
    106     int dx, dy;
    107 
    108     PixmapPtr pPixmap = fbGetWindowPixmap(pWin);
    109     DrawablePtr pDrawable = &pPixmap->drawable;
    110 
    111     dx = ptOldOrg.x - pWin->drawable.x;
    112     dy = ptOldOrg.y - pWin->drawable.y;
    113     RegionTranslate(prgnSrc, -dx, -dy);
    114 
    115     RegionNull(&rgnDst);
    116 
    117     RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
    118 
    119 #ifdef COMPOSITE
    120     if (pPixmap->screen_x || pPixmap->screen_y)
    121         RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
    122 #endif
    123 
    124     miCopyRegion(pDrawable, pDrawable,
    125                  0, &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
    126 
    127     RegionUninit(&rgnDst);
    128     fbValidateDrawable(&pWin->drawable);
    129 }
    130 
    131 static void
    132 fbFixupWindowPixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
    133 {
    134     PixmapPtr pPixmap = *ppPixmap;
    135 
    136     if (FbEvenTile(pPixmap->drawable.width * pPixmap->drawable.bitsPerPixel))
    137         fbPadPixmap(pPixmap);
    138 }
    139 
    140 Bool
    141 fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
    142 {
    143     if (mask & CWBackPixmap) {
    144         if (pWin->backgroundState == BackgroundPixmap)
    145             fbFixupWindowPixmap(&pWin->drawable, &pWin->background.pixmap);
    146     }
    147     if (mask & CWBorderPixmap) {
    148         if (pWin->borderIsPixel == FALSE)
    149             fbFixupWindowPixmap(&pWin->drawable, &pWin->border.pixmap);
    150     }
    151     return TRUE;
    152 }
    153 
    154 void
    155 fbFillRegionSolid(DrawablePtr pDrawable,
    156                   RegionPtr pRegion, FbBits and, FbBits xor)
    157 {
    158     FbBits *dst;
    159     FbStride dstStride;
    160     int dstBpp;
    161     int dstXoff, dstYoff;
    162     int n = RegionNumRects(pRegion);
    163     BoxPtr pbox = RegionRects(pRegion);
    164 
    165 #ifndef FB_ACCESS_WRAPPER
    166     int try_mmx = 0;
    167 
    168     if (!and)
    169         try_mmx = 1;
    170 #endif
    171 
    172     fbGetDrawable(pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
    173 
    174     while (n--) {
    175 #ifndef FB_ACCESS_WRAPPER
    176         if (!try_mmx || !pixman_fill((uint32_t *) dst, dstStride, dstBpp,
    177                                      pbox->x1 + dstXoff, pbox->y1 + dstYoff,
    178                                      (pbox->x2 - pbox->x1),
    179                                      (pbox->y2 - pbox->y1), xor)) {
    180 #endif
    181             fbSolid(dst + (pbox->y1 + dstYoff) * dstStride,
    182                     dstStride,
    183                     (pbox->x1 + dstXoff) * dstBpp,
    184                     dstBpp,
    185                     (pbox->x2 - pbox->x1) * dstBpp,
    186                     pbox->y2 - pbox->y1, and, xor);
    187 #ifndef FB_ACCESS_WRAPPER
    188         }
    189 #endif
    190         fbValidateDrawable(pDrawable);
    191         pbox++;
    192     }
    193 
    194     fbFinishAccess(pDrawable);
    195 }