dri_util: Assume error checking is done properly in glXMakeCurrent
[mesa.git] / src / mesa / drivers / dri / common / dri_util.c
index 11c189a6600c388b5a8dda7d67008fadb8b08288..d2ffa5da6427ee11cf40d75168abd0c570d65835 100644 (file)
@@ -153,19 +153,24 @@ static int driBindContext(__DRIcontext *pcp,
 {
     __DRIscreen *psp = NULL;
 
-    /* Bind the drawable to the context */
+    /*
+    ** Assume error checking is done properly in glXMakeCurrent before
+    ** calling driUnbindContext.
+    */
 
-    if (pcp) {
-       psp = pcp->driScreenPriv;
-       pcp->driDrawablePriv = pdp;
-       pcp->driReadablePriv = prp;
-       if (pdp) {
-           pdp->driContextPriv = pcp;
-           dri_get_drawable(pdp);
-       }
-       if ( prp && pdp != prp ) {
-           dri_get_drawable(prp);
-       }
+    if (!pcp)
+       return GL_FALSE;
+
+    /* Bind the drawable to the context */
+    psp = pcp->driScreenPriv;
+    pcp->driDrawablePriv = pdp;
+    pcp->driReadablePriv = prp;
+    if (pdp) {
+       pdp->driContextPriv = pcp;
+       dri_get_drawable(pdp);
+    }
+    if (prp && pdp != prp) {
+       dri_get_drawable(prp);
     }
 
     /*
@@ -173,7 +178,6 @@ static int driBindContext(__DRIcontext *pcp,
     ** initialize the drawable information if has not been done before.
     */
 
-    assert(psp);
     if (!psp->dri2.enabled) {
        if (pdp && !pdp->pStamp) {
            DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
@@ -188,7 +192,6 @@ static int driBindContext(__DRIcontext *pcp,
     }
 
     /* Call device-specific MakeCurrent */
-
     return (*psp->DriverAPI.MakeCurrent)(pcp, pdp, prp);
 }