glx: Implement __DRI_BACKGROUND_CALLABLE
authorPaul Berry <stereotype441@gmail.com>
Wed, 14 Nov 2012 23:50:27 +0000 (15:50 -0800)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 16 Mar 2017 03:14:18 +0000 (14:14 +1100)
v2: Marek: Add DRI3 support.

v3: (Timothy Arceri) use C99 initializers.

Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Acked-by: Marek Olšák <maraeo@gmail.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
src/glx/dri2_glx.c
src/glx/dri3_glx.c

index 5b93f2f6f49a2875aa65c601c8c5327c7adce947..145f44d6e8cffee23f3fffa5cbee31852cb480b4 100644 (file)
@@ -74,7 +74,7 @@ struct dri2_display
 
    __glxHashTable *dri2Hash;
 
-   const __DRIextension *loader_extensions[4];
+   const __DRIextension *loader_extensions[5];
 };
 
 struct dri2_drawable
@@ -946,6 +946,13 @@ dri2GetSwapInterval(__GLXDRIdrawable *pdraw)
   return priv->swap_interval;
 }
 
+static void
+driSetBackgroundContext(void *loaderPrivate)
+{
+   struct dri2_context *pcp = (struct dri2_context *) loaderPrivate;
+   __glXSetCurrentContext(&pcp->base);
+}
+
 static const __DRIdri2LoaderExtension dri2LoaderExtension = {
    .base = { __DRI_DRI2_LOADER, 3 },
 
@@ -966,6 +973,12 @@ static const __DRIuseInvalidateExtension dri2UseInvalidate = {
    .base = { __DRI_USE_INVALIDATE, 1 }
 };
 
+static const __DRIbackgroundCallableExtension driBackgroundCallable = {
+   .base = { __DRI_BACKGROUND_CALLABLE, 1 },
+
+   .setBackgroundContext    = driSetBackgroundContext,
+};
+
 _X_HIDDEN void
 dri2InvalidateBuffers(Display *dpy, XID drawable)
 {
@@ -1395,6 +1408,8 @@ dri2CreateDisplay(Display * dpy)
    
    pdp->loader_extensions[i++] = &dri2UseInvalidate.base;
 
+   pdp->loader_extensions[i++] = &driBackgroundCallable.base;
+
    pdp->loader_extensions[i++] = NULL;
 
    pdp->dri2Hash = __glxHashCreate();
index 9c15395adf8a49f8efa0e164630172c0b66f09ae..e1dc5aa4a83a9ea0768058b66b36ebbcb7021d56 100644 (file)
@@ -496,6 +496,13 @@ dri3_flush_front_buffer(__DRIdrawable *driDrawable, void *loaderPrivate)
    loader_dri3_wait_gl(draw);
 }
 
+static void
+dri_set_background_context(void *loaderPrivate)
+{
+   struct dri3_context *pcp = (struct dri3_context *)loaderPrivate;
+   __glXSetCurrentContext(&pcp->base);
+}
+
 /* The image loader extension record for DRI3
  */
 static const __DRIimageLoaderExtension imageLoaderExtension = {
@@ -509,9 +516,16 @@ const __DRIuseInvalidateExtension dri3UseInvalidate = {
    .base = { __DRI_USE_INVALIDATE, 1 }
 };
 
+static const __DRIbackgroundCallableExtension driBackgroundCallable = {
+   .base = { __DRI_BACKGROUND_CALLABLE, 1 },
+
+   .setBackgroundContext = dri_set_background_context,
+};
+
 static const __DRIextension *loader_extensions[] = {
    &imageLoaderExtension.base,
    &dri3UseInvalidate.base,
+   &driBackgroundCallable.base,
    NULL
 };