dri_util: move context functions
authorGeorge Sapountzis <gsapountzis@gmail.com>
Fri, 4 Nov 2011 14:19:22 +0000 (16:19 +0200)
committerGeorge Sapountzis <gsapountzis@gmail.com>
Fri, 4 Nov 2011 21:33:05 +0000 (23:33 +0200)
src/mesa/drivers/dri/common/dri_util.c

index 1a106cd88a4aa224b99b040c5cc9fd39f48e7b9a..1023394ef587913250ed4f1691c6786d879c2a15 100644 (file)
@@ -133,6 +133,92 @@ static const __DRIextension **driGetExtensions(__DRIscreen *psp)
 /*@}*/
 
 
+/*****************************************************************/
+/** \name Context handling functions                             */
+/*****************************************************************/
+/*@{*/
+
+static __DRIcontext *
+dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
+                          const __DRIconfig *config,
+                          __DRIcontext *shared, void *data)
+{
+    __DRIcontext *context;
+    const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
+    void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
+    gl_api mesa_api;
+
+    if (!(screen->api_mask & (1 << api)))
+       return NULL;
+
+    switch (api) {
+    case __DRI_API_OPENGL:
+           mesa_api = API_OPENGL;
+           break;
+    case __DRI_API_GLES:
+           mesa_api = API_OPENGLES;
+           break;
+    case __DRI_API_GLES2:
+           mesa_api = API_OPENGLES2;
+           break;
+    default:
+           return NULL;
+    }
+
+    context = malloc(sizeof *context);
+    if (!context)
+       return NULL;
+
+    context->driScreenPriv = screen;
+    context->driDrawablePriv = NULL;
+    context->loaderPrivate = data;
+
+    if (!driDriverAPI.CreateContext(mesa_api, modes,
+                                   context, shareCtx) ) {
+        free(context);
+        return NULL;
+    }
+
+    return context;
+}
+
+
+static __DRIcontext *
+dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
+                     __DRIcontext *shared, void *data)
+{
+   return dri2CreateNewContextForAPI(screen, __DRI_API_OPENGL,
+                                    config, shared, data);
+}
+
+/**
+ * Destroy the per-context private information.
+ * 
+ * \internal
+ * This function calls __DriverAPIRec::DestroyContext on \p contextPrivate, calls
+ * drmDestroyContext(), and finally frees \p contextPrivate.
+ */
+static void
+driDestroyContext(__DRIcontext *pcp)
+{
+    if (pcp) {
+       driDriverAPI.DestroyContext(pcp);
+       free(pcp);
+    }
+}
+
+static int
+driCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask)
+{
+    (void) dest;
+    (void) src;
+    (void) mask;
+    return GL_FALSE;
+}
+
+/*@}*/
+
+
 /*****************************************************************/
 /** \name Context (un)binding functions                          */
 /*****************************************************************/
@@ -343,98 +429,12 @@ driDestroyDrawable(__DRIdrawable *pdp)
 
 /*@}*/
 
-
-/*****************************************************************/
-/** \name Context handling functions                             */
-/*****************************************************************/
-/*@{*/
-
-/**
- * Destroy the per-context private information.
- * 
- * \internal
- * This function calls __DriverAPIRec::DestroyContext on \p contextPrivate, calls
- * drmDestroyContext(), and finally frees \p contextPrivate.
- */
-static void
-driDestroyContext(__DRIcontext *pcp)
-{
-    if (pcp) {
-       driDriverAPI.DestroyContext(pcp);
-       free(pcp);
-    }
-}
-
 static unsigned int
 dri2GetAPIMask(__DRIscreen *screen)
 {
     return screen->api_mask;
 }
 
-static __DRIcontext *
-dri2CreateNewContextForAPI(__DRIscreen *screen, int api,
-                          const __DRIconfig *config,
-                          __DRIcontext *shared, void *data)
-{
-    __DRIcontext *context;
-    const struct gl_config *modes = (config != NULL) ? &config->modes : NULL;
-    void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
-    gl_api mesa_api;
-
-    if (!(screen->api_mask & (1 << api)))
-       return NULL;
-
-    switch (api) {
-    case __DRI_API_OPENGL:
-           mesa_api = API_OPENGL;
-           break;
-    case __DRI_API_GLES:
-           mesa_api = API_OPENGLES;
-           break;
-    case __DRI_API_GLES2:
-           mesa_api = API_OPENGLES2;
-           break;
-    default:
-           return NULL;
-    }
-
-    context = malloc(sizeof *context);
-    if (!context)
-       return NULL;
-
-    context->driScreenPriv = screen;
-    context->driDrawablePriv = NULL;
-    context->loaderPrivate = data;
-    
-    if (!driDriverAPI.CreateContext(mesa_api, modes,
-                                   context, shareCtx) ) {
-        free(context);
-        return NULL;
-    }
-
-    return context;
-}
-
-
-static __DRIcontext *
-dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
-                     __DRIcontext *shared, void *data)
-{
-   return dri2CreateNewContextForAPI(screen, __DRI_API_OPENGL,
-                                    config, shared, data);
-}
-
-static int
-driCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask)
-{
-    (void) dest;
-    (void) src;
-    (void) mask;
-    return GL_FALSE;
-}
-
-/*@}*/
-
 
 /** Core interface */
 const __DRIcoreExtension driCoreExtension = {