[PATCH 09/12] dbe: Fold the window private private into the window private

Adam Jackson ajax at redhat.com
Tue Oct 16 11:56:22 PDT 2012


Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 dbe/Makefile.am    |  3 +-
 dbe/dbe.c          |  5 ++-
 dbe/dbestruct.h    | 14 ++++++++
 dbe/midbe.c        | 99 ++++++++++++++++++++----------------------------------
 dbe/midbestr.h     | 75 -----------------------------------------
 dix/privates.c     |  1 -
 include/privates.h |  1 -
 7 files changed, 54 insertions(+), 144 deletions(-)
 delete mode 100644 dbe/midbestr.h

diff --git a/dbe/Makefile.am b/dbe/Makefile.am
index 043555b..7d034c7 100644
--- a/dbe/Makefile.am
+++ b/dbe/Makefile.am
@@ -9,5 +9,4 @@ endif
 libdbe_la_SOURCES = \
         dbe.c \
         midbe.c \
-        midbe.h \
-        midbestr.h
+        midbe.h
diff --git a/dbe/dbe.c b/dbe/dbe.c
index 3054c54..5524615 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -229,8 +229,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
          * Allocate a window priv.
          */
 
-        pDbeWindowPriv =
-            dixAllocateObjectWithPrivates(DbeWindowPrivRec, PRIVATE_DBE_WINDOW);
+        pDbeWindowPriv = calloc(1, sizeof(DbeWindowPrivRec));
         if (!pDbeWindowPriv)
             return BadAlloc;
 
@@ -1222,7 +1221,7 @@ DbeWindowPrivDelete(pointer pDbeWinPriv, XID id)
                       NULL);
 
         /* We are done with the window priv. */
-        dixFreeObjectWithPrivates(pDbeWindowPriv, PRIVATE_DBE_WINDOW);
+        free(pDbeWindowPriv);
     }
 
     return Success;
diff --git a/dbe/dbestruct.h b/dbe/dbestruct.h
index 22dc460..2002066 100644
--- a/dbe/dbestruct.h
+++ b/dbe/dbestruct.h
@@ -143,6 +143,20 @@ typedef struct _DbeWindowPrivRec {
      */
     XID initIDs[DBE_INIT_MAX_IDS];
 
+    /* Pointer to a drawable that contains the contents of the back buffer.
+     */
+    PixmapPtr pBackBuffer;
+
+    /* Pointer to a drawable that contains the contents of the front buffer.
+     * This pointer is only used for the XdbeUntouched swap action.  For that
+     * swap action, we need to copy the front buffer (window) contents into
+     * this drawable, copy the contents of current back buffer drawable (the
+     * back buffer) into the window, swap the front and back drawable pointers,
+     * and then swap the drawable/resource associations in the resource
+     * database.
+     */
+    PixmapPtr pFrontBuffer;
+
     /* Device-specific private information.
      */
     PrivateRec *devPrivates;
diff --git a/dbe/midbe.c b/dbe/midbe.c
index 71c7963..3663fdd 100644
--- a/dbe/midbe.c
+++ b/dbe/midbe.c
@@ -48,7 +48,6 @@
 #include "resource.h"
 #include "opaque.h"
 #include "dbestruct.h"
-#include "midbestr.h"
 #include "regionstr.h"
 #include "gcstruct.h"
 #include "inputstr.h"
@@ -57,9 +56,6 @@
 
 #include <stdio.h>
 
-static DevPrivateKeyRec miDbeWindowPrivPrivKeyRec;
-
-#define miDbeWindowPrivPrivKey (&miDbeWindowPrivPrivKeyRec)
 
 /******************************************************************************
  *
@@ -138,7 +134,6 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
 {
     ScreenPtr pScreen;
     DbeWindowPrivPtr pDbeWindowPriv;
-    MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
     DbeScreenPrivPtr pDbeScreenPriv;
     GCPtr pGC;
     xRectangle clearRect;
@@ -156,12 +151,8 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
 
         pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
 
-        /* Setup the window priv priv. */
-        pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
-        pDbeWindowPrivPriv->pDbeWindowPriv = pDbeWindowPriv;
-
         /* Get a front pixmap. */
-        if (!(pDbeWindowPrivPriv->pFrontBuffer =
+        if (!(pDbeWindowPriv->pFrontBuffer =
               (*pScreen->CreatePixmap) (pScreen, pDbeWindowPriv->width,
                                         pDbeWindowPriv->height,
                                         pWin->drawable.depth, 0))) {
@@ -169,22 +160,22 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
         }
 
         /* Get a back pixmap. */
-        if (!(pDbeWindowPrivPriv->pBackBuffer =
+        if (!(pDbeWindowPriv->pBackBuffer =
               (*pScreen->CreatePixmap) (pScreen, pDbeWindowPriv->width,
                                         pDbeWindowPriv->height,
                                         pWin->drawable.depth, 0))) {
-            (*pScreen->DestroyPixmap) (pDbeWindowPrivPriv->pFrontBuffer);
+            (*pScreen->DestroyPixmap) (pDbeWindowPriv->pFrontBuffer);
             return BadAlloc;
         }
 
         /* Security creation/labeling check. */
         rc = XaceHook(XACE_RESOURCE_ACCESS, serverClient, bufId,
-                      dbeDrawableResType, pDbeWindowPrivPriv->pBackBuffer,
+                      dbeDrawableResType, pDbeWindowPriv->pBackBuffer,
                       RT_WINDOW, pWin, DixCreateAccess);
 
         /* Make the back pixmap a DBE drawable resource. */
         if (rc != Success || !AddResource(bufId, dbeDrawableResType,
-                                          pDbeWindowPrivPriv->pBackBuffer)) {
+                                          pDbeWindowPriv->pBackBuffer)) {
             /* free the buffer and the drawable resource */
             FreeResource(bufId, RT_NONE);
             return (rc == Success) ? BadAlloc : rc;
@@ -193,11 +184,11 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
         /* Clear the back buffer. */
         pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
         if ((*pDbeScreenPriv->SetupBackgroundPainter) (pWin, pGC)) {
-            ValidateGC((DrawablePtr) pDbeWindowPrivPriv->pBackBuffer, pGC);
+            ValidateGC((DrawablePtr) pDbeWindowPriv->pBackBuffer, pGC);
             clearRect.x = clearRect.y = 0;
-            clearRect.width = pDbeWindowPrivPriv->pBackBuffer->drawable.width;
-            clearRect.height = pDbeWindowPrivPriv->pBackBuffer->drawable.height;
-            (*pGC->ops->PolyFillRect) ((DrawablePtr) pDbeWindowPrivPriv->
+            clearRect.width = pDbeWindowPriv->pBackBuffer->drawable.width;
+            clearRect.height = pDbeWindowPriv->pBackBuffer->drawable.height;
+            (*pGC->ops->PolyFillRect) ((DrawablePtr) pDbeWindowPriv->
                                        pBackBuffer, pGC, 1, &clearRect);
         }
         FreeScratchGC(pGC);
@@ -210,9 +201,8 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
          */
 
         /* Associate the new ID with an existing pixmap. */
-        pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
         if (!AddResource(bufId, dbeDrawableResType,
-                         (pointer) pDbeWindowPrivPriv->pBackBuffer)) {
+                         (pointer) pDbeWindowPriv->pBackBuffer)) {
             return BadAlloc;
         }
 
@@ -237,12 +227,10 @@ static void
 miDbeAliasBuffers(DbeWindowPrivPtr pDbeWindowPriv)
 {
     int i;
-    MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv =
-        MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
 
     for (i = 0; i < pDbeWindowPriv->nBufferIDs; i++) {
         ChangeResourceValue(pDbeWindowPriv->IDs[i], dbeDrawableResType,
-                            (pointer) pDbeWindowPrivPriv->pBackBuffer);
+                            (pointer) pDbeWindowPriv->pBackBuffer);
     }
 
 }                               /* miDbeAliasBuffers() */
@@ -261,15 +249,15 @@ static int
 miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
 {
     DbeScreenPrivPtr pDbeScreenPriv;
+    DbeWindowPrivPtr pDbeWindowPriv;
     GCPtr pGC;
     WindowPtr pWin;
-    MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
     PixmapPtr pTmpBuffer;
     xRectangle clearRect;
 
     pWin = swapInfo[0].pWindow;
     pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
-    pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin);
+    pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
     pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
 
     /*
@@ -286,9 +274,9 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
         break;
 
     case XdbeUntouched:
-        ValidateGC((DrawablePtr) pDbeWindowPrivPriv->pFrontBuffer, pGC);
+        ValidateGC((DrawablePtr) pDbeWindowPriv->pFrontBuffer, pGC);
         (*pGC->ops->CopyArea) ((DrawablePtr) pWin,
-                               (DrawablePtr) pDbeWindowPrivPriv->pFrontBuffer,
+                               (DrawablePtr) pDbeWindowPriv->pFrontBuffer,
                                pGC, 0, 0, pWin->drawable.width,
                                pWin->drawable.height, 0, 0);
         break;
@@ -305,7 +293,7 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
      */
 
     ValidateGC((DrawablePtr) pWin, pGC);
-    (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPrivPriv->pBackBuffer,
+    (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pBackBuffer,
                            (DrawablePtr) pWin, pGC, 0, 0,
                            pWin->drawable.width, pWin->drawable.height, 0, 0);
 
@@ -321,23 +309,23 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
 
     case XdbeBackground:
         if ((*pDbeScreenPriv->SetupBackgroundPainter) (pWin, pGC)) {
-            ValidateGC((DrawablePtr) pDbeWindowPrivPriv->pBackBuffer, pGC);
+            ValidateGC((DrawablePtr) pDbeWindowPriv->pBackBuffer, pGC);
             clearRect.x = 0;
             clearRect.y = 0;
-            clearRect.width = pDbeWindowPrivPriv->pBackBuffer->drawable.width;
-            clearRect.height = pDbeWindowPrivPriv->pBackBuffer->drawable.height;
-            (*pGC->ops->PolyFillRect) ((DrawablePtr) pDbeWindowPrivPriv->
+            clearRect.width = pDbeWindowPriv->pBackBuffer->drawable.width;
+            clearRect.height = pDbeWindowPriv->pBackBuffer->drawable.height;
+            (*pGC->ops->PolyFillRect) ((DrawablePtr) pDbeWindowPriv->
                                        pBackBuffer, pGC, 1, &clearRect);
         }
         break;
 
     case XdbeUntouched:
         /* Swap pixmap pointers. */
-        pTmpBuffer = pDbeWindowPrivPriv->pBackBuffer;
-        pDbeWindowPrivPriv->pBackBuffer = pDbeWindowPrivPriv->pFrontBuffer;
-        pDbeWindowPrivPriv->pFrontBuffer = pTmpBuffer;
+        pTmpBuffer = pDbeWindowPriv->pBackBuffer;
+        pDbeWindowPriv->pBackBuffer = pDbeWindowPriv->pFrontBuffer;
+        pDbeWindowPriv->pFrontBuffer = pTmpBuffer;
 
-        miDbeAliasBuffers(pDbeWindowPrivPriv->pDbeWindowPriv);
+        miDbeAliasBuffers(pDbeWindowPriv);
 
         break;
 
@@ -427,8 +415,6 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
 static void
 miDbeWinPrivDelete(DbeWindowPrivPtr pDbeWindowPriv, XID bufId)
 {
-    MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
-
     if (pDbeWindowPriv->nBufferIDs != 0) {
         /* We still have at least one more buffer ID associated with this
          * window.
@@ -440,18 +426,15 @@ miDbeWinPrivDelete(DbeWindowPrivPtr pDbeWindowPriv, XID bufId)
      * free some stuff.
      */
 
-    pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
-
     /* Destroy the front and back pixmaps. */
-    if (pDbeWindowPrivPriv->pFrontBuffer) {
+    if (pDbeWindowPriv->pFrontBuffer) {
         (*pDbeWindowPriv->pWindow->drawable.pScreen->
-         DestroyPixmap) (pDbeWindowPrivPriv->pFrontBuffer);
+         DestroyPixmap) (pDbeWindowPriv->pFrontBuffer);
     }
-    if (pDbeWindowPrivPriv->pBackBuffer) {
+    if (pDbeWindowPriv->pBackBuffer) {
         (*pDbeWindowPriv->pWindow->drawable.pScreen->
-         DestroyPixmap) (pDbeWindowPrivPriv->pBackBuffer);
+         DestroyPixmap) (pDbeWindowPriv->pBackBuffer);
     }
-
 }                               /* miDbeWinPrivDelete() */
 
 /******************************************************************************
@@ -627,10 +610,6 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
     else {
         /* Clear out the new DBE buffer pixmaps. */
 
-        MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
-
-        pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
-
         /* I suppose this could avoid quite a bit of work if
          * it computed the minimal area required.
          */
@@ -641,9 +620,9 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
         }
         /* Copy the contents of the old front pixmap to the new one. */
         if (pWin->bitGravity != ForgetGravity) {
-            (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPrivPriv->
-                                   pFrontBuffer, (DrawablePtr) pFrontBuffer,
-                                   pGC, sourcex, sourcey, savewidth, saveheight,
+            (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pFrontBuffer,
+				   (DrawablePtr) pFrontBuffer, pGC,
+				   sourcex, sourcey, savewidth, saveheight,
                                    destx, desty);
         }
 
@@ -654,8 +633,8 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
         }
         /* Copy the contents of the old back pixmap to the new one. */
         if (pWin->bitGravity != ForgetGravity) {
-            (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPrivPriv->
-                                   pBackBuffer, (DrawablePtr) pBackBuffer, pGC,
+            (*pGC->ops->CopyArea) ((DrawablePtr) pDbeWindowPriv->pBackBuffer,
+				   (DrawablePtr) pBackBuffer, pGC,
                                    sourcex, sourcey, savewidth, saveheight,
                                    destx, desty);
         }
@@ -664,11 +643,11 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
          * pixmaps.
          */
 
-        (*pScreen->DestroyPixmap) (pDbeWindowPrivPriv->pFrontBuffer);
-        (*pScreen->DestroyPixmap) (pDbeWindowPrivPriv->pBackBuffer);
+        (*pScreen->DestroyPixmap) (pDbeWindowPriv->pFrontBuffer);
+        (*pScreen->DestroyPixmap) (pDbeWindowPriv->pBackBuffer);
 
-        pDbeWindowPrivPriv->pFrontBuffer = pFrontBuffer;
-        pDbeWindowPrivPriv->pBackBuffer = pBackBuffer;
+        pDbeWindowPriv->pFrontBuffer = pFrontBuffer;
+        pDbeWindowPriv->pBackBuffer = pBackBuffer;
 
         /* Make sure all XID are associated with the new back pixmap. */
         miDbeAliasBuffers(pDbeWindowPriv);
@@ -693,10 +672,6 @@ miDbePositionWindow(WindowPtr pWin, int x, int y)
 Bool
 miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
 {
-    if (!dixRegisterPrivateKey(&miDbeWindowPrivPrivKeyRec, PRIVATE_DBE_WINDOW,
-                               sizeof(MiDbeWindowPrivPrivRec)))
-        return FALSE;
-
     /* Wrap functions. */
     pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
     pScreen->PositionWindow = miDbePositionWindow;
diff --git a/dbe/midbestr.h b/dbe/midbestr.h
deleted file mode 100644
index 70017b0..0000000
--- a/dbe/midbestr.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/******************************************************************************
- * 
- * Copyright (c) 1994, 1995  Hewlett-Packard Company
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- * Except as contained in this notice, the name of the Hewlett-Packard
- * Company shall not be used in advertising or otherwise to promote the
- * sale, use or other dealings in this Software without prior written
- * authorization from the Hewlett-Packard Company.
- * 
- *     Header file for users of machine-independent DBE code
- * 
- *****************************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef MIDBE_STRUCT_H
-#define MIDBE_STRUCT_H
-
-/* DEFINES */
-
-#define MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv) \
-    (!(pDbeWindowPriv) ? NULL : (MiDbeWindowPrivPrivPtr) \
-     dixLookupPrivate(&(pDbeWindowPriv)->devPrivates, miDbeWindowPrivPrivKey))
-
-#define MI_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin)\
-    MI_DBE_WINDOW_PRIV_PRIV(DBE_WINDOW_PRIV(pWin))
-
-/* TYPEDEFS */
-
-typedef struct _MiDbeWindowPrivPrivRec {
-    /* Place machine-specific fields in here.
-     * Since this is mi code, we do not really have machine-specific fields.
-     */
-
-    /* Pointer to a drawable that contains the contents of the back buffer.
-     */
-    PixmapPtr pBackBuffer;
-
-    /* Pointer to a drawable that contains the contents of the front buffer.
-     * This pointer is only used for the XdbeUntouched swap action.  For that
-     * swap action, we need to copy the front buffer (window) contents into
-     * this drawable, copy the contents of current back buffer drawable (the
-     * back buffer) into the window, swap the front and back drawable pointers,
-     * and then swap the drawable/resource associations in the resource
-     * database.
-     */
-    PixmapPtr pFrontBuffer;
-
-    /* Pointer back to our window private with which we are associated. */
-    DbeWindowPrivPtr pDbeWindowPriv;
-
-} MiDbeWindowPrivPrivRec, *MiDbeWindowPrivPrivPtr;
-
-#endif                          /* MIDBE_STRUCT_H */
diff --git a/dix/privates.c b/dix/privates.c
index 55b9345..41b1a76 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -105,7 +105,6 @@ static const char *key_names[PRIVATE_LAST] = {
     [PRIVATE_CURSOR_BITS] = "CURSOR_BITS",
 
     /* extension privates */
-    [PRIVATE_DBE_WINDOW] = "DBE_WINDOW",
     [PRIVATE_DAMAGE] = "DAMAGE",
     [PRIVATE_GLYPH] = "GLYPH",
     [PRIVATE_GLYPHSET] = "GLYPHSET",
diff --git a/include/privates.h b/include/privates.h
index 2c8864b..0abdce7 100644
--- a/include/privates.h
+++ b/include/privates.h
@@ -46,7 +46,6 @@ typedef enum {
     PRIVATE_CURSOR_BITS,
 
     /* extension privates */
-    PRIVATE_DBE_WINDOW,
     PRIVATE_DAMAGE,
     PRIVATE_GLYPH,
     PRIVATE_GLYPHSET,
-- 
1.7.12.1



More information about the xorg-devel mailing list