diff options
author | marha <marha@users.sourceforge.net> | 2011-04-28 07:58:00 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-04-28 07:58:00 +0000 |
commit | 57a879849643e79d9674198a3a77c59532fb79b4 (patch) | |
tree | 19ece2254fadb6c2077aa09098dd8a51a5578d2a /xorg-server/hw/xquartz | |
parent | 96d6df5da9cddedf4931bf8e17f96e242467c661 (diff) | |
download | vcxsrv-57a879849643e79d9674198a3a77c59532fb79b4.tar.gz vcxsrv-57a879849643e79d9674198a3a77c59532fb79b4.tar.bz2 vcxsrv-57a879849643e79d9674198a3a77c59532fb79b4.zip |
xserver xkeyboard-config mesa git update 28 Apr 2011
Diffstat (limited to 'xorg-server/hw/xquartz')
32 files changed, 3368 insertions, 3533 deletions
diff --git a/xorg-server/hw/xquartz/GL/capabilities.c b/xorg-server/hw/xquartz/GL/capabilities.c index fc7dd57dd..dd3f855f4 100644 --- a/xorg-server/hw/xquartz/GL/capabilities.c +++ b/xorg-server/hw/xquartz/GL/capabilities.c @@ -507,7 +507,7 @@ bool getGlCapabilities(struct glCapabilities *cap) { err = CGLQueryRendererInfo((GLuint)-1, &info, &numRenderers); if(err) { - fprintf(stderr, "CGLQueryRendererInfo error: %s\n", CGLErrorString(err)); + ErrorF("CGLQueryRendererInfo error: %s\n", CGLErrorString(err)); return err; } @@ -518,8 +518,8 @@ bool getGlCapabilities(struct glCapabilities *cap) { err = handleRendererDescriptions(info, r, &tmpconf); if(err) { - fprintf(stderr, "handleRendererDescriptions returned error: %s\n", CGLErrorString(err)); - fprintf(stderr, "trying to continue...\n"); + ErrorF("handleRendererDescriptions returned error: %s\n", CGLErrorString(err)); + ErrorF("trying to continue...\n"); continue; } diff --git a/xorg-server/hw/xquartz/GL/indirect.c b/xorg-server/hw/xquartz/GL/indirect.c index b7ee109ed..6da27c78a 100644 --- a/xorg-server/hw/xquartz/GL/indirect.c +++ b/xorg-server/hw/xquartz/GL/indirect.c @@ -1,1614 +1,1613 @@ -/*
- * GLX implementation that uses Apple's OpenGL.framework
- * (Indirect rendering path -- it's also used for some direct mode code too)
- *
- * Copyright (c) 2007, 2008, 2009 Apple Inc.
- * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
- * Copyright (c) 2002 Greg Parker. All Rights Reserved.
- *
- * Portions of this file are copied from Mesa's xf86glx.c,
- * which contains the following copyright:
- *
- * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "dri.h"
-
-#include <AvailabilityMacros.h>
-
-#define GL_GLEXT_WUNDEF_SUPPORT
-
-#include <OpenGL/OpenGL.h>
-#include <OpenGL/gl.h>
-#include <OpenGL/glext.h>
-#include <OpenGL/CGLContext.h>
-
-/* These next few GL_EXT pre-processing blocks are to explicitly define
- * these symbols to 0 if they are not set by OpenGL.framework. This
- * prevents the X11 glext.h from setting them to 1.
- */
-
-#ifndef GL_EXT_fragment_shader
-#define GL_EXT_fragment_shader 0
-#endif
-
-#ifndef GL_EXT_blend_equation_separate
-#define GL_EXT_blend_equation_separate 0
-#endif
-
-#ifndef GL_EXT_blend_func_separate
-#define GL_EXT_blend_func_separate 0
-#endif
-
-#ifndef GL_EXT_depth_bounds_test
-#define GL_EXT_depth_bounds_test 0
-#endif
-
-#ifndef GL_EXT_compiled_vertex_array
-#define GL_EXT_compiled_vertex_array 0
-#endif
-
-#ifndef GL_EXT_cull_vertex
-#define GL_EXT_cull_vertex 0
-#endif
-
-#ifndef GL_EXT_fog_coord
-#define GL_EXT_fog_coord 0
-#endif
-
-#ifndef GL_EXT_framebuffer_blit
-#define GL_EXT_framebuffer_blit 0
-#endif
-
-#ifndef GL_EXT_framebuffer_object
-#define GL_EXT_framebuffer_object 0
-#endif
-
-#ifndef GL_EXT_gpu_program_parameters
-#define GL_EXT_gpu_program_parameters 0
-#endif
-
-#ifndef GL_EXT_multi_draw_arrays
-#define GL_EXT_multi_draw_arrays 0
-#endif
-
-#ifndef GL_EXT_point_parameters
-#define GL_EXT_point_parameters 0
-#endif
-
-#ifndef GL_EXT_polygon_offset
-#define GL_EXT_polygon_offset 0
-#endif
-
-#ifndef GL_EXT_secondary_color
-#define GL_EXT_secondary_color 0
-#endif
-
-#ifndef GL_EXT_stencil_two_side
-#define GL_EXT_stencil_two_side 0
-#endif
-
-#ifndef GL_EXT_timer_query
-#define GL_EXT_timer_query 0
-#endif
-
-#ifndef GL_EXT_vertex_array
-#define GL_EXT_vertex_array 0
-#endif
-
-/* Tiger PPC doesn't have the associated symbols, but glext.h says it does. Liars!
- * http://trac.macports.org/ticket/20638
- */
-#if defined(__ppc__) && MAC_OS_X_VERSION_MIN_REQUIRED < 1050
-#undef GL_EXT_gpu_program_parameters
-#define GL_EXT_gpu_program_parameters 0
-#endif
-
-#include <GL/glxproto.h>
-#include <windowstr.h>
-#include <resource.h>
-#include <GL/glxint.h>
-#include <GL/glxtokens.h>
-#include <scrnintstr.h>
-#include <glxserver.h>
-#include <glxscreens.h>
-#include <glxdrawable.h>
-#include <glxcontext.h>
-#include <glxext.h>
-#include <glxutil.h>
-#include <glxscreens.h>
-#include <GL/internal/glcore.h>
-#include "x-hash.h"
-#include "x-list.h"
-
-//#include "capabilities.h"
-#include "visualConfigs.h"
-
-typedef unsigned long long GLuint64EXT;
-typedef long long GLint64EXT;
-#include <dispatch.h>
-#include <Xplugin.h>
-#include <glapi.h>
-#include <glapitable.h>
-
-__GLXprovider * GlxGetDRISWrastProvider (void);
-
-// Write debugging output, or not
-#ifdef GLAQUA_DEBUG
-#define GLAQUA_DEBUG_MSG ErrorF
-#else
-#define GLAQUA_DEBUG_MSG(a, ...)
-#endif
-
-static void setup_dispatch_table(void);
-GLuint __glFloorLog2(GLuint val);
-void warn_func(void * p1, char *format, ...);
-
-// some prototypes
-static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen);
-static __GLXdrawable * __glXAquaScreenCreateDrawable(ClientPtr client, __GLXscreen *screen, DrawablePtr pDraw, XID drawId, int type, XID glxDrawId, __GLXconfig *conf);
-
-static void __glXAquaContextDestroy(__GLXcontext *baseContext);
-static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext);
-static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext);
-static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask);
-
-static CGLPixelFormatObj makeFormat(__GLXconfig *conf);
-
-__GLXprovider __glXDRISWRastProvider = {
- __glXAquaScreenProbe,
- "Core OpenGL",
- NULL
-};
-
-typedef struct __GLXAquaScreen __GLXAquaScreen;
-typedef struct __GLXAquaContext __GLXAquaContext;
-typedef struct __GLXAquaDrawable __GLXAquaDrawable;
-
-struct __GLXAquaScreen {
- __GLXscreen base;
- int index;
- int num_vis;
-};
-
-struct __GLXAquaContext {
- __GLXcontext base;
- CGLContextObj ctx;
- CGLPixelFormatObj pixelFormat;
- xp_surface_id sid;
- unsigned isAttached :1;
-};
-
-struct __GLXAquaDrawable {
- __GLXdrawable base;
- DrawablePtr pDraw;
- xp_surface_id sid;
- __GLXAquaContext *context;
-};
-
-
-static __GLXcontext *
-__glXAquaScreenCreateContext(__GLXscreen *screen,
- __GLXconfig *conf,
- __GLXcontext *baseShareContext)
-{
- __GLXAquaContext *context;
- __GLXAquaContext *shareContext = (__GLXAquaContext *) baseShareContext;
- CGLError gl_err;
-
- GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n");
-
- context = calloc(1, sizeof (__GLXAquaContext));
-
- if (context == NULL)
- return NULL;
-
- memset(context, 0, sizeof *context);
-
- context->base.pGlxScreen = screen;
-
- context->base.destroy = __glXAquaContextDestroy;
- context->base.makeCurrent = __glXAquaContextMakeCurrent;
- context->base.loseCurrent = __glXAquaContextLoseCurrent;
- context->base.copy = __glXAquaContextCopy;
- /*FIXME verify that the context->base is fully initialized. */
-
- context->pixelFormat = makeFormat(conf);
-
- if (!context->pixelFormat) {
- free(context);
- return NULL;
- }
-
- context->ctx = NULL;
- gl_err = CGLCreateContext(context->pixelFormat,
- shareContext ? shareContext->ctx : NULL,
- &context->ctx);
-
- if (gl_err != 0) {
- ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err));
- CGLDestroyPixelFormat(context->pixelFormat);
- free(context);
- return NULL;
- }
-
- setup_dispatch_table();
- GLAQUA_DEBUG_MSG("glAquaCreateContext done\n");
-
- return &context->base;
-}
-
-/* maps from surface id -> list of __GLcontext */
-static x_hash_table *surface_hash;
-
-static void __glXAquaContextDestroy(__GLXcontext *baseContext) {
- x_list *lst;
-
- __GLXAquaContext *context = (__GLXAquaContext *) baseContext;
-
- GLAQUA_DEBUG_MSG("glAquaContextDestroy (ctx %p)\n", baseContext);
- if (context != NULL) {
- if (context->sid != 0 && surface_hash != NULL) {
- lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
- lst = x_list_remove(lst, context);
- x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
- }
-
- if (context->ctx != NULL)
- CGLDestroyContext(context->ctx);
-
- if (context->pixelFormat != NULL)
- CGLDestroyPixelFormat(context->pixelFormat);
-
- free(context);
- }
-}
-
-static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext) {
- CGLError gl_err;
-
- GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%p)\n", baseContext);
-
- gl_err = CGLSetCurrentContext(NULL);
- if (gl_err != 0)
- ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
-
- __glXLastContext = NULL; // Mesa does this; why?
-
- return GL_TRUE;
-}
-
-/* Called when a surface is destroyed as a side effect of destroying
- the window it's attached to. */
-static void surface_notify(void *_arg, void *data) {
- DRISurfaceNotifyArg *arg = (DRISurfaceNotifyArg *)_arg;
- __GLXAquaDrawable *draw = (__GLXAquaDrawable *)data;
- __GLXAquaContext *context;
- x_list *lst;
- if(_arg == NULL || data == NULL) {
- ErrorF("surface_notify called with bad params");
- return;
- }
-
- GLAQUA_DEBUG_MSG("surface_notify(%p, %p)\n", _arg, data);
- switch (arg->kind) {
- case AppleDRISurfaceNotifyDestroyed:
- if (surface_hash != NULL)
- x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(arg->id));
- draw->pDraw = NULL;
- draw->sid = 0;
- break;
-
- case AppleDRISurfaceNotifyChanged:
- if (surface_hash != NULL) {
- lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id), NULL);
- for (; lst != NULL; lst = lst->next)
- {
- context = lst->data;
- xp_update_gl_context(context->ctx);
- }
- }
- break;
- default:
- ErrorF("surface_notify: unknown kind %d\n", arg->kind);
- break;
- }
-}
-
-static BOOL attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) {
- DrawablePtr pDraw;
-
- GLAQUA_DEBUG_MSG("attach(%p, %p)\n", context, draw);
-
- if(NULL == context || NULL == draw)
- return TRUE;
-
- pDraw = draw->base.pDraw;
-
- if(NULL == pDraw) {
- ErrorF("%s:%s() pDraw is NULL!\n", __FILE__, __func__);
- return TRUE;
- }
-
- if (draw->sid == 0) {
- //if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw,
- if (!DRICreateSurface(pDraw->pScreen, pDraw->id, pDraw,
- 0, &draw->sid, NULL,
- surface_notify, draw))
- return TRUE;
- draw->pDraw = pDraw;
- }
-
- if (!context->isAttached || context->sid != draw->sid) {
- x_list *lst;
-
- if (xp_attach_gl_context(context->ctx, draw->sid) != Success) {
- //quartzProcs->DestroySurface(pDraw->pScreen, pDraw->id, pDraw,
- DRIDestroySurface(pDraw->pScreen, pDraw->id, pDraw,
- surface_notify, draw);
- if (surface_hash != NULL)
- x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(draw->sid));
-
- draw->sid = 0;
- return TRUE;
- }
-
- context->isAttached = TRUE;
- context->sid = draw->sid;
-
- if (surface_hash == NULL)
- surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
-
- lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
- if (x_list_find(lst, context) == NULL) {
- lst = x_list_prepend(lst, context);
- x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
- }
-
-
-
- GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id,
- (unsigned int) draw->sid);
- }
-
- draw->context = context;
-
- return FALSE;
-}
-
-#if 0 // unused
-static void unattach(__GLXAquaContext *context) {
- x_list *lst;
- GLAQUA_DEBUG_MSG("unattach\n");
- if (context == NULL) {
- ErrorF("Tried to unattach a null context\n");
- return;
- }
- if (context->isAttached) {
- GLAQUA_DEBUG_MSG("unattaching\n");
-
- if (surface_hash != NULL) {
- lst = x_hash_table_lookup(surface_hash, (void *) context->sid, NULL);
- lst = x_list_remove(lst, context);
- x_hash_table_insert(surface_hash, (void *) context->sid, lst);
- }
-
- CGLClearDrawable(context->ctx);
- context->isAttached = FALSE;
- context->sid = 0;
- }
-}
-#endif
-
-static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext) {
- CGLError gl_err;
- __GLXAquaContext *context = (__GLXAquaContext *) baseContext;
- __GLXAquaDrawable *drawPriv = (__GLXAquaDrawable *) context->base.drawPriv;
-
- GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%p)\n", baseContext);
-
- if(attach(context, drawPriv))
- return /*error*/ 0;
-
- gl_err = CGLSetCurrentContext(context->ctx);
- if (gl_err != 0)
- ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
-
- return gl_err == 0;
-}
-
-static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask)
-{
- CGLError gl_err;
-
- __GLXAquaContext *dst = (__GLXAquaContext *) baseDst;
- __GLXAquaContext *src = (__GLXAquaContext *) baseSrc;
-
- GLAQUA_DEBUG_MSG("GLXAquaContextCopy\n");
-
- gl_err = CGLCopyContext(src->ctx, dst->ctx, mask);
- if (gl_err != 0)
- ErrorF("CGLCopyContext error: %s\n", CGLErrorString(gl_err));
-
- return gl_err == 0;
-}
-
-/* Drawing surface notification callbacks */
-static GLboolean __glXAquaDrawableSwapBuffers(ClientPtr client, __GLXdrawable *base) {
- CGLError err;
- __GLXAquaDrawable *drawable;
-
- // GLAQUA_DEBUG_MSG("glAquaDrawableSwapBuffers(%p)\n",base);
-
- if(!base) {
- ErrorF("%s passed NULL\n", __func__);
- return GL_FALSE;
- }
-
- drawable = (__GLXAquaDrawable *)base;
-
- if(NULL == drawable->context) {
- ErrorF("%s called with a NULL->context for drawable %p!\n",
- __func__, (void *)drawable);
- return GL_FALSE;
- }
-
- err = CGLFlushDrawable(drawable->context->ctx);
-
- if(kCGLNoError != err) {
- ErrorF("CGLFlushDrawable error: %s in %s\n", CGLErrorString(err),
- __func__);
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-
-static CGLPixelFormatObj makeFormat(__GLXconfig *conf) {
- CGLPixelFormatAttribute attr[64];
- CGLPixelFormatObj fobj;
- GLint formats;
- CGLError error;
- int i = 0;
-
- if(conf->doubleBufferMode)
- attr[i++] = kCGLPFADoubleBuffer;
-
- if(conf->stereoMode)
- attr[i++] = kCGLPFAStereo;
-
- attr[i++] = kCGLPFAColorSize;
- attr[i++] = conf->redBits + conf->greenBits + conf->blueBits;
- attr[i++] = kCGLPFAAlphaSize;
- attr[i++] = conf->alphaBits;
-
- if((conf->accumRedBits + conf->accumGreenBits + conf->accumBlueBits +
- conf->accumAlphaBits) > 0) {
-
- attr[i++] = kCGLPFAAccumSize;
- attr[i++] = conf->accumRedBits + conf->accumGreenBits
- + conf->accumBlueBits + conf->accumAlphaBits;
- }
-
- attr[i++] = kCGLPFADepthSize;
- attr[i++] = conf->depthBits;
-
- if(conf->stencilBits) {
- attr[i++] = kCGLPFAStencilSize;
- attr[i++] = conf->stencilBits;
- }
-
- if(conf->numAuxBuffers > 0) {
- attr[i++] = kCGLPFAAuxBuffers;
- attr[i++] = conf->numAuxBuffers;
- }
-
- if(conf->sampleBuffers > 0) {
- attr[i++] = kCGLPFASampleBuffers;
- attr[i++] = conf->sampleBuffers;
- attr[i++] = kCGLPFASamples;
- attr[i++] = conf->samples;
- }
-
- attr[i] = 0;
-
- error = CGLChoosePixelFormat(attr, &fobj, &formats);
- if(error) {
- ErrorF("error: creating pixel format %s\n", CGLErrorString(error));
- return NULL;
- }
-
- return fobj;
-}
-
-static void __glXAquaScreenDestroy(__GLXscreen *screen) {
-
- GLAQUA_DEBUG_MSG("glXAquaScreenDestroy(%p)\n", screen);
- __glXScreenDestroy(screen);
-
- free(screen);
-}
-
-/* This is called by __glXInitScreens(). */
-static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
- __GLXAquaScreen *screen;
-
- GLAQUA_DEBUG_MSG("glXAquaScreenProbe\n");
-
- if (pScreen == NULL)
- return NULL;
-
- screen = calloc(1, sizeof *screen);
-
- if(NULL == screen)
- return NULL;
-
- screen->base.destroy = __glXAquaScreenDestroy;
- screen->base.createContext = __glXAquaScreenCreateContext;
- screen->base.createDrawable = __glXAquaScreenCreateDrawable;
- screen->base.swapInterval = /*FIXME*/ NULL;
- screen->base.pScreen = pScreen;
-
- screen->base.fbconfigs = __glXAquaCreateVisualConfigs(&screen->base.numFBConfigs, pScreen->myNum);
-
- __glXScreenInit(&screen->base, pScreen);
-
- screen->base.GLXversion = strdup("1.4");
- screen->base.GLXextensions = strdup("GLX_SGIX_fbconfig "
- "GLX_SGIS_multisample "
- "GLX_ARB_multisample "
- "GLX_EXT_visual_info "
- "GLX_EXT_import_context ");
-
- /*We may be able to add more GLXextensions at a later time. */
-
- return &screen->base;
-}
-
-#if 0 // unused
-static void __glXAquaDrawableCopySubBuffer (__GLXdrawable *drawable,
- int x, int y, int w, int h) {
- /*TODO finish me*/
-}
-#endif
-
-static void __glXAquaDrawableDestroy(__GLXdrawable *base) {
- /* gstaplin: base is the head of the structure, so it's at the same
- * offset in memory.
- * Is this safe with strict aliasing? I noticed that the other dri code
- * does this too...
- */
- __GLXAquaDrawable *glxPriv = (__GLXAquaDrawable *)base;
-
- GLAQUA_DEBUG_MSG(__func__);
-
- /* It doesn't work to call DRIDestroySurface here, the drawable's
- already gone.. But dri.c notices the window destruction and
- frees the surface itself. */
-
- /*gstaplin: verify the statement above. The surface destroy
- *messages weren't making it through, and may still not be.
- *We need a good test case for surface creation and destruction.
- *We also need a good way to enable introspection on the server
- *to validate the test, beyond using gdb with print.
- */
-
- free(glxPriv);
-}
-
-static __GLXdrawable *
-__glXAquaScreenCreateDrawable(ClientPtr client,
- __GLXscreen *screen,
- DrawablePtr pDraw,
- XID drawId,
- int type,
- XID glxDrawId,
- __GLXconfig *conf) {
- __GLXAquaDrawable *glxPriv;
-
- glxPriv = malloc(sizeof *glxPriv);
-
- if(glxPriv == NULL)
- return NULL;
-
- memset(glxPriv, 0, sizeof *glxPriv);
-
- if(!__glXDrawableInit(&glxPriv->base, screen, pDraw, type, glxDrawId, conf)) {
- free(glxPriv);
- return NULL;
- }
-
- glxPriv->base.destroy = __glXAquaDrawableDestroy;
- glxPriv->base.swapBuffers = __glXAquaDrawableSwapBuffers;
- glxPriv->base.copySubBuffer = NULL; /* __glXAquaDrawableCopySubBuffer; */
-
- glxPriv->pDraw = pDraw;
- glxPriv->sid = 0;
- glxPriv->context = NULL;
-
- return &glxPriv->base;
-}
-
-// Extra goodies for glx
-
-GLuint __glFloorLog2(GLuint val)
-{
- int c = 0;
-
- while (val > 1) {
- c++;
- val >>= 1;
- }
- return c;
-}
-
-static void setup_dispatch_table(void) {
- struct _glapi_table *disp=_glapi_get_dispatch();
-
- /* to update:
- * for f in $(grep 'define SET_' ../../../glx/dispatch.h | cut -f2 -d' ' | cut -f1 -d\( | sort -u); do grep -q $f indirect.c || echo $f ; done | grep -v by_offset | sed 's:SET_\(.*\)$:SET_\1(disp, gl\1)\;:' | pbcopy
- */
-
- SET_Accum(disp, glAccum);
- SET_AlphaFunc(disp, glAlphaFunc);
- SET_AreTexturesResident(disp, glAreTexturesResident);
- SET_ArrayElement(disp, glArrayElement);
- SET_Begin(disp, glBegin);
- SET_BindTexture(disp, glBindTexture);
- SET_Bitmap(disp, glBitmap);
- SET_BlendColor(disp, glBlendColor);
- SET_BlendEquation(disp, glBlendEquation);
- SET_BlendFunc(disp, glBlendFunc);
- SET_CallList(disp, glCallList);
- SET_CallLists(disp, glCallLists);
- SET_Clear(disp, glClear);
- SET_ClearAccum(disp, glClearAccum);
- SET_ClearColor(disp, glClearColor);
- SET_ClearDepth(disp, glClearDepth);
- SET_ClearIndex(disp, glClearIndex);
- SET_ClearStencil(disp, glClearStencil);
- SET_ClipPlane(disp, glClipPlane);
- SET_Color3b(disp, glColor3b);
- SET_Color3bv(disp, glColor3bv);
- SET_Color3d(disp, glColor3d);
- SET_Color3dv(disp, glColor3dv);
- SET_Color3f(disp, glColor3f);
- SET_Color3fv(disp, glColor3fv);
- SET_Color3i(disp, glColor3i);
- SET_Color3iv(disp, glColor3iv);
- SET_Color3s(disp, glColor3s);
- SET_Color3sv(disp, glColor3sv);
- SET_Color3ub(disp, glColor3ub);
- SET_Color3ubv(disp, glColor3ubv);
- SET_Color3ui(disp, glColor3ui);
- SET_Color3uiv(disp, glColor3uiv);
- SET_Color3us(disp, glColor3us);
- SET_Color3usv(disp, glColor3usv);
- SET_Color4b(disp, glColor4b);
- SET_Color4bv(disp, glColor4bv);
- SET_Color4d(disp, glColor4d);
- SET_Color4dv(disp, glColor4dv);
- SET_Color4f(disp, glColor4f);
- SET_Color4fv(disp, glColor4fv);
- SET_Color4i(disp, glColor4i);
- SET_Color4iv(disp, glColor4iv);
- SET_Color4s(disp, glColor4s);
- SET_Color4sv(disp, glColor4sv);
- SET_Color4ub(disp, glColor4ub);
- SET_Color4ubv(disp, glColor4ubv);
- SET_Color4ui(disp, glColor4ui);
- SET_Color4uiv(disp, glColor4uiv);
- SET_Color4us(disp, glColor4us);
- SET_Color4usv(disp, glColor4usv);
- SET_ColorMask(disp, glColorMask);
- SET_ColorMaterial(disp, glColorMaterial);
- SET_ColorPointer(disp, glColorPointer);
- SET_ColorSubTable(disp, glColorSubTable);
- SET_ColorTable(disp, glColorTable);
- SET_ColorTableParameterfv(disp, glColorTableParameterfv);
- SET_ColorTableParameteriv(disp, glColorTableParameteriv);
- SET_ConvolutionFilter1D(disp, glConvolutionFilter1D);
- SET_ConvolutionFilter2D(disp, glConvolutionFilter2D);
- SET_ConvolutionParameterf(disp, glConvolutionParameterf);
- SET_ConvolutionParameterfv(disp, glConvolutionParameterfv);
- SET_ConvolutionParameteri(disp, glConvolutionParameteri);
- SET_ConvolutionParameteriv(disp, glConvolutionParameteriv);
- SET_CopyColorSubTable(disp, glCopyColorSubTable);
- SET_CopyColorTable(disp, glCopyColorTable);
- SET_CopyConvolutionFilter1D(disp, glCopyConvolutionFilter1D);
- SET_CopyConvolutionFilter2D(disp, glCopyConvolutionFilter2D);
- SET_CopyPixels(disp, glCopyPixels);
- SET_CopyTexImage1D(disp, glCopyTexImage1D);
- SET_CopyTexImage2D(disp, glCopyTexImage2D);
- SET_CopyTexSubImage1D(disp, glCopyTexSubImage1D);
- SET_CopyTexSubImage2D(disp, glCopyTexSubImage2D);
- SET_CopyTexSubImage3D(disp, glCopyTexSubImage3D);
- SET_CullFace(disp, glCullFace);
- SET_DeleteLists(disp, glDeleteLists);
- SET_DeleteTextures(disp, glDeleteTextures);
- SET_DepthFunc(disp, glDepthFunc);
- SET_DepthMask(disp, glDepthMask);
- SET_DepthRange(disp, glDepthRange);
- SET_Disable(disp, glDisable);
- SET_DisableClientState(disp, glDisableClientState);
- SET_DrawArrays(disp, glDrawArrays);
- SET_DrawBuffer(disp, glDrawBuffer);
- SET_DrawElements(disp, glDrawElements);
- SET_DrawPixels(disp, glDrawPixels);
- SET_DrawRangeElements(disp, glDrawRangeElements);
- SET_EdgeFlag(disp, glEdgeFlag);
- SET_EdgeFlagPointer(disp, glEdgeFlagPointer);
- SET_EdgeFlagv(disp, glEdgeFlagv);
- SET_Enable(disp, glEnable);
- SET_EnableClientState(disp, glEnableClientState);
- SET_End(disp, glEnd);
- SET_EndList(disp, glEndList);
- SET_EvalCoord1d(disp, glEvalCoord1d);
- SET_EvalCoord1dv(disp, glEvalCoord1dv);
- SET_EvalCoord1f(disp, glEvalCoord1f);
- SET_EvalCoord1fv(disp, glEvalCoord1fv);
- SET_EvalCoord2d(disp, glEvalCoord2d);
- SET_EvalCoord2dv(disp, glEvalCoord2dv);
- SET_EvalCoord2f(disp, glEvalCoord2f);
- SET_EvalCoord2fv(disp, glEvalCoord2fv);
- SET_EvalMesh1(disp, glEvalMesh1);
- SET_EvalMesh2(disp, glEvalMesh2);
- SET_EvalPoint1(disp, glEvalPoint1);
- SET_EvalPoint2(disp, glEvalPoint2);
- SET_FeedbackBuffer(disp, glFeedbackBuffer);
- SET_Finish(disp, glFinish);
- SET_Flush(disp, glFlush);
- SET_Fogf(disp, glFogf);
- SET_Fogfv(disp, glFogfv);
- SET_Fogi(disp, glFogi);
- SET_Fogiv(disp, glFogiv);
- SET_FrontFace(disp, glFrontFace);
- SET_Frustum(disp, glFrustum);
- SET_GenLists(disp, glGenLists);
- SET_GenTextures(disp, glGenTextures);
- SET_GetBooleanv(disp, glGetBooleanv);
- SET_GetClipPlane(disp, glGetClipPlane);
- SET_GetColorTable(disp, glGetColorTable);
- SET_GetColorTableParameterfv(disp, glGetColorTableParameterfv);
- SET_GetColorTableParameteriv(disp, glGetColorTableParameteriv);
- SET_GetConvolutionFilter(disp, glGetConvolutionFilter);
- SET_GetConvolutionParameterfv(disp, glGetConvolutionParameterfv);
- SET_GetConvolutionParameteriv(disp, glGetConvolutionParameteriv);
- SET_GetDoublev(disp, glGetDoublev);
- SET_GetError(disp, glGetError);
- SET_GetFloatv(disp, glGetFloatv);
- SET_GetHistogram(disp, glGetHistogram);
- SET_GetHistogramParameterfv(disp, glGetHistogramParameterfv);
- SET_GetHistogramParameteriv(disp, glGetHistogramParameteriv);
- SET_GetIntegerv(disp, glGetIntegerv);
- SET_GetLightfv(disp, glGetLightfv);
- SET_GetLightiv(disp, glGetLightiv);
- SET_GetMapdv(disp, glGetMapdv);
- SET_GetMapfv(disp, glGetMapfv);
- SET_GetMapiv(disp, glGetMapiv);
- SET_GetMaterialfv(disp, glGetMaterialfv);
- SET_GetMaterialiv(disp, glGetMaterialiv);
- SET_GetMinmax(disp, glGetMinmax);
- SET_GetMinmaxParameterfv(disp, glGetMinmaxParameterfv);
- SET_GetMinmaxParameteriv(disp, glGetMinmaxParameteriv);
- SET_GetPixelMapfv(disp, glGetPixelMapfv);
- SET_GetPixelMapuiv(disp, glGetPixelMapuiv);
- SET_GetPixelMapusv(disp, glGetPixelMapusv);
- SET_GetPointerv(disp, glGetPointerv);
- SET_GetPolygonStipple(disp, glGetPolygonStipple);
- SET_GetSeparableFilter(disp, glGetSeparableFilter);
- SET_GetString(disp, glGetString);
- SET_GetTexEnvfv(disp, glGetTexEnvfv);
- SET_GetTexEnviv(disp, glGetTexEnviv);
- SET_GetTexGendv(disp, glGetTexGendv);
- SET_GetTexGenfv(disp, glGetTexGenfv);
- SET_GetTexGeniv(disp, glGetTexGeniv);
- SET_GetTexImage(disp, glGetTexImage);
- SET_GetTexLevelParameterfv(disp, glGetTexLevelParameterfv);
- SET_GetTexLevelParameteriv(disp, glGetTexLevelParameteriv);
- SET_GetTexParameterfv(disp, glGetTexParameterfv);
- SET_GetTexParameteriv(disp, glGetTexParameteriv);
- SET_Hint(disp, glHint);
- SET_Histogram(disp, glHistogram);
- SET_IndexMask(disp, glIndexMask);
- SET_IndexPointer(disp, glIndexPointer);
- SET_Indexd(disp, glIndexd);
- SET_Indexdv(disp, glIndexdv);
- SET_Indexf(disp, glIndexf);
- SET_Indexfv(disp, glIndexfv);
- SET_Indexi(disp, glIndexi);
- SET_Indexiv(disp, glIndexiv);
- SET_Indexs(disp, glIndexs);
- SET_Indexsv(disp, glIndexsv);
- SET_Indexub(disp, glIndexub);
- SET_Indexubv(disp, glIndexubv);
- SET_InitNames(disp, glInitNames);
- SET_InterleavedArrays(disp, glInterleavedArrays);
- SET_IsEnabled(disp, glIsEnabled);
- SET_IsList(disp, glIsList);
- SET_IsTexture(disp, glIsTexture);
- SET_LightModelf(disp, glLightModelf);
- SET_LightModelfv(disp, glLightModelfv);
- SET_LightModeli(disp, glLightModeli);
- SET_LightModeliv(disp, glLightModeliv);
- SET_Lightf(disp, glLightf);
- SET_Lightfv(disp, glLightfv);
- SET_Lighti(disp, glLighti);
- SET_Lightiv(disp, glLightiv);
- SET_LineStipple(disp, glLineStipple);
- SET_LineWidth(disp, glLineWidth);
- SET_ListBase(disp, glListBase);
- SET_LoadIdentity(disp, glLoadIdentity);
- SET_LoadMatrixd(disp, glLoadMatrixd);
- SET_LoadMatrixf(disp, glLoadMatrixf);
- SET_LoadName(disp, glLoadName);
- SET_LogicOp(disp, glLogicOp);
- SET_Map1d(disp, glMap1d);
- SET_Map1f(disp, glMap1f);
- SET_Map2d(disp, glMap2d);
- SET_Map2f(disp, glMap2f);
- SET_MapGrid1d(disp, glMapGrid1d);
- SET_MapGrid1f(disp, glMapGrid1f);
- SET_MapGrid2d(disp, glMapGrid2d);
- SET_MapGrid2f(disp, glMapGrid2f);
- SET_Materialf(disp, glMaterialf);
- SET_Materialfv(disp, glMaterialfv);
- SET_Materiali(disp, glMateriali);
- SET_Materialiv(disp, glMaterialiv);
- SET_MatrixMode(disp, glMatrixMode);
- SET_Minmax(disp, glMinmax);
- SET_MultMatrixd(disp, glMultMatrixd);
- SET_MultMatrixf(disp, glMultMatrixf);
- SET_NewList(disp, glNewList);
- SET_Normal3b(disp, glNormal3b);
- SET_Normal3bv(disp, glNormal3bv);
- SET_Normal3d(disp, glNormal3d);
- SET_Normal3dv(disp, glNormal3dv);
- SET_Normal3f(disp, glNormal3f);
- SET_Normal3fv(disp, glNormal3fv);
- SET_Normal3i(disp, glNormal3i);
- SET_Normal3iv(disp, glNormal3iv);
- SET_Normal3s(disp, glNormal3s);
- SET_Normal3sv(disp, glNormal3sv);
- SET_NormalPointer(disp, glNormalPointer);
- SET_Ortho(disp, glOrtho);
- SET_PassThrough(disp, glPassThrough);
- SET_PixelMapfv(disp, glPixelMapfv);
- SET_PixelMapuiv(disp, glPixelMapuiv);
- SET_PixelMapusv(disp, glPixelMapusv);
- SET_PixelStoref(disp, glPixelStoref);
- SET_PixelStorei(disp, glPixelStorei);
- SET_PixelTransferf(disp, glPixelTransferf);
- SET_PixelTransferi(disp, glPixelTransferi);
- SET_PixelZoom(disp, glPixelZoom);
- SET_PointSize(disp, glPointSize);
- SET_PolygonMode(disp, glPolygonMode);
- SET_PolygonOffset(disp, glPolygonOffset);
- SET_PolygonStipple(disp, glPolygonStipple);
- SET_PopAttrib(disp, glPopAttrib);
- SET_PopClientAttrib(disp, glPopClientAttrib);
- SET_PopMatrix(disp, glPopMatrix);
- SET_PopName(disp, glPopName);
- SET_PrioritizeTextures(disp, glPrioritizeTextures);
- SET_PushAttrib(disp, glPushAttrib);
- SET_PushClientAttrib(disp, glPushClientAttrib);
- SET_PushMatrix(disp, glPushMatrix);
- SET_PushName(disp, glPushName);
- SET_RasterPos2d(disp, glRasterPos2d);
- SET_RasterPos2dv(disp, glRasterPos2dv);
- SET_RasterPos2f(disp, glRasterPos2f);
- SET_RasterPos2fv(disp, glRasterPos2fv);
- SET_RasterPos2i(disp, glRasterPos2i);
- SET_RasterPos2iv(disp, glRasterPos2iv);
- SET_RasterPos2s(disp, glRasterPos2s);
- SET_RasterPos2sv(disp, glRasterPos2sv);
- SET_RasterPos3d(disp, glRasterPos3d);
- SET_RasterPos3dv(disp, glRasterPos3dv);
- SET_RasterPos3f(disp, glRasterPos3f);
- SET_RasterPos3fv(disp, glRasterPos3fv);
- SET_RasterPos3i(disp, glRasterPos3i);
- SET_RasterPos3iv(disp, glRasterPos3iv);
- SET_RasterPos3s(disp, glRasterPos3s);
- SET_RasterPos3sv(disp, glRasterPos3sv);
- SET_RasterPos4d(disp, glRasterPos4d);
- SET_RasterPos4dv(disp, glRasterPos4dv);
- SET_RasterPos4f(disp, glRasterPos4f);
- SET_RasterPos4fv(disp, glRasterPos4fv);
- SET_RasterPos4i(disp, glRasterPos4i);
- SET_RasterPos4iv(disp, glRasterPos4iv);
- SET_RasterPos4s(disp, glRasterPos4s);
- SET_RasterPos4sv(disp, glRasterPos4sv);
- SET_ReadBuffer(disp, glReadBuffer);
- SET_ReadPixels(disp, glReadPixels);
- SET_Rectd(disp, glRectd);
- SET_Rectdv(disp, glRectdv);
- SET_Rectf(disp, glRectf);
- SET_Rectfv(disp, glRectfv);
- SET_Recti(disp, glRecti);
- SET_Rectiv(disp, glRectiv);
- SET_Rects(disp, glRects);
- SET_Rectsv(disp, glRectsv);
- SET_RenderMode(disp, glRenderMode);
- SET_ResetHistogram(disp, glResetHistogram);
- SET_ResetMinmax(disp, glResetMinmax);
- SET_Rotated(disp, glRotated);
- SET_Rotatef(disp, glRotatef);
- SET_Scaled(disp, glScaled);
- SET_Scalef(disp, glScalef);
- SET_Scissor(disp, glScissor);
- SET_SelectBuffer(disp, glSelectBuffer);
- SET_SeparableFilter2D(disp, glSeparableFilter2D);
- SET_ShadeModel(disp, glShadeModel);
- SET_StencilFunc(disp, glStencilFunc);
- SET_StencilMask(disp, glStencilMask);
- SET_StencilOp(disp, glStencilOp);
- SET_TexCoord1d(disp, glTexCoord1d);
- SET_TexCoord1dv(disp, glTexCoord1dv);
- SET_TexCoord1f(disp, glTexCoord1f);
- SET_TexCoord1fv(disp, glTexCoord1fv);
- SET_TexCoord1i(disp, glTexCoord1i);
- SET_TexCoord1iv(disp, glTexCoord1iv);
- SET_TexCoord1s(disp, glTexCoord1s);
- SET_TexCoord1sv(disp, glTexCoord1sv);
- SET_TexCoord2d(disp, glTexCoord2d);
- SET_TexCoord2dv(disp, glTexCoord2dv);
- SET_TexCoord2f(disp, glTexCoord2f);
- SET_TexCoord2fv(disp, glTexCoord2fv);
- SET_TexCoord2i(disp, glTexCoord2i);
- SET_TexCoord2iv(disp, glTexCoord2iv);
- SET_TexCoord2s(disp, glTexCoord2s);
- SET_TexCoord2sv(disp, glTexCoord2sv);
- SET_TexCoord3d(disp, glTexCoord3d);
- SET_TexCoord3dv(disp, glTexCoord3dv);
- SET_TexCoord3f(disp, glTexCoord3f);
- SET_TexCoord3fv(disp, glTexCoord3fv);
- SET_TexCoord3i(disp, glTexCoord3i);
- SET_TexCoord3iv(disp, glTexCoord3iv);
- SET_TexCoord3s(disp, glTexCoord3s);
- SET_TexCoord3sv(disp, glTexCoord3sv);
- SET_TexCoord4d(disp, glTexCoord4d);
- SET_TexCoord4dv(disp, glTexCoord4dv);
- SET_TexCoord4f(disp, glTexCoord4f);
- SET_TexCoord4fv(disp, glTexCoord4fv);
- SET_TexCoord4i(disp, glTexCoord4i);
- SET_TexCoord4iv(disp, glTexCoord4iv);
- SET_TexCoord4s(disp, glTexCoord4s);
- SET_TexCoord4sv(disp, glTexCoord4sv);
- SET_TexCoordPointer(disp, glTexCoordPointer);
- SET_TexEnvf(disp, glTexEnvf);
- SET_TexEnvfv(disp, glTexEnvfv);
- SET_TexEnvi(disp, glTexEnvi);
- SET_TexEnviv(disp, glTexEnviv);
- SET_TexGend(disp, glTexGend);
- SET_TexGendv(disp, glTexGendv);
- SET_TexGenf(disp, glTexGenf);
- SET_TexGenfv(disp, glTexGenfv);
- SET_TexGeni(disp, glTexGeni);
- SET_TexGeniv(disp, glTexGeniv);
-
- /* Pointer Incompatability:
- * internalformat is a GLenum according to /System/Library/Frameworks/OpenGL.framework/Headers/gl.h
- * extern void glTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
- * extern void glTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
- * extern void glTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
- *
- * and it's a GLint in glx/glapitable.h and according to the man page
- * void ( * TexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels);
- * void ( * TexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels);
- * void ( * TexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels);
- *
- * <rdar://problem/6953344> gl.h contains incorrect prototypes for glTexImage[123]D
- */
-
- SET_TexImage1D(disp, (void *)glTexImage1D);
- SET_TexImage2D(disp, (void *)glTexImage2D);
- SET_TexImage3D(disp, (void *)glTexImage3D);
- SET_TexParameterf(disp, glTexParameterf);
- SET_TexParameterfv(disp, glTexParameterfv);
- SET_TexParameteri(disp, glTexParameteri);
- SET_TexParameteriv(disp, glTexParameteriv);
- SET_TexSubImage1D(disp, glTexSubImage1D);
- SET_TexSubImage2D(disp, glTexSubImage2D);
- SET_TexSubImage3D(disp, glTexSubImage3D);
- SET_Translated(disp, glTranslated);
- SET_Translatef(disp, glTranslatef);
- SET_Vertex2d(disp, glVertex2d);
- SET_Vertex2dv(disp, glVertex2dv);
- SET_Vertex2f(disp, glVertex2f);
- SET_Vertex2fv(disp, glVertex2fv);
- SET_Vertex2i(disp, glVertex2i);
- SET_Vertex2iv(disp, glVertex2iv);
- SET_Vertex2s(disp, glVertex2s);
- SET_Vertex2sv(disp, glVertex2sv);
- SET_Vertex3d(disp, glVertex3d);
- SET_Vertex3dv(disp, glVertex3dv);
- SET_Vertex3f(disp, glVertex3f);
- SET_Vertex3fv(disp, glVertex3fv);
- SET_Vertex3i(disp, glVertex3i);
- SET_Vertex3iv(disp, glVertex3iv);
- SET_Vertex3s(disp, glVertex3s);
- SET_Vertex3sv(disp, glVertex3sv);
- SET_Vertex4d(disp, glVertex4d);
- SET_Vertex4dv(disp, glVertex4dv);
- SET_Vertex4f(disp, glVertex4f);
- SET_Vertex4fv(disp, glVertex4fv);
- SET_Vertex4i(disp, glVertex4i);
- SET_Vertex4iv(disp, glVertex4iv);
- SET_Vertex4s(disp, glVertex4s);
- SET_Vertex4sv(disp, glVertex4sv);
- SET_VertexPointer(disp, glVertexPointer);
- SET_Viewport(disp, glViewport);
-
-#if GL_VERSION_2_0
- SET_AttachShader(disp, glAttachShader);
- SET_DeleteShader(disp, glDeleteShader);
- SET_DetachShader(disp, glDetachShader);
- SET_GetAttachedShaders(disp, glGetAttachedShaders);
- SET_GetProgramInfoLog(disp, glGetProgramInfoLog);
- SET_GetShaderInfoLog(disp, glGetShaderInfoLog);
- SET_GetShaderiv(disp, glGetShaderiv);
- SET_IsShader(disp, glIsShader);
- SET_StencilFuncSeparate(disp, glStencilFuncSeparate);
- SET_StencilMaskSeparate(disp, glStencilMaskSeparate);
- SET_StencilOpSeparate(disp, glStencilOpSeparate);
-#endif
-
-#if GL_VERSION_2_1
- SET_UniformMatrix2x3fv(disp, glUniformMatrix2x3fv);
- SET_UniformMatrix2x4fv(disp, glUniformMatrix2x4fv);
- SET_UniformMatrix3x2fv(disp, glUniformMatrix3x2fv);
- SET_UniformMatrix3x4fv(disp, glUniformMatrix3x4fv);
- SET_UniformMatrix4x2fv(disp, glUniformMatrix4x2fv);
- SET_UniformMatrix4x3fv(disp, glUniformMatrix4x3fv);
-#endif
-
-#if GL_APPLE_vertex_array_object
- SET_BindVertexArrayAPPLE(disp, glBindVertexArrayAPPLE);
- SET_DeleteVertexArraysAPPLE(disp, glDeleteVertexArraysAPPLE);
- SET_GenVertexArraysAPPLE(disp, glGenVertexArraysAPPLE);
- SET_IsVertexArrayAPPLE(disp, glIsVertexArrayAPPLE);
-#endif
-
-#if GL_ARB_draw_buffers
- SET_DrawBuffersARB(disp, glDrawBuffersARB);
-#endif
-
-#if GL_ARB_multisample
- SET_SampleCoverageARB(disp, glSampleCoverageARB);
-#endif
-
-#if GL_ARB_multitexture
- SET_ActiveTextureARB(disp, glActiveTextureARB);
- SET_ClientActiveTextureARB(disp, glClientActiveTextureARB);
- SET_MultiTexCoord1dARB(disp, glMultiTexCoord1dARB);
- SET_MultiTexCoord1dvARB(disp, glMultiTexCoord1dvARB);
- SET_MultiTexCoord1fARB(disp, glMultiTexCoord1fARB);
- SET_MultiTexCoord1fvARB(disp, glMultiTexCoord1fvARB);
- SET_MultiTexCoord1iARB(disp, glMultiTexCoord1iARB);
- SET_MultiTexCoord1ivARB(disp, glMultiTexCoord1ivARB);
- SET_MultiTexCoord1sARB(disp, glMultiTexCoord1sARB);
- SET_MultiTexCoord1svARB(disp, glMultiTexCoord1svARB);
- SET_MultiTexCoord2dARB(disp, glMultiTexCoord2dARB);
- SET_MultiTexCoord2dvARB(disp, glMultiTexCoord2dvARB);
- SET_MultiTexCoord2fARB(disp, glMultiTexCoord2fARB);
- SET_MultiTexCoord2fvARB(disp, glMultiTexCoord2fvARB);
- SET_MultiTexCoord2iARB(disp, glMultiTexCoord2iARB);
- SET_MultiTexCoord2ivARB(disp, glMultiTexCoord2ivARB);
- SET_MultiTexCoord2sARB(disp, glMultiTexCoord2sARB);
- SET_MultiTexCoord2svARB(disp, glMultiTexCoord2svARB);
- SET_MultiTexCoord3dARB(disp, glMultiTexCoord3dARB);
- SET_MultiTexCoord3dvARB(disp, glMultiTexCoord3dvARB);
- SET_MultiTexCoord3fARB(disp, glMultiTexCoord3fARB);
- SET_MultiTexCoord3fvARB(disp, glMultiTexCoord3fvARB);
- SET_MultiTexCoord3iARB(disp, glMultiTexCoord3iARB);
- SET_MultiTexCoord3ivARB(disp, glMultiTexCoord3ivARB);
- SET_MultiTexCoord3sARB(disp, glMultiTexCoord3sARB);
- SET_MultiTexCoord3svARB(disp, glMultiTexCoord3svARB);
- SET_MultiTexCoord4dARB(disp, glMultiTexCoord4dARB);
- SET_MultiTexCoord4dvARB(disp, glMultiTexCoord4dvARB);
- SET_MultiTexCoord4fARB(disp, glMultiTexCoord4fARB);
- SET_MultiTexCoord4fvARB(disp, glMultiTexCoord4fvARB);
- SET_MultiTexCoord4iARB(disp, glMultiTexCoord4iARB);
- SET_MultiTexCoord4ivARB(disp, glMultiTexCoord4ivARB);
- SET_MultiTexCoord4sARB(disp, glMultiTexCoord4sARB);
- SET_MultiTexCoord4svARB(disp, glMultiTexCoord4svARB);
-#endif
-
-#if GL_ARB_occlusion_query
- SET_BeginQueryARB(disp, glBeginQueryARB);
- SET_DeleteQueriesARB(disp, glDeleteQueriesARB);
- SET_EndQueryARB(disp, glEndQueryARB);
- SET_GenQueriesARB(disp, glGenQueriesARB);
- SET_GetQueryObjectivARB(disp, glGetQueryObjectivARB);
- SET_GetQueryObjectuivARB(disp, glGetQueryObjectuivARB);
- SET_GetQueryivARB(disp, glGetQueryivARB);
- SET_IsQueryARB(disp, glIsQueryARB);
-#endif
-
-#if GL_ARB_shader_objects
- SET_AttachObjectARB(disp, glAttachObjectARB);
- SET_CompileShaderARB(disp, glCompileShaderARB);
- SET_DeleteObjectARB(disp, glDeleteObjectARB);
- SET_GetHandleARB(disp, glGetHandleARB);
- SET_DetachObjectARB(disp, glDetachObjectARB);
- SET_CreateProgramObjectARB(disp, glCreateProgramObjectARB);
- SET_CreateShaderObjectARB(disp, glCreateShaderObjectARB);
- SET_GetInfoLogARB(disp, glGetInfoLogARB);
- SET_GetActiveUniformARB(disp, glGetActiveUniformARB);
- SET_GetAttachedObjectsARB(disp, glGetAttachedObjectsARB);
- SET_GetObjectParameterfvARB(disp, glGetObjectParameterfvARB);
- SET_GetObjectParameterivARB(disp, glGetObjectParameterivARB);
- SET_GetShaderSourceARB(disp, glGetShaderSourceARB);
- SET_GetUniformLocationARB(disp, glGetUniformLocationARB);
- SET_GetUniformfvARB(disp, glGetUniformfvARB);
- SET_GetUniformivARB(disp, glGetUniformivARB);
- SET_LinkProgramARB(disp, glLinkProgramARB);
- SET_ShaderSourceARB(disp, glShaderSourceARB);
- SET_Uniform1fARB(disp, glUniform1fARB);
- SET_Uniform1fvARB(disp, glUniform1fvARB);
- SET_Uniform1iARB(disp, glUniform1iARB);
- SET_Uniform1ivARB(disp, glUniform1ivARB);
- SET_Uniform2fARB(disp, glUniform2fARB);
- SET_Uniform2fvARB(disp, glUniform2fvARB);
- SET_Uniform2iARB(disp, glUniform2iARB);
- SET_Uniform2ivARB(disp, glUniform2ivARB);
- SET_Uniform3fARB(disp, glUniform3fARB);
- SET_Uniform3fvARB(disp, glUniform3fvARB);
- SET_Uniform3iARB(disp, glUniform3iARB);
- SET_Uniform3ivARB(disp, glUniform3ivARB);
- SET_Uniform4fARB(disp, glUniform4fARB);
- SET_Uniform4fvARB(disp, glUniform4fvARB);
- SET_Uniform4iARB(disp, glUniform4iARB);
- SET_Uniform4ivARB(disp, glUniform4ivARB);
- SET_UniformMatrix2fvARB(disp, glUniformMatrix2fvARB);
- SET_UniformMatrix3fvARB(disp, glUniformMatrix3fvARB);
- SET_UniformMatrix4fvARB(disp, glUniformMatrix4fvARB);
- SET_UseProgramObjectARB(disp, glUseProgramObjectARB);
- SET_ValidateProgramARB(disp, glValidateProgramARB);
-#endif
-
-#if GL_ARB_texture_compression
- SET_CompressedTexImage1DARB(disp, glCompressedTexImage1DARB);
- SET_CompressedTexImage2DARB(disp, glCompressedTexImage2DARB);
- SET_CompressedTexImage3DARB(disp, glCompressedTexImage3DARB);
- SET_CompressedTexSubImage1DARB(disp, glCompressedTexSubImage1DARB);
- SET_CompressedTexSubImage2DARB(disp, glCompressedTexSubImage2DARB);
- SET_CompressedTexSubImage3DARB(disp, glCompressedTexSubImage3DARB);
- SET_GetCompressedTexImageARB(disp, glGetCompressedTexImageARB);
-#endif
-
-#if GL_ARB_transpose_matrix
- SET_LoadTransposeMatrixdARB(disp, glLoadTransposeMatrixdARB);
- SET_LoadTransposeMatrixfARB(disp, glLoadTransposeMatrixfARB);
- SET_MultTransposeMatrixdARB(disp, glMultTransposeMatrixdARB);
- SET_MultTransposeMatrixfARB(disp, glMultTransposeMatrixfARB);
-#endif
-
-#if GL_ARB_vertex_buffer_object
- SET_BindBufferARB(disp, glBindBufferARB);
- SET_BufferDataARB(disp, glBufferDataARB);
- SET_BufferSubDataARB(disp, glBufferSubDataARB);
- SET_DeleteBuffersARB(disp, glDeleteBuffersARB);
- SET_GenBuffersARB(disp, glGenBuffersARB);
- SET_GetBufferParameterivARB(disp, glGetBufferParameterivARB);
- SET_GetBufferPointervARB(disp, glGetBufferPointervARB);
- SET_GetBufferSubDataARB(disp, glGetBufferSubDataARB);
- SET_IsBufferARB(disp, glIsBufferARB);
- SET_MapBufferARB(disp, glMapBufferARB);
- SET_UnmapBufferARB(disp, glUnmapBufferARB);
-#endif
-
-#if GL_ARB_vertex_program
- SET_DisableVertexAttribArrayARB(disp, glDisableVertexAttribArrayARB);
- SET_EnableVertexAttribArrayARB(disp, glEnableVertexAttribArrayARB);
- SET_GetProgramEnvParameterdvARB(disp, glGetProgramEnvParameterdvARB);
- SET_GetProgramEnvParameterfvARB(disp, glGetProgramEnvParameterfvARB);
- SET_GetProgramLocalParameterdvARB(disp, glGetProgramLocalParameterdvARB);
- SET_GetProgramLocalParameterfvARB(disp, glGetProgramLocalParameterfvARB);
- SET_GetProgramStringARB(disp, glGetProgramStringARB);
- SET_GetProgramivARB(disp, glGetProgramivARB);
- SET_GetVertexAttribdvARB(disp, glGetVertexAttribdvARB);
- SET_GetVertexAttribfvARB(disp, glGetVertexAttribfvARB);
- SET_GetVertexAttribivARB(disp, glGetVertexAttribivARB);
- SET_ProgramEnvParameter4dARB(disp, glProgramEnvParameter4dARB);
- SET_ProgramEnvParameter4dvARB(disp, glProgramEnvParameter4dvARB);
- SET_ProgramEnvParameter4fARB(disp, glProgramEnvParameter4fARB);
- SET_ProgramEnvParameter4fvARB(disp, glProgramEnvParameter4fvARB);
- SET_ProgramLocalParameter4dARB(disp, glProgramLocalParameter4dARB);
- SET_ProgramLocalParameter4dvARB(disp, glProgramLocalParameter4dvARB);
- SET_ProgramLocalParameter4fARB(disp, glProgramLocalParameter4fARB);
- SET_ProgramLocalParameter4fvARB(disp, glProgramLocalParameter4fvARB);
- SET_ProgramStringARB(disp, glProgramStringARB);
- SET_VertexAttrib1dARB(disp, glVertexAttrib1dARB);
- SET_VertexAttrib1dvARB(disp, glVertexAttrib1dvARB);
- SET_VertexAttrib1fARB(disp, glVertexAttrib1fARB);
- SET_VertexAttrib1fvARB(disp, glVertexAttrib1fvARB);
- SET_VertexAttrib1sARB(disp, glVertexAttrib1sARB);
- SET_VertexAttrib1svARB(disp, glVertexAttrib1svARB);
- SET_VertexAttrib2dARB(disp, glVertexAttrib2dARB);
- SET_VertexAttrib2dvARB(disp, glVertexAttrib2dvARB);
- SET_VertexAttrib2fARB(disp, glVertexAttrib2fARB);
- SET_VertexAttrib2fvARB(disp, glVertexAttrib2fvARB);
- SET_VertexAttrib2sARB(disp, glVertexAttrib2sARB);
- SET_VertexAttrib2svARB(disp, glVertexAttrib2svARB);
- SET_VertexAttrib3dARB(disp, glVertexAttrib3dARB);
- SET_VertexAttrib3dvARB(disp, glVertexAttrib3dvARB);
- SET_VertexAttrib3fARB(disp, glVertexAttrib3fARB);
- SET_VertexAttrib3fvARB(disp, glVertexAttrib3fvARB);
- SET_VertexAttrib3sARB(disp, glVertexAttrib3sARB);
- SET_VertexAttrib3svARB(disp, glVertexAttrib3svARB);
- SET_VertexAttrib4NbvARB(disp, glVertexAttrib4NbvARB);
- SET_VertexAttrib4NivARB(disp, glVertexAttrib4NivARB);
- SET_VertexAttrib4NsvARB(disp, glVertexAttrib4NsvARB);
- SET_VertexAttrib4NubARB(disp, glVertexAttrib4NubARB);
- SET_VertexAttrib4NubvARB(disp, glVertexAttrib4NubvARB);
- SET_VertexAttrib4NuivARB(disp, glVertexAttrib4NuivARB);
- SET_VertexAttrib4NusvARB(disp, glVertexAttrib4NusvARB);
- SET_VertexAttrib4bvARB(disp, glVertexAttrib4bvARB);
- SET_VertexAttrib4dARB(disp, glVertexAttrib4dARB);
- SET_VertexAttrib4dvARB(disp, glVertexAttrib4dvARB);
- SET_VertexAttrib4fARB(disp, glVertexAttrib4fARB);
- SET_VertexAttrib4fvARB(disp, glVertexAttrib4fvARB);
- SET_VertexAttrib4ivARB(disp, glVertexAttrib4ivARB);
- SET_VertexAttrib4sARB(disp, glVertexAttrib4sARB);
- SET_VertexAttrib4svARB(disp, glVertexAttrib4svARB);
- SET_VertexAttrib4ubvARB(disp, glVertexAttrib4ubvARB);
- SET_VertexAttrib4uivARB(disp, glVertexAttrib4uivARB);
- SET_VertexAttrib4usvARB(disp, glVertexAttrib4usvARB);
- SET_VertexAttribPointerARB(disp, glVertexAttribPointerARB);
-#endif
-
-#if GL_ARB_vertex_shader
- SET_BindAttribLocationARB(disp, glBindAttribLocationARB);
- SET_GetActiveAttribARB(disp, glGetActiveAttribARB);
- SET_GetAttribLocationARB(disp, glGetAttribLocationARB);
-#endif
-
-#if GL_ARB_window_pos
- SET_WindowPos2dMESA(disp, glWindowPos2dARB);
- SET_WindowPos2dvMESA(disp, glWindowPos2dvARB);
- SET_WindowPos2fMESA(disp, glWindowPos2fARB);
- SET_WindowPos2fvMESA(disp, glWindowPos2fvARB);
- SET_WindowPos2iMESA(disp, glWindowPos2iARB);
- SET_WindowPos2ivMESA(disp, glWindowPos2ivARB);
- SET_WindowPos2sMESA(disp, glWindowPos2sARB);
- SET_WindowPos2svMESA(disp, glWindowPos2svARB);
- SET_WindowPos3dMESA(disp, glWindowPos3dARB);
- SET_WindowPos3dvMESA(disp, glWindowPos3dvARB);
- SET_WindowPos3fMESA(disp, glWindowPos3fARB);
- SET_WindowPos3fvMESA(disp, glWindowPos3fvARB);
- SET_WindowPos3iMESA(disp, glWindowPos3iARB);
- SET_WindowPos3ivMESA(disp, glWindowPos3ivARB);
- SET_WindowPos3sMESA(disp, glWindowPos3sARB);
- SET_WindowPos3svMESA(disp, glWindowPos3svARB);
-#endif
-
-#if GL_ATI_fragment_shader
- SET_AlphaFragmentOp1ATI(disp, glAlphaFragmentOp1ATI);
- SET_AlphaFragmentOp2ATI(disp, glAlphaFragmentOp2ATI);
- SET_AlphaFragmentOp3ATI(disp, glAlphaFragmentOp3ATI);
- SET_BeginFragmentShaderATI(disp, glBeginFragmentShaderATI);
- SET_BindFragmentShaderATI(disp, glBindFragmentShaderATI);
- SET_ColorFragmentOp1ATI(disp, glColorFragmentOp1ATI);
- SET_ColorFragmentOp2ATI(disp, glColorFragmentOp2ATI);
- SET_ColorFragmentOp3ATI(disp, glColorFragmentOp3ATI);
- SET_DeleteFragmentShaderATI(disp, glDeleteFragmentShaderATI);
- SET_EndFragmentShaderATI(disp, glEndFragmentShaderATI);
- SET_GenFragmentShadersATI(disp, glGenFragmentShadersATI);
- SET_PassTexCoordATI(disp, glPassTexCoordATI);
- SET_SampleMapATI(disp, glSampleMapATI);
- SET_SetFragmentShaderConstantATI(disp, glSetFragmentShaderConstantATI);
-#elif GL_EXT_fragment_shader
- SET_AlphaFragmentOp1ATI(disp, glAlphaFragmentOp1EXT);
- SET_AlphaFragmentOp2ATI(disp, glAlphaFragmentOp2EXT);
- SET_AlphaFragmentOp3ATI(disp, glAlphaFragmentOp3EXT);
- SET_BeginFragmentShaderATI(disp, glBeginFragmentShaderEXT);
- SET_BindFragmentShaderATI(disp, glBindFragmentShaderEXT);
- SET_ColorFragmentOp1ATI(disp, glColorFragmentOp1EXT);
- SET_ColorFragmentOp2ATI(disp, glColorFragmentOp2EXT);
- SET_ColorFragmentOp3ATI(disp, glColorFragmentOp3EXT);
- SET_DeleteFragmentShaderATI(disp, glDeleteFragmentShaderEXT);
- SET_EndFragmentShaderATI(disp, glEndFragmentShaderEXT);
- SET_GenFragmentShadersATI(disp, glGenFragmentShadersEXT);
- SET_PassTexCoordATI(disp, glPassTexCoordEXT);
- SET_SampleMapATI(disp, glSampleMapEXT);
- SET_SetFragmentShaderConstantATI(disp, glSetFragmentShaderConstantEXT);
-#endif
-
-#if GL_ATI_separate_stencil
- SET_StencilFuncSeparateATI(disp, glStencilFuncSeparateATI);
-#endif
-
-#if GL_EXT_blend_equation_separate
- SET_BlendEquationSeparateEXT(disp, glBlendEquationSeparateEXT);
-#endif
-
-#if GL_EXT_blend_func_separate
- SET_BlendFuncSeparateEXT(disp, glBlendFuncSeparateEXT);
-#endif
-
-#if GL_EXT_depth_bounds_test
- SET_DepthBoundsEXT(disp, glDepthBoundsEXT);
-#endif
-
-#if GL_EXT_compiled_vertex_array
- SET_LockArraysEXT(disp, glLockArraysEXT);
- SET_UnlockArraysEXT(disp, glUnlockArraysEXT);
-#endif
-
-#if GL_EXT_cull_vertex
- SET_CullParameterdvEXT(disp, glCullParameterdvEXT);
- SET_CullParameterfvEXT(disp, glCullParameterfvEXT);
-#endif
-
-#if GL_EXT_fog_coord
- SET_FogCoordPointerEXT(disp, glFogCoordPointerEXT);
- SET_FogCoorddEXT(disp, glFogCoorddEXT);
- SET_FogCoorddvEXT(disp, glFogCoorddvEXT);
- SET_FogCoordfEXT(disp, glFogCoordfEXT);
- SET_FogCoordfvEXT(disp, glFogCoordfvEXT);
-#endif
-
-#if GL_EXT_framebuffer_blit
- SET_BlitFramebufferEXT(disp, glBlitFramebufferEXT);
-#endif
-
-#if GL_EXT_framebuffer_object
- SET_BindFramebufferEXT(disp, glBindFramebufferEXT);
- SET_BindRenderbufferEXT(disp, glBindRenderbufferEXT);
- SET_CheckFramebufferStatusEXT(disp, glCheckFramebufferStatusEXT);
- SET_DeleteFramebuffersEXT(disp, glDeleteFramebuffersEXT);
- SET_DeleteRenderbuffersEXT(disp, glDeleteRenderbuffersEXT);
- SET_FramebufferRenderbufferEXT(disp, glFramebufferRenderbufferEXT);
- SET_FramebufferTexture1DEXT(disp, glFramebufferTexture1DEXT);
- SET_FramebufferTexture2DEXT(disp, glFramebufferTexture2DEXT);
- SET_FramebufferTexture3DEXT(disp, glFramebufferTexture3DEXT);
- SET_GenerateMipmapEXT(disp, glGenerateMipmapEXT);
- SET_GenFramebuffersEXT(disp, glGenFramebuffersEXT);
- SET_GenRenderbuffersEXT(disp, glGenRenderbuffersEXT);
- SET_GetFramebufferAttachmentParameterivEXT(disp, glGetFramebufferAttachmentParameterivEXT);
- SET_GetRenderbufferParameterivEXT(disp, glGetRenderbufferParameterivEXT);
- SET_IsFramebufferEXT(disp, glIsFramebufferEXT);
- SET_IsRenderbufferEXT(disp, glIsRenderbufferEXT);
- SET_RenderbufferStorageEXT(disp, glRenderbufferStorageEXT);
-#endif
-
-#if GL_EXT_gpu_program_parameters
- SET_ProgramEnvParameters4fvEXT(disp, glProgramEnvParameters4fvEXT);
- SET_ProgramLocalParameters4fvEXT(disp, glProgramLocalParameters4fvEXT);
-#endif
-
-#if GL_EXT_multi_draw_arrays
- /* Pointer Incompatability:
- * This warning can be safely ignored. OpenGL.framework adds const to the
- * two pointers.
- *
- * extern void glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei);
- *
- * void ( * MultiDrawArraysEXT)(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount);
- */
- SET_MultiDrawArraysEXT(disp, (void *)glMultiDrawArraysEXT);
- SET_MultiDrawElementsEXT(disp, glMultiDrawElementsEXT);
-#endif
-
-#if GL_EXT_point_parameters
- SET_PointParameterfEXT(disp, glPointParameterfEXT);
- SET_PointParameterfvEXT(disp, glPointParameterfvEXT);
-#elif GL_ARB_point_parameters
- SET_PointParameterfEXT(disp, glPointParameterfARB);
- SET_PointParameterfvEXT(disp, glPointParameterfvARB);
-#endif
-
-#if GL_EXT_polygon_offset
- SET_PolygonOffsetEXT(disp, glPolygonOffsetEXT);
-#endif
-
-#if GL_EXT_secondary_color
- SET_SecondaryColor3bEXT(disp, glSecondaryColor3bEXT);
- SET_SecondaryColor3bvEXT(disp, glSecondaryColor3bvEXT);
- SET_SecondaryColor3dEXT(disp, glSecondaryColor3dEXT);
- SET_SecondaryColor3dvEXT(disp, glSecondaryColor3dvEXT);
- SET_SecondaryColor3fEXT(disp, glSecondaryColor3fEXT);
- SET_SecondaryColor3fvEXT(disp, glSecondaryColor3fvEXT);
- SET_SecondaryColor3iEXT(disp, glSecondaryColor3iEXT);
- SET_SecondaryColor3ivEXT(disp, glSecondaryColor3ivEXT);
- SET_SecondaryColor3sEXT(disp, glSecondaryColor3sEXT);
- SET_SecondaryColor3svEXT(disp, glSecondaryColor3svEXT);
- SET_SecondaryColor3ubEXT(disp, glSecondaryColor3ubEXT);
- SET_SecondaryColor3ubvEXT(disp, glSecondaryColor3ubvEXT);
- SET_SecondaryColor3uiEXT(disp, glSecondaryColor3uiEXT);
- SET_SecondaryColor3uivEXT(disp, glSecondaryColor3uivEXT);
- SET_SecondaryColor3usEXT(disp, glSecondaryColor3usEXT);
- SET_SecondaryColor3usvEXT(disp, glSecondaryColor3usvEXT);
- SET_SecondaryColorPointerEXT(disp, glSecondaryColorPointerEXT);
-#endif
-
-#if GL_EXT_stencil_two_side
- SET_ActiveStencilFaceEXT(disp, glActiveStencilFaceEXT);
-#endif
-
-#if GL_EXT_timer_query
- SET_GetQueryObjecti64vEXT(disp, glGetQueryObjecti64vEXT);
- SET_GetQueryObjectui64vEXT(disp, glGetQueryObjectui64vEXT);
-#endif
-
-#if GL_EXT_vertex_array
- SET_ColorPointerEXT(disp, glColorPointerEXT);
- SET_EdgeFlagPointerEXT(disp, glEdgeFlagPointerEXT);
- SET_IndexPointerEXT(disp, glIndexPointerEXT);
- SET_NormalPointerEXT(disp, glNormalPointerEXT);
- SET_TexCoordPointerEXT(disp, glTexCoordPointerEXT);
- SET_VertexPointerEXT(disp, glVertexPointerEXT);
-#endif
-
-#if GL_IBM_multimode_draw_arrays
- SET_MultiModeDrawArraysIBM(disp, glMultiModeDrawArraysIBM);
- SET_MultiModeDrawElementsIBM(disp, glMultiModeDrawElementsIBM);
-#endif
-
-#if GL_MESA_resize_buffers
- SET_ResizeBuffersMESA(disp, glResizeBuffersMESA);
-#endif
-
-#if GL_MESA_window_pos
- SET_WindowPos4dMESA(disp, glWindowPos4dMESA);
- SET_WindowPos4dvMESA(disp, glWindowPos4dvMESA);
- SET_WindowPos4fMESA(disp, glWindowPos4fMESA);
- SET_WindowPos4fvMESA(disp, glWindowPos4fvMESA);
- SET_WindowPos4iMESA(disp, glWindowPos4iMESA);
- SET_WindowPos4ivMESA(disp, glWindowPos4ivMESA);
- SET_WindowPos4sMESA(disp, glWindowPos4sMESA);
- SET_WindowPos4svMESA(disp, glWindowPos4svMESA);
-#endif
-
-#if GL_NV_fence
- SET_DeleteFencesNV(disp, glDeleteFencesNV);
- SET_FinishFenceNV(disp, glFinishFenceNV);
- SET_GenFencesNV(disp, glGenFencesNV);
- SET_GetFenceivNV(disp, glGetFenceivNV);
- SET_IsFenceNV(disp, glIsFenceNV);
- SET_SetFenceNV(disp, glSetFenceNV);
- SET_TestFenceNV(disp, glTestFenceNV);
-#endif
-
-#if GL_NV_fragment_program
- SET_GetProgramNamedParameterdvNV(disp, glGetProgramNamedParameterdvNV);
- SET_GetProgramNamedParameterfvNV(disp, glGetProgramNamedParameterfvNV);
- SET_ProgramNamedParameter4dNV(disp, glProgramNamedParameter4dNV);
- SET_ProgramNamedParameter4dvNV(disp, glProgramNamedParameter4dvNV);
- SET_ProgramNamedParameter4fNV(disp, glProgramNamedParameter4fNV);
- SET_ProgramNamedParameter4fvNV(disp, glProgramNamedParameter4fvNV);
-#endif
-
-#if GL_NV_geometry_program4
- SET_FramebufferTextureLayerEXT(disp, glFramebufferTextureLayerEXT);
-#endif
-
-#if GL_NV_point_sprite
- SET_PointParameteriNV(disp, glPointParameteriNV);
- SET_PointParameterivNV(disp, glPointParameterivNV);
-#endif
-
-#if GL_NV_register_combiners
- SET_CombinerInputNV(disp, glCombinerInputNV);
- SET_CombinerOutputNV(disp, glCombinerOutputNV);
- SET_CombinerParameterfNV(disp, glCombinerParameterfNV);
- SET_CombinerParameterfvNV(disp, glCombinerParameterfvNV);
- SET_CombinerParameteriNV(disp, glCombinerParameteriNV);
- SET_CombinerParameterivNV(disp, glCombinerParameterivNV);
- SET_FinalCombinerInputNV(disp, glFinalCombinerInputNV);
- SET_GetCombinerInputParameterfvNV(disp, glGetCombinerInputParameterfvNV);
- SET_GetCombinerInputParameterivNV(disp, glGetCombinerInputParameterivNV);
- SET_GetCombinerOutputParameterfvNV(disp, glGetCombinerOutputParameterfvNV);
- SET_GetCombinerOutputParameterivNV(disp, glGetCombinerOutputParameterivNV);
- SET_GetFinalCombinerInputParameterfvNV(disp, glGetFinalCombinerInputParameterfvNV);
- SET_GetFinalCombinerInputParameterivNV(disp, glGetFinalCombinerInputParameterivNV);
-#endif
-
-#if GL_NV_vertex_array_range
- SET_FlushVertexArrayRangeNV(disp, glFlushVertexArrayRangeNV);
- SET_VertexArrayRangeNV(disp, glVertexArrayRangeNV);
-#endif
-
-#if GL_NV_vertex_program
- SET_AreProgramsResidentNV(disp, glAreProgramsResidentNV);
- SET_BindProgramNV(disp, glBindProgramNV);
- SET_DeleteProgramsNV(disp, glDeleteProgramsNV);
- SET_ExecuteProgramNV(disp, glExecuteProgramNV);
- SET_GenProgramsNV(disp, glGenProgramsNV);
- SET_GetProgramParameterdvNV(disp, glGetProgramParameterdvNV);
- SET_GetProgramParameterfvNV(disp, glGetProgramParameterfvNV);
- SET_GetProgramStringNV(disp, glGetProgramStringNV);
- SET_GetProgramivNV(disp, glGetProgramivNV);
- SET_GetTrackMatrixivNV(disp, glGetTrackMatrixivNV);
- SET_GetVertexAttribPointervNV(disp, glGetVertexAttribPointervNV);
- SET_GetVertexAttribdvNV(disp, glGetVertexAttribdvNV);
- SET_GetVertexAttribfvNV(disp, glGetVertexAttribfvNV);
- SET_GetVertexAttribivNV(disp, glGetVertexAttribivNV);
- SET_IsProgramNV(disp, glIsProgramNV);
- SET_LoadProgramNV(disp, glLoadProgramNV);
- SET_ProgramParameters4dvNV(disp, glProgramParameters4dvNV);
- SET_ProgramParameters4fvNV(disp, glProgramParameters4fvNV);
- SET_RequestResidentProgramsNV(disp, glRequestResidentProgramsNV);
- SET_TrackMatrixNV(disp, glTrackMatrixNV);
- SET_VertexAttrib1dNV(disp, glVertexAttrib1dNV)
- SET_VertexAttrib1dvNV(disp, glVertexAttrib1dvNV)
- SET_VertexAttrib1fNV(disp, glVertexAttrib1fNV)
- SET_VertexAttrib1fvNV(disp, glVertexAttrib1fvNV)
- SET_VertexAttrib1sNV(disp, glVertexAttrib1sNV)
- SET_VertexAttrib1svNV(disp, glVertexAttrib1svNV)
- SET_VertexAttrib2dNV(disp, glVertexAttrib2dNV)
- SET_VertexAttrib2dvNV(disp, glVertexAttrib2dvNV)
- SET_VertexAttrib2fNV(disp, glVertexAttrib2fNV)
- SET_VertexAttrib2fvNV(disp, glVertexAttrib2fvNV)
- SET_VertexAttrib2sNV(disp, glVertexAttrib2sNV)
- SET_VertexAttrib2svNV(disp, glVertexAttrib2svNV)
- SET_VertexAttrib3dNV(disp, glVertexAttrib3dNV)
- SET_VertexAttrib3dvNV(disp, glVertexAttrib3dvNV)
- SET_VertexAttrib3fNV(disp, glVertexAttrib3fNV)
- SET_VertexAttrib3fvNV(disp, glVertexAttrib3fvNV)
- SET_VertexAttrib3sNV(disp, glVertexAttrib3sNV)
- SET_VertexAttrib3svNV(disp, glVertexAttrib3svNV)
- SET_VertexAttrib4dNV(disp, glVertexAttrib4dNV)
- SET_VertexAttrib4dvNV(disp, glVertexAttrib4dvNV)
- SET_VertexAttrib4fNV(disp, glVertexAttrib4fNV)
- SET_VertexAttrib4fvNV(disp, glVertexAttrib4fvNV)
- SET_VertexAttrib4sNV(disp, glVertexAttrib4sNV)
- SET_VertexAttrib4svNV(disp, glVertexAttrib4svNV)
- SET_VertexAttrib4ubNV(disp, glVertexAttrib4ubNV)
- SET_VertexAttrib4ubvNV(disp, glVertexAttrib4ubvNV)
- SET_VertexAttribPointerNV(disp, glVertexAttribPointerNV)
- SET_VertexAttribs1dvNV(disp, glVertexAttribs1dvNV)
- SET_VertexAttribs1fvNV(disp, glVertexAttribs1fvNV)
- SET_VertexAttribs1svNV(disp, glVertexAttribs1svNV)
- SET_VertexAttribs2dvNV(disp, glVertexAttribs2dvNV)
- SET_VertexAttribs2fvNV(disp, glVertexAttribs2fvNV)
- SET_VertexAttribs2svNV(disp, glVertexAttribs2svNV)
- SET_VertexAttribs3dvNV(disp, glVertexAttribs3dvNV)
- SET_VertexAttribs3fvNV(disp, glVertexAttribs3fvNV)
- SET_VertexAttribs3svNV(disp, glVertexAttribs3svNV)
- SET_VertexAttribs4dvNV(disp, glVertexAttribs4dvNV)
- SET_VertexAttribs4fvNV(disp, glVertexAttribs4fvNV)
- SET_VertexAttribs4svNV(disp, glVertexAttribs4svNV)
- SET_VertexAttribs4ubvNV(disp, glVertexAttribs4ubvNV)
-#endif
-
-#if GL_SGIS_multisample
- SET_SampleMaskSGIS(disp, glSampleMaskSGIS);
- SET_SamplePatternSGIS(disp, glSamplePatternSGIS);
-#endif
-
-#if GL_SGIS_pixel_texture
- SET_GetPixelTexGenParameterfvSGIS(disp, glGetPixelTexGenParameterfvSGIS);
- SET_GetPixelTexGenParameterivSGIS(disp, glGetPixelTexGenParameterivSGIS);
- SET_PixelTexGenParameterfSGIS(disp, glPixelTexGenParameterfSGIS);
- SET_PixelTexGenParameterfvSGIS(disp, glPixelTexGenParameterfvSGIS);
- SET_PixelTexGenParameteriSGIS(disp, glPixelTexGenParameteriSGIS);
- SET_PixelTexGenParameterivSGIS(disp, glPixelTexGenParameterivSGIS);
- SET_PixelTexGenSGIX(disp, glPixelTexGenSGIX);
-#endif
-}
+/* + * GLX implementation that uses Apple's OpenGL.framework + * (Indirect rendering path -- it's also used for some direct mode code too) + * + * Copyright (c) 2007, 2008, 2009 Apple Inc. + * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2002 Greg Parker. All Rights Reserved. + * + * Portions of this file are copied from Mesa's xf86glx.c, + * which contains the following copyright: + * + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "dri.h" + +#include <AvailabilityMacros.h> + +#define GL_GLEXT_WUNDEF_SUPPORT + +#include <OpenGL/OpenGL.h> +#include <OpenGL/gl.h> +#include <OpenGL/glext.h> +#include <OpenGL/CGLContext.h> + +/* These next few GL_EXT pre-processing blocks are to explicitly define + * these symbols to 0 if they are not set by OpenGL.framework. This + * prevents the X11 glext.h from setting them to 1. + */ + +#ifndef GL_EXT_fragment_shader +#define GL_EXT_fragment_shader 0 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 0 +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 0 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 0 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 0 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 0 +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 0 +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 0 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 0 +#endif + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 0 +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 0 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 0 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 0 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 0 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 0 +#endif + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 0 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 0 +#endif + +/* Tiger PPC doesn't have the associated symbols, but glext.h says it does. Liars! + * http://trac.macports.org/ticket/20638 + */ +#if defined(__ppc__) && MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +#undef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 0 +#endif + +#include <GL/glxproto.h> +#include <windowstr.h> +#include <resource.h> +#include <GL/glxint.h> +#include <GL/glxtokens.h> +#include <scrnintstr.h> +#include <glxserver.h> +#include <glxscreens.h> +#include <glxdrawable.h> +#include <glxcontext.h> +#include <glxext.h> +#include <glxutil.h> +#include <GL/internal/glcore.h> +#include "x-hash.h" +#include "x-list.h" + +//#include "capabilities.h" +#include "visualConfigs.h" + +typedef unsigned long long GLuint64EXT; +typedef long long GLint64EXT; +#include <dispatch.h> +#include <Xplugin.h> +#include <glapi.h> +#include <glapitable.h> + +__GLXprovider * GlxGetDRISWrastProvider (void); + +// Write debugging output, or not +#ifdef GLAQUA_DEBUG +#define GLAQUA_DEBUG_MSG ErrorF +#else +#define GLAQUA_DEBUG_MSG(a, ...) +#endif + +static void setup_dispatch_table(void); +GLuint __glFloorLog2(GLuint val); +void warn_func(void * p1, char *format, ...); + +// some prototypes +static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen); +static __GLXdrawable * __glXAquaScreenCreateDrawable(ClientPtr client, __GLXscreen *screen, DrawablePtr pDraw, XID drawId, int type, XID glxDrawId, __GLXconfig *conf); + +static void __glXAquaContextDestroy(__GLXcontext *baseContext); +static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext); +static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext); +static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask); + +static CGLPixelFormatObj makeFormat(__GLXconfig *conf); + +__GLXprovider __glXDRISWRastProvider = { + __glXAquaScreenProbe, + "Core OpenGL", + NULL +}; + +typedef struct __GLXAquaScreen __GLXAquaScreen; +typedef struct __GLXAquaContext __GLXAquaContext; +typedef struct __GLXAquaDrawable __GLXAquaDrawable; + +struct __GLXAquaScreen { + __GLXscreen base; + int index; + int num_vis; +}; + +struct __GLXAquaContext { + __GLXcontext base; + CGLContextObj ctx; + CGLPixelFormatObj pixelFormat; + xp_surface_id sid; + unsigned isAttached :1; +}; + +struct __GLXAquaDrawable { + __GLXdrawable base; + DrawablePtr pDraw; + xp_surface_id sid; + __GLXAquaContext *context; +}; + + +static __GLXcontext * +__glXAquaScreenCreateContext(__GLXscreen *screen, + __GLXconfig *conf, + __GLXcontext *baseShareContext) +{ + __GLXAquaContext *context; + __GLXAquaContext *shareContext = (__GLXAquaContext *) baseShareContext; + CGLError gl_err; + + GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n"); + + context = calloc(1, sizeof (__GLXAquaContext)); + + if (context == NULL) + return NULL; + + memset(context, 0, sizeof *context); + + context->base.pGlxScreen = screen; + + context->base.destroy = __glXAquaContextDestroy; + context->base.makeCurrent = __glXAquaContextMakeCurrent; + context->base.loseCurrent = __glXAquaContextLoseCurrent; + context->base.copy = __glXAquaContextCopy; + /*FIXME verify that the context->base is fully initialized. */ + + context->pixelFormat = makeFormat(conf); + + if (!context->pixelFormat) { + free(context); + return NULL; + } + + context->ctx = NULL; + gl_err = CGLCreateContext(context->pixelFormat, + shareContext ? shareContext->ctx : NULL, + &context->ctx); + + if (gl_err != 0) { + ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err)); + CGLDestroyPixelFormat(context->pixelFormat); + free(context); + return NULL; + } + + setup_dispatch_table(); + GLAQUA_DEBUG_MSG("glAquaCreateContext done\n"); + + return &context->base; +} + +/* maps from surface id -> list of __GLcontext */ +static x_hash_table *surface_hash; + +static void __glXAquaContextDestroy(__GLXcontext *baseContext) { + x_list *lst; + + __GLXAquaContext *context = (__GLXAquaContext *) baseContext; + + GLAQUA_DEBUG_MSG("glAquaContextDestroy (ctx %p)\n", baseContext); + if (context != NULL) { + if (context->sid != 0 && surface_hash != NULL) { + lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL); + lst = x_list_remove(lst, context); + x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst); + } + + if (context->ctx != NULL) + CGLDestroyContext(context->ctx); + + if (context->pixelFormat != NULL) + CGLDestroyPixelFormat(context->pixelFormat); + + free(context); + } +} + +static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext) { + CGLError gl_err; + + GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%p)\n", baseContext); + + gl_err = CGLSetCurrentContext(NULL); + if (gl_err != 0) + ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); + + __glXLastContext = NULL; // Mesa does this; why? + + return GL_TRUE; +} + +/* Called when a surface is destroyed as a side effect of destroying + the window it's attached to. */ +static void surface_notify(void *_arg, void *data) { + DRISurfaceNotifyArg *arg = (DRISurfaceNotifyArg *)_arg; + __GLXAquaDrawable *draw = (__GLXAquaDrawable *)data; + __GLXAquaContext *context; + x_list *lst; + if(_arg == NULL || data == NULL) { + ErrorF("surface_notify called with bad params"); + return; + } + + GLAQUA_DEBUG_MSG("surface_notify(%p, %p)\n", _arg, data); + switch (arg->kind) { + case AppleDRISurfaceNotifyDestroyed: + if (surface_hash != NULL) + x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(arg->id)); + draw->pDraw = NULL; + draw->sid = 0; + break; + + case AppleDRISurfaceNotifyChanged: + if (surface_hash != NULL) { + lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id), NULL); + for (; lst != NULL; lst = lst->next) + { + context = lst->data; + xp_update_gl_context(context->ctx); + } + } + break; + default: + ErrorF("surface_notify: unknown kind %d\n", arg->kind); + break; + } +} + +static BOOL attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) { + DrawablePtr pDraw; + + GLAQUA_DEBUG_MSG("attach(%p, %p)\n", context, draw); + + if(NULL == context || NULL == draw) + return TRUE; + + pDraw = draw->base.pDraw; + + if(NULL == pDraw) { + ErrorF("%s:%s() pDraw is NULL!\n", __FILE__, __func__); + return TRUE; + } + + if (draw->sid == 0) { + //if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw, + if (!DRICreateSurface(pDraw->pScreen, pDraw->id, pDraw, + 0, &draw->sid, NULL, + surface_notify, draw)) + return TRUE; + draw->pDraw = pDraw; + } + + if (!context->isAttached || context->sid != draw->sid) { + x_list *lst; + + if (xp_attach_gl_context(context->ctx, draw->sid) != Success) { + //quartzProcs->DestroySurface(pDraw->pScreen, pDraw->id, pDraw, + DRIDestroySurface(pDraw->pScreen, pDraw->id, pDraw, + surface_notify, draw); + if (surface_hash != NULL) + x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(draw->sid)); + + draw->sid = 0; + return TRUE; + } + + context->isAttached = TRUE; + context->sid = draw->sid; + + if (surface_hash == NULL) + surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL); + + lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL); + if (x_list_find(lst, context) == NULL) { + lst = x_list_prepend(lst, context); + x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst); + } + + + + GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id, + (unsigned int) draw->sid); + } + + draw->context = context; + + return FALSE; +} + +#if 0 // unused +static void unattach(__GLXAquaContext *context) { + x_list *lst; + GLAQUA_DEBUG_MSG("unattach\n"); + if (context == NULL) { + ErrorF("Tried to unattach a null context\n"); + return; + } + if (context->isAttached) { + GLAQUA_DEBUG_MSG("unattaching\n"); + + if (surface_hash != NULL) { + lst = x_hash_table_lookup(surface_hash, (void *) context->sid, NULL); + lst = x_list_remove(lst, context); + x_hash_table_insert(surface_hash, (void *) context->sid, lst); + } + + CGLClearDrawable(context->ctx); + context->isAttached = FALSE; + context->sid = 0; + } +} +#endif + +static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext) { + CGLError gl_err; + __GLXAquaContext *context = (__GLXAquaContext *) baseContext; + __GLXAquaDrawable *drawPriv = (__GLXAquaDrawable *) context->base.drawPriv; + + GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%p)\n", baseContext); + + if(attach(context, drawPriv)) + return /*error*/ 0; + + gl_err = CGLSetCurrentContext(context->ctx); + if (gl_err != 0) + ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); + + return gl_err == 0; +} + +static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask) +{ + CGLError gl_err; + + __GLXAquaContext *dst = (__GLXAquaContext *) baseDst; + __GLXAquaContext *src = (__GLXAquaContext *) baseSrc; + + GLAQUA_DEBUG_MSG("GLXAquaContextCopy\n"); + + gl_err = CGLCopyContext(src->ctx, dst->ctx, mask); + if (gl_err != 0) + ErrorF("CGLCopyContext error: %s\n", CGLErrorString(gl_err)); + + return gl_err == 0; +} + +/* Drawing surface notification callbacks */ +static GLboolean __glXAquaDrawableSwapBuffers(ClientPtr client, __GLXdrawable *base) { + CGLError err; + __GLXAquaDrawable *drawable; + + // GLAQUA_DEBUG_MSG("glAquaDrawableSwapBuffers(%p)\n",base); + + if(!base) { + ErrorF("%s passed NULL\n", __func__); + return GL_FALSE; + } + + drawable = (__GLXAquaDrawable *)base; + + if(NULL == drawable->context) { + ErrorF("%s called with a NULL->context for drawable %p!\n", + __func__, (void *)drawable); + return GL_FALSE; + } + + err = CGLFlushDrawable(drawable->context->ctx); + + if(kCGLNoError != err) { + ErrorF("CGLFlushDrawable error: %s in %s\n", CGLErrorString(err), + __func__); + return GL_FALSE; + } + + return GL_TRUE; +} + + +static CGLPixelFormatObj makeFormat(__GLXconfig *conf) { + CGLPixelFormatAttribute attr[64]; + CGLPixelFormatObj fobj; + GLint formats; + CGLError error; + int i = 0; + + if(conf->doubleBufferMode) + attr[i++] = kCGLPFADoubleBuffer; + + if(conf->stereoMode) + attr[i++] = kCGLPFAStereo; + + attr[i++] = kCGLPFAColorSize; + attr[i++] = conf->redBits + conf->greenBits + conf->blueBits; + attr[i++] = kCGLPFAAlphaSize; + attr[i++] = conf->alphaBits; + + if((conf->accumRedBits + conf->accumGreenBits + conf->accumBlueBits + + conf->accumAlphaBits) > 0) { + + attr[i++] = kCGLPFAAccumSize; + attr[i++] = conf->accumRedBits + conf->accumGreenBits + + conf->accumBlueBits + conf->accumAlphaBits; + } + + attr[i++] = kCGLPFADepthSize; + attr[i++] = conf->depthBits; + + if(conf->stencilBits) { + attr[i++] = kCGLPFAStencilSize; + attr[i++] = conf->stencilBits; + } + + if(conf->numAuxBuffers > 0) { + attr[i++] = kCGLPFAAuxBuffers; + attr[i++] = conf->numAuxBuffers; + } + + if(conf->sampleBuffers > 0) { + attr[i++] = kCGLPFASampleBuffers; + attr[i++] = conf->sampleBuffers; + attr[i++] = kCGLPFASamples; + attr[i++] = conf->samples; + } + + attr[i] = 0; + + error = CGLChoosePixelFormat(attr, &fobj, &formats); + if(error) { + ErrorF("error: creating pixel format %s\n", CGLErrorString(error)); + return NULL; + } + + return fobj; +} + +static void __glXAquaScreenDestroy(__GLXscreen *screen) { + + GLAQUA_DEBUG_MSG("glXAquaScreenDestroy(%p)\n", screen); + __glXScreenDestroy(screen); + + free(screen); +} + +/* This is called by __glXInitScreens(). */ +static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) { + __GLXAquaScreen *screen; + + GLAQUA_DEBUG_MSG("glXAquaScreenProbe\n"); + + if (pScreen == NULL) + return NULL; + + screen = calloc(1, sizeof *screen); + + if(NULL == screen) + return NULL; + + screen->base.destroy = __glXAquaScreenDestroy; + screen->base.createContext = __glXAquaScreenCreateContext; + screen->base.createDrawable = __glXAquaScreenCreateDrawable; + screen->base.swapInterval = /*FIXME*/ NULL; + screen->base.pScreen = pScreen; + + screen->base.fbconfigs = __glXAquaCreateVisualConfigs(&screen->base.numFBConfigs, pScreen->myNum); + + __glXScreenInit(&screen->base, pScreen); + + screen->base.GLXversion = strdup("1.4"); + screen->base.GLXextensions = strdup("GLX_SGIX_fbconfig " + "GLX_SGIS_multisample " + "GLX_ARB_multisample " + "GLX_EXT_visual_info " + "GLX_EXT_import_context "); + + /*We may be able to add more GLXextensions at a later time. */ + + return &screen->base; +} + +#if 0 // unused +static void __glXAquaDrawableCopySubBuffer (__GLXdrawable *drawable, + int x, int y, int w, int h) { + /*TODO finish me*/ +} +#endif + +static void __glXAquaDrawableDestroy(__GLXdrawable *base) { + /* gstaplin: base is the head of the structure, so it's at the same + * offset in memory. + * Is this safe with strict aliasing? I noticed that the other dri code + * does this too... + */ + __GLXAquaDrawable *glxPriv = (__GLXAquaDrawable *)base; + + GLAQUA_DEBUG_MSG(__func__); + + /* It doesn't work to call DRIDestroySurface here, the drawable's + already gone.. But dri.c notices the window destruction and + frees the surface itself. */ + + /*gstaplin: verify the statement above. The surface destroy + *messages weren't making it through, and may still not be. + *We need a good test case for surface creation and destruction. + *We also need a good way to enable introspection on the server + *to validate the test, beyond using gdb with print. + */ + + free(glxPriv); +} + +static __GLXdrawable * +__glXAquaScreenCreateDrawable(ClientPtr client, + __GLXscreen *screen, + DrawablePtr pDraw, + XID drawId, + int type, + XID glxDrawId, + __GLXconfig *conf) { + __GLXAquaDrawable *glxPriv; + + glxPriv = malloc(sizeof *glxPriv); + + if(glxPriv == NULL) + return NULL; + + memset(glxPriv, 0, sizeof *glxPriv); + + if(!__glXDrawableInit(&glxPriv->base, screen, pDraw, type, glxDrawId, conf)) { + free(glxPriv); + return NULL; + } + + glxPriv->base.destroy = __glXAquaDrawableDestroy; + glxPriv->base.swapBuffers = __glXAquaDrawableSwapBuffers; + glxPriv->base.copySubBuffer = NULL; /* __glXAquaDrawableCopySubBuffer; */ + + glxPriv->pDraw = pDraw; + glxPriv->sid = 0; + glxPriv->context = NULL; + + return &glxPriv->base; +} + +// Extra goodies for glx + +GLuint __glFloorLog2(GLuint val) +{ + int c = 0; + + while (val > 1) { + c++; + val >>= 1; + } + return c; +} + +static void setup_dispatch_table(void) { + struct _glapi_table *disp=_glapi_get_dispatch(); + + /* to update: + * for f in $(grep 'define SET_' ../../../glx/dispatch.h | cut -f2 -d' ' | cut -f1 -d\( | sort -u); do grep -q $f indirect.c || echo $f ; done | grep -v by_offset | sed 's:SET_\(.*\)$:SET_\1(disp, gl\1)\;:' | pbcopy + */ + + SET_Accum(disp, glAccum); + SET_AlphaFunc(disp, glAlphaFunc); + SET_AreTexturesResident(disp, glAreTexturesResident); + SET_ArrayElement(disp, glArrayElement); + SET_Begin(disp, glBegin); + SET_BindTexture(disp, glBindTexture); + SET_Bitmap(disp, glBitmap); + SET_BlendColor(disp, glBlendColor); + SET_BlendEquation(disp, glBlendEquation); + SET_BlendFunc(disp, glBlendFunc); + SET_CallList(disp, glCallList); + SET_CallLists(disp, glCallLists); + SET_Clear(disp, glClear); + SET_ClearAccum(disp, glClearAccum); + SET_ClearColor(disp, glClearColor); + SET_ClearDepth(disp, glClearDepth); + SET_ClearIndex(disp, glClearIndex); + SET_ClearStencil(disp, glClearStencil); + SET_ClipPlane(disp, glClipPlane); + SET_Color3b(disp, glColor3b); + SET_Color3bv(disp, glColor3bv); + SET_Color3d(disp, glColor3d); + SET_Color3dv(disp, glColor3dv); + SET_Color3f(disp, glColor3f); + SET_Color3fv(disp, glColor3fv); + SET_Color3i(disp, glColor3i); + SET_Color3iv(disp, glColor3iv); + SET_Color3s(disp, glColor3s); + SET_Color3sv(disp, glColor3sv); + SET_Color3ub(disp, glColor3ub); + SET_Color3ubv(disp, glColor3ubv); + SET_Color3ui(disp, glColor3ui); + SET_Color3uiv(disp, glColor3uiv); + SET_Color3us(disp, glColor3us); + SET_Color3usv(disp, glColor3usv); + SET_Color4b(disp, glColor4b); + SET_Color4bv(disp, glColor4bv); + SET_Color4d(disp, glColor4d); + SET_Color4dv(disp, glColor4dv); + SET_Color4f(disp, glColor4f); + SET_Color4fv(disp, glColor4fv); + SET_Color4i(disp, glColor4i); + SET_Color4iv(disp, glColor4iv); + SET_Color4s(disp, glColor4s); + SET_Color4sv(disp, glColor4sv); + SET_Color4ub(disp, glColor4ub); + SET_Color4ubv(disp, glColor4ubv); + SET_Color4ui(disp, glColor4ui); + SET_Color4uiv(disp, glColor4uiv); + SET_Color4us(disp, glColor4us); + SET_Color4usv(disp, glColor4usv); + SET_ColorMask(disp, glColorMask); + SET_ColorMaterial(disp, glColorMaterial); + SET_ColorPointer(disp, glColorPointer); + SET_ColorSubTable(disp, glColorSubTable); + SET_ColorTable(disp, glColorTable); + SET_ColorTableParameterfv(disp, glColorTableParameterfv); + SET_ColorTableParameteriv(disp, glColorTableParameteriv); + SET_ConvolutionFilter1D(disp, glConvolutionFilter1D); + SET_ConvolutionFilter2D(disp, glConvolutionFilter2D); + SET_ConvolutionParameterf(disp, glConvolutionParameterf); + SET_ConvolutionParameterfv(disp, glConvolutionParameterfv); + SET_ConvolutionParameteri(disp, glConvolutionParameteri); + SET_ConvolutionParameteriv(disp, glConvolutionParameteriv); + SET_CopyColorSubTable(disp, glCopyColorSubTable); + SET_CopyColorTable(disp, glCopyColorTable); + SET_CopyConvolutionFilter1D(disp, glCopyConvolutionFilter1D); + SET_CopyConvolutionFilter2D(disp, glCopyConvolutionFilter2D); + SET_CopyPixels(disp, glCopyPixels); + SET_CopyTexImage1D(disp, glCopyTexImage1D); + SET_CopyTexImage2D(disp, glCopyTexImage2D); + SET_CopyTexSubImage1D(disp, glCopyTexSubImage1D); + SET_CopyTexSubImage2D(disp, glCopyTexSubImage2D); + SET_CopyTexSubImage3D(disp, glCopyTexSubImage3D); + SET_CullFace(disp, glCullFace); + SET_DeleteLists(disp, glDeleteLists); + SET_DeleteTextures(disp, glDeleteTextures); + SET_DepthFunc(disp, glDepthFunc); + SET_DepthMask(disp, glDepthMask); + SET_DepthRange(disp, glDepthRange); + SET_Disable(disp, glDisable); + SET_DisableClientState(disp, glDisableClientState); + SET_DrawArrays(disp, glDrawArrays); + SET_DrawBuffer(disp, glDrawBuffer); + SET_DrawElements(disp, glDrawElements); + SET_DrawPixels(disp, glDrawPixels); + SET_DrawRangeElements(disp, glDrawRangeElements); + SET_EdgeFlag(disp, glEdgeFlag); + SET_EdgeFlagPointer(disp, glEdgeFlagPointer); + SET_EdgeFlagv(disp, glEdgeFlagv); + SET_Enable(disp, glEnable); + SET_EnableClientState(disp, glEnableClientState); + SET_End(disp, glEnd); + SET_EndList(disp, glEndList); + SET_EvalCoord1d(disp, glEvalCoord1d); + SET_EvalCoord1dv(disp, glEvalCoord1dv); + SET_EvalCoord1f(disp, glEvalCoord1f); + SET_EvalCoord1fv(disp, glEvalCoord1fv); + SET_EvalCoord2d(disp, glEvalCoord2d); + SET_EvalCoord2dv(disp, glEvalCoord2dv); + SET_EvalCoord2f(disp, glEvalCoord2f); + SET_EvalCoord2fv(disp, glEvalCoord2fv); + SET_EvalMesh1(disp, glEvalMesh1); + SET_EvalMesh2(disp, glEvalMesh2); + SET_EvalPoint1(disp, glEvalPoint1); + SET_EvalPoint2(disp, glEvalPoint2); + SET_FeedbackBuffer(disp, glFeedbackBuffer); + SET_Finish(disp, glFinish); + SET_Flush(disp, glFlush); + SET_Fogf(disp, glFogf); + SET_Fogfv(disp, glFogfv); + SET_Fogi(disp, glFogi); + SET_Fogiv(disp, glFogiv); + SET_FrontFace(disp, glFrontFace); + SET_Frustum(disp, glFrustum); + SET_GenLists(disp, glGenLists); + SET_GenTextures(disp, glGenTextures); + SET_GetBooleanv(disp, glGetBooleanv); + SET_GetClipPlane(disp, glGetClipPlane); + SET_GetColorTable(disp, glGetColorTable); + SET_GetColorTableParameterfv(disp, glGetColorTableParameterfv); + SET_GetColorTableParameteriv(disp, glGetColorTableParameteriv); + SET_GetConvolutionFilter(disp, glGetConvolutionFilter); + SET_GetConvolutionParameterfv(disp, glGetConvolutionParameterfv); + SET_GetConvolutionParameteriv(disp, glGetConvolutionParameteriv); + SET_GetDoublev(disp, glGetDoublev); + SET_GetError(disp, glGetError); + SET_GetFloatv(disp, glGetFloatv); + SET_GetHistogram(disp, glGetHistogram); + SET_GetHistogramParameterfv(disp, glGetHistogramParameterfv); + SET_GetHistogramParameteriv(disp, glGetHistogramParameteriv); + SET_GetIntegerv(disp, glGetIntegerv); + SET_GetLightfv(disp, glGetLightfv); + SET_GetLightiv(disp, glGetLightiv); + SET_GetMapdv(disp, glGetMapdv); + SET_GetMapfv(disp, glGetMapfv); + SET_GetMapiv(disp, glGetMapiv); + SET_GetMaterialfv(disp, glGetMaterialfv); + SET_GetMaterialiv(disp, glGetMaterialiv); + SET_GetMinmax(disp, glGetMinmax); + SET_GetMinmaxParameterfv(disp, glGetMinmaxParameterfv); + SET_GetMinmaxParameteriv(disp, glGetMinmaxParameteriv); + SET_GetPixelMapfv(disp, glGetPixelMapfv); + SET_GetPixelMapuiv(disp, glGetPixelMapuiv); + SET_GetPixelMapusv(disp, glGetPixelMapusv); + SET_GetPointerv(disp, glGetPointerv); + SET_GetPolygonStipple(disp, glGetPolygonStipple); + SET_GetSeparableFilter(disp, glGetSeparableFilter); + SET_GetString(disp, glGetString); + SET_GetTexEnvfv(disp, glGetTexEnvfv); + SET_GetTexEnviv(disp, glGetTexEnviv); + SET_GetTexGendv(disp, glGetTexGendv); + SET_GetTexGenfv(disp, glGetTexGenfv); + SET_GetTexGeniv(disp, glGetTexGeniv); + SET_GetTexImage(disp, glGetTexImage); + SET_GetTexLevelParameterfv(disp, glGetTexLevelParameterfv); + SET_GetTexLevelParameteriv(disp, glGetTexLevelParameteriv); + SET_GetTexParameterfv(disp, glGetTexParameterfv); + SET_GetTexParameteriv(disp, glGetTexParameteriv); + SET_Hint(disp, glHint); + SET_Histogram(disp, glHistogram); + SET_IndexMask(disp, glIndexMask); + SET_IndexPointer(disp, glIndexPointer); + SET_Indexd(disp, glIndexd); + SET_Indexdv(disp, glIndexdv); + SET_Indexf(disp, glIndexf); + SET_Indexfv(disp, glIndexfv); + SET_Indexi(disp, glIndexi); + SET_Indexiv(disp, glIndexiv); + SET_Indexs(disp, glIndexs); + SET_Indexsv(disp, glIndexsv); + SET_Indexub(disp, glIndexub); + SET_Indexubv(disp, glIndexubv); + SET_InitNames(disp, glInitNames); + SET_InterleavedArrays(disp, glInterleavedArrays); + SET_IsEnabled(disp, glIsEnabled); + SET_IsList(disp, glIsList); + SET_IsTexture(disp, glIsTexture); + SET_LightModelf(disp, glLightModelf); + SET_LightModelfv(disp, glLightModelfv); + SET_LightModeli(disp, glLightModeli); + SET_LightModeliv(disp, glLightModeliv); + SET_Lightf(disp, glLightf); + SET_Lightfv(disp, glLightfv); + SET_Lighti(disp, glLighti); + SET_Lightiv(disp, glLightiv); + SET_LineStipple(disp, glLineStipple); + SET_LineWidth(disp, glLineWidth); + SET_ListBase(disp, glListBase); + SET_LoadIdentity(disp, glLoadIdentity); + SET_LoadMatrixd(disp, glLoadMatrixd); + SET_LoadMatrixf(disp, glLoadMatrixf); + SET_LoadName(disp, glLoadName); + SET_LogicOp(disp, glLogicOp); + SET_Map1d(disp, glMap1d); + SET_Map1f(disp, glMap1f); + SET_Map2d(disp, glMap2d); + SET_Map2f(disp, glMap2f); + SET_MapGrid1d(disp, glMapGrid1d); + SET_MapGrid1f(disp, glMapGrid1f); + SET_MapGrid2d(disp, glMapGrid2d); + SET_MapGrid2f(disp, glMapGrid2f); + SET_Materialf(disp, glMaterialf); + SET_Materialfv(disp, glMaterialfv); + SET_Materiali(disp, glMateriali); + SET_Materialiv(disp, glMaterialiv); + SET_MatrixMode(disp, glMatrixMode); + SET_Minmax(disp, glMinmax); + SET_MultMatrixd(disp, glMultMatrixd); + SET_MultMatrixf(disp, glMultMatrixf); + SET_NewList(disp, glNewList); + SET_Normal3b(disp, glNormal3b); + SET_Normal3bv(disp, glNormal3bv); + SET_Normal3d(disp, glNormal3d); + SET_Normal3dv(disp, glNormal3dv); + SET_Normal3f(disp, glNormal3f); + SET_Normal3fv(disp, glNormal3fv); + SET_Normal3i(disp, glNormal3i); + SET_Normal3iv(disp, glNormal3iv); + SET_Normal3s(disp, glNormal3s); + SET_Normal3sv(disp, glNormal3sv); + SET_NormalPointer(disp, glNormalPointer); + SET_Ortho(disp, glOrtho); + SET_PassThrough(disp, glPassThrough); + SET_PixelMapfv(disp, glPixelMapfv); + SET_PixelMapuiv(disp, glPixelMapuiv); + SET_PixelMapusv(disp, glPixelMapusv); + SET_PixelStoref(disp, glPixelStoref); + SET_PixelStorei(disp, glPixelStorei); + SET_PixelTransferf(disp, glPixelTransferf); + SET_PixelTransferi(disp, glPixelTransferi); + SET_PixelZoom(disp, glPixelZoom); + SET_PointSize(disp, glPointSize); + SET_PolygonMode(disp, glPolygonMode); + SET_PolygonOffset(disp, glPolygonOffset); + SET_PolygonStipple(disp, glPolygonStipple); + SET_PopAttrib(disp, glPopAttrib); + SET_PopClientAttrib(disp, glPopClientAttrib); + SET_PopMatrix(disp, glPopMatrix); + SET_PopName(disp, glPopName); + SET_PrioritizeTextures(disp, glPrioritizeTextures); + SET_PushAttrib(disp, glPushAttrib); + SET_PushClientAttrib(disp, glPushClientAttrib); + SET_PushMatrix(disp, glPushMatrix); + SET_PushName(disp, glPushName); + SET_RasterPos2d(disp, glRasterPos2d); + SET_RasterPos2dv(disp, glRasterPos2dv); + SET_RasterPos2f(disp, glRasterPos2f); + SET_RasterPos2fv(disp, glRasterPos2fv); + SET_RasterPos2i(disp, glRasterPos2i); + SET_RasterPos2iv(disp, glRasterPos2iv); + SET_RasterPos2s(disp, glRasterPos2s); + SET_RasterPos2sv(disp, glRasterPos2sv); + SET_RasterPos3d(disp, glRasterPos3d); + SET_RasterPos3dv(disp, glRasterPos3dv); + SET_RasterPos3f(disp, glRasterPos3f); + SET_RasterPos3fv(disp, glRasterPos3fv); + SET_RasterPos3i(disp, glRasterPos3i); + SET_RasterPos3iv(disp, glRasterPos3iv); + SET_RasterPos3s(disp, glRasterPos3s); + SET_RasterPos3sv(disp, glRasterPos3sv); + SET_RasterPos4d(disp, glRasterPos4d); + SET_RasterPos4dv(disp, glRasterPos4dv); + SET_RasterPos4f(disp, glRasterPos4f); + SET_RasterPos4fv(disp, glRasterPos4fv); + SET_RasterPos4i(disp, glRasterPos4i); + SET_RasterPos4iv(disp, glRasterPos4iv); + SET_RasterPos4s(disp, glRasterPos4s); + SET_RasterPos4sv(disp, glRasterPos4sv); + SET_ReadBuffer(disp, glReadBuffer); + SET_ReadPixels(disp, glReadPixels); + SET_Rectd(disp, glRectd); + SET_Rectdv(disp, glRectdv); + SET_Rectf(disp, glRectf); + SET_Rectfv(disp, glRectfv); + SET_Recti(disp, glRecti); + SET_Rectiv(disp, glRectiv); + SET_Rects(disp, glRects); + SET_Rectsv(disp, glRectsv); + SET_RenderMode(disp, glRenderMode); + SET_ResetHistogram(disp, glResetHistogram); + SET_ResetMinmax(disp, glResetMinmax); + SET_Rotated(disp, glRotated); + SET_Rotatef(disp, glRotatef); + SET_Scaled(disp, glScaled); + SET_Scalef(disp, glScalef); + SET_Scissor(disp, glScissor); + SET_SelectBuffer(disp, glSelectBuffer); + SET_SeparableFilter2D(disp, glSeparableFilter2D); + SET_ShadeModel(disp, glShadeModel); + SET_StencilFunc(disp, glStencilFunc); + SET_StencilMask(disp, glStencilMask); + SET_StencilOp(disp, glStencilOp); + SET_TexCoord1d(disp, glTexCoord1d); + SET_TexCoord1dv(disp, glTexCoord1dv); + SET_TexCoord1f(disp, glTexCoord1f); + SET_TexCoord1fv(disp, glTexCoord1fv); + SET_TexCoord1i(disp, glTexCoord1i); + SET_TexCoord1iv(disp, glTexCoord1iv); + SET_TexCoord1s(disp, glTexCoord1s); + SET_TexCoord1sv(disp, glTexCoord1sv); + SET_TexCoord2d(disp, glTexCoord2d); + SET_TexCoord2dv(disp, glTexCoord2dv); + SET_TexCoord2f(disp, glTexCoord2f); + SET_TexCoord2fv(disp, glTexCoord2fv); + SET_TexCoord2i(disp, glTexCoord2i); + SET_TexCoord2iv(disp, glTexCoord2iv); + SET_TexCoord2s(disp, glTexCoord2s); + SET_TexCoord2sv(disp, glTexCoord2sv); + SET_TexCoord3d(disp, glTexCoord3d); + SET_TexCoord3dv(disp, glTexCoord3dv); + SET_TexCoord3f(disp, glTexCoord3f); + SET_TexCoord3fv(disp, glTexCoord3fv); + SET_TexCoord3i(disp, glTexCoord3i); + SET_TexCoord3iv(disp, glTexCoord3iv); + SET_TexCoord3s(disp, glTexCoord3s); + SET_TexCoord3sv(disp, glTexCoord3sv); + SET_TexCoord4d(disp, glTexCoord4d); + SET_TexCoord4dv(disp, glTexCoord4dv); + SET_TexCoord4f(disp, glTexCoord4f); + SET_TexCoord4fv(disp, glTexCoord4fv); + SET_TexCoord4i(disp, glTexCoord4i); + SET_TexCoord4iv(disp, glTexCoord4iv); + SET_TexCoord4s(disp, glTexCoord4s); + SET_TexCoord4sv(disp, glTexCoord4sv); + SET_TexCoordPointer(disp, glTexCoordPointer); + SET_TexEnvf(disp, glTexEnvf); + SET_TexEnvfv(disp, glTexEnvfv); + SET_TexEnvi(disp, glTexEnvi); + SET_TexEnviv(disp, glTexEnviv); + SET_TexGend(disp, glTexGend); + SET_TexGendv(disp, glTexGendv); + SET_TexGenf(disp, glTexGenf); + SET_TexGenfv(disp, glTexGenfv); + SET_TexGeni(disp, glTexGeni); + SET_TexGeniv(disp, glTexGeniv); + + /* Pointer Incompatability: + * internalformat is a GLenum according to /System/Library/Frameworks/OpenGL.framework/Headers/gl.h + * extern void glTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + * extern void glTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + * extern void glTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + * + * and it's a GLint in glx/glapitable.h and according to the man page + * void ( * TexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels); + * void ( * TexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels); + * void ( * TexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels); + * + * <rdar://problem/6953344> gl.h contains incorrect prototypes for glTexImage[123]D + */ + + SET_TexImage1D(disp, (void *)glTexImage1D); + SET_TexImage2D(disp, (void *)glTexImage2D); + SET_TexImage3D(disp, (void *)glTexImage3D); + SET_TexParameterf(disp, glTexParameterf); + SET_TexParameterfv(disp, glTexParameterfv); + SET_TexParameteri(disp, glTexParameteri); + SET_TexParameteriv(disp, glTexParameteriv); + SET_TexSubImage1D(disp, glTexSubImage1D); + SET_TexSubImage2D(disp, glTexSubImage2D); + SET_TexSubImage3D(disp, glTexSubImage3D); + SET_Translated(disp, glTranslated); + SET_Translatef(disp, glTranslatef); + SET_Vertex2d(disp, glVertex2d); + SET_Vertex2dv(disp, glVertex2dv); + SET_Vertex2f(disp, glVertex2f); + SET_Vertex2fv(disp, glVertex2fv); + SET_Vertex2i(disp, glVertex2i); + SET_Vertex2iv(disp, glVertex2iv); + SET_Vertex2s(disp, glVertex2s); + SET_Vertex2sv(disp, glVertex2sv); + SET_Vertex3d(disp, glVertex3d); + SET_Vertex3dv(disp, glVertex3dv); + SET_Vertex3f(disp, glVertex3f); + SET_Vertex3fv(disp, glVertex3fv); + SET_Vertex3i(disp, glVertex3i); + SET_Vertex3iv(disp, glVertex3iv); + SET_Vertex3s(disp, glVertex3s); + SET_Vertex3sv(disp, glVertex3sv); + SET_Vertex4d(disp, glVertex4d); + SET_Vertex4dv(disp, glVertex4dv); + SET_Vertex4f(disp, glVertex4f); + SET_Vertex4fv(disp, glVertex4fv); + SET_Vertex4i(disp, glVertex4i); + SET_Vertex4iv(disp, glVertex4iv); + SET_Vertex4s(disp, glVertex4s); + SET_Vertex4sv(disp, glVertex4sv); + SET_VertexPointer(disp, glVertexPointer); + SET_Viewport(disp, glViewport); + +#if GL_VERSION_2_0 + SET_AttachShader(disp, glAttachShader); + SET_DeleteShader(disp, glDeleteShader); + SET_DetachShader(disp, glDetachShader); + SET_GetAttachedShaders(disp, glGetAttachedShaders); + SET_GetProgramInfoLog(disp, glGetProgramInfoLog); + SET_GetShaderInfoLog(disp, glGetShaderInfoLog); + SET_GetShaderiv(disp, glGetShaderiv); + SET_IsShader(disp, glIsShader); + SET_StencilFuncSeparate(disp, glStencilFuncSeparate); + SET_StencilMaskSeparate(disp, glStencilMaskSeparate); + SET_StencilOpSeparate(disp, glStencilOpSeparate); +#endif + +#if GL_VERSION_2_1 + SET_UniformMatrix2x3fv(disp, glUniformMatrix2x3fv); + SET_UniformMatrix2x4fv(disp, glUniformMatrix2x4fv); + SET_UniformMatrix3x2fv(disp, glUniformMatrix3x2fv); + SET_UniformMatrix3x4fv(disp, glUniformMatrix3x4fv); + SET_UniformMatrix4x2fv(disp, glUniformMatrix4x2fv); + SET_UniformMatrix4x3fv(disp, glUniformMatrix4x3fv); +#endif + +#if GL_APPLE_vertex_array_object + SET_BindVertexArrayAPPLE(disp, glBindVertexArrayAPPLE); + SET_DeleteVertexArraysAPPLE(disp, glDeleteVertexArraysAPPLE); + SET_GenVertexArraysAPPLE(disp, glGenVertexArraysAPPLE); + SET_IsVertexArrayAPPLE(disp, glIsVertexArrayAPPLE); +#endif + +#if GL_ARB_draw_buffers + SET_DrawBuffersARB(disp, glDrawBuffersARB); +#endif + +#if GL_ARB_multisample + SET_SampleCoverageARB(disp, glSampleCoverageARB); +#endif + +#if GL_ARB_multitexture + SET_ActiveTextureARB(disp, glActiveTextureARB); + SET_ClientActiveTextureARB(disp, glClientActiveTextureARB); + SET_MultiTexCoord1dARB(disp, glMultiTexCoord1dARB); + SET_MultiTexCoord1dvARB(disp, glMultiTexCoord1dvARB); + SET_MultiTexCoord1fARB(disp, glMultiTexCoord1fARB); + SET_MultiTexCoord1fvARB(disp, glMultiTexCoord1fvARB); + SET_MultiTexCoord1iARB(disp, glMultiTexCoord1iARB); + SET_MultiTexCoord1ivARB(disp, glMultiTexCoord1ivARB); + SET_MultiTexCoord1sARB(disp, glMultiTexCoord1sARB); + SET_MultiTexCoord1svARB(disp, glMultiTexCoord1svARB); + SET_MultiTexCoord2dARB(disp, glMultiTexCoord2dARB); + SET_MultiTexCoord2dvARB(disp, glMultiTexCoord2dvARB); + SET_MultiTexCoord2fARB(disp, glMultiTexCoord2fARB); + SET_MultiTexCoord2fvARB(disp, glMultiTexCoord2fvARB); + SET_MultiTexCoord2iARB(disp, glMultiTexCoord2iARB); + SET_MultiTexCoord2ivARB(disp, glMultiTexCoord2ivARB); + SET_MultiTexCoord2sARB(disp, glMultiTexCoord2sARB); + SET_MultiTexCoord2svARB(disp, glMultiTexCoord2svARB); + SET_MultiTexCoord3dARB(disp, glMultiTexCoord3dARB); + SET_MultiTexCoord3dvARB(disp, glMultiTexCoord3dvARB); + SET_MultiTexCoord3fARB(disp, glMultiTexCoord3fARB); + SET_MultiTexCoord3fvARB(disp, glMultiTexCoord3fvARB); + SET_MultiTexCoord3iARB(disp, glMultiTexCoord3iARB); + SET_MultiTexCoord3ivARB(disp, glMultiTexCoord3ivARB); + SET_MultiTexCoord3sARB(disp, glMultiTexCoord3sARB); + SET_MultiTexCoord3svARB(disp, glMultiTexCoord3svARB); + SET_MultiTexCoord4dARB(disp, glMultiTexCoord4dARB); + SET_MultiTexCoord4dvARB(disp, glMultiTexCoord4dvARB); + SET_MultiTexCoord4fARB(disp, glMultiTexCoord4fARB); + SET_MultiTexCoord4fvARB(disp, glMultiTexCoord4fvARB); + SET_MultiTexCoord4iARB(disp, glMultiTexCoord4iARB); + SET_MultiTexCoord4ivARB(disp, glMultiTexCoord4ivARB); + SET_MultiTexCoord4sARB(disp, glMultiTexCoord4sARB); + SET_MultiTexCoord4svARB(disp, glMultiTexCoord4svARB); +#endif + +#if GL_ARB_occlusion_query + SET_BeginQueryARB(disp, glBeginQueryARB); + SET_DeleteQueriesARB(disp, glDeleteQueriesARB); + SET_EndQueryARB(disp, glEndQueryARB); + SET_GenQueriesARB(disp, glGenQueriesARB); + SET_GetQueryObjectivARB(disp, glGetQueryObjectivARB); + SET_GetQueryObjectuivARB(disp, glGetQueryObjectuivARB); + SET_GetQueryivARB(disp, glGetQueryivARB); + SET_IsQueryARB(disp, glIsQueryARB); +#endif + +#if GL_ARB_shader_objects + SET_AttachObjectARB(disp, glAttachObjectARB); + SET_CompileShaderARB(disp, glCompileShaderARB); + SET_DeleteObjectARB(disp, glDeleteObjectARB); + SET_GetHandleARB(disp, glGetHandleARB); + SET_DetachObjectARB(disp, glDetachObjectARB); + SET_CreateProgramObjectARB(disp, glCreateProgramObjectARB); + SET_CreateShaderObjectARB(disp, glCreateShaderObjectARB); + SET_GetInfoLogARB(disp, glGetInfoLogARB); + SET_GetActiveUniformARB(disp, glGetActiveUniformARB); + SET_GetAttachedObjectsARB(disp, glGetAttachedObjectsARB); + SET_GetObjectParameterfvARB(disp, glGetObjectParameterfvARB); + SET_GetObjectParameterivARB(disp, glGetObjectParameterivARB); + SET_GetShaderSourceARB(disp, glGetShaderSourceARB); + SET_GetUniformLocationARB(disp, glGetUniformLocationARB); + SET_GetUniformfvARB(disp, glGetUniformfvARB); + SET_GetUniformivARB(disp, glGetUniformivARB); + SET_LinkProgramARB(disp, glLinkProgramARB); + SET_ShaderSourceARB(disp, glShaderSourceARB); + SET_Uniform1fARB(disp, glUniform1fARB); + SET_Uniform1fvARB(disp, glUniform1fvARB); + SET_Uniform1iARB(disp, glUniform1iARB); + SET_Uniform1ivARB(disp, glUniform1ivARB); + SET_Uniform2fARB(disp, glUniform2fARB); + SET_Uniform2fvARB(disp, glUniform2fvARB); + SET_Uniform2iARB(disp, glUniform2iARB); + SET_Uniform2ivARB(disp, glUniform2ivARB); + SET_Uniform3fARB(disp, glUniform3fARB); + SET_Uniform3fvARB(disp, glUniform3fvARB); + SET_Uniform3iARB(disp, glUniform3iARB); + SET_Uniform3ivARB(disp, glUniform3ivARB); + SET_Uniform4fARB(disp, glUniform4fARB); + SET_Uniform4fvARB(disp, glUniform4fvARB); + SET_Uniform4iARB(disp, glUniform4iARB); + SET_Uniform4ivARB(disp, glUniform4ivARB); + SET_UniformMatrix2fvARB(disp, glUniformMatrix2fvARB); + SET_UniformMatrix3fvARB(disp, glUniformMatrix3fvARB); + SET_UniformMatrix4fvARB(disp, glUniformMatrix4fvARB); + SET_UseProgramObjectARB(disp, glUseProgramObjectARB); + SET_ValidateProgramARB(disp, glValidateProgramARB); +#endif + +#if GL_ARB_texture_compression + SET_CompressedTexImage1DARB(disp, glCompressedTexImage1DARB); + SET_CompressedTexImage2DARB(disp, glCompressedTexImage2DARB); + SET_CompressedTexImage3DARB(disp, glCompressedTexImage3DARB); + SET_CompressedTexSubImage1DARB(disp, glCompressedTexSubImage1DARB); + SET_CompressedTexSubImage2DARB(disp, glCompressedTexSubImage2DARB); + SET_CompressedTexSubImage3DARB(disp, glCompressedTexSubImage3DARB); + SET_GetCompressedTexImageARB(disp, glGetCompressedTexImageARB); +#endif + +#if GL_ARB_transpose_matrix + SET_LoadTransposeMatrixdARB(disp, glLoadTransposeMatrixdARB); + SET_LoadTransposeMatrixfARB(disp, glLoadTransposeMatrixfARB); + SET_MultTransposeMatrixdARB(disp, glMultTransposeMatrixdARB); + SET_MultTransposeMatrixfARB(disp, glMultTransposeMatrixfARB); +#endif + +#if GL_ARB_vertex_buffer_object + SET_BindBufferARB(disp, glBindBufferARB); + SET_BufferDataARB(disp, glBufferDataARB); + SET_BufferSubDataARB(disp, glBufferSubDataARB); + SET_DeleteBuffersARB(disp, glDeleteBuffersARB); + SET_GenBuffersARB(disp, glGenBuffersARB); + SET_GetBufferParameterivARB(disp, glGetBufferParameterivARB); + SET_GetBufferPointervARB(disp, glGetBufferPointervARB); + SET_GetBufferSubDataARB(disp, glGetBufferSubDataARB); + SET_IsBufferARB(disp, glIsBufferARB); + SET_MapBufferARB(disp, glMapBufferARB); + SET_UnmapBufferARB(disp, glUnmapBufferARB); +#endif + +#if GL_ARB_vertex_program + SET_DisableVertexAttribArrayARB(disp, glDisableVertexAttribArrayARB); + SET_EnableVertexAttribArrayARB(disp, glEnableVertexAttribArrayARB); + SET_GetProgramEnvParameterdvARB(disp, glGetProgramEnvParameterdvARB); + SET_GetProgramEnvParameterfvARB(disp, glGetProgramEnvParameterfvARB); + SET_GetProgramLocalParameterdvARB(disp, glGetProgramLocalParameterdvARB); + SET_GetProgramLocalParameterfvARB(disp, glGetProgramLocalParameterfvARB); + SET_GetProgramStringARB(disp, glGetProgramStringARB); + SET_GetProgramivARB(disp, glGetProgramivARB); + SET_GetVertexAttribdvARB(disp, glGetVertexAttribdvARB); + SET_GetVertexAttribfvARB(disp, glGetVertexAttribfvARB); + SET_GetVertexAttribivARB(disp, glGetVertexAttribivARB); + SET_ProgramEnvParameter4dARB(disp, glProgramEnvParameter4dARB); + SET_ProgramEnvParameter4dvARB(disp, glProgramEnvParameter4dvARB); + SET_ProgramEnvParameter4fARB(disp, glProgramEnvParameter4fARB); + SET_ProgramEnvParameter4fvARB(disp, glProgramEnvParameter4fvARB); + SET_ProgramLocalParameter4dARB(disp, glProgramLocalParameter4dARB); + SET_ProgramLocalParameter4dvARB(disp, glProgramLocalParameter4dvARB); + SET_ProgramLocalParameter4fARB(disp, glProgramLocalParameter4fARB); + SET_ProgramLocalParameter4fvARB(disp, glProgramLocalParameter4fvARB); + SET_ProgramStringARB(disp, glProgramStringARB); + SET_VertexAttrib1dARB(disp, glVertexAttrib1dARB); + SET_VertexAttrib1dvARB(disp, glVertexAttrib1dvARB); + SET_VertexAttrib1fARB(disp, glVertexAttrib1fARB); + SET_VertexAttrib1fvARB(disp, glVertexAttrib1fvARB); + SET_VertexAttrib1sARB(disp, glVertexAttrib1sARB); + SET_VertexAttrib1svARB(disp, glVertexAttrib1svARB); + SET_VertexAttrib2dARB(disp, glVertexAttrib2dARB); + SET_VertexAttrib2dvARB(disp, glVertexAttrib2dvARB); + SET_VertexAttrib2fARB(disp, glVertexAttrib2fARB); + SET_VertexAttrib2fvARB(disp, glVertexAttrib2fvARB); + SET_VertexAttrib2sARB(disp, glVertexAttrib2sARB); + SET_VertexAttrib2svARB(disp, glVertexAttrib2svARB); + SET_VertexAttrib3dARB(disp, glVertexAttrib3dARB); + SET_VertexAttrib3dvARB(disp, glVertexAttrib3dvARB); + SET_VertexAttrib3fARB(disp, glVertexAttrib3fARB); + SET_VertexAttrib3fvARB(disp, glVertexAttrib3fvARB); + SET_VertexAttrib3sARB(disp, glVertexAttrib3sARB); + SET_VertexAttrib3svARB(disp, glVertexAttrib3svARB); + SET_VertexAttrib4NbvARB(disp, glVertexAttrib4NbvARB); + SET_VertexAttrib4NivARB(disp, glVertexAttrib4NivARB); + SET_VertexAttrib4NsvARB(disp, glVertexAttrib4NsvARB); + SET_VertexAttrib4NubARB(disp, glVertexAttrib4NubARB); + SET_VertexAttrib4NubvARB(disp, glVertexAttrib4NubvARB); + SET_VertexAttrib4NuivARB(disp, glVertexAttrib4NuivARB); + SET_VertexAttrib4NusvARB(disp, glVertexAttrib4NusvARB); + SET_VertexAttrib4bvARB(disp, glVertexAttrib4bvARB); + SET_VertexAttrib4dARB(disp, glVertexAttrib4dARB); + SET_VertexAttrib4dvARB(disp, glVertexAttrib4dvARB); + SET_VertexAttrib4fARB(disp, glVertexAttrib4fARB); + SET_VertexAttrib4fvARB(disp, glVertexAttrib4fvARB); + SET_VertexAttrib4ivARB(disp, glVertexAttrib4ivARB); + SET_VertexAttrib4sARB(disp, glVertexAttrib4sARB); + SET_VertexAttrib4svARB(disp, glVertexAttrib4svARB); + SET_VertexAttrib4ubvARB(disp, glVertexAttrib4ubvARB); + SET_VertexAttrib4uivARB(disp, glVertexAttrib4uivARB); + SET_VertexAttrib4usvARB(disp, glVertexAttrib4usvARB); + SET_VertexAttribPointerARB(disp, glVertexAttribPointerARB); +#endif + +#if GL_ARB_vertex_shader + SET_BindAttribLocationARB(disp, glBindAttribLocationARB); + SET_GetActiveAttribARB(disp, glGetActiveAttribARB); + SET_GetAttribLocationARB(disp, glGetAttribLocationARB); +#endif + +#if GL_ARB_window_pos + SET_WindowPos2dMESA(disp, glWindowPos2dARB); + SET_WindowPos2dvMESA(disp, glWindowPos2dvARB); + SET_WindowPos2fMESA(disp, glWindowPos2fARB); + SET_WindowPos2fvMESA(disp, glWindowPos2fvARB); + SET_WindowPos2iMESA(disp, glWindowPos2iARB); + SET_WindowPos2ivMESA(disp, glWindowPos2ivARB); + SET_WindowPos2sMESA(disp, glWindowPos2sARB); + SET_WindowPos2svMESA(disp, glWindowPos2svARB); + SET_WindowPos3dMESA(disp, glWindowPos3dARB); + SET_WindowPos3dvMESA(disp, glWindowPos3dvARB); + SET_WindowPos3fMESA(disp, glWindowPos3fARB); + SET_WindowPos3fvMESA(disp, glWindowPos3fvARB); + SET_WindowPos3iMESA(disp, glWindowPos3iARB); + SET_WindowPos3ivMESA(disp, glWindowPos3ivARB); + SET_WindowPos3sMESA(disp, glWindowPos3sARB); + SET_WindowPos3svMESA(disp, glWindowPos3svARB); +#endif + +#if GL_ATI_fragment_shader + SET_AlphaFragmentOp1ATI(disp, glAlphaFragmentOp1ATI); + SET_AlphaFragmentOp2ATI(disp, glAlphaFragmentOp2ATI); + SET_AlphaFragmentOp3ATI(disp, glAlphaFragmentOp3ATI); + SET_BeginFragmentShaderATI(disp, glBeginFragmentShaderATI); + SET_BindFragmentShaderATI(disp, glBindFragmentShaderATI); + SET_ColorFragmentOp1ATI(disp, glColorFragmentOp1ATI); + SET_ColorFragmentOp2ATI(disp, glColorFragmentOp2ATI); + SET_ColorFragmentOp3ATI(disp, glColorFragmentOp3ATI); + SET_DeleteFragmentShaderATI(disp, glDeleteFragmentShaderATI); + SET_EndFragmentShaderATI(disp, glEndFragmentShaderATI); + SET_GenFragmentShadersATI(disp, glGenFragmentShadersATI); + SET_PassTexCoordATI(disp, glPassTexCoordATI); + SET_SampleMapATI(disp, glSampleMapATI); + SET_SetFragmentShaderConstantATI(disp, glSetFragmentShaderConstantATI); +#elif GL_EXT_fragment_shader + SET_AlphaFragmentOp1ATI(disp, glAlphaFragmentOp1EXT); + SET_AlphaFragmentOp2ATI(disp, glAlphaFragmentOp2EXT); + SET_AlphaFragmentOp3ATI(disp, glAlphaFragmentOp3EXT); + SET_BeginFragmentShaderATI(disp, glBeginFragmentShaderEXT); + SET_BindFragmentShaderATI(disp, glBindFragmentShaderEXT); + SET_ColorFragmentOp1ATI(disp, glColorFragmentOp1EXT); + SET_ColorFragmentOp2ATI(disp, glColorFragmentOp2EXT); + SET_ColorFragmentOp3ATI(disp, glColorFragmentOp3EXT); + SET_DeleteFragmentShaderATI(disp, glDeleteFragmentShaderEXT); + SET_EndFragmentShaderATI(disp, glEndFragmentShaderEXT); + SET_GenFragmentShadersATI(disp, glGenFragmentShadersEXT); + SET_PassTexCoordATI(disp, glPassTexCoordEXT); + SET_SampleMapATI(disp, glSampleMapEXT); + SET_SetFragmentShaderConstantATI(disp, glSetFragmentShaderConstantEXT); +#endif + +#if GL_ATI_separate_stencil + SET_StencilFuncSeparateATI(disp, glStencilFuncSeparateATI); +#endif + +#if GL_EXT_blend_equation_separate + SET_BlendEquationSeparateEXT(disp, glBlendEquationSeparateEXT); +#endif + +#if GL_EXT_blend_func_separate + SET_BlendFuncSeparateEXT(disp, glBlendFuncSeparateEXT); +#endif + +#if GL_EXT_depth_bounds_test + SET_DepthBoundsEXT(disp, glDepthBoundsEXT); +#endif + +#if GL_EXT_compiled_vertex_array + SET_LockArraysEXT(disp, glLockArraysEXT); + SET_UnlockArraysEXT(disp, glUnlockArraysEXT); +#endif + +#if GL_EXT_cull_vertex + SET_CullParameterdvEXT(disp, glCullParameterdvEXT); + SET_CullParameterfvEXT(disp, glCullParameterfvEXT); +#endif + +#if GL_EXT_fog_coord + SET_FogCoordPointerEXT(disp, glFogCoordPointerEXT); + SET_FogCoorddEXT(disp, glFogCoorddEXT); + SET_FogCoorddvEXT(disp, glFogCoorddvEXT); + SET_FogCoordfEXT(disp, glFogCoordfEXT); + SET_FogCoordfvEXT(disp, glFogCoordfvEXT); +#endif + +#if GL_EXT_framebuffer_blit + SET_BlitFramebufferEXT(disp, glBlitFramebufferEXT); +#endif + +#if GL_EXT_framebuffer_object + SET_BindFramebufferEXT(disp, glBindFramebufferEXT); + SET_BindRenderbufferEXT(disp, glBindRenderbufferEXT); + SET_CheckFramebufferStatusEXT(disp, glCheckFramebufferStatusEXT); + SET_DeleteFramebuffersEXT(disp, glDeleteFramebuffersEXT); + SET_DeleteRenderbuffersEXT(disp, glDeleteRenderbuffersEXT); + SET_FramebufferRenderbufferEXT(disp, glFramebufferRenderbufferEXT); + SET_FramebufferTexture1DEXT(disp, glFramebufferTexture1DEXT); + SET_FramebufferTexture2DEXT(disp, glFramebufferTexture2DEXT); + SET_FramebufferTexture3DEXT(disp, glFramebufferTexture3DEXT); + SET_GenerateMipmapEXT(disp, glGenerateMipmapEXT); + SET_GenFramebuffersEXT(disp, glGenFramebuffersEXT); + SET_GenRenderbuffersEXT(disp, glGenRenderbuffersEXT); + SET_GetFramebufferAttachmentParameterivEXT(disp, glGetFramebufferAttachmentParameterivEXT); + SET_GetRenderbufferParameterivEXT(disp, glGetRenderbufferParameterivEXT); + SET_IsFramebufferEXT(disp, glIsFramebufferEXT); + SET_IsRenderbufferEXT(disp, glIsRenderbufferEXT); + SET_RenderbufferStorageEXT(disp, glRenderbufferStorageEXT); +#endif + +#if GL_EXT_gpu_program_parameters + SET_ProgramEnvParameters4fvEXT(disp, glProgramEnvParameters4fvEXT); + SET_ProgramLocalParameters4fvEXT(disp, glProgramLocalParameters4fvEXT); +#endif + +#if GL_EXT_multi_draw_arrays + /* Pointer Incompatability: + * This warning can be safely ignored. OpenGL.framework adds const to the + * two pointers. + * + * extern void glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei); + * + * void ( * MultiDrawArraysEXT)(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount); + */ + SET_MultiDrawArraysEXT(disp, (void *)glMultiDrawArraysEXT); + SET_MultiDrawElementsEXT(disp, glMultiDrawElementsEXT); +#endif + +#if GL_EXT_point_parameters + SET_PointParameterfEXT(disp, glPointParameterfEXT); + SET_PointParameterfvEXT(disp, glPointParameterfvEXT); +#elif GL_ARB_point_parameters + SET_PointParameterfEXT(disp, glPointParameterfARB); + SET_PointParameterfvEXT(disp, glPointParameterfvARB); +#endif + +#if GL_EXT_polygon_offset + SET_PolygonOffsetEXT(disp, glPolygonOffsetEXT); +#endif + +#if GL_EXT_secondary_color + SET_SecondaryColor3bEXT(disp, glSecondaryColor3bEXT); + SET_SecondaryColor3bvEXT(disp, glSecondaryColor3bvEXT); + SET_SecondaryColor3dEXT(disp, glSecondaryColor3dEXT); + SET_SecondaryColor3dvEXT(disp, glSecondaryColor3dvEXT); + SET_SecondaryColor3fEXT(disp, glSecondaryColor3fEXT); + SET_SecondaryColor3fvEXT(disp, glSecondaryColor3fvEXT); + SET_SecondaryColor3iEXT(disp, glSecondaryColor3iEXT); + SET_SecondaryColor3ivEXT(disp, glSecondaryColor3ivEXT); + SET_SecondaryColor3sEXT(disp, glSecondaryColor3sEXT); + SET_SecondaryColor3svEXT(disp, glSecondaryColor3svEXT); + SET_SecondaryColor3ubEXT(disp, glSecondaryColor3ubEXT); + SET_SecondaryColor3ubvEXT(disp, glSecondaryColor3ubvEXT); + SET_SecondaryColor3uiEXT(disp, glSecondaryColor3uiEXT); + SET_SecondaryColor3uivEXT(disp, glSecondaryColor3uivEXT); + SET_SecondaryColor3usEXT(disp, glSecondaryColor3usEXT); + SET_SecondaryColor3usvEXT(disp, glSecondaryColor3usvEXT); + SET_SecondaryColorPointerEXT(disp, glSecondaryColorPointerEXT); +#endif + +#if GL_EXT_stencil_two_side + SET_ActiveStencilFaceEXT(disp, glActiveStencilFaceEXT); +#endif + +#if GL_EXT_timer_query + SET_GetQueryObjecti64vEXT(disp, glGetQueryObjecti64vEXT); + SET_GetQueryObjectui64vEXT(disp, glGetQueryObjectui64vEXT); +#endif + +#if GL_EXT_vertex_array + SET_ColorPointerEXT(disp, glColorPointerEXT); + SET_EdgeFlagPointerEXT(disp, glEdgeFlagPointerEXT); + SET_IndexPointerEXT(disp, glIndexPointerEXT); + SET_NormalPointerEXT(disp, glNormalPointerEXT); + SET_TexCoordPointerEXT(disp, glTexCoordPointerEXT); + SET_VertexPointerEXT(disp, glVertexPointerEXT); +#endif + +#if GL_IBM_multimode_draw_arrays + SET_MultiModeDrawArraysIBM(disp, glMultiModeDrawArraysIBM); + SET_MultiModeDrawElementsIBM(disp, glMultiModeDrawElementsIBM); +#endif + +#if GL_MESA_resize_buffers + SET_ResizeBuffersMESA(disp, glResizeBuffersMESA); +#endif + +#if GL_MESA_window_pos + SET_WindowPos4dMESA(disp, glWindowPos4dMESA); + SET_WindowPos4dvMESA(disp, glWindowPos4dvMESA); + SET_WindowPos4fMESA(disp, glWindowPos4fMESA); + SET_WindowPos4fvMESA(disp, glWindowPos4fvMESA); + SET_WindowPos4iMESA(disp, glWindowPos4iMESA); + SET_WindowPos4ivMESA(disp, glWindowPos4ivMESA); + SET_WindowPos4sMESA(disp, glWindowPos4sMESA); + SET_WindowPos4svMESA(disp, glWindowPos4svMESA); +#endif + +#if GL_NV_fence + SET_DeleteFencesNV(disp, glDeleteFencesNV); + SET_FinishFenceNV(disp, glFinishFenceNV); + SET_GenFencesNV(disp, glGenFencesNV); + SET_GetFenceivNV(disp, glGetFenceivNV); + SET_IsFenceNV(disp, glIsFenceNV); + SET_SetFenceNV(disp, glSetFenceNV); + SET_TestFenceNV(disp, glTestFenceNV); +#endif + +#if GL_NV_fragment_program + SET_GetProgramNamedParameterdvNV(disp, glGetProgramNamedParameterdvNV); + SET_GetProgramNamedParameterfvNV(disp, glGetProgramNamedParameterfvNV); + SET_ProgramNamedParameter4dNV(disp, glProgramNamedParameter4dNV); + SET_ProgramNamedParameter4dvNV(disp, glProgramNamedParameter4dvNV); + SET_ProgramNamedParameter4fNV(disp, glProgramNamedParameter4fNV); + SET_ProgramNamedParameter4fvNV(disp, glProgramNamedParameter4fvNV); +#endif + +#if GL_NV_geometry_program4 + SET_FramebufferTextureLayerEXT(disp, glFramebufferTextureLayerEXT); +#endif + +#if GL_NV_point_sprite + SET_PointParameteriNV(disp, glPointParameteriNV); + SET_PointParameterivNV(disp, glPointParameterivNV); +#endif + +#if GL_NV_register_combiners + SET_CombinerInputNV(disp, glCombinerInputNV); + SET_CombinerOutputNV(disp, glCombinerOutputNV); + SET_CombinerParameterfNV(disp, glCombinerParameterfNV); + SET_CombinerParameterfvNV(disp, glCombinerParameterfvNV); + SET_CombinerParameteriNV(disp, glCombinerParameteriNV); + SET_CombinerParameterivNV(disp, glCombinerParameterivNV); + SET_FinalCombinerInputNV(disp, glFinalCombinerInputNV); + SET_GetCombinerInputParameterfvNV(disp, glGetCombinerInputParameterfvNV); + SET_GetCombinerInputParameterivNV(disp, glGetCombinerInputParameterivNV); + SET_GetCombinerOutputParameterfvNV(disp, glGetCombinerOutputParameterfvNV); + SET_GetCombinerOutputParameterivNV(disp, glGetCombinerOutputParameterivNV); + SET_GetFinalCombinerInputParameterfvNV(disp, glGetFinalCombinerInputParameterfvNV); + SET_GetFinalCombinerInputParameterivNV(disp, glGetFinalCombinerInputParameterivNV); +#endif + +#if GL_NV_vertex_array_range + SET_FlushVertexArrayRangeNV(disp, glFlushVertexArrayRangeNV); + SET_VertexArrayRangeNV(disp, glVertexArrayRangeNV); +#endif + +#if GL_NV_vertex_program + SET_AreProgramsResidentNV(disp, glAreProgramsResidentNV); + SET_BindProgramNV(disp, glBindProgramNV); + SET_DeleteProgramsNV(disp, glDeleteProgramsNV); + SET_ExecuteProgramNV(disp, glExecuteProgramNV); + SET_GenProgramsNV(disp, glGenProgramsNV); + SET_GetProgramParameterdvNV(disp, glGetProgramParameterdvNV); + SET_GetProgramParameterfvNV(disp, glGetProgramParameterfvNV); + SET_GetProgramStringNV(disp, glGetProgramStringNV); + SET_GetProgramivNV(disp, glGetProgramivNV); + SET_GetTrackMatrixivNV(disp, glGetTrackMatrixivNV); + SET_GetVertexAttribPointervNV(disp, glGetVertexAttribPointervNV); + SET_GetVertexAttribdvNV(disp, glGetVertexAttribdvNV); + SET_GetVertexAttribfvNV(disp, glGetVertexAttribfvNV); + SET_GetVertexAttribivNV(disp, glGetVertexAttribivNV); + SET_IsProgramNV(disp, glIsProgramNV); + SET_LoadProgramNV(disp, glLoadProgramNV); + SET_ProgramParameters4dvNV(disp, glProgramParameters4dvNV); + SET_ProgramParameters4fvNV(disp, glProgramParameters4fvNV); + SET_RequestResidentProgramsNV(disp, glRequestResidentProgramsNV); + SET_TrackMatrixNV(disp, glTrackMatrixNV); + SET_VertexAttrib1dNV(disp, glVertexAttrib1dNV) + SET_VertexAttrib1dvNV(disp, glVertexAttrib1dvNV) + SET_VertexAttrib1fNV(disp, glVertexAttrib1fNV) + SET_VertexAttrib1fvNV(disp, glVertexAttrib1fvNV) + SET_VertexAttrib1sNV(disp, glVertexAttrib1sNV) + SET_VertexAttrib1svNV(disp, glVertexAttrib1svNV) + SET_VertexAttrib2dNV(disp, glVertexAttrib2dNV) + SET_VertexAttrib2dvNV(disp, glVertexAttrib2dvNV) + SET_VertexAttrib2fNV(disp, glVertexAttrib2fNV) + SET_VertexAttrib2fvNV(disp, glVertexAttrib2fvNV) + SET_VertexAttrib2sNV(disp, glVertexAttrib2sNV) + SET_VertexAttrib2svNV(disp, glVertexAttrib2svNV) + SET_VertexAttrib3dNV(disp, glVertexAttrib3dNV) + SET_VertexAttrib3dvNV(disp, glVertexAttrib3dvNV) + SET_VertexAttrib3fNV(disp, glVertexAttrib3fNV) + SET_VertexAttrib3fvNV(disp, glVertexAttrib3fvNV) + SET_VertexAttrib3sNV(disp, glVertexAttrib3sNV) + SET_VertexAttrib3svNV(disp, glVertexAttrib3svNV) + SET_VertexAttrib4dNV(disp, glVertexAttrib4dNV) + SET_VertexAttrib4dvNV(disp, glVertexAttrib4dvNV) + SET_VertexAttrib4fNV(disp, glVertexAttrib4fNV) + SET_VertexAttrib4fvNV(disp, glVertexAttrib4fvNV) + SET_VertexAttrib4sNV(disp, glVertexAttrib4sNV) + SET_VertexAttrib4svNV(disp, glVertexAttrib4svNV) + SET_VertexAttrib4ubNV(disp, glVertexAttrib4ubNV) + SET_VertexAttrib4ubvNV(disp, glVertexAttrib4ubvNV) + SET_VertexAttribPointerNV(disp, glVertexAttribPointerNV) + SET_VertexAttribs1dvNV(disp, glVertexAttribs1dvNV) + SET_VertexAttribs1fvNV(disp, glVertexAttribs1fvNV) + SET_VertexAttribs1svNV(disp, glVertexAttribs1svNV) + SET_VertexAttribs2dvNV(disp, glVertexAttribs2dvNV) + SET_VertexAttribs2fvNV(disp, glVertexAttribs2fvNV) + SET_VertexAttribs2svNV(disp, glVertexAttribs2svNV) + SET_VertexAttribs3dvNV(disp, glVertexAttribs3dvNV) + SET_VertexAttribs3fvNV(disp, glVertexAttribs3fvNV) + SET_VertexAttribs3svNV(disp, glVertexAttribs3svNV) + SET_VertexAttribs4dvNV(disp, glVertexAttribs4dvNV) + SET_VertexAttribs4fvNV(disp, glVertexAttribs4fvNV) + SET_VertexAttribs4svNV(disp, glVertexAttribs4svNV) + SET_VertexAttribs4ubvNV(disp, glVertexAttribs4ubvNV) +#endif + +#if GL_SGIS_multisample + SET_SampleMaskSGIS(disp, glSampleMaskSGIS); + SET_SamplePatternSGIS(disp, glSamplePatternSGIS); +#endif + +#if GL_SGIS_pixel_texture + SET_GetPixelTexGenParameterfvSGIS(disp, glGetPixelTexGenParameterfvSGIS); + SET_GetPixelTexGenParameterivSGIS(disp, glGetPixelTexGenParameterivSGIS); + SET_PixelTexGenParameterfSGIS(disp, glPixelTexGenParameterfSGIS); + SET_PixelTexGenParameterfvSGIS(disp, glPixelTexGenParameterfvSGIS); + SET_PixelTexGenParameteriSGIS(disp, glPixelTexGenParameteriSGIS); + SET_PixelTexGenParameterivSGIS(disp, glPixelTexGenParameterivSGIS); + SET_PixelTexGenSGIX(disp, glPixelTexGenSGIX); +#endif +} diff --git a/xorg-server/hw/xquartz/GL/visualConfigs.c b/xorg-server/hw/xquartz/GL/visualConfigs.c index 0d5793262..2c2a9a29e 100644 --- a/xorg-server/hw/xquartz/GL/visualConfigs.c +++ b/xorg-server/hw/xquartz/GL/visualConfigs.c @@ -1,285 +1,284 @@ -/*
- * Copyright (c) 2007, 2008 Apple Inc.
- * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
- * Copyright (c) 2002 Greg Parker. All Rights Reserved.
- *
- * Portions of this file are copied from Mesa's xf86glx.c,
- * which contains the following copyright:
- *
- * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "dri.h"
-
-#include <OpenGL/OpenGL.h>
-#include <OpenGL/gl.h>
-#include <OpenGL/glext.h>
-#include <OpenGL/CGLContext.h>
-
-#include <GL/glxproto.h>
-#include <windowstr.h>
-#include <resource.h>
-#include <GL/glxint.h>
-#include <GL/glxtokens.h>
-#include <scrnintstr.h>
-#include <glxserver.h>
-#include <glxscreens.h>
-#include <glxdrawable.h>
-#include <glxcontext.h>
-#include <glxext.h>
-#include <glxutil.h>
-#include <glxscreens.h>
-#include <GL/internal/glcore.h>
-
-#include "capabilities.h"
-#include "visualConfigs.h"
-#include "darwinfb.h"
-
-/* Based originally on code from indirect.c which was based on code from i830_dri.c. */
-__GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber) {
- int numConfigs = 0;
- __GLXconfig *visualConfigs, *c;
- struct glCapabilities caps;
- struct glCapabilitiesConfig *conf;
- int stereo, depth, aux, buffers, stencil, accum, color, msample;
-
- if(getGlCapabilities(&caps)) {
- ErrorF("error from getGlCapabilities()!\n");
- return NULL;
- }
-
- /*
- conf->stereo is 0 or 1, but we need at least 1 iteration of the loop,
- so we treat a true conf->stereo as 2.
-
- The depth size is 0 or 24. Thus we do 2 iterations for that.
-
- conf->aux_buffers (when available/non-zero) result in 2 iterations instead of 1.
-
- conf->buffers indicates whether we have single or double buffering.
-
- conf->total_stencil_bit_depths
-
- conf->total_color_buffers indicates the RGB/RGBA color depths.
-
- conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
-
- conf->total_depth_buffer_depths
-
- conf->multisample_buffers iterations (with at least 1 if equal to 0). We add 1
- for the 0 multisampling config.
-
- */
-
- assert(NULL != caps.configurations);
-
- numConfigs = 0;
-
- for(conf = caps.configurations; conf; conf = conf->next) {
- if(conf->total_color_buffers <= 0)
- continue;
-
- numConfigs += (conf->stereo ? 2 : 1)
- * (conf->aux_buffers ? 2 : 1)
- * conf->buffers
- * ((conf->total_stencil_bit_depths > 0) ? conf->total_stencil_bit_depths : 1)
- * conf->total_color_buffers
- * ((conf->total_accum_buffers > 0) ? conf->total_accum_buffers : 1)
- * conf->total_depth_buffer_depths
- * (conf->multisample_buffers + 1);
- }
-
- if(numConfigsPtr)
- *numConfigsPtr = numConfigs;
-
- visualConfigs = calloc(sizeof(*visualConfigs), numConfigs);
-
- if(NULL == visualConfigs) {
- ErrorF("xcalloc failure when allocating visualConfigs\n");
- freeGlCapabilities(&caps);
- return NULL;
- }
-
- c = visualConfigs; /* current buffer */
- for(conf = caps.configurations; conf; conf = conf->next) {
- for(stereo = 0; stereo < (conf->stereo ? 2 : 1); ++stereo) {
- for(aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) {
- for(buffers = 0; buffers < conf->buffers; ++buffers) {
- for(stencil = 0; stencil < ((conf->total_stencil_bit_depths > 0) ?
- conf->total_stencil_bit_depths : 1); ++stencil) {
- for(color = 0; color < conf->total_color_buffers; ++color) {
- for(accum = 0; accum < ((conf->total_accum_buffers > 0) ?
- conf->total_accum_buffers : 1); ++accum) {
- for(depth = 0; depth < conf->total_depth_buffer_depths; ++depth) {
- for(msample = 0; msample < (conf->multisample_buffers + 1); ++msample) {
-
- // Global
- c->visualID = -1;
- c->visualType = GLX_TRUE_COLOR;
- c->next = c + 1;
-
- c->screen = screenNumber;
-
- c->level = 0;
- c->indexBits = 0;
- c->pixmapMode = 0; // TODO: What should this be?
-
- if(conf->accelerated) {
- c->visualRating = GLX_NONE;
- } else {
- c->visualRating = GLX_SLOW_VISUAL_EXT;
- }
-
- c->transparentPixel = GLX_NONE;
- c->transparentRed = GLX_NONE;
- c->transparentGreen = GLX_NONE;
- c->transparentBlue = GLX_NONE;
- c->transparentAlpha = GLX_NONE;
- c->transparentIndex = GLX_NONE;
-
- c->visualSelectGroup = 0;
-
- c->swapMethod = GLX_SWAP_UNDEFINED_OML;
-
- // Stereo
- c->stereoMode = stereo ? TRUE : FALSE;
-
- // Aux buffers
- c->numAuxBuffers = aux ? conf->aux_buffers : 0;
-
- // Double Buffered
- c->doubleBufferMode = buffers ? TRUE : FALSE;
-
- // Stencil Buffer
- if(conf->total_stencil_bit_depths > 0) {
- c->stencilBits = conf->stencil_bit_depths[stencil];
- } else {
- c->stencilBits = 0;
- }
-
- // Color
- if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->color_buffers[color].a) {
- c->alphaBits = conf->color_buffers[color].a;
- } else {
- c->alphaBits = 0;
- }
- c->redBits = conf->color_buffers[color].r;
- c->greenBits = conf->color_buffers[color].g;
- c->blueBits = conf->color_buffers[color].b;
-
- c->rgbBits = c->alphaBits + c->redBits + c->greenBits + c->blueBits;
-
- c->alphaMask = AM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
- c->redMask = RM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
- c->greenMask = GM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
- c->blueMask = BM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
-
- // Accumulation Buffers
- if(conf->total_accum_buffers > 0) {
- c->accumRedBits = conf->accum_buffers[accum].r;
- c->accumGreenBits = conf->accum_buffers[accum].g;
- c->accumBlueBits = conf->accum_buffers[accum].b;
- if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->accum_buffers[accum].a) {
- c->accumAlphaBits = conf->accum_buffers[accum].a;
- } else {
- c->accumAlphaBits = 0;
- }
- } else {
- c->accumRedBits = 0;
- c->accumGreenBits = 0;
- c->accumBlueBits = 0;
- c->accumAlphaBits = 0;
- }
-
- // Depth
- c->depthBits = conf->depth_buffers[depth];
-
- // MultiSample
- if(msample > 0) {
- c->samples = conf->multisample_samples;
- c->sampleBuffers = conf->multisample_buffers;
- } else {
- c->samples = 0;
- c->sampleBuffers = 0;
- }
-
- /*
- * The Apple libGL supports GLXPixmaps and
- * GLXPbuffers in direct mode.
- */
- /* SGIX_fbconfig / GLX 1.3 */
- c->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
- c->renderType = GLX_RGBA_BIT;
- c->xRenderable = GL_TRUE;
- c->fbconfigID = -1;
-
- /* SGIX_pbuffer / GLX 1.3 */
-
- /*
- * The CGL layer provides a way of retrieving
- * the maximum pbuffer width/height, but only
- * if we create a context and call glGetIntegerv.
- *
- * The following values are from a test program
- * that does so.
- */
- c->maxPbufferWidth = 8192;
- c->maxPbufferHeight = 8192;
- c->maxPbufferPixels = /*Do we need this?*/ 0;
- /*
- * There is no introspection for this sort of thing
- * with CGL. What should we do realistically?
- */
- c->optimalPbufferWidth = 0;
- c->optimalPbufferHeight = 0;
-
- /* EXT_texture_from_pixmap */
- c->bindToTextureRgb = 0;
- c->bindToTextureRgba = 0;
- c->bindToMipmapTexture = 0;
- c->bindToTextureTargets = 0;
- c->yInverted = 0;
-
- c = c->next;
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- (c-1)->next = NULL;
-
- if (c - visualConfigs != numConfigs) {
- FatalError("numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n", numConfigs, (int)(c - visualConfigs));
- }
-
- freeGlCapabilities(&caps);
- return visualConfigs;
-}
+/* + * Copyright (c) 2007, 2008 Apple Inc. + * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2002 Greg Parker. All Rights Reserved. + * + * Portions of this file are copied from Mesa's xf86glx.c, + * which contains the following copyright: + * + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "dri.h" + +#include <OpenGL/OpenGL.h> +#include <OpenGL/gl.h> +#include <OpenGL/glext.h> +#include <OpenGL/CGLContext.h> + +#include <GL/glxproto.h> +#include <windowstr.h> +#include <resource.h> +#include <GL/glxint.h> +#include <GL/glxtokens.h> +#include <scrnintstr.h> +#include <glxserver.h> +#include <glxscreens.h> +#include <glxdrawable.h> +#include <glxcontext.h> +#include <glxext.h> +#include <glxutil.h> +#include <GL/internal/glcore.h> + +#include "capabilities.h" +#include "visualConfigs.h" +#include "darwinfb.h" + +/* Based originally on code from indirect.c which was based on code from i830_dri.c. */ +__GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber) { + int numConfigs = 0; + __GLXconfig *visualConfigs, *c; + struct glCapabilities caps; + struct glCapabilitiesConfig *conf; + int stereo, depth, aux, buffers, stencil, accum, color, msample; + + if(getGlCapabilities(&caps)) { + ErrorF("error from getGlCapabilities()!\n"); + return NULL; + } + + /* + conf->stereo is 0 or 1, but we need at least 1 iteration of the loop, + so we treat a true conf->stereo as 2. + + The depth size is 0 or 24. Thus we do 2 iterations for that. + + conf->aux_buffers (when available/non-zero) result in 2 iterations instead of 1. + + conf->buffers indicates whether we have single or double buffering. + + conf->total_stencil_bit_depths + + conf->total_color_buffers indicates the RGB/RGBA color depths. + + conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0) + + conf->total_depth_buffer_depths + + conf->multisample_buffers iterations (with at least 1 if equal to 0). We add 1 + for the 0 multisampling config. + + */ + + assert(NULL != caps.configurations); + + numConfigs = 0; + + for(conf = caps.configurations; conf; conf = conf->next) { + if(conf->total_color_buffers <= 0) + continue; + + numConfigs += (conf->stereo ? 2 : 1) + * (conf->aux_buffers ? 2 : 1) + * conf->buffers + * ((conf->total_stencil_bit_depths > 0) ? conf->total_stencil_bit_depths : 1) + * conf->total_color_buffers + * ((conf->total_accum_buffers > 0) ? conf->total_accum_buffers : 1) + * conf->total_depth_buffer_depths + * (conf->multisample_buffers + 1); + } + + if(numConfigsPtr) + *numConfigsPtr = numConfigs; + + visualConfigs = calloc(sizeof(*visualConfigs), numConfigs); + + if(NULL == visualConfigs) { + ErrorF("xcalloc failure when allocating visualConfigs\n"); + freeGlCapabilities(&caps); + return NULL; + } + + c = visualConfigs; /* current buffer */ + for(conf = caps.configurations; conf; conf = conf->next) { + for(stereo = 0; stereo < (conf->stereo ? 2 : 1); ++stereo) { + for(aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) { + for(buffers = 0; buffers < conf->buffers; ++buffers) { + for(stencil = 0; stencil < ((conf->total_stencil_bit_depths > 0) ? + conf->total_stencil_bit_depths : 1); ++stencil) { + for(color = 0; color < conf->total_color_buffers; ++color) { + for(accum = 0; accum < ((conf->total_accum_buffers > 0) ? + conf->total_accum_buffers : 1); ++accum) { + for(depth = 0; depth < conf->total_depth_buffer_depths; ++depth) { + for(msample = 0; msample < (conf->multisample_buffers + 1); ++msample) { + + // Global + c->visualID = -1; + c->visualType = GLX_TRUE_COLOR; + c->next = c + 1; + + c->screen = screenNumber; + + c->level = 0; + c->indexBits = 0; + c->pixmapMode = 0; // TODO: What should this be? + + if(conf->accelerated) { + c->visualRating = GLX_NONE; + } else { + c->visualRating = GLX_SLOW_VISUAL_EXT; + } + + c->transparentPixel = GLX_NONE; + c->transparentRed = GLX_NONE; + c->transparentGreen = GLX_NONE; + c->transparentBlue = GLX_NONE; + c->transparentAlpha = GLX_NONE; + c->transparentIndex = GLX_NONE; + + c->visualSelectGroup = 0; + + c->swapMethod = GLX_SWAP_UNDEFINED_OML; + + // Stereo + c->stereoMode = stereo ? TRUE : FALSE; + + // Aux buffers + c->numAuxBuffers = aux ? conf->aux_buffers : 0; + + // Double Buffered + c->doubleBufferMode = buffers ? TRUE : FALSE; + + // Stencil Buffer + if(conf->total_stencil_bit_depths > 0) { + c->stencilBits = conf->stencil_bit_depths[stencil]; + } else { + c->stencilBits = 0; + } + + // Color + if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->color_buffers[color].a) { + c->alphaBits = conf->color_buffers[color].a; + } else { + c->alphaBits = 0; + } + c->redBits = conf->color_buffers[color].r; + c->greenBits = conf->color_buffers[color].g; + c->blueBits = conf->color_buffers[color].b; + + c->rgbBits = c->alphaBits + c->redBits + c->greenBits + c->blueBits; + + c->alphaMask = AM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits); + c->redMask = RM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits); + c->greenMask = GM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits); + c->blueMask = BM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits); + + // Accumulation Buffers + if(conf->total_accum_buffers > 0) { + c->accumRedBits = conf->accum_buffers[accum].r; + c->accumGreenBits = conf->accum_buffers[accum].g; + c->accumBlueBits = conf->accum_buffers[accum].b; + if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->accum_buffers[accum].a) { + c->accumAlphaBits = conf->accum_buffers[accum].a; + } else { + c->accumAlphaBits = 0; + } + } else { + c->accumRedBits = 0; + c->accumGreenBits = 0; + c->accumBlueBits = 0; + c->accumAlphaBits = 0; + } + + // Depth + c->depthBits = conf->depth_buffers[depth]; + + // MultiSample + if(msample > 0) { + c->samples = conf->multisample_samples; + c->sampleBuffers = conf->multisample_buffers; + } else { + c->samples = 0; + c->sampleBuffers = 0; + } + + /* + * The Apple libGL supports GLXPixmaps and + * GLXPbuffers in direct mode. + */ + /* SGIX_fbconfig / GLX 1.3 */ + c->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; + c->renderType = GLX_RGBA_BIT; + c->xRenderable = GL_TRUE; + c->fbconfigID = -1; + + /* SGIX_pbuffer / GLX 1.3 */ + + /* + * The CGL layer provides a way of retrieving + * the maximum pbuffer width/height, but only + * if we create a context and call glGetIntegerv. + * + * The following values are from a test program + * that does so. + */ + c->maxPbufferWidth = 8192; + c->maxPbufferHeight = 8192; + c->maxPbufferPixels = /*Do we need this?*/ 0; + /* + * There is no introspection for this sort of thing + * with CGL. What should we do realistically? + */ + c->optimalPbufferWidth = 0; + c->optimalPbufferHeight = 0; + + /* EXT_texture_from_pixmap */ + c->bindToTextureRgb = 0; + c->bindToTextureRgba = 0; + c->bindToMipmapTexture = 0; + c->bindToTextureTargets = 0; + c->yInverted = 0; + + c = c->next; + } + } + } + } + } + } + } + } + } + + (c-1)->next = NULL; + + if (c - visualConfigs != numConfigs) { + FatalError("numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n", numConfigs, (int)(c - visualConfigs)); + } + + freeGlCapabilities(&caps); + return visualConfigs; +} diff --git a/xorg-server/hw/xquartz/Makefile.am b/xorg-server/hw/xquartz/Makefile.am index 61b04e0e1..76f624d78 100644 --- a/xorg-server/hw/xquartz/Makefile.am +++ b/xorg-server/hw/xquartz/Makefile.am @@ -33,8 +33,7 @@ libXquartz_la_SOURCES = \ quartzCocoa.m \ quartzKeyboard.c \ quartzStartup.c \ - quartzRandR.c \ - threadSafety.c + quartzRandR.c EXTRA_DIST = \ X11Application.h \ @@ -50,5 +49,4 @@ EXTRA_DIST = \ quartzKeyboard.h \ quartzRandR.h \ sanitizedCarbon.h \ - sanitizedCocoa.h \ - threadSafety.h + sanitizedCocoa.h diff --git a/xorg-server/hw/xquartz/X11Application.m b/xorg-server/hw/xquartz/X11Application.m index e56bf0cf3..283132e75 100644 --- a/xorg-server/hw/xquartz/X11Application.m +++ b/xorg-server/hw/xquartz/X11Application.m @@ -41,7 +41,6 @@ #include "quartz.h" #include "darwinEvents.h" #include "quartzKeyboard.h" -#include "quartz.h" #include <X11/extensions/applewmconst.h> #include "micmap.h" #include "exglobals.h" @@ -237,8 +236,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) { if ([self isActive]) { [self deactivate]; - if (!_x_active && quartzProcs->IsX11Window([e window], - [e windowNumber])) + if (!_x_active && quartzProcs->IsX11Window([e windowNumber])) [self activateX:YES]; } } @@ -980,7 +978,7 @@ static inline pthread_t create_thread(void *(*func)(void *), void *arg) { static void *xpbproxy_x_thread(void *args) { xpbproxy_run(); - fprintf(stderr, "xpbproxy thread is terminating unexpectedly.\n"); + ErrorF("xpbproxy thread is terminating unexpectedly.\n"); return NULL; } @@ -1014,7 +1012,7 @@ void X11ApplicationMain (int argc, char **argv, char **envp) { NSMaxY([[NSScreen mainScreen] visibleFrame]); #ifdef HAVE_LIBDISPATCH - eventTranslationQueue = dispatch_queue_create(LAUNCHD_ID_PREFIX".X11.NSEventsToX11EventsQueue", NULL); + eventTranslationQueue = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.NSEventsToX11EventsQueue", NULL); assert(eventTranslationQueue != NULL); #endif @@ -1023,15 +1021,15 @@ void X11ApplicationMain (int argc, char **argv, char **envp) { last_key_layout = TISCopyCurrentKeyboardLayoutInputSource(); if(!last_key_layout) - fprintf(stderr, "X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n"); + ErrorF("X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n"); #else KLGetCurrentKeyboardLayout(&last_key_layout); if(!last_key_layout) - fprintf(stderr, "X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n"); + ErrorF("X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n"); #endif if (!QuartsResyncKeymap(FALSE)) { - fprintf(stderr, "X11ApplicationMain: Could not build a valid keymap.\n"); + ErrorF("X11ApplicationMain: Could not build a valid keymap.\n"); } /* Tell the server thread that it can proceed */ @@ -1372,7 +1370,7 @@ static const char *untrusted_str(NSEvent *e) { #endif /* Update keyInfo */ if (!QuartsResyncKeymap(TRUE)) { - fprintf(stderr, "sendX11NSEvent: Could not build a valid keymap.\n"); + ErrorF("sendX11NSEvent: Could not build a valid keymap.\n"); } } } diff --git a/xorg-server/hw/xquartz/applewmExt.h b/xorg-server/hw/xquartz/applewmExt.h index 5ef8b5496..f622f79b4 100644 --- a/xorg-server/hw/xquartz/applewmExt.h +++ b/xorg-server/hw/xquartz/applewmExt.h @@ -32,10 +32,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define _APPLEWMEXT_H_ #include "window.h" +#include <Xplugin.h> typedef int (*DisableUpdateProc)(void); typedef int (*EnableUpdateProc)(void); typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level); +#if XPLUGIN_VERSION < 4 typedef int (*FrameGetRectProc)(int type, int class, const BoxRec *outer, const BoxRec *inner, BoxRec *ret); typedef int (*FrameHitTestProc)(int class, int x, int y, @@ -45,6 +47,17 @@ typedef int (*FrameDrawProc)(WindowPtr pWin, int class, unsigned int attr, const BoxRec *outer, const BoxRec *inner, unsigned int title_len, const unsigned char *title_bytes); +#else +typedef int (*FrameGetRectProc)(xp_frame_rect type, xp_frame_class class, const BoxRec *outer, + const BoxRec *inner, BoxRec *ret); +typedef int (*FrameHitTestProc)(xp_frame_class class, int x, int y, + const BoxRec *outer, + const BoxRec *inner, int *ret); +typedef int (*FrameDrawProc)(WindowPtr pWin, xp_frame_class class, xp_frame_attr attr, + const BoxRec *outer, const BoxRec *inner, + unsigned int title_len, + const unsigned char *title_bytes); +#endif typedef int (*SendPSNProc)(uint32_t hi, uint32_t lo); typedef int (*AttachTransientProc)(WindowPtr pWinChild, WindowPtr pWinParent); diff --git a/xorg-server/hw/xquartz/bundle/Info.plist.cpp b/xorg-server/hw/xquartz/bundle/Info.plist.cpp index 0e98218be..a4b8e1926 100644 --- a/xorg-server/hw/xquartz/bundle/Info.plist.cpp +++ b/xorg-server/hw/xquartz/bundle/Info.plist.cpp @@ -7,11 +7,11 @@ <key>CFBundleExecutable</key> <string>X11</string> <key>CFBundleGetInfoString</key> - <string>LAUNCHD_ID_PREFIX.X11</string> + <string>BUNDLE_ID_PREFIX.X11</string> <key>CFBundleIconFile</key> <string>X11.icns</string> <key>CFBundleIdentifier</key> - <string>LAUNCHD_ID_PREFIX.X11</string> + <string>BUNDLE_ID_PREFIX.X11</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> @@ -19,9 +19,9 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>2.6.1</string> + <string>2.7.0</string> <key>CFBundleVersion</key> - <string>2.6.1</string> + <string>2.7.0</string> <key>CFBundleSignature</key> <string>x11a</string> <key>CSResourcesFileMapped</key> diff --git a/xorg-server/hw/xquartz/bundle/Makefile.am b/xorg-server/hw/xquartz/bundle/Makefile.am index 34598aa6a..6deecae55 100644 --- a/xorg-server/hw/xquartz/bundle/Makefile.am +++ b/xorg-server/hw/xquartz/bundle/Makefile.am @@ -1,92 +1,92 @@ -include cpprules.in
-
-CPP_FILES_FLAGS = \
- -DLAUNCHD_ID_PREFIX="$(LAUNCHD_ID_PREFIX)" \
- -DAPPLE_APPLICATION_NAME="$(APPLE_APPLICATION_NAME)"
-
-if XQUARTZ_SPARKLE
-CPP_FILES_FLAGS += -DXQUARTZ_SPARKLE
-endif
-
-install-data-hook:
- $(srcdir)/mk_bundke.sh $(srcdir) $(builddir) $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app install
-
-uninstall-hook:
- $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Resources
- $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Info.plist
- $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/PkgInfo
-
-noinst_PRE = Info.plist.cpp
-noinst_DATA = $(noinst_PRE:plist.cpp=plist)
-
-CLEANFILES = $(noinst_DATA)
-
-resourcedir=$(libdir)/X11/xserver
-resource_DATA = Xquartz.plist
-
-EXTRA_DIST = \
- mk_bundke.sh \
- X11.sh \
- Info.plist.cpp \
- PkgInfo \
- $(resource_DATA) \
- Resources/ar.lproj/InfoPlist.strings \
- Resources/ar.lproj/Localizable.strings \
- Resources/ar.lproj/main.nib/designable.nib \
- Resources/ar.lproj/main.nib/keyedobjects.nib \
- Resources/da.lproj/InfoPlist.strings \
- Resources/da.lproj/Localizable.strings \
- Resources/da.lproj/main.nib/keyedobjects.nib \
- Resources/Dutch.lproj/InfoPlist.strings \
- Resources/Dutch.lproj/Localizable.strings \
- Resources/Dutch.lproj/main.nib/keyedobjects.nib \
- Resources/English.lproj/InfoPlist.strings \
- Resources/English.lproj/Localizable.strings \
- Resources/English.lproj/main.nib/designable.nib \
- Resources/English.lproj/main.nib/keyedobjects.nib \
- Resources/fi.lproj/InfoPlist.strings \
- Resources/fi.lproj/Localizable.strings \
- Resources/fi.lproj/main.nib/keyedobjects.nib \
- Resources/French.lproj/InfoPlist.strings \
- Resources/French.lproj/Localizable.strings \
- Resources/French.lproj/main.nib/keyedobjects.nib \
- Resources/German.lproj/InfoPlist.strings \
- Resources/German.lproj/Localizable.strings \
- Resources/German.lproj/main.nib/keyedobjects.nib \
- Resources/Italian.lproj/InfoPlist.strings \
- Resources/Italian.lproj/Localizable.strings \
- Resources/Italian.lproj/main.nib/keyedobjects.nib \
- Resources/Japanese.lproj/InfoPlist.strings \
- Resources/Japanese.lproj/Localizable.strings \
- Resources/Japanese.lproj/main.nib/keyedobjects.nib \
- Resources/ko.lproj/InfoPlist.strings \
- Resources/ko.lproj/Localizable.strings \
- Resources/ko.lproj/main.nib/keyedobjects.nib \
- Resources/no.lproj/InfoPlist.strings \
- Resources/no.lproj/Localizable.strings \
- Resources/no.lproj/main.nib/keyedobjects.nib \
- Resources/pl.lproj/InfoPlist.strings \
- Resources/pl.lproj/Localizable.strings \
- Resources/pl.lproj/main.nib/keyedobjects.nib \
- Resources/pt.lproj/InfoPlist.strings \
- Resources/pt.lproj/Localizable.strings \
- Resources/pt.lproj/main.nib/keyedobjects.nib \
- Resources/pt_PT.lproj/InfoPlist.strings \
- Resources/pt_PT.lproj/Localizable.strings \
- Resources/pt_PT.lproj/main.nib/keyedobjects.nib \
- Resources/ru.lproj/InfoPlist.strings \
- Resources/ru.lproj/Localizable.strings \
- Resources/ru.lproj/main.nib/keyedobjects.nib \
- Resources/Spanish.lproj/InfoPlist.strings \
- Resources/Spanish.lproj/Localizable.strings \
- Resources/Spanish.lproj/main.nib/keyedobjects.nib \
- Resources/sv.lproj/InfoPlist.strings \
- Resources/sv.lproj/Localizable.strings \
- Resources/sv.lproj/main.nib/keyedobjects.nib \
- Resources/X11.icns \
- Resources/zh_CN.lproj/InfoPlist.strings \
- Resources/zh_CN.lproj/Localizable.strings \
- Resources/zh_CN.lproj/main.nib/keyedobjects.nib \
- Resources/zh_TW.lproj/InfoPlist.strings \
- Resources/zh_TW.lproj/Localizable.strings \
- Resources/zh_TW.lproj/main.nib/keyedobjects.nib
+include cpprules.in + +CPP_FILES_FLAGS = \ + -DBUNDLE_ID_PREFIX="$(BUNDLE_ID_PREFIX)" \ + -DAPPLE_APPLICATION_NAME="$(APPLE_APPLICATION_NAME)" + +if XQUARTZ_SPARKLE +CPP_FILES_FLAGS += -DXQUARTZ_SPARKLE +endif + +install-data-hook: + $(srcdir)/mk_bundke.sh $(srcdir) $(builddir) $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app install + +uninstall-hook: + $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Resources + $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Info.plist + $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/PkgInfo + +noinst_PRE = Info.plist.cpp +noinst_DATA = $(noinst_PRE:plist.cpp=plist) + +CLEANFILES = $(noinst_DATA) + +resourcedir=$(libdir)/X11/xserver +resource_DATA = Xquartz.plist + +EXTRA_DIST = \ + mk_bundke.sh \ + X11.sh \ + Info.plist.cpp \ + PkgInfo \ + $(resource_DATA) \ + Resources/ar.lproj/InfoPlist.strings \ + Resources/ar.lproj/Localizable.strings \ + Resources/ar.lproj/main.nib/designable.nib \ + Resources/ar.lproj/main.nib/keyedobjects.nib \ + Resources/da.lproj/InfoPlist.strings \ + Resources/da.lproj/Localizable.strings \ + Resources/da.lproj/main.nib/keyedobjects.nib \ + Resources/Dutch.lproj/InfoPlist.strings \ + Resources/Dutch.lproj/Localizable.strings \ + Resources/Dutch.lproj/main.nib/keyedobjects.nib \ + Resources/English.lproj/InfoPlist.strings \ + Resources/English.lproj/Localizable.strings \ + Resources/English.lproj/main.nib/designable.nib \ + Resources/English.lproj/main.nib/keyedobjects.nib \ + Resources/fi.lproj/InfoPlist.strings \ + Resources/fi.lproj/Localizable.strings \ + Resources/fi.lproj/main.nib/keyedobjects.nib \ + Resources/French.lproj/InfoPlist.strings \ + Resources/French.lproj/Localizable.strings \ + Resources/French.lproj/main.nib/keyedobjects.nib \ + Resources/German.lproj/InfoPlist.strings \ + Resources/German.lproj/Localizable.strings \ + Resources/German.lproj/main.nib/keyedobjects.nib \ + Resources/Italian.lproj/InfoPlist.strings \ + Resources/Italian.lproj/Localizable.strings \ + Resources/Italian.lproj/main.nib/keyedobjects.nib \ + Resources/Japanese.lproj/InfoPlist.strings \ + Resources/Japanese.lproj/Localizable.strings \ + Resources/Japanese.lproj/main.nib/keyedobjects.nib \ + Resources/ko.lproj/InfoPlist.strings \ + Resources/ko.lproj/Localizable.strings \ + Resources/ko.lproj/main.nib/keyedobjects.nib \ + Resources/no.lproj/InfoPlist.strings \ + Resources/no.lproj/Localizable.strings \ + Resources/no.lproj/main.nib/keyedobjects.nib \ + Resources/pl.lproj/InfoPlist.strings \ + Resources/pl.lproj/Localizable.strings \ + Resources/pl.lproj/main.nib/keyedobjects.nib \ + Resources/pt.lproj/InfoPlist.strings \ + Resources/pt.lproj/Localizable.strings \ + Resources/pt.lproj/main.nib/keyedobjects.nib \ + Resources/pt_PT.lproj/InfoPlist.strings \ + Resources/pt_PT.lproj/Localizable.strings \ + Resources/pt_PT.lproj/main.nib/keyedobjects.nib \ + Resources/ru.lproj/InfoPlist.strings \ + Resources/ru.lproj/Localizable.strings \ + Resources/ru.lproj/main.nib/keyedobjects.nib \ + Resources/Spanish.lproj/InfoPlist.strings \ + Resources/Spanish.lproj/Localizable.strings \ + Resources/Spanish.lproj/main.nib/keyedobjects.nib \ + Resources/sv.lproj/InfoPlist.strings \ + Resources/sv.lproj/Localizable.strings \ + Resources/sv.lproj/main.nib/keyedobjects.nib \ + Resources/X11.icns \ + Resources/zh_CN.lproj/InfoPlist.strings \ + Resources/zh_CN.lproj/Localizable.strings \ + Resources/zh_CN.lproj/main.nib/keyedobjects.nib \ + Resources/zh_TW.lproj/InfoPlist.strings \ + Resources/zh_TW.lproj/Localizable.strings \ + Resources/zh_TW.lproj/main.nib/keyedobjects.nib diff --git a/xorg-server/hw/xquartz/darwin.c b/xorg-server/hw/xquartz/darwin.c index 00be74ba0..50234f243 100644 --- a/xorg-server/hw/xquartz/darwin.c +++ b/xorg-server/hw/xquartz/darwin.c @@ -133,28 +133,12 @@ static PixmapFormatRec formats[] = { }; const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]); -#ifndef OSNAME -#define OSNAME " Darwin" -#endif -#ifndef OSVENDOR -#define OSVENDOR "" -#endif -#ifndef PRE_RELEASE -#define PRE_RELEASE XORG_VERSION_SNAP -#endif -#ifndef BUILD_DATE -#define BUILD_DATE "" -#endif -#ifndef XORG_RELEASE -#define XORG_RELEASE "?" -#endif - void DarwinPrintBanner(void) { - // this should change depending on which specific server we are building ErrorF("Xquartz starting:\n"); - ErrorF("X.Org X Server %s\nBuild Date: %s\n", XSERVER_VERSION, BUILD_DATE ); + ErrorF("X.Org X Server %s\n", XSERVER_VERSION); + ErrorF("Build Date: %s\n", BUILD_DATE ); } @@ -605,6 +589,13 @@ void OsVendorFatalError( void ) void OsVendorInit(void) { if (serverGeneration == 1) { + char *lf; + char *home = getenv("HOME"); + assert(home); + assert(0 < asprintf(&lf, "%s/Library/Logs/X11.%s.log", home, bundle_id_prefix)); + LogInit(lf, ".old"); + free(lf); + DarwinPrintBanner(); #ifdef ENABLE_DEBUG_LOG { diff --git a/xorg-server/hw/xquartz/darwin.h b/xorg-server/hw/xquartz/darwin.h index 360225742..507c6f7f6 100644 --- a/xorg-server/hw/xquartz/darwin.h +++ b/xorg-server/hw/xquartz/darwin.h @@ -34,8 +34,6 @@ #include <X11/extensions/XKB.h> #include <assert.h> -#include "threadSafety.h" - #include "darwinfb.h" // From darwin.c @@ -75,12 +73,15 @@ extern int darwinDesiredDepth; extern int darwinMainScreenX; extern int darwinMainScreenY; +// bundle-main.c +extern char *bundle_id_prefix; + #define ENABLE_DEBUG_LOG 1 #ifdef ENABLE_DEBUG_LOG extern FILE *debug_log_fp; #define DEBUG_LOG_NAME "x11-debug.txt" -#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%s:%s:%d " msg, threadSafetyID(pthread_self()), __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp); +#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp); #else #define DEBUG_LOG(msg, args...) #endif diff --git a/xorg-server/hw/xquartz/darwinEvents.c b/xorg-server/hw/xquartz/darwinEvents.c index 40d8a4e9e..f3e12250e 100644 --- a/xorg-server/hw/xquartz/darwinEvents.c +++ b/xorg-server/hw/xquartz/darwinEvents.c @@ -113,7 +113,7 @@ void darwinEvents_lock(void) { if((err = pthread_mutex_lock(&mieq_lock))) { ErrorF("%s:%s:%d: Failed to lock mieq_lock: %d\n", __FILE__, __FUNCTION__, __LINE__, err); - spewCallStack(); + xorg_backtrace(); } if(darwinEvents == NULL) { pthread_cond_wait(&mieq_ready_cond, &mieq_lock); @@ -126,7 +126,7 @@ void darwinEvents_unlock(void) { if((err = pthread_mutex_unlock(&mieq_lock))) { ErrorF("%s:%s:%d: Failed to unlock mieq_lock: %d\n", __FILE__, __FUNCTION__, __LINE__, err); - spewCallStack(); + xorg_backtrace(); } } @@ -197,8 +197,6 @@ static void DarwinUpdateModifiers( static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) { XQuartzEvent *e = &(ie->xquartz_event); - TA_SERVER(); - switch(e->subtype) { case kXquartzControllerNotify: DEBUG_LOG("kXquartzControllerNotify\n"); @@ -381,8 +379,6 @@ void ProcessInputEvents(void) { char nullbyte; int x = sizeof(nullbyte); - TA_SERVER(); - mieqProcessInputEvents(); // Empty the signaling pipe diff --git a/xorg-server/hw/xquartz/mach-startup/bundle-main.c b/xorg-server/hw/xquartz/mach-startup/bundle-main.c index 6a6c01c3b..846025b44 100644 --- a/xorg-server/hw/xquartz/mach-startup/bundle-main.c +++ b/xorg-server/hw/xquartz/mach-startup/bundle-main.c @@ -64,6 +64,9 @@ /* From darwinEvents.c ... but don't want to pull in all the server cruft */ void DarwinListenOnOpenFD(int fd); +/* Ditto, from os/log.c */ +extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2); + extern int noPanoramiXExtension; #define DEFAULT_CLIENT X11BINDIR "/xterm" @@ -88,7 +91,7 @@ asm (".desc ___crashreporter_info__, 0x10"); static const char *__crashreporter_info__base = "X.Org X Server " XSERVER_VERSION " Build Date: " BUILD_DATE; -static char *launchd_id_prefix = NULL; +char *bundle_id_prefix = NULL; static char *server_bootstrap_name = NULL; #define DEBUG 1 @@ -134,19 +137,27 @@ static mach_port_t checkin_or_register(char *bname) { /* We probably were not started by launchd or the old mach_init */ kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp); if (kr != KERN_SUCCESS) { - fprintf(stderr, "mach_port_allocate(): %s\n", mach_error_string(kr)); + ErrorF("mach_port_allocate(): %s\n", mach_error_string(kr)); exit(EXIT_FAILURE); } kr = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND); if (kr != KERN_SUCCESS) { - fprintf(stderr, "mach_port_insert_right(): %s\n", mach_error_string(kr)); + ErrorF("mach_port_insert_right(): %s\n", mach_error_string(kr)); exit(EXIT_FAILURE); } +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" // bootstrap_register +#endif kr = bootstrap_register(bootstrap_port, bname, mp); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + if (kr != KERN_SUCCESS) { - fprintf(stderr, "bootstrap_register(): %s\n", mach_error_string(kr)); + ErrorF("bootstrap_register(): %s\n", mach_error_string(kr)); exit(EXIT_FAILURE); } @@ -189,7 +200,7 @@ static int accept_fd_handoff(int connected_fd) { *((int*)CMSG_DATA(cmsg)) = -1; if(recvmsg(connected_fd, &msg, 0) < 0) { - fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", strerror(errno)); + ErrorF("X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", strerror(errno)); return -1; } @@ -222,14 +233,14 @@ static void *socket_handoff_thread(void *arg) { while(launchd_fd == -1) { connected_fd = accept(handoff_data->fd, NULL, NULL); if(connected_fd == -1) { - fprintf(stderr, "X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno)); + ErrorF("X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno)); sleep(2); continue; } launchd_fd = accept_fd_handoff(connected_fd); if(launchd_fd == -1) - fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n"); + ErrorF("X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n"); close(connected_fd); } @@ -238,7 +249,7 @@ static void *socket_handoff_thread(void *arg) { unlink(handoff_data->filename); free(handoff_data); - fprintf(stderr, "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd); + ErrorF("X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd); DarwinListenOnOpenFD(launchd_fd); #ifndef HAVE_LIBDISPATCH @@ -266,24 +277,24 @@ static int create_socket(char *filename_out) { ret_fd = socket(PF_UNIX, SOCK_STREAM, 0); if(ret_fd == -1) { - fprintf(stderr, "X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno)); + ErrorF("X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno)); continue; } if(bind(ret_fd, servaddr, servaddr_len) != 0) { - fprintf(stderr, "X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno)); + ErrorF("X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno)); close(ret_fd); return 0; } if(listen(ret_fd, 10) != 0) { - fprintf(stderr, "X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno)); + ErrorF("X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno)); close(ret_fd); return 0; } #ifdef DEBUG - fprintf(stderr, "X11.app: Listening on socket for fd handoff: (%d) %s\n", ret_fd, filename_out); + ErrorF("X11.app: Listening on socket for fd handoff: (%d) %s\n", ret_fd, filename_out); #endif return ret_fd; @@ -301,7 +312,7 @@ kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename) handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t)); if(!handoff_data) { - fprintf(stderr, "X11.app: Error allocating memory for handoff_data\n"); + ErrorF("X11.app: Error allocating memory for handoff_data\n"); return KERN_FAILURE; } @@ -322,7 +333,7 @@ kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename) #endif #ifdef DEBUG - fprintf(stderr, "X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n"); + ErrorF("X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n"); #endif return KERN_SUCCESS; @@ -347,7 +358,7 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv, * unset DISPLAY or we can run into problems with pbproxy */ if(!launchd_socket_handed_off) { - fprintf(stderr, "X11.app: No launchd socket handed off, unsetting DISPLAY\n"); + ErrorF("X11.app: No launchd socket handed off, unsetting DISPLAY\n"); unsetenv("DISPLAY"); } @@ -355,10 +366,10 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv, return KERN_FAILURE; } - fprintf(stderr, "X11.app: do_start_x11_server(): argc=%d\n", argvCnt); + ErrorF("X11.app: do_start_x11_server(): argc=%d\n", argvCnt); for(i=0; i < argvCnt; i++) { _argv[i] = argv[i]; - fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]); + ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]); } _argv[argvCnt] = NULL; @@ -396,7 +407,7 @@ static int startup_trigger(int argc, char **argv, char **envp) { newenvp = (string_array_t)alloca(envpc * sizeof(string_t)); if(!newargv || !newenvp) { - fprintf(stderr, "Memory allocation failure\n"); + ErrorF("Memory allocation failure\n"); exit(EXIT_FAILURE); } @@ -410,16 +421,16 @@ static int startup_trigger(int argc, char **argv, char **envp) { kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp); if (kr != KERN_SUCCESS) { #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 - fprintf(stderr, "bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr)); + ErrorF("bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr)); #else - fprintf(stderr, "bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr); + ErrorF("bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr); #endif exit(EXIT_FAILURE); } kr = start_x11_server(mp, newargv, argc, newenvp, envpc); if (kr != KERN_SUCCESS) { - fprintf(stderr, "start_x11_server: %s\n", mach_error_string(kr)); + ErrorF("start_x11_server: %s\n", mach_error_string(kr)); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); @@ -441,10 +452,10 @@ static int startup_trigger(int argc, char **argv, char **envp) { /* Start the server */ if((s = getenv("DISPLAY"))) { - fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s); + ErrorF("X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s); unsetenv("DISPLAY"); } else { - fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n"); + ErrorF("X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n"); } return execute(command_from_prefs("startx_script", DEFAULT_STARTX)); } @@ -483,23 +494,23 @@ static void setup_env(void) { /* fallback to hardcoded value if we can't discover it */ if(!pds) { - pds = LAUNCHD_ID_PREFIX".X11"; + pds = BUNDLE_ID_PREFIX".X11"; } server_bootstrap_name = strdup(pds); if(!server_bootstrap_name) { - fprintf(stderr, "X11.app: Memory allocation error.\n"); + ErrorF("X11.app: Memory allocation error.\n"); exit(1); } setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1); len = strlen(server_bootstrap_name); - launchd_id_prefix = malloc(sizeof(char) * (len - 3)); - if(!launchd_id_prefix) { - fprintf(stderr, "X11.app: Memory allocation error.\n"); + bundle_id_prefix = malloc(sizeof(char) * (len - 3)); + if(!bundle_id_prefix) { + ErrorF("X11.app: Memory allocation error.\n"); exit(1); } - strlcpy(launchd_id_prefix, server_bootstrap_name, len - 3); + strlcpy(bundle_id_prefix, server_bootstrap_name, len - 3); /* We need to unset DISPLAY if it is not our socket */ if(disp) { @@ -511,27 +522,27 @@ static void setup_env(void) { } if(s && *s) { - if(strcmp(launchd_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) { - fprintf(stderr, "X11.app: Detected old style launchd DISPLAY, please update xinit.\n"); + if(strcmp(bundle_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) { + ErrorF("X11.app: Detected old style launchd DISPLAY, please update xinit.\n"); } else { temp = (char *)malloc(sizeof(char) * len); if(!temp) { - fprintf(stderr, "X11.app: Memory allocation error creating space for socket name test.\n"); + ErrorF("X11.app: Memory allocation error creating space for socket name test.\n"); exit(1); } - strlcpy(temp, launchd_id_prefix, len); + strlcpy(temp, bundle_id_prefix, len); strlcat(temp, ":0", len); if(strcmp(temp, s) != 0) { /* If we don't have a match, unset it. */ - fprintf(stderr, "X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, launchd_id_prefix); + ErrorF("X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, bundle_id_prefix); unsetenv("DISPLAY"); } free(temp); } } else { /* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */ - fprintf(stderr, "X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n"); + ErrorF("X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n"); unsetenv("DISPLAY"); } } @@ -562,9 +573,9 @@ int main(int argc, char **argv, char **envp) { /* Setup the initial crasherporter info */ strlcpy(__crashreporter_info_buff__, __crashreporter_info__base, sizeof(__crashreporter_info_buff__)); - fprintf(stderr, "X11.app: main(): argc=%d\n", argc); + ErrorF("X11.app: main(): argc=%d\n", argc); for(i=0; i < argc; i++) { - fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]); + ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]); if(!strcmp(argv[i], "--listenonly")) { listenOnly = TRUE; } @@ -572,7 +583,7 @@ int main(int argc, char **argv, char **envp) { mp = checkin_or_register(server_bootstrap_name); if(mp == MACH_PORT_NULL) { - fprintf(stderr, "NULL mach service: %s", server_bootstrap_name); + ErrorF("NULL mach service: %s", server_bootstrap_name); return EXIT_FAILURE; } @@ -621,10 +632,10 @@ int main(int argc, char **argv, char **envp) { } /* Main event loop */ - fprintf(stderr, "Waiting for startup parameters via Mach IPC.\n"); + ErrorF("Waiting for startup parameters via Mach IPC.\n"); kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0); if (kr != KERN_SUCCESS) { - fprintf(stderr, "%s.X11(mp): %s\n", LAUNCHD_ID_PREFIX, mach_error_string(kr)); + ErrorF("%s.X11(mp): %s\n", BUNDLE_ID_PREFIX, mach_error_string(kr)); return EXIT_FAILURE; } @@ -640,9 +651,9 @@ static int execute(const char *command) { newargv[2] = command; newargv[3] = NULL; - fprintf(stderr, "X11.app: Launching %s:\n", command); + ErrorF("X11.app: Launching %s:\n", command); for(p=newargv; *p; p++) { - fprintf(stderr, "\targv[%ld] = %s\n", (long int)(p - newargv), *p); + ErrorF("\targv[%ld] = %s\n", (long int)(p - newargv), *p); } execvp (newargv[0], (char * const *) newargv); diff --git a/xorg-server/hw/xquartz/mach-startup/launchd_fd.c b/xorg-server/hw/xquartz/mach-startup/launchd_fd.c index 6dace8ea1..5c7e03cf3 100644 --- a/xorg-server/hw/xquartz/mach-startup/launchd_fd.c +++ b/xorg-server/hw/xquartz/mach-startup/launchd_fd.c @@ -69,11 +69,11 @@ int launchd_display_fd(void) { return ERROR_FD; } - listening_fd_array = launch_data_dict_lookup(sockets_dict, LAUNCHD_ID_PREFIX":0"); + listening_fd_array = launch_data_dict_lookup(sockets_dict, BUNDLE_ID_PREFIX":0"); if (NULL == listening_fd_array) { listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0"); if (NULL == listening_fd_array) { - fprintf(stderr,"launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n", LAUNCHD_ID_PREFIX); + fprintf(stderr,"launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n", BUNDLE_ID_PREFIX); return ERROR_FD; } } diff --git a/xorg-server/hw/xquartz/mach-startup/stub.c b/xorg-server/hw/xquartz/mach-startup/stub.c index ccf5ab426..c8a628311 100644 --- a/xorg-server/hw/xquartz/mach-startup/stub.c +++ b/xorg-server/hw/xquartz/mach-startup/stub.c @@ -40,7 +40,7 @@ #include <sys/socket.h> #include <sys/un.h> -#define kX11AppBundleId LAUNCHD_ID_PREFIX".X11" +#define kX11AppBundleId BUNDLE_ID_PREFIX".X11" #define kX11AppBundlePath "/Contents/MacOS/X11" static char *server_bootstrap_name = kX11AppBundleId; @@ -56,15 +56,6 @@ static char *server_bootstrap_name = kX11AppBundleId; #include "launchd_fd.h" -#ifndef BUILD_DATE -#define BUILD_DATE "?" -#endif -#ifndef XSERVER_VERSION -#define XSERVER_VERSION "?" -#endif - -#define DEBUG 1 - static char x11_path[PATH_MAX + 1]; static pid_t x11app_pid = 0; @@ -197,13 +188,6 @@ int main(int argc, char **argv, char **envp) { string_t handoff_socket_filename; sig_t handler; - if(argc == 2 && !strcmp(argv[1], "-version")) { - fprintf(stderr, "X.org Release 7.5\n"); - fprintf(stderr, "X.Org X Server %s\n", XSERVER_VERSION); - fprintf(stderr, "Build Date: %s\n", BUILD_DATE); - return EXIT_SUCCESS; - } - if(getenv("X11_PREFS_DOMAIN")) server_bootstrap_name = getenv("X11_PREFS_DOMAIN"); @@ -300,8 +284,8 @@ int main(int argc, char **argv, char **envp) { /* We have fixed-size string lengths due to limitations in IPC, * so we need to copy our argv and envp. */ - newargv = (string_array_t)malloc(argc * sizeof(string_t)); - newenvp = (string_array_t)malloc(envpc * sizeof(string_t)); + newargv = (string_array_t)calloc((1 + argc), sizeof(string_t)); + newenvp = (string_array_t)calloc((1 + envpc), sizeof(string_t)); if(!newargv || !newenvp) { fprintf(stderr, "Xquartz: Memory allocation failure\n"); diff --git a/xorg-server/hw/xquartz/pbproxy/Makefile.am b/xorg-server/hw/xquartz/pbproxy/Makefile.am index 188664259..b8b95d232 100644 --- a/xorg-server/hw/xquartz/pbproxy/Makefile.am +++ b/xorg-server/hw/xquartz/pbproxy/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks \ - -DLAUNCHD_ID_PREFIX=\"$(LAUNCHD_ID_PREFIX)\" + -DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\" AM_CFLAGS=$(XPBPROXY_CFLAGS) diff --git a/xorg-server/hw/xquartz/pbproxy/app-main.m b/xorg-server/hw/xquartz/pbproxy/app-main.m index b00e90a6d..9055bad06 100644 --- a/xorg-server/hw/xquartz/pbproxy/app-main.m +++ b/xorg-server/hw/xquartz/pbproxy/app-main.m @@ -34,7 +34,7 @@ #include <unistd.h> /*for getpid*/ #include <Cocoa/Cocoa.h> -static const char *app_prefs_domain = LAUNCHD_ID_PREFIX".xpbproxy"; +static const char *app_prefs_domain = BUNDLE_ID_PREFIX".xpbproxy"; CFStringRef app_prefs_domain_cfstr; /* Stubs */ @@ -53,12 +53,22 @@ static void signal_handler (int sig) { } } +void +ErrorF(const char * f, ...) +{ + va_list args; + + va_start(args, f); + vfprintf(stderr, f, args); + va_end(args); +} + int main (int argc, const char *argv[]) { const char *s; int i; #ifdef DEBUG - printf("pid: %u\n", getpid()); + ErrorF("pid: %u\n", getpid()); #endif xpbproxy_is_standalone = YES; @@ -70,13 +80,13 @@ int main (int argc, const char *argv[]) { if(strcmp (argv[i], "--prefs-domain") == 0 && i+1 < argc) { app_prefs_domain = argv[++i]; } else if (strcmp (argv[i], "--help") == 0) { - printf("usage: xpbproxy OPTIONS\n" + ErrorF("usage: xpbproxy OPTIONS\n" "Pasteboard proxying for X11.\n\n" "--prefs-domain <domain> Change the domain used for reading preferences\n" " (default: %s)\n", app_prefs_domain); return 0; } else { - fprintf(stderr, "usage: xpbproxy OPTIONS...\n" + ErrorF("usage: xpbproxy OPTIONS...\n" "Try 'xpbproxy --help' for more information.\n"); return 1; } diff --git a/xorg-server/hw/xquartz/pbproxy/main.m b/xorg-server/hw/xquartz/pbproxy/main.m index cfdc7696d..dbdb6d05c 100644 --- a/xorg-server/hw/xquartz/pbproxy/main.m +++ b/xorg-server/hw/xquartz/pbproxy/main.m @@ -1,165 +1,149 @@ -/* main.m
- Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation files
- (the "Software"), to deal in the Software without restriction,
- including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software,
- and to permit persons to whom the Software is furnished to do so,
- subject to the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
-
- Except as contained in this notice, the name(s) of the above
- copyright holders shall not be used in advertising or otherwise to
- promote the sale, use or other dealings in this Software without
- prior written authorization.
- */
-
-#include "pbproxy.h"
-#import "x-selection.h"
-
-#include <pthread.h>
-#include <unistd.h>
-#include <X11/extensions/applewm.h>
-
-Display *xpbproxy_dpy;
-int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
-int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
-BOOL xpbproxy_have_xfixes;
-
-extern char *display;
-
-#ifdef STANDALONE_XPBPROXY
-BOOL xpbproxy_is_standalone = NO;
-#endif
-
-x_selection *_selection_object;
-
-extern BOOL serverInitComplete;
-extern pthread_mutex_t serverInitCompleteMutex;
-extern pthread_cond_t serverInitCompleteCond;
-
-static inline void wait_for_server_init(void) {
- /* If the server hasn't finished initializing, wait for it... */
- if(!serverInitComplete) {
- pthread_mutex_lock(&serverInitCompleteMutex);
- while(!serverInitComplete)
- pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
- pthread_mutex_unlock(&serverInitCompleteMutex);
- }
-}
-
-static int x_io_error_handler (Display *dpy) {
- /* We lost our connection to the server. */
-
- TRACE ();
-
- /* trigger the thread to restart?
- * NO - this would be to a "deeper" problem, and restarts would just
- * make things worse...
- */
-#ifdef STANDALONE_XPBPROXY
- if(xpbproxy_is_standalone)
- exit(EXIT_FAILURE);
-#endif
-
- /* Prevent _XIOError from calling exit() */
- pthread_exit(NULL);
- return 0;
-}
-
-static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
- return 0;
-}
-
-int xpbproxy_run (void) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- size_t i;
-
- wait_for_server_init();
-
- for(i=0, xpbproxy_dpy=NULL; !xpbproxy_dpy && i<5; i++) {
- xpbproxy_dpy = XOpenDisplay(NULL);
-
- if(!xpbproxy_dpy && display) {
- char _display[32];
- snprintf(_display, sizeof(_display), ":%s", display);
- setenv("DISPLAY", _display, TRUE);
-
- xpbproxy_dpy=XOpenDisplay(_display);
- }
- if(!xpbproxy_dpy)
- sleep(1);
- }
-
- if (xpbproxy_dpy == NULL) {
- fprintf (stderr, "xpbproxy: can't open default display\n");
- [pool release];
- return EXIT_FAILURE;
- }
-
- XSetIOErrorHandler (x_io_error_handler);
- XSetErrorHandler (x_error_handler);
-
- if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
- &xpbproxy_apple_wm_error_base)) {
- fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n");
- [pool release];
- return EXIT_FAILURE;
- }
-
- xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
-
- XAppleWMSelectInput (xpbproxy_dpy, AppleWMActivationNotifyMask |
- AppleWMPasteboardNotifyMask);
-
- _selection_object = [[x_selection alloc] init];
-
- if(!xpbproxy_input_register()) {
- [pool release];
- return EXIT_FAILURE;
- }
-
- [pool release];
-
- CFRunLoopRun();
-
- return EXIT_SUCCESS;
-}
-
-id xpbproxy_selection_object (void) {
- return _selection_object;
-}
-
-Time xpbproxy_current_timestamp (void) {
- /* FIXME: may want to fetch a timestamp from the server.. */
- return CurrentTime;
-}
-
-void debug_printf (const char *fmt, ...) {
- static int spew = -1;
-
- if (spew == -1) {
- char *x = getenv ("DEBUG");
- spew = (x != NULL && atoi (x) != 0);
- }
-
- if (spew) {
- va_list args;
- va_start(args, fmt);
- vfprintf (stderr, fmt, args);
- va_end(args);
- }
-}
+/* main.m + Copyright (c) 2002, 2008 Apple Computer, Inc. All rights reserved. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT + HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the name(s) of the above + copyright holders shall not be used in advertising or otherwise to + promote the sale, use or other dealings in this Software without + prior written authorization. + */ + +#include "pbproxy.h" +#import "x-selection.h" + +#include <pthread.h> +#include <unistd.h> +#include <X11/extensions/applewm.h> + +Display *xpbproxy_dpy; +int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base; +int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base; +BOOL xpbproxy_have_xfixes; + +extern char *display; + +#ifdef STANDALONE_XPBPROXY +BOOL xpbproxy_is_standalone = NO; +#endif + +x_selection *_selection_object; + +extern BOOL serverInitComplete; +extern pthread_mutex_t serverInitCompleteMutex; +extern pthread_cond_t serverInitCompleteCond; + +static inline void wait_for_server_init(void) { + /* If the server hasn't finished initializing, wait for it... */ + if(!serverInitComplete) { + pthread_mutex_lock(&serverInitCompleteMutex); + while(!serverInitComplete) + pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex); + pthread_mutex_unlock(&serverInitCompleteMutex); + } +} + +static int x_io_error_handler (Display *dpy) { + /* We lost our connection to the server. */ + + TRACE (); + + /* trigger the thread to restart? + * NO - this would be to a "deeper" problem, and restarts would just + * make things worse... + */ +#ifdef STANDALONE_XPBPROXY + if(xpbproxy_is_standalone) + exit(EXIT_FAILURE); +#endif + + /* Prevent _XIOError from calling exit() */ + pthread_exit(NULL); + return 0; +} + +static int x_error_handler (Display *dpy, XErrorEvent *errevent) { + return 0; +} + +int xpbproxy_run (void) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + size_t i; + + wait_for_server_init(); + + for(i=0, xpbproxy_dpy=NULL; !xpbproxy_dpy && i<5; i++) { + xpbproxy_dpy = XOpenDisplay(NULL); + + if(!xpbproxy_dpy && display) { + char _display[32]; + snprintf(_display, sizeof(_display), ":%s", display); + setenv("DISPLAY", _display, TRUE); + + xpbproxy_dpy=XOpenDisplay(_display); + } + if(!xpbproxy_dpy) + sleep(1); + } + + if (xpbproxy_dpy == NULL) { + ErrorF("xpbproxy: can't open default display\n"); + [pool release]; + return EXIT_FAILURE; + } + + XSetIOErrorHandler (x_io_error_handler); + XSetErrorHandler (x_error_handler); + + if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base, + &xpbproxy_apple_wm_error_base)) { + ErrorF("xpbproxy: can't open AppleWM server extension\n"); + [pool release]; + return EXIT_FAILURE; + } + + xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base); + + XAppleWMSelectInput (xpbproxy_dpy, AppleWMActivationNotifyMask | + AppleWMPasteboardNotifyMask); + + _selection_object = [[x_selection alloc] init]; + + if(!xpbproxy_input_register()) { + [pool release]; + return EXIT_FAILURE; + } + + [pool release]; + + CFRunLoopRun(); + + return EXIT_SUCCESS; +} + +id xpbproxy_selection_object (void) { + return _selection_object; +} + +Time xpbproxy_current_timestamp (void) { + /* FIXME: may want to fetch a timestamp from the server.. */ + return CurrentTime; +} diff --git a/xorg-server/hw/xquartz/pbproxy/pbproxy.h b/xorg-server/hw/xquartz/pbproxy/pbproxy.h index 013f981d4..fcbf4c4ba 100644 --- a/xorg-server/hw/xquartz/pbproxy/pbproxy.h +++ b/xorg-server/hw/xquartz/pbproxy/pbproxy.h @@ -77,14 +77,16 @@ extern BOOL xpbproxy_have_xfixes; /* from x-input.m */ extern BOOL xpbproxy_input_register (void); +/* os/log.c or app-main.m */ +extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2); + #ifdef DEBUG /* BEWARE: this can cause a string memory leak, according to the leaks program. */ -# define DB(msg, args...) debug_printf("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args) +# define DebugF(msg, args...) ErrorF("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args) #else -# define DB(msg, args...) do {} while (0) +# define DebugF(...) /* */ #endif -#define TRACE() DB("TRACE\n") -extern void debug_printf (const char *fmt, ...); +#define TRACE() DebugF("TRACE\n") #endif /* PBPROXY_H */ diff --git a/xorg-server/hw/xquartz/pbproxy/x-input.m b/xorg-server/hw/xquartz/pbproxy/x-input.m index 405ba3c73..ebb89980f 100644 --- a/xorg-server/hw/xquartz/pbproxy/x-input.m +++ b/xorg-server/hw/xquartz/pbproxy/x-input.m @@ -87,7 +87,7 @@ static void xpbproxy_process_xevents(void) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; if(pool == nil) { - fprintf(stderr, "unable to allocate/init auto release pool!\n"); + ErrorF("unable to allocate/init auto release pool!\n"); return; } diff --git a/xorg-server/hw/xquartz/pbproxy/x-selection.m b/xorg-server/hw/xquartz/pbproxy/x-selection.m index ef84f8bfb..7964f5193 100644 --- a/xorg-server/hw/xquartz/pbproxy/x-selection.m +++ b/xorg-server/hw/xquartz/pbproxy/x-selection.m @@ -81,19 +81,19 @@ static struct propdata null_propdata = {NULL, 0, 0}; #ifdef DEBUG static void -dump_prefs (FILE *fp) { - fprintf(fp, - "pbproxy preferences:\n" - "\tactive %u\n" - "\tprimary_on_grab %u\n" - "\tclipboard_to_pasteboard %u\n" - "\tpasteboard_to_primary %u\n" - "\tpasteboard_to_clipboard %u\n", - pbproxy_prefs.active, - pbproxy_prefs.primary_on_grab, - pbproxy_prefs.clipboard_to_pasteboard, - pbproxy_prefs.pasteboard_to_primary, - pbproxy_prefs.pasteboard_to_clipboard); +dump_prefs() { + ErrorF(fp, + "pbproxy preferences:\n" + "\tactive %u\n" + "\tprimary_on_grab %u\n" + "\tclipboard_to_pasteboard %u\n" + "\tpasteboard_to_primary %u\n" + "\tpasteboard_to_clipboard %u\n", + pbproxy_prefs.active, + pbproxy_prefs.primary_on_grab, + pbproxy_prefs.clipboard_to_pasteboard, + pbproxy_prefs.pasteboard_to_primary, + pbproxy_prefs.pasteboard_to_clipboard); } #endif @@ -152,7 +152,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato unsigned char *newbuf = NULL; #ifdef TEST - printf("bytesleft %lu\n", bytesleft); + ErrorF("bytesleft %lu\n", bytesleft); #endif if (Success != XGetWindowProperty (xpbproxy_dpy, win, property, @@ -161,24 +161,29 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato type, &format, &numitems, &bytesleft, &chunk)) { - DB ("Error while getting window property.\n"); + DebugF ("Error while getting window property.\n"); *pdata = null_propdata; free (buf); return True; } #ifdef TEST - printf("format %d numitems %lu bytesleft %lu\n", + ErrorF("format %d numitems %lu bytesleft %lu\n", format, numitems, bytesleft); - printf("type %s\n", XGetAtomName (xpbproxy_dpy, *type)); + ErrorF("type %s\n", XGetAtomName (xpbproxy_dpy, *type)); #endif /* Format is the number of bits. */ - chunkbytesize = numitems * (format / 8); + if (format == 8) + chunkbytesize = numitems; + else if (format == 16) + chunkbytesize = numitems * sizeof(short); + else if (format == 32) + chunkbytesize = numitems * sizeof(long); #ifdef TEST - printf("chunkbytesize %zu\n", chunkbytesize); + ErrorF("chunkbytesize %zu\n", chunkbytesize); #endif newbuflen = buflen + chunkbytesize; if (newbuflen > 0) @@ -206,7 +211,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato } #ifdef TEST - printf("bytesleft %lu\n", bytesleft); + ErrorF("bytesleft %lu\n", bytesleft); #endif } while (bytesleft > 0); @@ -231,13 +236,13 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato if (pdata->format != 32) { - fprintf(stderr, "Atom list is expected to be formatted as an array of 32bit values.\n"); + ErrorF("Atom list is expected to be formatted as an array of 32bit values.\n"); return None; } - for (i = 0, step = pdata->format >> 3; i < pdata->length; i += step) + for (i = 0, step = sizeof(long); i < pdata->length; i += step) { - a = (Atom)*(uint32_t *)(pdata->data + i); + a = (Atom)*(long *)(pdata->data + i); if (a == atoms->image_png) { @@ -260,7 +265,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato char *type = XGetAtomName(xpbproxy_dpy, a); if (type) { - DB("Unhandled X11 mime type: %s", type); + DebugF("Unhandled X11 mime type: %s", type); XFree(type); } } @@ -373,7 +378,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato if (countNow != changeCount) { - DB ("changed pasteboard!\n"); + DebugF ("changed pasteboard!\n"); changeCount = countNow; if (pbproxy_prefs.pasteboard_to_primary) @@ -457,9 +462,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato return TRUE; if(owner != None) { - fprintf (stderr, "A clipboard manager using window 0x%lx " - "already owns the clipboard selection. " - "pbproxy will not sync clipboard to pasteboard.\n", owner); + ErrorF("A clipboard manager using window 0x%lx already owns the clipboard selection. " + "pbproxy will not sync clipboard to pasteboard.\n", owner); return FALSE; } @@ -486,7 +490,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato TRACE (); - DB ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection)); + DebugF ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection)); if(e->selection == atoms->clipboard) { /* @@ -503,7 +507,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato /* Another CLIPBOARD_MANAGER has set itself as owner. Disable syncing * to avoid a race. */ - fprintf(stderr, "Another clipboard manager was started! " + ErrorF("Another clipboard manager was started! " "xpbproxy is disabling syncing with clipboard.\n"); pbproxy_prefs.clipboard_to_pasteboard = NO; } @@ -528,7 +532,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato * The owner probably died or we are just starting up pbproxy. * Set pbproxy's _selection_window as the owner, and continue. */ - DB ("No clipboard owner.\n"); + DebugF ("No clipboard owner.\n"); [self copy_completed:atoms->clipboard]; return; } else if (owner == _selection_window) { @@ -536,7 +540,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato return; } - DB ("requesting targets\n"); + DebugF ("requesting targets\n"); request_atom = atoms->targets; XConvertSelection (xpbproxy_dpy, atoms->clipboard, atoms->targets, @@ -576,7 +580,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato * We are supposed to use an empty event mask, and not propagate * the event, according to the ICCCM. */ - DB ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor); + DebugF ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor); XSendEvent (xpbproxy_dpy, reply->xselection.requestor, False, 0, reply); XFlush (xpbproxy_dpy); @@ -613,7 +617,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato if ([pbtypes containsObject:NSStringPboardType]) { /* We have a string type that we can convert to UTF8, or Latin-1... */ - DB ("NSStringPboardType\n"); + DebugF ("NSStringPboardType\n"); list[count] = atoms->utf8_string; ++count; list[count] = atoms->string; @@ -625,18 +629,26 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato /* TODO add the NSPICTPboardType back again, once we have conversion * functionality in send_image. */ +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType +#endif if ([pbtypes containsObject:NSPICTPboardType] || [pbtypes containsObject:NSTIFFPboardType]) { /* We can convert a TIFF to a PNG or JPEG. */ - DB ("NSTIFFPboardType\n"); + DebugF ("NSTIFFPboardType\n"); list[count] = atoms->image_png; ++count; list[count] = atoms->image_jpeg; ++count; } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + if (count) { /* We have a list of ATOMs to send. */ @@ -671,7 +683,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato return; } - DB ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]); + DebugF ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]); data = [pb stringForType:NSStringPboardType]; @@ -691,19 +703,19 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato length = strlen (bytes); if (length < 50) { - DB ("UTF-8: %s\n", bytes); - DB ("UTF-8 length: %u\n", length); + DebugF ("UTF-8: %s\n", bytes); + DebugF ("UTF-8 length: %u\n", length); } } else { - DB ("Latin-1\n"); + DebugF ("Latin-1\n"); bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding]; /*WARNING: bytes is not NUL-terminated. */ length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding]; } - DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target)); + DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target)); XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target, 8, PropModeReplace, (unsigned char *) bytes, length); @@ -745,7 +757,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato { if (8 != textprop.format) - DB ("textprop.format is unexpectedly not 8 - it's %d instead\n", + DebugF ("textprop.format is unexpectedly not 8 - it's %d instead\n", textprop.format); XChangeProperty (xpbproxy_dpy, e->requestor, e->property, @@ -837,7 +849,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato if (nil == data) { [img autorelease]; - fprintf(stderr, "unable to convert PICT to TIFF!\n"); + ErrorF("unable to convert PICT to TIFF!\n"); return YES; } @@ -913,7 +925,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato imagetype = NSJPEGFileType; else { - fprintf(stderr, "internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n"); + ErrorF("internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n"); } pbtypes = [pb types]; @@ -925,7 +937,14 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato if (NO == [self send_image_tiff_reply:e pasteboard:pb type:imagetype]) return; } +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType +#endif else if ([pbtypes containsObject:NSPICTPboardType]) +#ifdef __clang__ +#pragma clang diagnostic pop +#endif { if (NO == [self send_image_pict_reply:e pasteboard:pb type:imagetype]) return; @@ -977,7 +996,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato if (None != e->target) - DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target)); + DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target)); if (e->target == atoms->targets) { @@ -1029,15 +1048,15 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato [self release_pending]; if (None == e->property) { - DB ("e->property is None.\n"); + DebugF ("e->property is None.\n"); [self copy_completed:e->selection]; /* Nothing is selected. */ return; } #if 0 - printf ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection)); - printf ("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property)); + ErrorF("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection)); + ErrorF("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property)); #endif if ([self is_incr_type:e]) @@ -1046,7 +1065,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato * This is an INCR-style transfer, which means that we * will get the data after a series of PropertyNotify events. */ - DB ("is INCR\n"); + DebugF ("is INCR\n"); if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type)) { @@ -1063,7 +1082,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato pending.requestor = e->requestor; pending.selection = e->selection; - DB ("set pending.requestor to 0x%lx\n", pending.requestor); + DebugF ("set pending.requestor to 0x%lx\n", pending.requestor); } else { @@ -1076,7 +1095,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato /* We have the complete selection data.*/ [self handle_selection:e->selection type:type propdata:&pdata]; - DB ("handled selection with the first notify_event\n"); + DebugF ("handled selection with the first notify_event\n"); } } @@ -1096,7 +1115,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato if (name) { - DB ("e->atom %s\n", name); + DebugF ("e->atom %s\n", name); XFree(name); } #endif @@ -1104,7 +1123,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato if (None != pending.requestor && PropertyNewValue == e->state) { - DB ("pending.requestor 0x%lx\n", pending.requestor); + DebugF ("pending.requestor 0x%lx\n", pending.requestor); if (get_property (e->window, e->atom, &pdata, /*Delete*/ True, &type)) { @@ -1146,7 +1165,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato case XFixesSelectionWindowDestroyNotify: case XFixesSelectionClientCloseNotify: default: - fprintf(stderr, "Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype); + ErrorF("Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype); break; } } @@ -1176,7 +1195,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato if (name) { - DB ("requesting %s\n", name); + DebugF ("requesting %s\n", name); } #endif request_atom = preferred; @@ -1200,11 +1219,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato if (nil == data) { - DB ("unable to create NSData object!\n"); + DebugF ("unable to create NSData object!\n"); return; } - DB ("data retainCount before NSBitmapImageRep initWithData: %u\n", + DebugF ("data retainCount before NSBitmapImageRep initWithData: %u\n", [data retainCount]); bmimage = [[NSBitmapImageRep alloc] initWithData:data]; @@ -1212,11 +1231,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato if (nil == bmimage) { [data autorelease]; - DB ("unable to create NSBitmapImageRep!\n"); + DebugF ("unable to create NSBitmapImageRep!\n"); return; } - DB ("data retainCount after NSBitmapImageRep initWithData: %u\n", + DebugF ("data retainCount after NSBitmapImageRep initWithData: %u\n", [data retainCount]); @try @@ -1226,13 +1245,13 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato @catch (NSException *e) { - DB ("NSTIFFException!\n"); + DebugF ("NSTIFFException!\n"); [data autorelease]; [bmimage autorelease]; return; } - DB ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]); + DebugF ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]); pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil]; @@ -1246,12 +1265,12 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato [pb declareTypes:pbtypes owner:nil]; if (YES != [pb setData:tiff forType:NSTIFFPboardType]) { - DB ("writing pasteboard data failed!\n"); + DebugF ("writing pasteboard data failed!\n"); } [data autorelease]; - DB ("bmimage retainCount before release %u\n", [bmimage retainCount]); + DebugF ("bmimage retainCount before release %u\n", [bmimage retainCount]); [bmimage autorelease]; } @@ -1279,10 +1298,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato [pb declareTypes:pbtypes owner:nil]; if (YES != [pb setString:string forType:NSStringPboardType]) { - fprintf(stderr, "pasteboard setString:forType: failed!\n"); + ErrorF("pasteboard setString:forType: failed!\n"); } [string autorelease]; - DB ("done handling utf8 string\n"); + DebugF ("done handling utf8 string\n"); } /* This handles the STRING type, which should be in Latin-1. */ @@ -1308,7 +1327,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato [pb declareTypes:pbtypes owner:nil]; if (YES != [pb setString:string forType:NSStringPboardType]) { - fprintf(stderr, "pasteboard setString:forType failed in handle_string!\n"); + ErrorF("pasteboard setString:forType failed in handle_string!\n"); } [string autorelease]; } @@ -1374,7 +1393,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato name = XGetAtomName (xpbproxy_dpy, selection); if (name) { - DB ("copy_completed: %s\n", name); + DebugF ("copy_completed: %s\n", name); XFree (name); } #endif @@ -1435,10 +1454,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato pbproxy_prefs.pasteboard_to_clipboard = prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), pbproxy_prefs.pasteboard_to_clipboard); /* This is used for debugging. */ - //dump_prefs(stdout); + //dump_prefs(); if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !xpbproxy_have_xfixes) { - fprintf(stderr, "Disabling sync_primary_on_select functionality due to missing XFixes extension.\n"); + ErrorF("Disabling sync_primary_on_select functionality due to missing XFixes extension.\n"); pbproxy_prefs.primary_on_grab = NO; } diff --git a/xorg-server/hw/xquartz/quartz.c b/xorg-server/hw/xquartz/quartz.c index 4b72a89d3..0e71d3629 100644 --- a/xorg-server/hw/xquartz/quartz.c +++ b/xorg-server/hw/xquartz/quartz.c @@ -62,7 +62,7 @@ #include <sys/stat.h> #include <fcntl.h> #include <IOKit/pwr_mgt/IOPMLib.h> -#include <pthread.h> +#include <libkern/OSAtomic.h> #include <signal.h> #include <rootlessCommon.h> @@ -279,10 +279,10 @@ static void pokeActivityCallback(CFRunLoopTimerRef timer, void *info) { static void QuartzScreenSaver(int state) { static CFRunLoopTimerRef pokeActivityTimer = NULL; static CFRunLoopTimerContext pokeActivityContext = { 0, NULL, NULL, NULL, NULL }; - static pthread_mutex_t pokeActivityMutex = PTHREAD_MUTEX_INITIALIZER; + static OSSpinLock pokeActivitySpinLock = OS_SPINLOCK_INIT; + + OSSpinLockLock(&pokeActivitySpinLock); - pthread_mutex_lock(&pokeActivityMutex); - if(state) { if(pokeActivityTimer == NULL) goto QuartzScreenSaverEnd; @@ -303,7 +303,7 @@ static void QuartzScreenSaver(int state) { CFRunLoopAddTimer(CFRunLoopGetMain(), pokeActivityTimer, kCFRunLoopCommonModes); } QuartzScreenSaverEnd: - pthread_mutex_unlock(&pokeActivityMutex); + OSSpinLockUnlock(&pokeActivitySpinLock); } void QuartzShowFullscreen(int state) { diff --git a/xorg-server/hw/xquartz/quartz.h b/xorg-server/hw/xquartz/quartz.h index 67a7919b2..0a9c47a6b 100644 --- a/xorg-server/hw/xquartz/quartz.h +++ b/xorg-server/hw/xquartz/quartz.h @@ -70,7 +70,7 @@ typedef void (*UpdateScreenProc)(ScreenPtr pScreen); /* * Rootless helper functions */ -typedef Bool (*IsX11WindowProc)(void *nsWindow, int windowNumber); +typedef Bool (*IsX11WindowProc)(int windowNumber); typedef void (*HideWindowsProc)(Bool hide); /* diff --git a/xorg-server/hw/xquartz/quartzKeyboard.c b/xorg-server/hw/xquartz/quartzKeyboard.c index 54f709a8b..c54011488 100644 --- a/xorg-server/hw/xquartz/quartzKeyboard.c +++ b/xorg-server/hw/xquartz/quartzKeyboard.c @@ -56,8 +56,6 @@ #include "X11Application.h" -#include "threadSafety.h" - #ifdef NDEBUG #undef NDEBUG #include <assert.h> @@ -369,9 +367,9 @@ static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue if (pDev->kbdfeed) memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize); - //fprintf(stderr, "per_key_repeat =\n"); + //ErrorF("per_key_repeat =\n"); //for(i=0; i < XkbPerKeyBitArraySize; i++) - // fprintf(stderr, "%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n"); + // ErrorF("%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n"); /* And now we notify the puppies about the changes */ XkbDDXChangeControls(pDev, &old, ctrl); @@ -686,6 +684,11 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) { } #endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KLGetCurrentKeyboardLayout, KLGetKeyboardLayoutProperty +#endif + #if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 if (chr_data == NULL) { #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 @@ -719,6 +722,10 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) { } #endif +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 if(currentKeyLayoutRef) CFRelease(currentKeyLayoutRef); @@ -775,10 +782,16 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) { } #if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050 } else { // kchr - UInt32 c, state = 0, state2 = 0; + UInt32 c, state = 0, state2 = 0; UInt16 code; code = i | mods[j]; + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KeyTranslate +#endif + c = KeyTranslate (chr_data, code, &state); /* Dead keys are only processed on key-down, so ask @@ -789,6 +802,10 @@ static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) { if (state != 0) c = KeyTranslate (chr_data, code | 128, &state2); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + /* Characters seem to be in MacRoman encoding. */ if (c != 0 && c != 0x0010) { diff --git a/xorg-server/hw/xquartz/quartzKeyboard.h b/xorg-server/hw/xquartz/quartzKeyboard.h index 1151a0035..de4aed868 100644 --- a/xorg-server/hw/xquartz/quartzKeyboard.h +++ b/xorg-server/hw/xquartz/quartzKeyboard.h @@ -32,8 +32,6 @@ #include "X11/keysym.h" #include "inputstr.h" -#include <pthread.h> - // Each key can generate 4 glyphs. They are, in order: // unshifted, shifted, modeswitch unshifted, modeswitch shifted #define GLYPHS_PER_KEY 4 diff --git a/xorg-server/hw/xquartz/quartzStartup.c b/xorg-server/hw/xquartz/quartzStartup.c index 36c8182ae..00a9e48fd 100644 --- a/xorg-server/hw/xquartz/quartzStartup.c +++ b/xorg-server/hw/xquartz/quartzStartup.c @@ -84,10 +84,7 @@ void QuartzInitServer(int argc, char **argv, char **envp) { args->argv = argv; args->envp = envp; - APPKIT_THREAD_ID = pthread_self(); - SERVER_THREAD_ID = create_thread(server_thread, args); - - if (!SERVER_THREAD_ID) { + if (!create_thread(server_thread, args)) { FatalError("can't create secondary thread\n"); } } diff --git a/xorg-server/hw/xquartz/threadSafety.c b/xorg-server/hw/xquartz/threadSafety.c deleted file mode 100644 index 85f85bd0a..000000000 --- a/xorg-server/hw/xquartz/threadSafety.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2008 Apple, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "threadSafety.h" -#include "os.h" - -pthread_t APPKIT_THREAD_ID; -pthread_t SERVER_THREAD_ID; - -#include <AvailabilityMacros.h> - -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 -#include <execinfo.h> - -void spewCallStack(void) { - void* callstack[128]; - int i, frames = backtrace(callstack, 128); - char** strs = backtrace_symbols(callstack, frames); - - for (i = 0; i < frames; ++i) { - ErrorF("%s\n", strs[i]); - } - - free(strs); -} -#else -void spewCallStack(void) { - return; -} -#endif - -void _threadSafetyAssert(pthread_t tid, const char *file, const char *fun, int line) { - if(pthread_equal(pthread_self(), tid)) - return; - - /* NOOOO! */ - ErrorF("Thread Assertion Failed: self=%s, expected=%s\n%s:%s:%d\n", - threadSafetyID(pthread_self()), threadSafetyID(tid), - file, fun, line); - spewCallStack(); -} - -const char *threadSafetyID(pthread_t tid) { - if(pthread_equal(tid, APPKIT_THREAD_ID)) { - return "Appkit Thread"; - } else if(pthread_equal(tid, SERVER_THREAD_ID)) { - return "Xserver Thread"; - } else { - return "Unknown Thread"; - } -} diff --git a/xorg-server/hw/xquartz/threadSafety.h b/xorg-server/hw/xquartz/threadSafety.h deleted file mode 100644 index 3ff9eaf7e..000000000 --- a/xorg-server/hw/xquartz/threadSafety.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2008 Apple, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ - -#ifndef _XQ_THREAD_SAFETY_H_ -#define _XQ_THREAD_SAFETY_H_ - -#define DEBUG_THREADS 1 - -#include <pthread.h> - -extern pthread_t APPKIT_THREAD_ID; -extern pthread_t SERVER_THREAD_ID; - -/* Dump the call stack */ -void spewCallStack(void); - -/* Print message to ErrorF if we're in the wrong thread */ -void _threadSafetyAssert(pthread_t tid, const char *file, const char *fun, int line); - -/* Get a string that identifies our thread nicely */ -const char *threadSafetyID(pthread_t tid); - -#define threadSafetyAssert(tid) _threadSafetyAssert(tid, __FILE__, __FUNCTION__, __LINE__) - -#ifdef DEBUG_THREADS -#define TA_APPKIT() threadSafetyAssert(APPKIT_THREAD_ID) -#define TA_SERVER() threadSafetyAssert(SERVER_THREAD_ID) -#else -#define TA_SERVER() -#define TA_APPKIT() -#endif - -#endif /* _XQ_THREAD_SAFETY_H_ */ diff --git a/xorg-server/hw/xquartz/xpr/dri.c b/xorg-server/hw/xquartz/xpr/dri.c index 7b730df8e..8fef3b793 100644 --- a/xorg-server/hw/xquartz/xpr/dri.c +++ b/xorg-server/hw/xquartz/xpr/dri.c @@ -1,850 +1,845 @@ -/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002, 2009 Apple Computer, Inc.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Jens Owen <jens@valinux.com>
- * Rickard E. (Rik) Faith <faith@valinux.com>
- *
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifdef XFree86LOADER
-#include "xf86.h"
-#include "xf86_ansic.h"
-#else
-#include <sys/time.h>
-#include <unistd.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#define _APPLEDRI_SERVER_
-#include "appledristr.h"
-#include "swaprep.h"
-#include "dri.h"
-#include "dristruct.h"
-#include "mi.h"
-#include "mipointer.h"
-#include "rootless.h"
-#include "x-hash.h"
-#include "x-hook.h"
-#include "driWrap.h"
-
-#include <AvailabilityMacros.h>
-
-static DevPrivateKeyRec DRIScreenPrivKeyRec;
-#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
-static DevPrivateKeyRec DRIWindowPrivKeyRec;
-#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
-static DevPrivateKeyRec DRIPixmapPrivKeyRec;
-#define DRIPixmapPrivKey (&DRIPixmapPrivKeyRec)
-static DevPrivateKeyRec DRIPixmapBufferPrivKeyRec;
-#define DRIPixmapBufferPrivKey (&DRIPixmapBufferPrivKeyRec)
-
-static RESTYPE DRIDrawablePrivResType;
-
-static x_hash_table *surface_hash; /* maps surface ids -> drawablePrivs */
-
-static Bool DRIFreePixmapImp(DrawablePtr pDrawable);
-
-typedef struct {
- DrawablePtr pDrawable;
- int refCount;
- int bytesPerPixel;
- int width;
- int height;
- char shmPath[PATH_MAX];
- int fd; /* From shm_open (for now) */
- size_t length; /* length of buffer */
- void *buffer;
-} DRIPixmapBuffer, *DRIPixmapBufferPtr;
-
-Bool
-DRIScreenInit(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv;
- int i;
-
- if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
- if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
- return FALSE;
- if (!dixRegisterPrivateKey(&DRIPixmapPrivKeyRec, PRIVATE_PIXMAP, 0))
- return FALSE;
- if (!dixRegisterPrivateKey(&DRIPixmapBufferPrivKeyRec, PRIVATE_PIXMAP, 0))
- return FALSE;
-
- pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
- if (!pDRIPriv) {
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- return FALSE;
- }
-
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv);
- pDRIPriv->directRenderingSupport = TRUE;
- pDRIPriv->nrWindows = 0;
-
- /* Initialize drawable tables */
- for (i = 0; i < DRI_MAX_DRAWABLES; i++) {
- pDRIPriv->DRIDrawables[i] = NULL;
- }
-
- return TRUE;
-}
-
-Bool
-DRIFinishScreenInit(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- /* Wrap DRI support */
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = DRIValidateTree;
-
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = DRIPostValidateTree;
-
- pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
- pScreen->WindowExposures = DRIWindowExposures;
-
- pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = DRICopyWindow;
-
- pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
- pScreen->ClipNotify = DRIClipNotify;
-
- // ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum);
-
- return DRIWrapInit(pScreen);
-}
-
-void
-DRICloseScreen(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv && pDRIPriv->directRenderingSupport) {
- free(pDRIPriv);
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- }
-}
-
-Bool
-DRIExtensionInit(void)
-{
- DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete,
- "DRIDrawable");
-
- return DRIDrawablePrivResType != 0;
-}
-
-void
-DRIReset(void)
-{
- /*
- * This stub routine is called when the X Server recycles, resources
- * allocated by DRIExtensionInit need to be managed here.
- *
- * Currently this routine is a stub because all the interesting resources
- * are managed via the screen init process.
- */
-}
-
-Bool
-DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv)
- *isCapable = pDRIPriv->directRenderingSupport;
- else
- *isCapable = FALSE;
-
- return TRUE;
-}
-
-Bool
-DRIAuthConnection(ScreenPtr pScreen, unsigned int magic)
-{
-#if 0
- /* FIXME: something? */
-
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
-#endif
- return TRUE;
-}
-
-static void
-DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
-{
- xp_window_changes wc;
- unsigned int flags = 0;
-
- if (pDRIDrawablePriv->sid == 0)
- return;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- wc.depth = (pDraw->bitsPerPixel == 32 ? XP_DEPTH_ARGB8888
- : pDraw->bitsPerPixel == 16 ? XP_DEPTH_RGB555 : XP_DEPTH_NIL);
- if (wc.depth != XP_DEPTH_NIL)
- flags |= XP_DEPTH;
-#endif
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- WindowPtr pWin = (WindowPtr) pDraw;
- WindowPtr pTopWin = TopLevelParent(pWin);
-
- wc.x = pWin->drawable.x - (pTopWin->drawable.x - pTopWin->borderWidth);
- wc.y = pWin->drawable.y - (pTopWin->drawable.y - pTopWin->borderWidth);
- wc.width = pWin->drawable.width + 2 * pWin->borderWidth;
- wc.height = pWin->drawable.height + 2 * pWin->borderWidth;
- wc.bit_gravity = XP_GRAVITY_NONE;
-
- wc.shape_nrects = RegionNumRects(&pWin->clipList);
- wc.shape_rects = RegionRects(&pWin->clipList);
- wc.shape_tx = - (pTopWin->drawable.x - pTopWin->borderWidth);
- wc.shape_ty = - (pTopWin->drawable.y - pTopWin->borderWidth);
-
- flags |= XP_BOUNDS | XP_SHAPE;
-
- } else if (pDraw->type == DRAWABLE_PIXMAP) {
- wc.x = 0;
- wc.y = 0;
- wc.width = pDraw->width;
- wc.height = pDraw->height;
- wc.bit_gravity = XP_GRAVITY_NONE;
- flags |= XP_BOUNDS;
- }
-
- xp_configure_surface(pDRIDrawablePriv->sid, flags, &wc);
-}
-
-/* Return NULL if an error occurs. */
-static DRIDrawablePrivPtr
-CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr) {
- DRIDrawablePrivPtr pDRIDrawablePriv;
- xp_window_id wid = 0;
-
- *widPtr = 0;
-
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
- if (pDRIDrawablePriv == NULL) {
- xp_error err;
- xp_window_changes wc;
-
- /* allocate a DRI Window Private record */
- if (!(pDRIDrawablePriv = malloc(sizeof(*pDRIDrawablePriv)))) {
- return NULL;
- }
-
- pDRIDrawablePriv->pDraw = (DrawablePtr)pWin;
- pDRIDrawablePriv->pScreen = pScreen;
- pDRIDrawablePriv->refCount = 0;
- pDRIDrawablePriv->drawableIndex = -1;
- pDRIDrawablePriv->notifiers = NULL;
-
- /* find the physical window */
- wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE));
-
- if (wid == 0) {
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /* allocate the physical surface */
- err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
-
- if (err != Success) {
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /* Make it visible */
- wc.stack_mode = XP_MAPPED_ABOVE;
- wc.sibling = 0;
- err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
-
- if (err != Success) {
- xp_destroy_surface(pDRIDrawablePriv->sid);
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /* save private off of preallocated index */
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
- pDRIDrawablePriv);
- }
-
- *widPtr = wid;
-
- return pDRIDrawablePriv;
-}
-
-/* Return NULL if an error occurs. */
-static DRIDrawablePrivPtr
-CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix) {
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
-
- if (pDRIDrawablePriv == NULL) {
- xp_error err;
-
- /* allocate a DRI Window Private record */
- if (!(pDRIDrawablePriv = calloc(1, sizeof(*pDRIDrawablePriv)))) {
- return NULL;
- }
-
- pDRIDrawablePriv->pDraw = (DrawablePtr)pPix;
- pDRIDrawablePriv->pScreen = pScreen;
- pDRIDrawablePriv->refCount = 0;
- pDRIDrawablePriv->drawableIndex = -1;
- pDRIDrawablePriv->notifiers = NULL;
-
- /* Passing a null window id to Xplugin in 10.3+ asks for
- an accelerated offscreen surface. */
-
- err = xp_create_surface(0, &pDRIDrawablePriv->sid);
- if (err != Success) {
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /*
- * The DRIUpdateSurface will be called to resize the surface
- * after this function, if the export is successful.
- */
-
- /* save private off of preallocated index */
- dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey,
- pDRIDrawablePriv);
- }
-
- return pDRIDrawablePriv;
-}
-
-
-Bool
-DRICreateSurface(ScreenPtr pScreen, Drawable id,
- DrawablePtr pDrawable, xp_client_id client_id,
- xp_surface_id *surface_id, unsigned int ret_key[2],
- void (*notify) (void *arg, void *data), void *notify_data)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- xp_window_id wid = 0;
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pDRIDrawablePriv = CreateSurfaceForWindow(pScreen,
- (WindowPtr)pDrawable, &wid);
-
- if(NULL == pDRIDrawablePriv)
- return FALSE; /*error*/
- }
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- else if (pDrawable->type == DRAWABLE_PIXMAP) {
- pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen,
- (PixmapPtr)pDrawable);
-
- if(NULL == pDRIDrawablePriv)
- return FALSE; /*error*/
- }
-#endif
- else { /* for GLX 1.3, a PBuffer */
- /* NOT_DONE */
- return FALSE;
- }
-
-
- /* Finish initialization of new surfaces */
- if (pDRIDrawablePriv->refCount == 0) {
- unsigned int key[2] = {0};
- xp_error err;
-
- /* try to give the client access to the surface */
- if (client_id != 0) {
- /*
- * Xplugin accepts a 0 wid if the surface id is offscreen, such
- * as for a pixmap.
- */
- err = xp_export_surface(wid, pDRIDrawablePriv->sid,
- client_id, key);
- if (err != Success) {
- xp_destroy_surface(pDRIDrawablePriv->sid);
- free(pDRIDrawablePriv);
-
- /*
- * Now set the dix privates to NULL that were previously set.
- * This prevents reusing an invalid pointer.
- */
- if(pDrawable->type == DRAWABLE_WINDOW) {
- WindowPtr pWin = (WindowPtr)pDrawable;
-
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
- } else if(pDrawable->type == DRAWABLE_PIXMAP) {
- PixmapPtr pPix = (PixmapPtr)pDrawable;
-
- dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
- }
-
- return FALSE;
- }
- }
-
- pDRIDrawablePriv->key[0] = key[0];
- pDRIDrawablePriv->key[1] = key[1];
-
- ++pDRIPriv->nrWindows;
-
- /* and stash it by surface id */
- if (surface_hash == NULL)
- surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
- x_hash_table_insert(surface_hash,
- x_cvt_uint_to_vptr(pDRIDrawablePriv->sid), pDRIDrawablePriv);
-
- /* track this in case this window is destroyed */
- AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
-
- /* Initialize shape */
- DRIUpdateSurface(pDRIDrawablePriv, pDrawable);
- }
-
- pDRIDrawablePriv->refCount++;
-
- *surface_id = pDRIDrawablePriv->sid;
-
- if (ret_key != NULL) {
- ret_key[0] = pDRIDrawablePriv->key[0];
- ret_key[1] = pDRIDrawablePriv->key[1];
- }
-
- if (notify != NULL) {
- pDRIDrawablePriv->notifiers = x_hook_add(pDRIDrawablePriv->notifiers,
- notify, notify_data);
- }
-
- return TRUE;
-}
-
-Bool
-DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
- void (*notify) (void *, void *), void *notify_data)
-{
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable);
- } else if (pDrawable->type == DRAWABLE_PIXMAP) {
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr)pDrawable);
- } else {
- return FALSE;
- }
-
- if (pDRIDrawablePriv != NULL) {
- if (notify != NULL) {
- pDRIDrawablePriv->notifiers = x_hook_remove(pDRIDrawablePriv->notifiers,
- notify, notify_data);
- }
- if (--pDRIDrawablePriv->refCount <= 0) {
- /* This calls back to DRIDrawablePrivDelete
- which frees the private area */
- FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
- }
- }
-
- return TRUE;
-}
-
-Bool
-DRIDrawablePrivDelete(pointer pResource, XID id)
-{
- DrawablePtr pDrawable = (DrawablePtr)pResource;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
- WindowPtr pWin = NULL;
- PixmapPtr pPix = NULL;
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr)pDrawable;
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- } else if (pDrawable->type == DRAWABLE_PIXMAP) {
- pPix = (PixmapPtr)pDrawable;
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
- }
-
- if (pDRIDrawablePriv == NULL) {
- return DRIFreePixmapImp(pDrawable);
- }
-
- if (pDRIDrawablePriv->drawableIndex != -1) {
- /* release drawable table entry */
- pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
- }
-
- if (pDRIDrawablePriv->sid != 0) {
- xp_destroy_surface(pDRIDrawablePriv->sid);
- x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(pDRIDrawablePriv->sid));
- }
-
- if (pDRIDrawablePriv->notifiers != NULL)
- x_hook_free(pDRIDrawablePriv->notifiers);
-
- free(pDRIDrawablePriv);
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
- } else if (pDrawable->type == DRAWABLE_PIXMAP) {
- dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
- }
-
- --pDRIPriv->nrWindows;
-
- return TRUE;
-}
-
-void
-DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
- if (pDRIDrawablePriv) {
- /* FIXME: something? */
- }
-
- pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
-
- (*pScreen->WindowExposures)(pWin, prgn, bsreg);
-
- pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
- pScreen->WindowExposures = DRIWindowExposures;
-}
-
-void
-DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- if (pDRIPriv->nrWindows > 0) {
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- if (pDRIDrawablePriv != NULL) {
- DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
- }
- }
-
- /* unwrap */
- pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
-
- /* call lower layers */
- (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
-
- /* rewrap */
- pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = DRICopyWindow;
-}
-
-int
-DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen = pParent->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- int returnValue;
-
- /* unwrap */
- pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
-
- /* call lower layers */
- returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
-
- /* rewrap */
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = DRIValidateTree;
-
- return returnValue;
-}
-
-void
-DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen;
- DRIScreenPrivPtr pDRIPriv;
-
- if (pParent) {
- pScreen = pParent->drawable.pScreen;
- } else {
- pScreen = pChild->drawable.pScreen;
- }
- pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv->wrap.PostValidateTree) {
- /* unwrap */
- pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
-
- /* call lower layers */
- (*pScreen->PostValidateTree)(pParent, pChild, kind);
-
- /* rewrap */
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = DRIPostValidateTree;
- }
-}
-
-void
-DRIClipNotify(WindowPtr pWin, int dx, int dy)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
- DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
- }
-
- if (pDRIPriv->wrap.ClipNotify) {
- pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
-
- (*pScreen->ClipNotify)(pWin, dx, dy);
-
- pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
- pScreen->ClipNotify = DRIClipNotify;
- }
-}
-
-/* This lets us get at the unwrapped functions so that they can correctly
- * call the lower level functions, and choose whether they will be
- * called at every level of recursion (eg in validatetree).
- */
-DRIWrappedFuncsRec *
-DRIGetWrappedFuncs(ScreenPtr pScreen)
-{
- return &(DRI_SCREEN_PRIV(pScreen)->wrap);
-}
-
-void
-DRIQueryVersion(int *majorVersion,
- int *minorVersion,
- int *patchVersion)
-{
- *majorVersion = APPLE_DRI_MAJOR_VERSION;
- *minorVersion = APPLE_DRI_MINOR_VERSION;
- *patchVersion = APPLE_DRI_PATCH_VERSION;
-}
-
-void
-DRISurfaceNotify(xp_surface_id id, int kind)
-{
- DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
- DRISurfaceNotifyArg arg;
-
- arg.id = id;
- arg.kind = kind;
-
- if (surface_hash != NULL)
- {
- pDRIDrawablePriv = x_hash_table_lookup(surface_hash,
- x_cvt_uint_to_vptr(id), NULL);
- }
-
- if (pDRIDrawablePriv == NULL)
- return;
-
- if (kind == AppleDRISurfaceNotifyDestroyed)
- {
- pDRIDrawablePriv->sid = 0;
- x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(id));
- }
-
- x_hook_run(pDRIDrawablePriv->notifiers, &arg);
-
- if (kind == AppleDRISurfaceNotifyDestroyed)
- {
- /* Kill off the handle. */
-
- FreeResourceByType(pDRIDrawablePriv->pDraw->id,
- DRIDrawablePrivResType, FALSE);
- }
-}
-
-Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id,
- DrawablePtr pDrawable, char *path,
- size_t pathmax)
-{
- DRIPixmapBufferPtr shared;
- PixmapPtr pPix;
-
- if(pDrawable->type != DRAWABLE_PIXMAP)
- return FALSE;
-
- pPix = (PixmapPtr)pDrawable;
-
- shared = malloc(sizeof(*shared));
- if(NULL == shared) {
- FatalError("failed to allocate DRIPixmapBuffer in %s\n", __func__);
- }
-
- shared->pDrawable = pDrawable;
- shared->refCount = 1;
-
- if(pDrawable->bitsPerPixel >= 24) {
- shared->bytesPerPixel = 4;
- } else if(pDrawable->bitsPerPixel <= 16) {
- shared->bytesPerPixel = 2;
- }
-
- shared->width = pDrawable->width;
- shared->height = pDrawable->height;
-
- if(-1 == snprintf(shared->shmPath, sizeof(shared->shmPath),
- "%d_0x%lx", getpid(),
- (unsigned long)id)) {
- FatalError("buffer overflow in %s\n", __func__);
- }
-
- shared->fd = shm_open(shared->shmPath,
- O_RDWR | O_EXCL | O_CREAT,
- S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH);
-
- if(-1 == shared->fd) {
- free(shared);
- return FALSE;
- }
-
- shared->length = shared->width * shared->height * shared->bytesPerPixel;
-
- if(-1 == ftruncate(shared->fd, shared->length)) {
- ErrorF("failed to ftruncate (extend) file.");
- shm_unlink(shared->shmPath);
- close(shared->fd);
- free(shared);
- return FALSE;
- }
-
- shared->buffer = mmap(NULL, shared->length,
- PROT_READ | PROT_WRITE,
- MAP_FILE | MAP_SHARED, shared->fd, 0);
-
- if(MAP_FAILED == shared->buffer) {
- ErrorF("failed to mmap shared memory.");
- shm_unlink(shared->shmPath);
- close(shared->fd);
- free(shared);
- return FALSE;
- }
-
- strncpy(path, shared->shmPath, pathmax);
- path[pathmax - 1] = '\0';
-
- dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, shared);
-
- AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
-
- return TRUE;
-}
-
-
-Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height,
- int *pitch, int *bpp, void **ptr) {
- PixmapPtr pPix;
- DRIPixmapBufferPtr shared;
-
- if(pDrawable->type != DRAWABLE_PIXMAP)
- return FALSE;
-
- pPix = (PixmapPtr)pDrawable;
-
- shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey);
-
- if(NULL == shared)
- return FALSE;
-
- assert(pDrawable->width == shared->width);
- assert(pDrawable->height == shared->height);
-
- *width = shared->width;
- *height = shared->height;
- *bpp = shared->bytesPerPixel;
- *pitch = shared->width * shared->bytesPerPixel;
- *ptr = shared->buffer;
-
- return TRUE;
-}
-
-static Bool
-DRIFreePixmapImp(DrawablePtr pDrawable) {
- DRIPixmapBufferPtr shared;
- PixmapPtr pPix;
-
- if(pDrawable->type != DRAWABLE_PIXMAP)
- return FALSE;
-
- pPix = (PixmapPtr)pDrawable;
-
- shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey);
-
- if(NULL == shared)
- return FALSE;
-
- close(shared->fd);
- munmap(shared->buffer, shared->length);
- shm_unlink(shared->shmPath);
- free(shared);
-
- dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, (pointer)NULL);
-
- return TRUE;
-}
-
-void
-DRIDestroyPixmap(DrawablePtr pDrawable) {
- if(DRIFreePixmapImp(pDrawable))
- FreeResourceByType(pDrawable->id, DRIDrawablePrivResType, FALSE);
-
-}
+/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +Copyright 2000 VA Linux Systems, Inc. +Copyright (c) 2002, 2009 Apple Computer, Inc. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Jens Owen <jens@valinux.com> + * Rickard E. (Rik) Faith <faith@valinux.com> + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifdef XFree86LOADER +#include "xf86.h" +#include "xf86_ansic.h" +#else +#include <sys/time.h> +#include <unistd.h> +#endif + +#include <X11/X.h> +#include <X11/Xproto.h> +#include <fcntl.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <sys/stat.h> +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "colormapst.h" +#include "cursorstr.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include "servermd.h" +#define _APPLEDRI_SERVER_ +#include "appledristr.h" +#include "swaprep.h" +#include "dri.h" +#include "dristruct.h" +#include "mi.h" +#include "mipointer.h" +#include "rootless.h" +#include "x-hash.h" +#include "x-hook.h" +#include "driWrap.h" + +#include <AvailabilityMacros.h> + +static DevPrivateKeyRec DRIScreenPrivKeyRec; +#define DRIScreenPrivKey (&DRIScreenPrivKeyRec) +static DevPrivateKeyRec DRIWindowPrivKeyRec; +#define DRIWindowPrivKey (&DRIWindowPrivKeyRec) +static DevPrivateKeyRec DRIPixmapPrivKeyRec; +#define DRIPixmapPrivKey (&DRIPixmapPrivKeyRec) +static DevPrivateKeyRec DRIPixmapBufferPrivKeyRec; +#define DRIPixmapBufferPrivKey (&DRIPixmapBufferPrivKeyRec) + +static RESTYPE DRIDrawablePrivResType; + +static x_hash_table *surface_hash; /* maps surface ids -> drawablePrivs */ + +static Bool DRIFreePixmapImp(DrawablePtr pDrawable); + +typedef struct { + DrawablePtr pDrawable; + int refCount; + int bytesPerPixel; + int width; + int height; + char shmPath[PATH_MAX]; + int fd; /* From shm_open (for now) */ + size_t length; /* length of buffer */ + void *buffer; +} DRIPixmapBuffer, *DRIPixmapBufferPtr; + +Bool +DRIScreenInit(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv; + int i; + + if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0)) + return FALSE; + if (!dixRegisterPrivateKey(&DRIPixmapPrivKeyRec, PRIVATE_PIXMAP, 0)) + return FALSE; + if (!dixRegisterPrivateKey(&DRIPixmapBufferPrivKeyRec, PRIVATE_PIXMAP, 0)) + return FALSE; + + pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec)); + if (!pDRIPriv) { + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + return FALSE; + } + + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv); + pDRIPriv->directRenderingSupport = TRUE; + pDRIPriv->nrWindows = 0; + + /* Initialize drawable tables */ + for (i = 0; i < DRI_MAX_DRAWABLES; i++) { + pDRIPriv->DRIDrawables[i] = NULL; + } + + return TRUE; +} + +Bool +DRIFinishScreenInit(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + /* Wrap DRI support */ + pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree; + pScreen->ValidateTree = DRIValidateTree; + + pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree; + pScreen->PostValidateTree = DRIPostValidateTree; + + pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures; + pScreen->WindowExposures = DRIWindowExposures; + + pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow; + pScreen->CopyWindow = DRICopyWindow; + + pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify; + pScreen->ClipNotify = DRIClipNotify; + + // ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum); + + return DRIWrapInit(pScreen); +} + +void +DRICloseScreen(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (pDRIPriv && pDRIPriv->directRenderingSupport) { + free(pDRIPriv); + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + } +} + +Bool +DRIExtensionInit(void) +{ + DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete, + "DRIDrawable"); + + return DRIDrawablePrivResType != 0; +} + +void +DRIReset(void) +{ + /* + * This stub routine is called when the X Server recycles, resources + * allocated by DRIExtensionInit need to be managed here. + * + * Currently this routine is a stub because all the interesting resources + * are managed via the screen init process. + */ +} + +Bool +DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (pDRIPriv) + *isCapable = pDRIPriv->directRenderingSupport; + else + *isCapable = FALSE; + + return TRUE; +} + +Bool +DRIAuthConnection(ScreenPtr pScreen, unsigned int magic) +{ +#if 0 + /* FIXME: something? */ + + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE; +#endif + return TRUE; +} + +static void +DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw) +{ + xp_window_changes wc; + unsigned int flags = 0; + + if (pDRIDrawablePriv->sid == 0) + return; + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 + wc.depth = (pDraw->bitsPerPixel == 32 ? XP_DEPTH_ARGB8888 + : pDraw->bitsPerPixel == 16 ? XP_DEPTH_RGB555 : XP_DEPTH_NIL); + if (wc.depth != XP_DEPTH_NIL) + flags |= XP_DEPTH; +#endif + + if (pDraw->type == DRAWABLE_WINDOW) { + WindowPtr pWin = (WindowPtr) pDraw; + WindowPtr pTopWin = TopLevelParent(pWin); + + wc.x = pWin->drawable.x - (pTopWin->drawable.x - pTopWin->borderWidth); + wc.y = pWin->drawable.y - (pTopWin->drawable.y - pTopWin->borderWidth); + wc.width = pWin->drawable.width + 2 * pWin->borderWidth; + wc.height = pWin->drawable.height + 2 * pWin->borderWidth; + wc.bit_gravity = XP_GRAVITY_NONE; + + wc.shape_nrects = RegionNumRects(&pWin->clipList); + wc.shape_rects = RegionRects(&pWin->clipList); + wc.shape_tx = - (pTopWin->drawable.x - pTopWin->borderWidth); + wc.shape_ty = - (pTopWin->drawable.y - pTopWin->borderWidth); + + flags |= XP_BOUNDS | XP_SHAPE; + + } else if (pDraw->type == DRAWABLE_PIXMAP) { + wc.x = 0; + wc.y = 0; + wc.width = pDraw->width; + wc.height = pDraw->height; + wc.bit_gravity = XP_GRAVITY_NONE; + flags |= XP_BOUNDS; + } + + xp_configure_surface(pDRIDrawablePriv->sid, flags, &wc); +} + +/* Return NULL if an error occurs. */ +static DRIDrawablePrivPtr +CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr) { + DRIDrawablePrivPtr pDRIDrawablePriv; + xp_window_id wid = 0; + + *widPtr = 0; + + pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + + if (pDRIDrawablePriv == NULL) { + xp_error err; + xp_window_changes wc; + + /* allocate a DRI Window Private record */ + if (!(pDRIDrawablePriv = malloc(sizeof(*pDRIDrawablePriv)))) { + return NULL; + } + + pDRIDrawablePriv->pDraw = (DrawablePtr)pWin; + pDRIDrawablePriv->pScreen = pScreen; + pDRIDrawablePriv->refCount = 0; + pDRIDrawablePriv->drawableIndex = -1; + pDRIDrawablePriv->notifiers = NULL; + + /* find the physical window */ + wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE)); + + if (wid == 0) { + free(pDRIDrawablePriv); + return NULL; + } + + /* allocate the physical surface */ + err = xp_create_surface(wid, &pDRIDrawablePriv->sid); + + if (err != Success) { + free(pDRIDrawablePriv); + return NULL; + } + + /* Make it visible */ + wc.stack_mode = XP_MAPPED_ABOVE; + wc.sibling = 0; + err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc); + + if (err != Success) { + xp_destroy_surface(pDRIDrawablePriv->sid); + free(pDRIDrawablePriv); + return NULL; + } + + /* save private off of preallocated index */ + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, + pDRIDrawablePriv); + } + + *widPtr = wid; + + return pDRIDrawablePriv; +} + +/* Return NULL if an error occurs. */ +static DRIDrawablePrivPtr +CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix) { + DRIDrawablePrivPtr pDRIDrawablePriv; + + pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix); + + if (pDRIDrawablePriv == NULL) { + xp_error err; + + /* allocate a DRI Window Private record */ + if (!(pDRIDrawablePriv = calloc(1, sizeof(*pDRIDrawablePriv)))) { + return NULL; + } + + pDRIDrawablePriv->pDraw = (DrawablePtr)pPix; + pDRIDrawablePriv->pScreen = pScreen; + pDRIDrawablePriv->refCount = 0; + pDRIDrawablePriv->drawableIndex = -1; + pDRIDrawablePriv->notifiers = NULL; + + /* Passing a null window id to Xplugin in 10.3+ asks for + an accelerated offscreen surface. */ + + err = xp_create_surface(0, &pDRIDrawablePriv->sid); + if (err != Success) { + free(pDRIDrawablePriv); + return NULL; + } + + /* + * The DRIUpdateSurface will be called to resize the surface + * after this function, if the export is successful. + */ + + /* save private off of preallocated index */ + dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, + pDRIDrawablePriv); + } + + return pDRIDrawablePriv; +} + + +Bool +DRICreateSurface(ScreenPtr pScreen, Drawable id, + DrawablePtr pDrawable, xp_client_id client_id, + xp_surface_id *surface_id, unsigned int ret_key[2], + void (*notify) (void *arg, void *data), void *notify_data) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + xp_window_id wid = 0; + DRIDrawablePrivPtr pDRIDrawablePriv; + + if (pDrawable->type == DRAWABLE_WINDOW) { + pDRIDrawablePriv = CreateSurfaceForWindow(pScreen, + (WindowPtr)pDrawable, &wid); + + if(NULL == pDRIDrawablePriv) + return FALSE; /*error*/ + } +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 + else if (pDrawable->type == DRAWABLE_PIXMAP) { + pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen, + (PixmapPtr)pDrawable); + + if(NULL == pDRIDrawablePriv) + return FALSE; /*error*/ + } +#endif + else { /* for GLX 1.3, a PBuffer */ + /* NOT_DONE */ + return FALSE; + } + + + /* Finish initialization of new surfaces */ + if (pDRIDrawablePriv->refCount == 0) { + unsigned int key[2] = {0}; + xp_error err; + + /* try to give the client access to the surface */ + if (client_id != 0) { + /* + * Xplugin accepts a 0 wid if the surface id is offscreen, such + * as for a pixmap. + */ + err = xp_export_surface(wid, pDRIDrawablePriv->sid, + client_id, key); + if (err != Success) { + xp_destroy_surface(pDRIDrawablePriv->sid); + free(pDRIDrawablePriv); + + /* + * Now set the dix privates to NULL that were previously set. + * This prevents reusing an invalid pointer. + */ + if(pDrawable->type == DRAWABLE_WINDOW) { + WindowPtr pWin = (WindowPtr)pDrawable; + + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL); + } else if(pDrawable->type == DRAWABLE_PIXMAP) { + PixmapPtr pPix = (PixmapPtr)pDrawable; + + dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL); + } + + return FALSE; + } + } + + pDRIDrawablePriv->key[0] = key[0]; + pDRIDrawablePriv->key[1] = key[1]; + + ++pDRIPriv->nrWindows; + + /* and stash it by surface id */ + if (surface_hash == NULL) + surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL); + x_hash_table_insert(surface_hash, + x_cvt_uint_to_vptr(pDRIDrawablePriv->sid), pDRIDrawablePriv); + + /* track this in case this window is destroyed */ + AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable); + + /* Initialize shape */ + DRIUpdateSurface(pDRIDrawablePriv, pDrawable); + } + + pDRIDrawablePriv->refCount++; + + *surface_id = pDRIDrawablePriv->sid; + + if (ret_key != NULL) { + ret_key[0] = pDRIDrawablePriv->key[0]; + ret_key[1] = pDRIDrawablePriv->key[1]; + } + + if (notify != NULL) { + pDRIDrawablePriv->notifiers = x_hook_add(pDRIDrawablePriv->notifiers, + notify, notify_data); + } + + return TRUE; +} + +Bool +DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, + void (*notify) (void *, void *), void *notify_data) +{ + DRIDrawablePrivPtr pDRIDrawablePriv; + + if (pDrawable->type == DRAWABLE_WINDOW) { + pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable); + } else if (pDrawable->type == DRAWABLE_PIXMAP) { + pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr)pDrawable); + } else { + return FALSE; + } + + if (pDRIDrawablePriv != NULL) { + if (notify != NULL) { + pDRIDrawablePriv->notifiers = x_hook_remove(pDRIDrawablePriv->notifiers, + notify, notify_data); + } + if (--pDRIDrawablePriv->refCount <= 0) { + /* This calls back to DRIDrawablePrivDelete + which frees the private area */ + FreeResourceByType(id, DRIDrawablePrivResType, FALSE); + } + } + + return TRUE; +} + +Bool +DRIDrawablePrivDelete(pointer pResource, XID id) +{ + DrawablePtr pDrawable = (DrawablePtr)pResource; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv = NULL; + WindowPtr pWin = NULL; + PixmapPtr pPix = NULL; + + if (pDrawable->type == DRAWABLE_WINDOW) { + pWin = (WindowPtr)pDrawable; + pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + } else if (pDrawable->type == DRAWABLE_PIXMAP) { + pPix = (PixmapPtr)pDrawable; + pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix); + } + + if (pDRIDrawablePriv == NULL) { + return DRIFreePixmapImp(pDrawable); + } + + if (pDRIDrawablePriv->drawableIndex != -1) { + /* release drawable table entry */ + pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL; + } + + if (pDRIDrawablePriv->sid != 0) { + xp_destroy_surface(pDRIDrawablePriv->sid); + x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(pDRIDrawablePriv->sid)); + } + + if (pDRIDrawablePriv->notifiers != NULL) + x_hook_free(pDRIDrawablePriv->notifiers); + + free(pDRIDrawablePriv); + + if (pDrawable->type == DRAWABLE_WINDOW) { + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL); + } else if (pDrawable->type == DRAWABLE_PIXMAP) { + dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL); + } + + --pDRIPriv->nrWindows; + + return TRUE; +} + +void +DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + + if (pDRIDrawablePriv) { + /* FIXME: something? */ + } + + pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures; + + (*pScreen->WindowExposures)(pWin, prgn, bsreg); + + pScreen->WindowExposures = DRIWindowExposures; +} + +void +DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv; + + if (pDRIPriv->nrWindows > 0) { + pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + if (pDRIDrawablePriv != NULL) { + DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable); + } + } + + /* unwrap */ + pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow; + + /* call lower layers */ + (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); + + /* rewrap */ + pScreen->CopyWindow = DRICopyWindow; +} + +int +DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) +{ + ScreenPtr pScreen = pParent->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + int returnValue; + + /* unwrap */ + pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree; + + /* call lower layers */ + returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind); + + /* rewrap */ + pScreen->ValidateTree = DRIValidateTree; + + return returnValue; +} + +void +DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) +{ + ScreenPtr pScreen; + DRIScreenPrivPtr pDRIPriv; + + if (pParent) { + pScreen = pParent->drawable.pScreen; + } else { + pScreen = pChild->drawable.pScreen; + } + pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + if (pDRIPriv->wrap.PostValidateTree) { + /* unwrap */ + pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree; + + /* call lower layers */ + (*pScreen->PostValidateTree)(pParent, pChild, kind); + + /* rewrap */ + pScreen->PostValidateTree = DRIPostValidateTree; + } +} + +void +DRIClipNotify(WindowPtr pWin, int dx, int dy) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv; + + if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { + DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable); + } + + if (pDRIPriv->wrap.ClipNotify) { + pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify; + + (*pScreen->ClipNotify)(pWin, dx, dy); + + pScreen->ClipNotify = DRIClipNotify; + } +} + +/* This lets us get at the unwrapped functions so that they can correctly + * call the lower level functions, and choose whether they will be + * called at every level of recursion (eg in validatetree). + */ +DRIWrappedFuncsRec * +DRIGetWrappedFuncs(ScreenPtr pScreen) +{ + return &(DRI_SCREEN_PRIV(pScreen)->wrap); +} + +void +DRIQueryVersion(int *majorVersion, + int *minorVersion, + int *patchVersion) +{ + *majorVersion = APPLE_DRI_MAJOR_VERSION; + *minorVersion = APPLE_DRI_MINOR_VERSION; + *patchVersion = APPLE_DRI_PATCH_VERSION; +} + +void +DRISurfaceNotify(xp_surface_id id, int kind) +{ + DRIDrawablePrivPtr pDRIDrawablePriv = NULL; + DRISurfaceNotifyArg arg; + + arg.id = id; + arg.kind = kind; + + if (surface_hash != NULL) + { + pDRIDrawablePriv = x_hash_table_lookup(surface_hash, + x_cvt_uint_to_vptr(id), NULL); + } + + if (pDRIDrawablePriv == NULL) + return; + + if (kind == AppleDRISurfaceNotifyDestroyed) + { + pDRIDrawablePriv->sid = 0; + x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(id)); + } + + x_hook_run(pDRIDrawablePriv->notifiers, &arg); + + if (kind == AppleDRISurfaceNotifyDestroyed) + { + /* Kill off the handle. */ + + FreeResourceByType(pDRIDrawablePriv->pDraw->id, + DRIDrawablePrivResType, FALSE); + } +} + +Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id, + DrawablePtr pDrawable, char *path, + size_t pathmax) +{ + DRIPixmapBufferPtr shared; + PixmapPtr pPix; + + if(pDrawable->type != DRAWABLE_PIXMAP) + return FALSE; + + pPix = (PixmapPtr)pDrawable; + + shared = malloc(sizeof(*shared)); + if(NULL == shared) { + FatalError("failed to allocate DRIPixmapBuffer in %s\n", __func__); + } + + shared->pDrawable = pDrawable; + shared->refCount = 1; + + if(pDrawable->bitsPerPixel >= 24) { + shared->bytesPerPixel = 4; + } else if(pDrawable->bitsPerPixel <= 16) { + shared->bytesPerPixel = 2; + } + + shared->width = pDrawable->width; + shared->height = pDrawable->height; + + if(-1 == snprintf(shared->shmPath, sizeof(shared->shmPath), + "%d_0x%lx", getpid(), + (unsigned long)id)) { + FatalError("buffer overflow in %s\n", __func__); + } + + shared->fd = shm_open(shared->shmPath, + O_RDWR | O_EXCL | O_CREAT, + S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH); + + if(-1 == shared->fd) { + free(shared); + return FALSE; + } + + shared->length = shared->width * shared->height * shared->bytesPerPixel; + + if(-1 == ftruncate(shared->fd, shared->length)) { + ErrorF("failed to ftruncate (extend) file."); + shm_unlink(shared->shmPath); + close(shared->fd); + free(shared); + return FALSE; + } + + shared->buffer = mmap(NULL, shared->length, + PROT_READ | PROT_WRITE, + MAP_FILE | MAP_SHARED, shared->fd, 0); + + if(MAP_FAILED == shared->buffer) { + ErrorF("failed to mmap shared memory."); + shm_unlink(shared->shmPath); + close(shared->fd); + free(shared); + return FALSE; + } + + strncpy(path, shared->shmPath, pathmax); + path[pathmax - 1] = '\0'; + + dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, shared); + + AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable); + + return TRUE; +} + + +Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height, + int *pitch, int *bpp, void **ptr) { + PixmapPtr pPix; + DRIPixmapBufferPtr shared; + + if(pDrawable->type != DRAWABLE_PIXMAP) + return FALSE; + + pPix = (PixmapPtr)pDrawable; + + shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey); + + if(NULL == shared) + return FALSE; + + assert(pDrawable->width == shared->width); + assert(pDrawable->height == shared->height); + + *width = shared->width; + *height = shared->height; + *bpp = shared->bytesPerPixel; + *pitch = shared->width * shared->bytesPerPixel; + *ptr = shared->buffer; + + return TRUE; +} + +static Bool +DRIFreePixmapImp(DrawablePtr pDrawable) { + DRIPixmapBufferPtr shared; + PixmapPtr pPix; + + if(pDrawable->type != DRAWABLE_PIXMAP) + return FALSE; + + pPix = (PixmapPtr)pDrawable; + + shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey); + + if(NULL == shared) + return FALSE; + + close(shared->fd); + munmap(shared->buffer, shared->length); + shm_unlink(shared->shmPath); + free(shared); + + dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, (pointer)NULL); + + return TRUE; +} + +void +DRIDestroyPixmap(DrawablePtr pDrawable) { + if(DRIFreePixmapImp(pDrawable)) + FreeResourceByType(pDrawable->id, DRIDrawablePrivResType, FALSE); + +} diff --git a/xorg-server/hw/xquartz/xpr/xpr.h b/xorg-server/hw/xquartz/xpr/xpr.h index af1a90ca0..ebd89de3a 100644 --- a/xorg-server/hw/xquartz/xpr/xpr.h +++ b/xorg-server/hw/xquartz/xpr/xpr.h @@ -38,7 +38,7 @@ Bool QuartzModeBundleInit(void); void AppleDRIExtensionInit(void); void xprAppleWMInit(void); Bool xprInit(ScreenPtr pScreen); -Bool xprIsX11Window(void *nsWindow, int windowNumber); +Bool xprIsX11Window(int windowNumber); WindowPtr xprGetXWindow(xp_window_id wid); void xprHideWindows(Bool hide); diff --git a/xorg-server/hw/xquartz/xpr/xprAppleWM.c b/xorg-server/hw/xquartz/xpr/xprAppleWM.c index 21e6f98fa..b6b9a5fc8 100644 --- a/xorg-server/hw/xquartz/xpr/xprAppleWM.c +++ b/xorg-server/hw/xquartz/xpr/xprAppleWM.c @@ -114,8 +114,8 @@ static int xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent) { static int xprFrameDraw( WindowPtr pWin, - int class, - unsigned int attr, + xp_frame_class class, + xp_frame_attr attr, const BoxRec *outer, const BoxRec *inner, unsigned int title_len, diff --git a/xorg-server/hw/xquartz/xpr/xprEvent.c b/xorg-server/hw/xquartz/xpr/xprEvent.c index 38952b091..cc86c473d 100644 --- a/xorg-server/hw/xquartz/xpr/xprEvent.c +++ b/xorg-server/hw/xquartz/xpr/xprEvent.c @@ -1,81 +1,79 @@ -/* Copyright (c) 2008 Apple Inc.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
- * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name(s) of the above
- * copyright holders shall not be used in advertising or otherwise to
- * promote the sale, use or other dealings in this Software without
- * prior written authorization.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "xpr.h"
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "windowstr.h"
-#include "pixmapstr.h"
-#include "inputstr.h"
-#include "eventstr.h"
-#include "mi.h"
-#include "scrnintstr.h"
-#include "mipointer.h"
-
-#include "darwin.h"
-#include "quartz.h"
-#include "quartzKeyboard.h"
-#include "darwinEvents.h"
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <unistd.h>
-
-#include "rootlessWindow.h"
-#include "xprEvent.h"
-
-Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) {
- TA_SERVER();
-
- switch(e->subtype) {
- case kXquartzWindowState:
- DEBUG_LOG("kXquartzWindowState\n");
- RootlessNativeWindowStateChanged(xprGetXWindow(e->data[0]),
- e->data[1]);
- return TRUE;
-
- case kXquartzWindowMoved:
- DEBUG_LOG("kXquartzWindowMoved\n");
- RootlessNativeWindowMoved(xprGetXWindow(e->data[0]));
- return TRUE;
-
- case kXquartzBringAllToFront:
- DEBUG_LOG("kXquartzBringAllToFront\n");
- RootlessOrderAllWindows(e->data[0]);
- return TRUE;
- default:
- return FALSE;
- }
-}
+/* Copyright (c) 2008 Apple Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT + * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name(s) of the above + * copyright holders shall not be used in advertising or otherwise to + * promote the sale, use or other dealings in this Software without + * prior written authorization. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "xpr.h" + +#include <X11/X.h> +#include <X11/Xmd.h> +#include <X11/Xproto.h> +#include "misc.h" +#include "windowstr.h" +#include "pixmapstr.h" +#include "inputstr.h" +#include "eventstr.h" +#include "mi.h" +#include "scrnintstr.h" +#include "mipointer.h" + +#include "darwin.h" +#include "quartz.h" +#include "quartzKeyboard.h" +#include "darwinEvents.h" + +#include <sys/types.h> +#include <sys/uio.h> +#include <unistd.h> + +#include "rootlessWindow.h" +#include "xprEvent.h" + +Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) { + switch(e->subtype) { + case kXquartzWindowState: + DEBUG_LOG("kXquartzWindowState\n"); + RootlessNativeWindowStateChanged(xprGetXWindow(e->data[0]), + e->data[1]); + return TRUE; + + case kXquartzWindowMoved: + DEBUG_LOG("kXquartzWindowMoved\n"); + RootlessNativeWindowMoved(xprGetXWindow(e->data[0])); + return TRUE; + + case kXquartzBringAllToFront: + DEBUG_LOG("kXquartzBringAllToFront\n"); + RootlessOrderAllWindows(e->data[0]); + return TRUE; + default: + return FALSE; + } +} diff --git a/xorg-server/hw/xquartz/xpr/xprFrame.c b/xorg-server/hw/xquartz/xpr/xprFrame.c index 15598e942..5f6b1cb7b 100644 --- a/xorg-server/hw/xquartz/xpr/xprFrame.c +++ b/xorg-server/hw/xquartz/xpr/xprFrame.c @@ -1,7 +1,7 @@ /* * Xplugin rootless implementation frame functions * - * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2002-2011 Apple Computer, Inc. All rights reserved. * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -35,7 +35,6 @@ #include "rootlessCommon.h" #include <Xplugin.h> #include "x-hash.h" -#include "x-list.h" #include "applewmExt.h" #include "propertyst.h" @@ -44,9 +43,11 @@ #include "windowstr.h" #include "quartz.h" -#include "threadSafety.h" - +#ifdef HAVE_LIBDISPATCH +#include <dispatch/dispatch.h> +#else #include <pthread.h> +#endif #define DEFINE_ATOM_HELPER(func,atom_name) \ static Atom func (void) { \ @@ -63,7 +64,13 @@ DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID") /* Maps xp_window_id -> RootlessWindowRec */ static x_hash_table *window_hash; + +/* Need to guard window_hash since xprIsX11Window can be called from any thread. */ +#ifdef HAVE_LIBDISPATCH +static dispatch_queue_t window_hash_serial_q; +#else static pthread_mutex_t window_hash_mutex; +#endif /* Prototypes for static functions */ static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, @@ -93,8 +100,6 @@ static inline xp_error xprConfigureWindow(xp_window_id id, unsigned int mask, const xp_window_changes *values) { - TA_SERVER(); - return xp_configure_window(id, mask, values); } @@ -106,8 +111,6 @@ xprSetNativeProperty(RootlessWindowPtr pFrame) unsigned int native_id; long data; - TA_SERVER(); - err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id); if (err == Success) { @@ -137,8 +140,6 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, unsigned int mask = 0; xp_error err; - TA_SERVER(); - wc.x = newX; wc.y = newY; wc.width = pFrame->width; @@ -186,15 +187,15 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, return FALSE; } - if (window_hash == NULL) - { - window_hash = x_hash_table_new(NULL, NULL, NULL, NULL); - pthread_mutex_init(&window_hash_mutex, NULL); - } - +#ifdef HAVE_LIBDISPATCH + dispatch_async(window_hash_serial_q, ^{ + x_hash_table_insert(window_hash, pFrame->wid, pFrame); + }); +#else pthread_mutex_lock(&window_hash_mutex); x_hash_table_insert(window_hash, pFrame->wid, pFrame); pthread_mutex_unlock(&window_hash_mutex); +#endif xprSetNativeProperty(pFrame); @@ -209,11 +210,16 @@ static void xprDestroyFrame(RootlessFrameID wid) { xp_error err; - TA_SERVER(); - + +#ifdef HAVE_LIBDISPATCH + dispatch_async(window_hash_serial_q, ^{ + x_hash_table_remove(window_hash, wid); + }); +#else pthread_mutex_lock(&window_hash_mutex); x_hash_table_remove(window_hash, wid); pthread_mutex_unlock(&window_hash_mutex); +#endif err = xp_destroy_window(x_cvt_vptr_to_uint(wid)); if (err != Success) @@ -229,8 +235,6 @@ xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY) { xp_window_changes wc; - TA_SERVER(); - wc.x = newX; wc.y = newY; // ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY); @@ -248,8 +252,6 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, { xp_window_changes wc; - TA_SERVER(); - wc.x = newX; wc.y = newY; wc.width = newW; @@ -269,9 +271,11 @@ xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen, static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) { xp_window_changes wc; unsigned int mask = XP_STACKING; +#ifdef HAVE_LIBDISPATCH + __block +#endif + RootlessWindowRec *winRec; - TA_SERVER(); - /* Stack frame below nextWid it if it exists, or raise frame above everything otherwise. */ @@ -283,18 +287,24 @@ static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) { wc.sibling = x_cvt_vptr_to_uint(nextWid); } - if(window_hash) { - RootlessWindowRec *winRec = x_hash_table_lookup(window_hash, wid, NULL); - - if(winRec) { - if(XQuartzIsRootless) - wc.window_level = normal_window_levels[winRec->level]; - else if(XQuartzShieldingWindowLevel) - wc.window_level = XQuartzShieldingWindowLevel + 1; - else - wc.window_level = rooted_window_levels[winRec->level]; - mask |= XP_WINDOW_LEVEL; - } +#ifdef HAVE_LIBDISPATCH + dispatch_sync(window_hash_serial_q, ^{ + winRec = x_hash_table_lookup(window_hash, wid, NULL); + }); +#else + pthread_mutex_lock(&window_hash_mutex); + winRec = x_hash_table_lookup(window_hash, wid, NULL); + pthread_mutex_unlock(&window_hash_mutex); +#endif + + if(winRec) { + if(XQuartzIsRootless) + wc.window_level = normal_window_levels[winRec->level]; + else if(XQuartzShieldingWindowLevel) + wc.window_level = XQuartzShieldingWindowLevel + 1; + else + wc.window_level = rooted_window_levels[winRec->level]; + mask |= XP_WINDOW_LEVEL; } xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc); @@ -309,8 +319,6 @@ xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape) { xp_window_changes wc; - TA_SERVER(); - if (pShape != NULL) { wc.shape_nrects = RegionNumRects(pShape); @@ -336,8 +344,6 @@ xprUnmapFrame(RootlessFrameID wid) { xp_window_changes wc; - TA_SERVER(); - wc.stack_mode = XP_UNMAPPED; wc.sibling = 0; @@ -356,8 +362,6 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow) unsigned int rowbytes[2]; xp_error err; - TA_SERVER(); - err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, NULL); if (err != Success) FatalError("Could not lock window %i for drawing.", (int)x_cvt_vptr_to_uint(wid)); @@ -374,8 +378,7 @@ static void xprStopDrawing(RootlessFrameID wid, Bool flush) { xp_error err; - TA_SERVER(); - + err = xp_unlock_window(x_cvt_vptr_to_uint(wid), flush); if(err != Success) FatalError("Could not unlock window %i after drawing.", (int)x_cvt_vptr_to_uint(wid)); @@ -388,8 +391,6 @@ xprStopDrawing(RootlessFrameID wid, Bool flush) static void xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage) { - TA_SERVER(); - xp_flush_window(x_cvt_vptr_to_uint(wid)); } @@ -401,8 +402,6 @@ static void xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects, int shift_x, int shift_y) { - TA_SERVER(); - xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y); } @@ -416,8 +415,6 @@ xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin) { DeleteProperty(serverClient, oldWin, xa_native_window_id()); - TA_SERVER(); - xprSetNativeProperty(pFrame); } @@ -429,8 +426,6 @@ static Bool xprDoReorderWindow(RootlessWindowPtr pFrame) { WindowPtr pWin = pFrame->win; - TA_SERVER(); - return AppleWMDoReorderWindow(pWin); } @@ -443,8 +438,6 @@ static void xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects, int dx, int dy) { - TA_SERVER(); - xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid), dstNrects, dstRects, dx, dy); } @@ -479,11 +472,16 @@ xprInit(ScreenPtr pScreen) { RootlessInit(pScreen, &xprRootlessProcs); - TA_SERVER(); - rootless_CopyBytes_threshold = xp_copy_bytes_threshold; rootless_CopyWindow_threshold = xp_scroll_area_threshold; + assert((window_hash = x_hash_table_new(NULL, NULL, NULL, NULL))); +#ifdef HAVE_LIBDISPATCH + assert((window_hash_serial_q = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.xpr_window_hash", NULL))); +#else + assert(0 == pthread_mutex_init(&window_hash_mutex, NULL)); +#endif + return TRUE; } @@ -495,73 +493,36 @@ xprInit(ScreenPtr pScreen) WindowPtr xprGetXWindow(xp_window_id wid) { +#ifdef HAVE_LIBDISPATCH + RootlessWindowRec *winRec __block; + dispatch_sync(window_hash_serial_q, ^{ + winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); + }); +#else RootlessWindowRec *winRec; - - if (window_hash == NULL) - return NULL; - - winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); - - return winRec != NULL ? winRec->win : NULL; -} - -#ifdef UNUSED_CODE -/* - * Given the id of a physical window, try to find the top-level (or root) - * X window that it represents. - */ -WindowPtr -xprGetXWindowFromAppKit(int windowNumber) -{ - RootlessWindowRec *winRec; - Bool ret; - xp_window_id wid; - - if (window_hash == NULL) - return FALSE; - - /* need to lock, since this function can be called by any thread */ - pthread_mutex_lock(&window_hash_mutex); - - if (xp_lookup_native_window(windowNumber, &wid)) - ret = xprGetXWindow(wid) != NULL; - else - ret = FALSE; - - pthread_mutex_unlock(&window_hash_mutex); - - if (!ret) return NULL; winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL); + pthread_mutex_unlock(&window_hash_mutex); +#endif return winRec != NULL ? winRec->win : NULL; } -#endif /* * The windowNumber is an AppKit window number. Returns TRUE if xpr is * displaying a window with that number. */ Bool -xprIsX11Window(void *nsWindow, int windowNumber) +xprIsX11Window(int windowNumber) { Bool ret; xp_window_id wid; - if (window_hash == NULL) - return FALSE; - - /* need to lock, since this function can be called by any thread */ - - pthread_mutex_lock(&window_hash_mutex); - if (xp_lookup_native_window(windowNumber, &wid)) ret = xprGetXWindow(wid) != NULL; else ret = FALSE; - pthread_mutex_unlock(&window_hash_mutex); - return ret; } @@ -578,8 +539,6 @@ xprHideWindows(Bool hide) int screen; WindowPtr pRoot, pWin; - TA_SERVER(); - for (screen = 0; screen < screenInfo.numScreens; screen++) { RootlessFrameID prevWid = NULL; pRoot = screenInfo.screens[screen]->root; |