dri: cosmetic
authorGeorge Sapountzis <gsapountzis@gmail.com>
Fri, 4 Nov 2011 14:35:49 +0000 (16:35 +0200)
committerGeorge Sapountzis <gsapountzis@gmail.com>
Fri, 4 Nov 2011 21:33:06 +0000 (23:33 +0200)
To smooth minor diff between dri_util & drisw_util

src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/drisw_util.c

index c69fdce4405d3c06020b411d860e0a37f5bdecdc..1640c14480d296866cee1d17b949858bb99b6e9f 100644 (file)
@@ -74,23 +74,22 @@ dri2CreateNewScreen(int scrn, int fd,
        drmFreeVersion(version);
     }
 
+    psp->loaderPrivate = data;
+
     psp->extensions = emptyExtensionList;
     psp->fd = fd;
     psp->myNum = scrn;
 
     psp->api_mask = (1 << __DRI_API_OPENGL);
+
     *driver_configs = driDriverAPI.InitScreen(psp);
     if (*driver_configs == NULL) {
        free(psp);
        return NULL;
     }
 
-    psp->loaderPrivate = data;
-
-    driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions,
-                      __dri2NConfigOptions);
-    driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum,
-                       "dri2");
+    driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions, __dri2NConfigOptions);
+    driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum, "dri2");
 
     return psp;
 }
@@ -112,8 +111,7 @@ static void driDestroyScreen(__DRIscreen *psp)
 
        _mesa_destroy_shader_compiler();
 
-       if (driDriverAPI.DestroyScreen)
-           driDriverAPI.DestroyScreen(psp);
+       driDriverAPI.DestroyScreen(psp);
 
        driDestroyOptionCache(&psp->optionCache);
        driDestroyOptionInfo(&psp->optionInfo);
@@ -166,12 +164,13 @@ dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
     if (!context)
        return NULL;
 
+    context->loaderPrivate = data;
+
     context->driScreenPriv = screen;
     context->driDrawablePriv = NULL;
-    context->loaderPrivate = data;
+    context->driReadablePriv = NULL;
 
-    if (!driDriverAPI.CreateContext(mesa_api, modes,
-                                   context, shareCtx) ) {
+    if (!driDriverAPI.CreateContext(mesa_api, modes, context, shareCtx) ) {
         free(context);
         return NULL;
     }
@@ -184,8 +183,8 @@ static __DRIcontext *
 dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
                      __DRIcontext *shared, void *data)
 {
-   return dri2CreateNewContextForAPI(screen, __DRI_API_OPENGL,
-                                    config, shared, data);
+    return dri2CreateNewContextForAPI(screen, __DRI_API_OPENGL,
+                                     config, shared, data);
 }
 
 /**
@@ -252,7 +251,6 @@ static int driBindContext(__DRIcontext *pcp,
        dri_get_drawable(prp);
     }
 
-    /* Call device-specific MakeCurrent */
     return driDriverAPI.MakeCurrent(pcp, pdp, prp);
 }
 
@@ -283,15 +281,15 @@ static int driUnbindContext(__DRIcontext *pcp)
     */
 
     if (pcp == NULL)
-        return GL_FALSE;
+       return GL_FALSE;
 
     pdp = pcp->driDrawablePriv;
     prp = pcp->driReadablePriv;
 
     /* already unbound */
     if (!pdp && !prp)
-      return GL_TRUE;
-    /* Let driver unbind drawable from context */
+       return GL_TRUE;
+
     driDriverAPI.UnbindContext(pcp);
 
     assert(pdp);
@@ -303,20 +301,20 @@ static int driUnbindContext(__DRIcontext *pcp)
     dri_put_drawable(pdp);
 
     if (prp != pdp) {
-        if (prp->refcount == 0) {
+       if (prp->refcount == 0) {
            /* ERROR!!! */
            return GL_FALSE;
        }
 
-       dri_put_drawable(prp);
+       dri_put_drawable(prp);
     }
 
-
     /* XXX this is disabled so that if we call SwapBuffers on an unbound
      * window we can determine the last context bound to the window and
      * use that context's lock. (BrianP, 2-Dec-2000)
      */
-    pcp->driDrawablePriv = pcp->driReadablePriv = NULL;
+    pcp->driDrawablePriv = NULL;
+    pcp->driReadablePriv = NULL;
 
     return GL_TRUE;
 }
@@ -331,15 +329,12 @@ static void dri_get_drawable(__DRIdrawable *pdp)
 
 static void dri_put_drawable(__DRIdrawable *pdp)
 {
-    __DRIscreen *psp;
-
     if (pdp) {
        pdp->refcount--;
        if (pdp->refcount)
            return;
 
-       psp = pdp->driScreenPriv;
-        driDriverAPI.DestroyBuffer(pdp);
+       driDriverAPI.DestroyBuffer(pdp);
        free(pdp);
     }
 }
@@ -347,7 +342,7 @@ static void dri_put_drawable(__DRIdrawable *pdp)
 static __DRIdrawable *
 dri2CreateNewDrawable(__DRIscreen *screen,
                      const __DRIconfig *config,
-                     void *loaderPrivate)
+                     void *data)
 {
     __DRIdrawable *pdraw;
 
@@ -355,15 +350,18 @@ dri2CreateNewDrawable(__DRIscreen *screen,
     if (!pdraw)
        return NULL;
 
+    pdraw->loaderPrivate = data;
+
+    pdraw->driScreenPriv = screen;
     pdraw->driContextPriv = NULL;
-    pdraw->loaderPrivate = loaderPrivate;
-    pdraw->refcount = 1;
+    pdraw->refcount = 0;
     pdraw->lastStamp = 0;
     pdraw->w = 0;
     pdraw->h = 0;
-    pdraw->driScreenPriv = screen;
 
-    if (!driDriverAPI.CreateBuffer(screen, pdraw, &config->modes, 0)) {
+    dri_get_drawable(pdraw);
+
+    if (!driDriverAPI.CreateBuffer(screen, pdraw, &config->modes, GL_FALSE)) {
        free(pdraw);
        return NULL;
     }
@@ -391,7 +389,7 @@ dri2AllocateBuffer(__DRIscreen *screen,
 static void
 dri2ReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer)
 {
-   driDriverAPI.ReleaseBuffer(screen, buffer);
+    driDriverAPI.ReleaseBuffer(screen, buffer);
 }
 
 
index b720750eac9a419c672020793c2acf7c050f23d6..614339eeb422a7347eae8346fed77be01a60b633 100644 (file)
@@ -54,20 +54,19 @@ driCreateNewScreen(int scrn, const __DRIextension **extensions,
     static const __DRIextension *emptyExtensionList[] = { NULL };
     __DRIscreen *psp;
 
-    (void) data;
-
     psp = CALLOC_STRUCT(__DRIscreenRec);
     if (!psp)
        return NULL;
 
     setupLoaderExtensions(psp, extensions);
 
+    psp->loaderPrivate = data;
+
     psp->extensions = emptyExtensionList;
     psp->fd = -1;
     psp->myNum = scrn;
 
     *driver_configs = driDriverAPI.InitScreen(psp);
-
     if (*driver_configs == NULL) {
        FREE(psp);
        return NULL;
@@ -80,7 +79,6 @@ static void driDestroyScreen(__DRIscreen *psp)
 {
     if (psp) {
        driDriverAPI.DestroyScreen(psp);
-
        FREE(psp);
     }
 }
@@ -95,38 +93,13 @@ static const __DRIextension **driGetExtensions(__DRIscreen *psp)
  * Context functions
  */
 
-static __DRIcontext *
-driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
-                   __DRIcontext *shared, void *data)
-{
-    __DRIcontext *pcp;
-    void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
-
-    pcp = CALLOC_STRUCT(__DRIcontextRec);
-    if (!pcp)
-       return NULL;
-
-    pcp->loaderPrivate = data;
-
-    pcp->driScreenPriv = psp;
-    pcp->driDrawablePriv = NULL;
-    pcp->driReadablePriv = NULL;
-
-    if (!driDriverAPI.CreateContext(API_OPENGL,
-                           &config->modes, pcp, shareCtx)) {
-       FREE(pcp);
-       return NULL;
-    }
-
-    return pcp;
-}
-
 static __DRIcontext *
 driCreateNewContextForAPI(__DRIscreen *psp, int api,
                           const __DRIconfig *config,
                           __DRIcontext *shared, void *data)
 {
     __DRIcontext *pcp;
+    const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
     void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
     gl_api mesa_api;
 
@@ -154,8 +127,7 @@ driCreateNewContextForAPI(__DRIscreen *psp, int api,
     pcp->driDrawablePriv = NULL;
     pcp->driReadablePriv = NULL;
 
-    if (!driDriverAPI.CreateContext(mesa_api,
-                            &config->modes, pcp, shareCtx)) {
+    if (!driDriverAPI.CreateContext(mesa_api, modes, pcp, shareCtx)) {
         FREE(pcp);
         return NULL;
     }
@@ -163,6 +135,14 @@ driCreateNewContextForAPI(__DRIscreen *psp, int api,
     return pcp;
 }
 
+static __DRIcontext *
+driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
+                   __DRIcontext *shared, void *data)
+{
+    return driCreateNewContextForAPI(psp, __DRI_API_OPENGL,
+                                    config, shared, data);
+}
+
 static void
 driDestroyContext(__DRIcontext *pcp)
 {
@@ -193,7 +173,7 @@ static int driBindContext(__DRIcontext *pcp,
            pdp->driContextPriv = pcp;
            dri_get_drawable(pdp);
        }
-       if ( prp && pdp != prp ) {
+       if (prp && pdp != prp) {
            dri_get_drawable(prp);
        }
     }
@@ -248,7 +228,6 @@ static void dri_put_drawable(__DRIdrawable *pdp)
            return;
 
        driDriverAPI.DestroyBuffer(pdp);
-
        FREE(pdp);
     }
 }