X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglx%2Fapplegl_glx.c;h=c086e5146a84f1f3d2ad77d1ba772c89e19fb11a;hb=7f80a9ff1312406dcffae88bf6dcaaf99ca9e3a1;hp=3da1f19323fe438ccec0f4e9fa583591fcf6ba4b;hpb=3e54d63429fe7ca5db3c75c181abbaf7a7f55724;p=mesa.git diff --git a/src/glx/applegl_glx.c b/src/glx/applegl_glx.c index 3da1f19323f..c086e5146a8 100644 --- a/src/glx/applegl_glx.c +++ b/src/glx/applegl_glx.c @@ -1,5 +1,6 @@ /* * Copyright © 2010 Intel Corporation + * Copyright © 2011 Apple Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Soft- @@ -32,23 +33,35 @@ #if defined(GLX_USE_APPLEGL) +#include +#include + +#include "glxclient.h" +#include "apple/apple_glx_context.h" +#include "apple/apple_glx.h" +#include "apple/apple_cgl.h" +#include "glx_error.h" + static void applegl_destroy_context(struct glx_context *gc) { - apple_glx_destroy_context(&gc->driContext, gc->currentDpy); + apple_glx_destroy_context(&gc->driContext, gc->psc->dpy); } static int applegl_bind_context(struct glx_context *gc, struct glx_context *old, GLXDrawable draw, GLXDrawable read) { + Display *dpy = gc->psc->dpy; bool error = apple_glx_make_current_context(dpy, - (oldGC && oldGC != &dummyContext) ? oldGC->driContext : NUL~ + (old && old != &dummyContext) ? old->driContext : NULL, gc ? gc->driContext : NULL, draw); apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO"); if (error) - return GLXBadContext; + return 1; /* GLXBadContext is the same as Success (0) */ + + apple_glapi_set_dispatch(); return Success; } @@ -56,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 @@ -67,48 +98,56 @@ applegl_wait_gl(struct glx_context *gc) static void applegl_wait_x(struct glx_context *gc) { - apple_glx_waitx(gc->dpy, gc->driContext); + Display *dpy = gc->psc->dpy; + apple_glx_waitx(dpy, gc->driContext); +} + +static void * +applegl_get_proc_address(const char *symbol) +{ + return dlsym(apple_cgl_get_dl_handle(), 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, */ + .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, }; -static struct glx_context * +struct glx_context * applegl_create_context(struct glx_screen *psc, - struct glx_config *mode, + struct glx_config *config, struct glx_context *shareList, int renderType) { struct glx_context *gc; int errorcode; bool x11error; + Display *dpy = psc->dpy; + int screen = psc->scr; /* TODO: Integrate this with apple_glx_create_context and make * struct apple_glx_context inherit from struct glx_context. */ - gc = Xmalloc(sizeof *gc); - if (pcp == NULL) + gc = calloc(1, sizeof(*gc)); + if (gc == NULL) return NULL; - memset(gc, 0, sizeof *gc); - if (!glx_context_init(&gc->base, &psc->base, mode)) { - Xfree(gc); + if (!glx_context_init(gc, psc, config)) { + free(gc); return NULL; } gc->vtable = &applegl_context_vtable; gc->driContext = NULL; - gc->do_destroy = False; /* TODO: darwin: Integrate with above to do indirect */ - if(apple_glx_create_context(&gc->driContext, dpy, screen, fbconfig, + if(apple_glx_create_context(&gc->driContext, dpy, screen, config, shareList ? shareList->driContext : NULL, &errorcode, &x11error)) { __glXSendError(dpy, errorcode, 0, X_GLXCreateContext, x11error); @@ -117,16 +156,19 @@ applegl_create_context(struct glx_screen *psc, } gc->currentContextTag = -1; - gc->mode = fbconfig; - gc->isDirect = allowDirect; + gc->config = config; + gc->isDirect = GL_TRUE; gc->xid = 1; /* Just something not None, so we know when to destroy * it in MakeContextCurrent. */ return gc; } -struct glx_screen_vtable appegl_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 * @@ -134,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; @@ -146,10 +187,12 @@ applegl_create_screen(int screen, struct glx_display * priv) } _X_HIDDEN int -applegl_create_display(struct glx_display *display) +applegl_create_display(struct glx_display *glx_dpy) { - /* create applegl display and stuff in display->appleglDisplay */ - apple_init_glx(display); + if(!apple_init_glx(glx_dpy->dpy)) + return 1; + + return GLXBadContext; } #endif