[PATCH xserver 06/11] dmx: Remove scrnDefDrawables to remove a use of MAXFORMATS

Adam Jackson ajax at redhat.com
Fri Dec 9 19:52:33 UTC 2016


We only kinda needed this for the CreateGC screen hook, because that
gets called only with the GC itself so we don't have a drawable already
on the backend to point to. But since we know the GC depth, we can just
create a 1x1 pixmap at that depth on the fly instead.

The other place this was used was in restoring pixmap images, in which
case we know the destination pixmap and can just use that.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 hw/dmx/dmx.h          |  3 ---
 hw/dmx/dmxcursor.c    | 12 +-----------
 hw/dmx/dmxextension.c | 47 +++++++++++++++--------------------------------
 hw/dmx/dmxgc.c        |  9 +++++----
 hw/dmx/dmxscrinit.c   | 22 ----------------------
 5 files changed, 21 insertions(+), 72 deletions(-)

diff --git a/hw/dmx/dmx.h b/hw/dmx/dmx.h
index 7242e43..0a0fbe5 100644
--- a/hw/dmx/dmx.h
+++ b/hw/dmx/dmx.h
@@ -128,9 +128,6 @@ typedef struct _DMXScreenInfo {
     int scrnXSign;                /**< X offset sign of "screen" */
     int scrnYSign;                /**< Y offset sign of "screen" */
 
-                                  /** Default drawables for "screen" */
-    Drawable scrnDefDrawables[MAXFORMATS];
-
     struct _DMXScreenInfo *next;  /**< List of "screens" on same display */
     struct _DMXScreenInfo *over;  /**< List of "screens" that overlap */
 
diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c
index 0ef800e..08df848 100644
--- a/hw/dmx/dmxcursor.c
+++ b/hw/dmx/dmxcursor.c
@@ -614,17 +614,6 @@ dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor)
     v.background = 0L;
     v.clip_mask = None;
 
-    for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
-        if (dmxScreen->bePixmapFormats[i].depth == 1) {
-            /* Create GC in the back-end servers */
-            gc = XCreateGC(dmxScreen->beDisplay, dmxScreen->scrnDefDrawables[i],
-                           m, &v);
-            break;
-        }
-    }
-    if (!gc)
-        dmxLog(dmxFatal, "dmxRealizeCursor: gc not initialized\n");
-
     src = XCreatePixmap(dmxScreen->beDisplay, dmxScreen->scrnWin,
                         pBits->width, pBits->height, 1);
     msk = XCreatePixmap(dmxScreen->beDisplay, dmxScreen->scrnWin,
@@ -636,6 +625,7 @@ dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor)
                        pBits->width, pBits->height,
                        BitmapPad(dmxScreen->beDisplay), 0);
 
+    gc = XCreateGC(dmxScreen->beDisplay, src, m, &v);
     XPutImage(dmxScreen->beDisplay, src, gc, img, 0, 0, 0, 0,
               pBits->width, pBits->height);
 
diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index 82a02f0..009d4b6 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -759,6 +759,8 @@ dmxBERestorePixmapImage(void *value, XID id, RESTYPE type, void *p)
                 XImage *img;
                 int j;
                 XlibGC gc = NULL;
+                unsigned long m;
+                XGCValues v;
 
                 /* This should never happen, but just in case.... */
                 if (pSrc->drawable.width != pDst->drawable.width ||
@@ -772,22 +774,12 @@ dmxBERestorePixmapImage(void *value, XID id, RESTYPE type, void *p)
                                 pSrc->drawable.width, pSrc->drawable.height,
                                 -1, ZPixmap);
 
-                for (j = 0; j < dmxDstScreen->beNumPixmapFormats; j++) {
-                    if (dmxDstScreen->bePixmapFormats[j].depth == img->depth) {
-                        unsigned long m;
-                        XGCValues v;
-
-                        m = GCFunction | GCPlaneMask | GCClipMask;
-                        v.function = GXcopy;
-                        v.plane_mask = AllPlanes;
-                        v.clip_mask = None;
-
-                        gc = XCreateGC(dmxDstScreen->beDisplay,
-                                       dmxDstScreen->scrnDefDrawables[j],
-                                       m, &v);
-                        break;
-                    }
-                }
+                m = GCFunction | GCPlaneMask | GCClipMask;
+                v.function = GXcopy;
+                v.plane_mask = AllPlanes;
+                v.clip_mask = None;
+                gc = XCreateGC(dmxDstScreen->beDisplay, pDstPriv->pixmap,
+                               m, &v);
 
                 if (gc) {
                     XPutImage(dmxDstScreen->beDisplay,
@@ -840,23 +832,14 @@ dmxBERestorePixmap(PixmapPtr pPixmap)
             ScreenPtr pScreen = pPixmap->drawable.pScreen;
             DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
             XlibGC gc = NULL;
+            unsigned long m;
+            XGCValues v;
 
-            for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
-                if (dmxScreen->bePixmapFormats[i].depth ==
-                    pPixPriv->detachedImage->depth) {
-                    unsigned long m;
-                    XGCValues v;
-
-                    m = GCFunction | GCPlaneMask | GCClipMask;
-                    v.function = GXcopy;
-                    v.plane_mask = AllPlanes;
-                    v.clip_mask = None;
-
-                    gc = XCreateGC(dmxScreen->beDisplay,
-                                   dmxScreen->scrnDefDrawables[i], m, &v);
-                    break;
-                }
-            }
+            m = GCFunction | GCPlaneMask | GCClipMask;
+            v.function = GXcopy;
+            v.plane_mask = AllPlanes;
+            v.clip_mask = None;
+            gc = XCreateGC(dmxScreen->beDisplay, pPixPriv->pixmap, m, &v);
 
             if (gc) {
                 XPutImage(dmxScreen->beDisplay,
diff --git a/hw/dmx/dmxgc.c b/hw/dmx/dmxgc.c
index c4789a6..99f38c5 100644
--- a/hw/dmx/dmxgc.c
+++ b/hw/dmx/dmxgc.c
@@ -104,14 +104,15 @@ dmxBECreateGC(ScreenPtr pScreen, GCPtr pGC)
         if (pGC->depth == dmxScreen->bePixmapFormats[i].depth) {
             unsigned long mask;
             XGCValues gcvals;
+            PixmapPtr pix;
 
             mask = GCGraphicsExposures;
             gcvals.graphics_exposures = FALSE;
 
-            /* Create GC in the back-end servers */
-            pGCPriv->gc = XCreateGC(dmxScreen->beDisplay,
-                                    dmxScreen->scrnDefDrawables[i],
-                                    mask, &gcvals);
+            pix = XCreatePixmap(dmxScreen->beDisplay, dmxScreen->scrnWin,
+                                1, 1, pGC->depth);
+            pGCPriv->gc = XCreateGC(dmxScreen->beDisplay, pix, mask, &gcvals);
+            XFreePixmap(dmxScreen->beDisplay, pix);
             break;
         }
     }
diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c
index e441dce..4764249 100644
--- a/hw/dmx/dmxscrinit.c
+++ b/hw/dmx/dmxscrinit.c
@@ -158,19 +158,6 @@ dmxBEScreenInit(ScreenPtr pScreen)
     }
 
     XMapWindow(dmxScreen->beDisplay, dmxScreen->scrnWin);
-
-    /* Create default drawables (used during GC creation) */
-    for (i = 0; i < dmxScreen->beNumPixmapFormats; i++)
-	for (j = 0; j < dmxScreen->beNumDepths; j++)
-	    if ((dmxScreen->bePixmapFormats[i].depth == 1) ||
-		(dmxScreen->bePixmapFormats[i].depth ==
-		 dmxScreen->beDepths[j])) {
-		dmxScreen->scrnDefDrawables[i] = (Drawable)
-		    XCreatePixmap(dmxScreen->beDisplay, dmxScreen->scrnWin,
-				  1, 1,
-				  dmxScreen->bePixmapFormats[i].depth);
-		break;
-	    }
 }
 
 /** Initialize screen number \a pScreen->myNum. */
@@ -334,15 +321,6 @@ dmxBECloseScreen(ScreenPtr pScreen)
     XDestroyWindow(dmxScreen->beDisplay, dmxScreen->scrnWin);
     dmxScreen->scrnWin = (Window) 0;
 
-    /* Free the default drawables */
-    for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
-	if (dmxScreen->scrnDefDrawables[i]) {
-	    XFreePixmap(dmxScreen->beDisplay,
-			dmxScreen->scrnDefDrawables[i]);
-	    dmxScreen->scrnDefDrawables[i] = (Drawable) 0;
-	}
-    }
-
     /* Free resources allocated during initialization (in dmxinit.c) */
     for (i = 0; i < dmxScreen->beNumDefColormaps; i++)
         XFreeColormap(dmxScreen->beDisplay, dmxScreen->beDefColormaps[i]);
-- 
2.9.3



More information about the xorg-devel mailing list