Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / glx / dri2.c
index 21b9c21a85cf218d9d93b44bf480efe29f0d16c8..f00b96525aad1c6942ea8ebbfe768a456694260a 100644 (file)
@@ -38,7 +38,6 @@
 #include <X11/extensions/Xext.h>
 #include <X11/extensions/extutil.h>
 #include <X11/extensions/dri2proto.h>
-#include "xf86drm.h"
 #include "dri2.h"
 #include "glxclient.h"
 #include "GL/glxext.h"
@@ -54,7 +53,8 @@
 
 
 static char dri2ExtensionName[] = DRI2_NAME;
-static XExtensionInfo *dri2Info;
+static XExtensionInfo _dri2Info_data;
+static XExtensionInfo *dri2Info = &_dri2Info_data;
 static XEXT_GENERATE_CLOSE_DISPLAY (DRI2CloseDisplay, dri2Info)
 
 static Bool
@@ -94,7 +94,6 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
 
    switch ((wire->u.u.type & 0x7f) - info->codes->first_event) {
 
-#ifdef X_DRI2SwapBuffers
    case DRI2_BufferSwapComplete:
    {
       GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
@@ -102,6 +101,8 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
       __GLXDRIdrawable *pdraw;
 
       pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, awire->drawable);
+      if (pdraw == NULL)
+         return False;
 
       /* Ignore swap events if we're not looking for them */
       aevent->type = dri2GetSwapEventType(dpy, awire->drawable);
@@ -130,15 +131,17 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
       aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
 
       glxDraw = GetGLXDrawable(dpy, pdraw->drawable);
-      if (awire->sbc < glxDraw->lastEventSbc)
-        glxDraw->eventSbcWrap += 0x100000000;
-      glxDraw->lastEventSbc = awire->sbc;
-      aevent->sbc = awire->sbc + glxDraw->eventSbcWrap;
+      if (glxDraw != NULL) {
+         if (awire->sbc < glxDraw->lastEventSbc)
+            glxDraw->eventSbcWrap += 0x100000000;
+         glxDraw->lastEventSbc = awire->sbc;
+         aevent->sbc = awire->sbc + glxDraw->eventSbcWrap;
+      } else {
+         aevent->sbc = awire->sbc;
+      }
 
       return True;
    }
-#endif
-#ifdef DRI2_InvalidateBuffers
    case DRI2_InvalidateBuffers:
    {
       xDRI2InvalidateBuffers *awire = (xDRI2InvalidateBuffers *)wire;
@@ -146,7 +149,6 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
       dri2InvalidateBuffers(dpy, awire->drawable);
       return False;
    }
-#endif
    default:
       /* client doesn't support server event */
       break;
@@ -279,7 +281,6 @@ DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
    req->window = window;
 
    req->driverType = DRI2DriverDRI;
-#ifdef DRI2DriverPrimeShift
    {
       char *prime = getenv("DRI_PRIME");
       if (prime) {
@@ -291,7 +292,6 @@ DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
                ((primeid & DRI2DriverPrimeMask) << DRI2DriverPrimeShift);
       }
    }
-#endif
 
    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
       UnlockDisplay(dpy);
@@ -541,146 +541,4 @@ DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region,
    SyncHandle();
 }
 
-#ifdef X_DRI2SwapBuffers
-static void
-load_swap_req(xDRI2SwapBuffersReq *req, CARD64 target, CARD64 divisor,
-            CARD64 remainder)
-{
-    req->target_msc_hi = target >> 32;
-    req->target_msc_lo = target & 0xffffffff;
-    req->divisor_hi = divisor >> 32;
-    req->divisor_lo = divisor & 0xffffffff;
-    req->remainder_hi = remainder >> 32;
-    req->remainder_lo = remainder & 0xffffffff;
-}
-
-static CARD64
-vals_to_card64(CARD32 lo, CARD32 hi)
-{
-    return (CARD64)hi << 32 | lo;
-}
-
-void DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc,
-                    CARD64 divisor, CARD64 remainder, CARD64 *count)
-{
-    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
-    xDRI2SwapBuffersReq *req;
-    xDRI2SwapBuffersReply rep;
-
-    XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
-
-    LockDisplay(dpy);
-    GetReq(DRI2SwapBuffers, req);
-    req->reqType = info->codes->major_opcode;
-    req->dri2ReqType = X_DRI2SwapBuffers;
-    req->drawable = drawable;
-    load_swap_req(req, target_msc, divisor, remainder);
-
-    _XReply(dpy, (xReply *)&rep, 0, xFalse);
-
-    *count = vals_to_card64(rep.swap_lo, rep.swap_hi);
-
-    UnlockDisplay(dpy);
-    SyncHandle();
-}
-#endif
-
-#ifdef X_DRI2GetMSC
-Bool DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc,
-               CARD64 *sbc)
-{
-    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
-    xDRI2GetMSCReq *req;
-    xDRI2MSCReply rep;
-
-    XextCheckExtension (dpy, info, dri2ExtensionName, False);
-
-    LockDisplay(dpy);
-    GetReq(DRI2GetMSC, req);
-    req->reqType = info->codes->major_opcode;
-    req->dri2ReqType = X_DRI2GetMSC;
-    req->drawable = drawable;
-
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-       UnlockDisplay(dpy);
-       SyncHandle();
-       return False;
-    }
-
-    *ust = vals_to_card64(rep.ust_lo, rep.ust_hi);
-    *msc = vals_to_card64(rep.msc_lo, rep.msc_hi);
-    *sbc = vals_to_card64(rep.sbc_lo, rep.sbc_hi);
-
-    UnlockDisplay(dpy);
-    SyncHandle();
-
-    return True;
-}
-#endif
-
-#ifdef X_DRI2WaitMSC
-static void
-load_msc_req(xDRI2WaitMSCReq *req, CARD64 target, CARD64 divisor,
-            CARD64 remainder)
-{
-    req->target_msc_hi = target >> 32;
-    req->target_msc_lo = target & 0xffffffff;
-    req->divisor_hi = divisor >> 32;
-    req->divisor_lo = divisor & 0xffffffff;
-    req->remainder_hi = remainder >> 32;
-    req->remainder_lo = remainder & 0xffffffff;
-}
-
-Bool DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
-                CARD64 remainder, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
-{
-    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
-    xDRI2WaitMSCReq *req;
-    xDRI2MSCReply rep;
-
-    XextCheckExtension (dpy, info, dri2ExtensionName, False);
-
-    LockDisplay(dpy);
-    GetReq(DRI2WaitMSC, req);
-    req->reqType = info->codes->major_opcode;
-    req->dri2ReqType = X_DRI2WaitMSC;
-    req->drawable = drawable;
-    load_msc_req(req, target_msc, divisor, remainder);
-
-    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
-       UnlockDisplay(dpy);
-       SyncHandle();
-       return False;
-    }
-
-    *ust = ((CARD64)rep.ust_hi << 32) | (CARD64)rep.ust_lo;
-    *msc = ((CARD64)rep.msc_hi << 32) | (CARD64)rep.msc_lo;
-    *sbc = ((CARD64)rep.sbc_hi << 32) | (CARD64)rep.sbc_lo;
-
-    UnlockDisplay(dpy);
-    SyncHandle();
-
-    return True;
-}
-#endif
-
-#ifdef X_DRI2SwapInterval
-void DRI2SwapInterval(Display *dpy, XID drawable, int interval)
-{
-    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
-    xDRI2SwapIntervalReq *req;
-
-    XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
-
-    LockDisplay(dpy);
-    GetReq(DRI2SwapInterval, req);
-    req->reqType = info->codes->major_opcode;
-    req->dri2ReqType = X_DRI2SwapInterval;
-    req->drawable = drawable;
-    req->interval = interval;
-    UnlockDisplay(dpy);
-    SyncHandle();
-}
-#endif
-
 #endif /* GLX_DIRECT_RENDERING */