apple: ifdef out come glapi-foo on darwin
[mesa.git] / src / glx / dri_common.c
index 7866521e420f93c407f0f2c2e98e3b2ee2eb0aef..06a73e4a6b25039c32bec1181bced5f2780b8400 100644 (file)
@@ -39,7 +39,6 @@
 #include <dlfcn.h>
 #include <stdarg.h>
 #include "glxclient.h"
-#include "glcontextmodes.h"
 #include "dri_common.h"
 
 #ifndef RTLD_NOW
@@ -223,7 +222,9 @@ __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
       __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba),
       __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE,
                      bindToMipmapTexture),
-      __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),};
+      __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),
+      __ATTRIB(__DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE, sRGBCapable)
+};
 
 static int
 scalarEqual(struct glx_config *mode, unsigned int attrib, unsigned int value)
@@ -354,4 +355,58 @@ driDestroyConfigs(const __DRIconfig **configs)
    free(configs);
 }
 
+_X_HIDDEN __GLXDRIdrawable *
+driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
+{
+   struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
+   __GLXDRIdrawable *pdraw;
+   struct glx_screen *psc;
+
+   if (priv == NULL)
+      return NULL;
+
+   psc = priv->screens[gc->screen];
+   if (priv->drawHash == NULL)
+      return NULL;
+
+   if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0)
+      return pdraw;
+
+   pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
+                                          glxDrawable, gc->config);
+   if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
+      (*pdraw->destroyDrawable) (pdraw);
+      return NULL;
+   }
+
+   return pdraw;
+}
+
+_X_HIDDEN void
+driReleaseDrawables(struct glx_context *gc)
+{
+   struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
+   __GLXDRIdrawable *pdraw;
+
+   if (priv == NULL)
+      return;
+
+   if (__glxHashLookup(priv->drawHash,
+                      gc->currentDrawable, (void *) &pdraw) == 0) {
+      if (pdraw->drawable == pdraw->xDrawable) {
+        (*pdraw->destroyDrawable)(pdraw);
+        __glxHashDelete(priv->drawHash, gc->currentDrawable);
+      }
+   }
+
+   if (gc->currentDrawable != gc->currentReadable &&
+       __glxHashLookup(priv->drawHash,
+                      gc->currentReadable, (void *) &pdraw) == 0) {
+      if (pdraw->drawable == pdraw->xDrawable) {
+        (*pdraw->destroyDrawable)(pdraw);
+        __glxHashDelete(priv->drawHash, gc->currentReadable);
+      }
+   }
+}
+
 #endif /* GLX_DIRECT_RENDERING */