Merge git://proxy01.pd.intel.com:9419/git/mesa/mesa into crestline
[mesa.git] / src / glx / x11 / glx_pbuffer.c
index afdf710790867f663bb7892650cae4006ca81a68..472045e93d812d5f41056a89ec9296da2c05076f 100644 (file)
@@ -72,12 +72,15 @@ ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
 {
    __GLXdisplayPrivate *priv = __glXInitialize(dpy);
    CARD32 * output;
-
+   CARD8 opcode;
 
    if ( (dpy == NULL) || (drawable == 0) ) {
       return;
    }
 
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode)
+      return;
 
    LockDisplay(dpy);
 
@@ -87,7 +90,7 @@ ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
       GetReqExtra( GLXChangeDrawableAttributes, 8 + (8 * num_attribs), req );
       output = (CARD32 *) (req + 1);
 
-      req->reqType = __glXSetupForCommand(dpy);
+      req->reqType = opcode;
       req->glxCode = X_GLXChangeDrawableAttributes;
       req->drawable = drawable;
       req->numAttribs = (CARD32) num_attribs;
@@ -98,7 +101,7 @@ ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
       GetReqExtra( GLXVendorPrivateWithReply, 4 + (8 * num_attribs), vpreq );
       output = (CARD32 *) (vpreq + 1);
 
-      vpreq->reqType = __glXSetupForCommand(dpy);
+      vpreq->reqType = opcode;
       vpreq->glxCode = X_GLXVendorPrivateWithReply;
       vpreq->vendorCode = X_GLXvop_ChangeDrawableAttributesSGIX;
 
@@ -132,11 +135,15 @@ static void
 DestroyPbuffer( Display * dpy, GLXDrawable drawable )
 {
    __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+   CARD8 opcode;
 
    if ( (dpy == NULL) || (drawable == 0) ) {
       return;
    }
 
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode)
+      return;
 
    LockDisplay(dpy);
 
@@ -144,7 +151,7 @@ DestroyPbuffer( Display * dpy, GLXDrawable drawable )
       xGLXDestroyPbufferReq * req;
 
       GetReqExtra( GLXDestroyPbuffer, 4, req );
-      req->reqType = __glXSetupForCommand(dpy);
+      req->reqType = opcode;
       req->glxCode = X_GLXDestroyPbuffer;
       req->pbuffer = (GLXPbuffer) drawable;
    }
@@ -157,7 +164,7 @@ DestroyPbuffer( Display * dpy, GLXDrawable drawable )
 
       data[0] = (CARD32) drawable;
 
-      vpreq->reqType = __glXSetupForCommand(dpy);
+      vpreq->reqType = opcode;
       vpreq->glxCode = X_GLXVendorPrivateWithReply;
       vpreq->vendorCode = X_GLXvop_DestroyGLXPbufferSGIX;
    }
@@ -191,29 +198,36 @@ static int
 GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
                      int attribute, unsigned int *value )
 {
-   __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+   __GLXdisplayPrivate *priv;
    xGLXGetDrawableAttributesReply reply;
    CARD32 * data;
+   CARD8 opcode;
    unsigned int length;
    unsigned int i;
    unsigned int num_attributes;
+
+   if ( (dpy == NULL) || (drawable == 0) ) {
+      return 0;
+   }
+
+   priv = __glXInitialize(dpy);
    GLboolean use_glx_1_3 = ((priv->majorVersion > 1)
                            || (priv->minorVersion >= 3));
 
    *value = 0;
 
-   if ( (dpy == NULL) || (drawable == 0) ) {
+
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode)
       return 0;
-   }
 
-   
    LockDisplay(dpy);
 
    if ( use_glx_1_3 ) {
       xGLXGetDrawableAttributesReq *req;
 
       GetReqExtra( GLXGetDrawableAttributes, 4, req );
-      req->reqType = __glXSetupForCommand(dpy);
+      req->reqType = opcode;
       req->glxCode = X_GLXGetDrawableAttributes;
       req->drawable = drawable;
    }
@@ -224,7 +238,7 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
       data = (CARD32 *) (vpreq + 1);
       data[0] = (CARD32) drawable;
 
-      vpreq->reqType = __glXSetupForCommand(dpy);
+      vpreq->reqType = opcode;
       vpreq->glxCode = X_GLXVendorPrivateWithReply;
       vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX;
    }
@@ -284,6 +298,7 @@ CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
    xGLXCreateWindowReq * req;
    CARD32 * data;
    unsigned int i;
+   CARD8 opcode;
 
    i = 0;
    if (attrib_list) {
@@ -291,11 +306,15 @@ CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
           i++;
    }
 
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode)
+      return None;
+
    LockDisplay(dpy);
    GetReqExtra( GLXCreateWindow, 8 * i, req );
    data = (CARD32 *) (req + 1);
 
-   req->reqType = __glXSetupForCommand(dpy);
+   req->reqType = opcode;
    req->glxCode = glxCode;
    req->screen = (CARD32) fbconfig->screen;
    req->fbconfig = fbconfig->fbconfigID;
@@ -322,16 +341,21 @@ static void
 DestroyDrawable( Display * dpy, GLXDrawable drawable, CARD32 glxCode )
 {
    xGLXDestroyPbufferReq * req;
+   CARD8 opcode;
 
    if ( (dpy == NULL) || (drawable == 0) ) {
       return;
    }
 
 
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode)
+      return;
+
    LockDisplay(dpy);
 
    GetReqExtra( GLXDestroyPbuffer, 4, req );
-   req->reqType = __glXSetupForCommand(dpy);
+   req->reqType = opcode;
    req->glxCode = glxCode;
    req->pbuffer = (GLXPbuffer) drawable;
 
@@ -363,6 +387,7 @@ CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
    __GLXdisplayPrivate *priv = __glXInitialize(dpy);
    GLXDrawable id = 0;
    CARD32 * data;
+   CARD8 opcode;
    unsigned int  i;
 
    i = 0;
@@ -371,6 +396,10 @@ CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
           i++;
    }
 
+   opcode = __glXSetupForCommand(dpy);
+   if (!opcode)
+      return None;
+
    LockDisplay(dpy);
    id = XAllocID(dpy);
 
@@ -381,7 +410,7 @@ CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
       GetReqExtra( GLXCreatePbuffer, (8 * (i + extra)), req );
       data = (CARD32 *) (req + 1);
 
-      req->reqType = __glXSetupForCommand(dpy);
+      req->reqType = opcode;
       req->glxCode = X_GLXCreatePbuffer;
       req->screen = (CARD32) fbconfig->screen;
       req->fbconfig = fbconfig->fbconfigID;
@@ -402,7 +431,7 @@ CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
       GetReqExtra( GLXVendorPrivate, 20 + (8 * i), vpreq );
       data = (CARD32 *) (vpreq + 1);
 
-      vpreq->reqType = __glXSetupForCommand(dpy);
+      vpreq->reqType = opcode;
       vpreq->glxCode = X_GLXVendorPrivate;
       vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX;