Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / glx / applegl_glx.c
index 8766c88a136ac1ddab7af5c6bed8645a31dc4fca..c086e5146a84f1f3d2ad77d1ba772c89e19fb11a 100644 (file)
@@ -37,9 +37,9 @@
 #include <dlfcn.h>
 
 #include "glxclient.h"
-#include "apple_glx_context.h"
-#include "apple_glx.h"
-#include "apple_cgl.h"
+#include "apple/apple_glx_context.h"
+#include "apple/apple_glx.h"
+#include "apple/apple_cgl.h"
 #include "glx_error.h"
 
 static void
@@ -69,6 +69,24 @@ applegl_bind_context(struct glx_context *gc, struct glx_context *old,
 static void
 applegl_unbind_context(struct glx_context *gc, struct glx_context *new)
 {
+   Display *dpy;
+   bool error;
+
+   /* If we don't have a context, then we have nothing to unbind */
+   if (!gc)
+      return;
+
+   /* If we have a new context, keep this one around and remove it during bind. */
+   if (new)
+      return;
+
+   dpy = gc->psc->dpy;
+
+   error = apple_glx_make_current_context(dpy,
+                                         (gc != &dummyContext) ? gc->driContext : NULL,
+                                         NULL, None);
+
+   apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO");
 }
 
 static void
@@ -91,15 +109,15 @@ applegl_get_proc_address(const char *symbol)
 }
 
 static const struct glx_context_vtable applegl_context_vtable = {
-   applegl_destroy_context,
-   applegl_bind_context,
-   applegl_unbind_context,
-   applegl_wait_gl,
-   applegl_wait_x,
-   DRI_glXUseXFont,
-   NULL, /* bind_tex_image, */
-   NULL, /* release_tex_image, */
-   applegl_get_proc_address,
+   .destroy             = applegl_destroy_context,
+   .bind                = applegl_bind_context,
+   .unbind              = applegl_unbind_context,
+   .wait_gl             = applegl_wait_gl,
+   .wait_x              = applegl_wait_x,
+   .use_x_font          = DRI_glXUseXFont,
+   .bind_tex_image      = NULL,
+   .release_tex_image   = NULL,
+   .get_proc_address    = applegl_get_proc_address,
 };
 
 struct glx_context *
@@ -116,12 +134,12 @@ applegl_create_context(struct glx_screen *psc,
    /* TODO: Integrate this with apple_glx_create_context and make
     * struct apple_glx_context inherit from struct glx_context. */
 
-   gc = Xcalloc(1, sizeof (*gc));
+   gc = calloc(1, sizeof(*gc));
    if (gc == NULL)
       return NULL;
 
    if (!glx_context_init(gc, psc, config)) {
-      Xfree(gc);
+      free(gc);
       return NULL;
    }
 
@@ -146,8 +164,11 @@ applegl_create_context(struct glx_screen *psc,
    return gc;
 }
 
-struct glx_screen_vtable applegl_screen_vtable = {
-   applegl_create_context
+static const struct glx_screen_vtable applegl_screen_vtable = {
+   .create_context         = applegl_create_context,
+   .create_context_attribs = NULL,
+   .query_renderer_integer = NULL,
+   .query_renderer_string  = NULL,
 };
 
 _X_HIDDEN struct glx_screen *
@@ -155,11 +176,10 @@ applegl_create_screen(int screen, struct glx_display * priv)
 {
    struct glx_screen *psc;
 
-   psc = Xmalloc(sizeof *psc);
+   psc = calloc(1, sizeof *psc);
    if (psc == NULL)
       return NULL;
 
-   memset(psc, 0, sizeof *psc);
    glx_screen_init(psc, screen, priv);
    psc->vtable = &applegl_screen_vtable;