#ifdef GLX_USE_APPLEGL
#include <pthread.h>
-#include "apple_glx_drawable.h"
-#include "glx_error.h"
+#include "apple/apple_glx_drawable.h"
#endif
+#include "glx_error.h"
+
#define WARN_ONCE_GLX_1_3(a, b) { \
static int warned=1; \
if(warned) { \
{
struct glx_display *priv = __glXInitialize(dpy);
- if (priv->minorVersion < 3) {
+ if (priv && priv->minorVersion < 3) {
fprintf(stderr,
"WARNING: Application calling GLX 1.3 function \"%s\" "
"when GLX 1.3 is not supported! This is an application bug!\n",
CARD8 opcode;
int i;
- if ((dpy == NULL) || (drawable == 0)) {
+ if ((priv == NULL) || (dpy == NULL) || (drawable == 0)) {
return;
}
__GLXDRIdrawable *pdraw;
struct glx_screen *psc;
+ if (priv == NULL) {
+ fprintf(stderr, "failed to create drawable\n");
+ return GL_FALSE;
+ }
+
psc = priv->screens[config->screen];
if (psc->driScreen == NULL)
return GL_TRUE;
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
XID xid;
- if (pdraw != NULL) {
+ if (priv != NULL && pdraw != NULL) {
xid = pdraw->xDrawable;
(*pdraw->destroyDrawable) (pdraw);
__glxHashDelete(priv->drawHash, drawable);
XID drawable, XID glxdrawable,
const int *attrib_list, size_t num_attribs)
{
- return GL_FALSE;
+ return GL_TRUE;
}
static void
unsigned int num_attributes;
GLboolean use_glx_1_3;
- if ((dpy == NULL) || (drawable == 0)) {
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
+ __GLXDRIdrawable *pdraw;
+#endif
+
+ if (dpy == NULL)
+ return 0;
+
+ /* Page 38 (page 52 of the PDF) of glxencode1.3.pdf says:
+ *
+ * "If drawable is not a valid GLX drawable, a GLXBadDrawable error is
+ * generated."
+ */
+ if (drawable == 0) {
+ __glXSendError(dpy, GLXBadDrawable, 0, X_GLXGetDrawableAttributes, false);
return 0;
}
priv = __glXInitialize(dpy);
+ if (priv == NULL)
+ return 0;
+
use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3));
*value = 0;
if (!opcode)
return 0;
+#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
+ pdraw = GetGLXDRIDrawable(dpy, drawable);
+
+ if (attribute == GLX_BACK_BUFFER_AGE_EXT) {
+ struct glx_screen *psc = pdraw->psc;
+ struct glx_context *gc = __glXGetCurrentContext();
+
+ /* The GLX_EXT_buffer_age spec says:
+ *
+ * "If querying GLX_BACK_BUFFER_AGE_EXT and <draw> is not bound to
+ * the calling thread's current context a GLXBadDrawable error is
+ * generated."
+ */
+ if (gc == NULL || gc->currentDpy != dpy ||
+ (gc->currentDrawable != drawable && gc->currentReadable != drawable)) {
+ __glXSendError(dpy, GLXBadDrawable, drawable, X_GLXGetDrawableAttributes, false);
+ return 0;
+ }
+
+ if (psc->driScreen->getBufferAge != NULL)
+ *value = psc->driScreen->getBufferAge(pdraw);
+
+ return 0;
+ }
+#endif
+
LockDisplay(dpy);
if (use_glx_1_3) {
length = reply.length;
if (length) {
num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
- data = (CARD32 *) Xmalloc(length * sizeof(CARD32));
+ data = malloc(length * sizeof(CARD32));
if (data == NULL) {
/* Throw data on the floor */
_XEatData(dpy, length);
}
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
- {
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
-
- if (pdraw != NULL && !pdraw->textureTarget)
+ if (pdraw != NULL) {
+ if (!pdraw->textureTarget)
pdraw->textureTarget =
determineTextureTarget((const int *) data, num_attributes);
- if (pdraw != NULL && !pdraw->textureFormat)
+ if (!pdraw->textureFormat)
pdraw->textureFormat =
determineTextureFormat((const int *) data, num_attributes);
}
#endif
- Xfree(data);
+ free(data);
}
}
Drawable drawable, const int *attrib_list, CARD8 glxCode)
{
xGLXCreateWindowReq *req;
+ struct glx_drawable *glxDraw;
CARD32 *data;
unsigned int i;
CARD8 opcode;
if (!opcode)
return None;
+ glxDraw = malloc(sizeof(*glxDraw));
+ if (!glxDraw)
+ return None;
+
LockDisplay(dpy);
GetReqExtra(GLXCreateWindow, 8 * i, req);
data = (CARD32 *) (req + 1);
UnlockDisplay(dpy);
SyncHandle();
+ if (InitGLXDrawable(dpy, glxDraw, drawable, xid)) {
+ free(glxDraw);
+ return None;
+ }
+
if (!CreateDRIDrawable(dpy, config, drawable, xid, attrib_list, i)) {
if (glxCode == X_GLXCreatePixmap)
glxCode = X_GLXDestroyPixmap;
protocolDestroyDrawable(dpy, drawable, glxCode);
+ DestroyGLXDrawable(dpy, drawable);
DestroyDRIDrawable(dpy, drawable, GL_FALSE);
return;
Pixmap pixmap;
GLboolean glx_1_3 = GL_FALSE;
+ if (priv == NULL)
+ return None;
+
i = 0;
if (attrib_list) {
while (attrib_list[i * 2])
struct glx_display *priv = __glXInitialize(dpy);
CARD8 opcode;
- if ((dpy == NULL) || (drawable == 0)) {
+ if ((priv == NULL) || (dpy == NULL) || (drawable == 0)) {
return;
}
return None;
}
- XFree(visinfo);
+ free(visinfo);
return win;
#else