summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorGeorge Sapountzis <[email protected]>2011-11-04 16:35:49 +0200
committerGeorge Sapountzis <[email protected]>2011-11-04 23:33:06 +0200
commitcd86a5d2f862f183f85ef8c7d51f69e028d04447 (patch)
tree548ba824ad298407a41f2a15f5d85b569d11bcfc /src/mesa/drivers
parent2fbba6bb906a4389de64cc6e961b531d8cd5c495 (diff)
dri: cosmetic
To smooth minor diff between dri_util & drisw_util
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/common/dri_util.c60
-rw-r--r--src/mesa/drivers/dri/common/drisw_util.c47
2 files changed, 42 insertions, 65 deletions
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index c69fdce4405..1640c14480d 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -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);
}
diff --git a/src/mesa/drivers/dri/common/drisw_util.c b/src/mesa/drivers/dri/common/drisw_util.c
index b720750eac9..614339eeb42 100644
--- a/src/mesa/drivers/dri/common/drisw_util.c
+++ b/src/mesa/drivers/dri/common/drisw_util.c
@@ -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);
}
}
@@ -96,37 +94,12 @@ static const __DRIextension **driGetExtensions(__DRIscreen *psp)
*/
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);
}
}