[cairo-commit] glitz/src/glx glitz_glx_context.c, 1.3, 1.4 glitz_glx_drawable.c, 1.2, 1.3 glitz_glx_info.c, 1.3, 1.4 glitz_glxint.h, 1.2, 1.3

David Reveman commit at pdx.freedesktop.org
Tue Apr 12 07:54:59 PDT 2005


Committed by: davidr

Update of /cvs/cairo/glitz/src/glx
In directory gabe:/tmp/cvs-serv20487/src/glx

Modified Files:
	glitz_glx_context.c glitz_glx_drawable.c glitz_glx_info.c 
	glitz_glxint.h 
Log Message:
Add glitz_context_t interface

Index: glitz_glx_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glx_context.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- glitz_glx_context.c	10 Mar 2005 22:45:30 -0000	1.3
+++ glitz_glx_context.c	12 Apr 2005 14:54:56 -0000	1.4
@@ -104,6 +104,101 @@
     XFree (fbconfigs);
 }
 
+static glitz_context_t *
+_glitz_glx_create_context (void                    *abstract_drawable,
+                           glitz_drawable_format_t *format)
+{
+  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *) abstract_drawable;
+  glitz_glx_screen_info_t *screen_info = drawable->screen_info;
+  int format_id = screen_info->format_ids[format->id];
+  glitz_glx_context_t *context;
+  
+  context = malloc (sizeof (glitz_glx_context_t));
+  if (!context)
+    return NULL;
+
+  _glitz_context_init (&context->base, &drawable->base);
+  
+  if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK)
+      _glitz_glx_context_create_using_fbconfig (screen_info,
+                                                format_id,
+                                                screen_info->root_context,
+                                                context);
+  else
+      _glitz_glx_context_create (screen_info,
+                                 format_id,
+                                 screen_info->root_context,
+                                 context);
+
+  return (glitz_context_t *) context;
+}
+
+static void
+_glitz_glx_context_destroy (void *abstract_context)
+{
+  glitz_glx_context_t *context = (glitz_glx_context_t *) abstract_context;
+  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+      context->base.drawable;
+  
+  if (drawable->screen_info->display_info->thread_info->cctx == &context->base)
+  {
+      glXMakeCurrent (drawable->screen_info->display_info->display,
+                      None, NULL);
+  
+      drawable->screen_info->display_info->thread_info->cctx = NULL;
+  }
+
+  glXDestroyContext (drawable->screen_info->display_info->display,
+                     context->context);
+
+  _glitz_context_fini (&context->base);
+  
+  free (context);
+}
+
+static void
+_glitz_glx_copy_context (void          *abstract_src,
+                         void          *abstract_dst,
+                         unsigned long mask)
+{
+  glitz_glx_context_t  *src = (glitz_glx_context_t *) abstract_src;
+  glitz_glx_context_t  *dst = (glitz_glx_context_t *) abstract_dst;
+  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+      src->base.drawable;
+
+  glXCopyContext (drawable->screen_info->display_info->display,
+                  src->context, dst->context, mask);
+}
+
+static void
+_glitz_glx_make_current (void *abstract_context,
+                         void *abstract_drawable)
+{
+  glitz_glx_context_t  *context = (glitz_glx_context_t *) abstract_context;
+  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *) abstract_drawable;
+  glitz_glx_display_info_t *display_info = drawable->screen_info->display_info;
+  
+  if ((glXGetCurrentContext () != context->context) ||
+      (glXGetCurrentDrawable () != drawable->drawable))
+    glXMakeCurrent (display_info->display, drawable->drawable,
+                    context->context);
+
+  display_info->thread_info->cctx = &context->base;
+}
+
+static glitz_function_pointer_t
+_glitz_glx_context_get_proc_address (void       *abstract_context,
+                                     const char *name)
+{
+  glitz_glx_context_t  *context = (glitz_glx_context_t *) abstract_context;
+  glitz_glx_drawable_t *drawable = (glitz_glx_drawable_t *)
+      context->base.drawable;
+
+  _glitz_glx_make_current (context, drawable);
+  
+  return glitz_glx_get_proc_address (name, drawable->screen_info);
+}
+
 glitz_glx_context_t *
 glitz_glx_context_get (glitz_glx_screen_info_t *screen_info,
                        glitz_drawable_format_t *format)
@@ -143,7 +238,7 @@
                                format_id,
                                screen_info->root_context,
                                context);
-
+  
   if (!screen_info->root_context)
     screen_info->root_context = context->context;
 
@@ -156,8 +251,13 @@
   context->backend.push_current = glitz_glx_push_current;
   context->backend.pop_current = glitz_glx_pop_current;
   context->backend.swap_buffers = glitz_glx_swap_buffers;
-  context->backend.make_current_read = glitz_glx_make_current_read;
-
+  
+  context->backend.create_context = _glitz_glx_create_context;
+  context->backend.destroy_context = _glitz_glx_context_destroy;
+  context->backend.copy_context = _glitz_glx_copy_context;
+  context->backend.make_current = _glitz_glx_make_current;
+  context->backend.get_proc_address = _glitz_glx_context_get_proc_address;
+  
   context->backend.drawable_formats = screen_info->formats;
   context->backend.n_drawable_formats = screen_info->n_formats;
 
@@ -203,7 +303,7 @@
 
   glitz_initiate_state (&_glitz_glx_gl_proc_address);
 
-  version = context->backend.gl.get_string (GLITZ_GL_VERSION);
+  version = (const char *) context->backend.gl.get_string (GLITZ_GL_VERSION);
   if (version)
   {
     /* Having trouble with TexSubImage2D to NPOT GL_TEXTURE_2D textures when
@@ -223,15 +323,27 @@
 
 static void
 _glitz_glx_context_make_current (glitz_glx_drawable_t *drawable,
-                                 glitz_bool_t         flush)
+                                 glitz_bool_t         finish)
 {
-  if (flush)
-    glFlush ();
+  glitz_glx_display_info_t *display_info = drawable->screen_info->display_info;
+                                 
+  if (finish)
+    glFinish ();
 
-  glXMakeCurrent (drawable->screen_info->display_info->display,
+  if (display_info->thread_info->cctx)
+  {
+      glitz_context_t *ctx = display_info->thread_info->cctx;
+
+      if (ctx->lose_current)
+          ctx->lose_current (ctx->closure);
+
+      display_info->thread_info->cctx = NULL;
+  }
+
+  glXMakeCurrent (display_info->display,
                   drawable->drawable,
                   drawable->context->context);
-
+  
   drawable->base.update_all = 1;
   
   if (!drawable->context->initialized)
@@ -247,11 +359,20 @@
   switch (constraint) {
   case GLITZ_NONE:
     break;
-  case GLITZ_ANY_CONTEXT_CURRENT:
-    context = glXGetCurrentContext ();
-    if (context == (GLXContext) 0)
+  case GLITZ_ANY_CONTEXT_CURRENT: {
+    glitz_glx_display_info_t *dinfo = drawable->screen_info->display_info;
+    
+    if (dinfo->thread_info->cctx)
+    {
       _glitz_glx_context_make_current (drawable, 0);
-    break;
+    }
+    else
+    {
+      context = glXGetCurrentContext ();
+      if (context == (GLXContext) 0)
+        _glitz_glx_context_make_current (drawable, 0);
+    }
+    } break;
   case GLITZ_CONTEXT_CURRENT:
     context = glXGetCurrentContext ();
     if (context != drawable->context->context)

Index: glitz_glx_drawable.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glx_drawable.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- glitz_glx_drawable.c	25 Jan 2005 19:50:26 -0000	1.2
+++ glitz_glx_drawable.c	12 Apr 2005 14:54:56 -0000	1.3
@@ -29,12 +29,6 @@
 
 #include "glitz_glxint.h"
 
-glitz_status_t
-glitz_glx_make_current_read (void *abstract_surface)
-{
-  return GLITZ_STATUS_NOT_SUPPORTED;
-}
-
 static glitz_glx_drawable_t *
 _glitz_glx_create_drawable (glitz_glx_screen_info_t *screen_info,
                             glitz_glx_context_t     *context,
@@ -73,7 +67,7 @@
     free (drawable);
     return NULL;
   }
-
+  
   screen_info->drawables++;
   
   return drawable;
@@ -139,7 +133,7 @@
   screen_info = glitz_glx_screen_info_get (display, screen);
   if (!screen_info)
     return NULL;
- 
+  
   context = glitz_glx_context_get (screen_info, format);
   if (!context)
     return NULL;

Index: glitz_glx_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glx_info.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- glitz_glx_info.c	12 Mar 2005 10:37:00 -0000	1.3
+++ glitz_glx_info.c	12 Apr 2005 14:54:56 -0000	1.4
@@ -277,6 +277,8 @@
     dlclose (thread_info->dlhand);
     thread_info->dlhand = NULL;
   }
+  
+  thread_info->cctx = NULL;
 }
 
 #ifdef XTHREADS
@@ -295,6 +297,7 @@
   thread_info->n_displays = 0;
   thread_info->gl_library = NULL;
   thread_info->dlhand = NULL;
+  thread_info->cctx = NULL;
 }
 
 static void

Index: glitz_glxint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glx/glitz_glxint.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- glitz_glxint.h	25 Jan 2005 19:50:26 -0000	1.2
+++ glitz_glxint.h	12 Apr 2005 14:54:56 -0000	1.3
@@ -64,6 +64,7 @@
   int                      n_displays;
   char                     *gl_library;
   void                     *dlhand;
+  glitz_context_t          *cctx;
 } glitz_glx_thread_info_t;
 
 struct _glitz_glx_display_info_t {
@@ -80,6 +81,7 @@
 } glitz_glx_context_info_t;
 
 typedef struct _glitz_glx_context_t {
+  glitz_context_t   base;
   GLXContext        context;
   glitz_format_id_t id;
   GLXFBConfig       fbconfig;
@@ -164,6 +166,10 @@
 extern glitz_surface_t __internal_linkage *
 glitz_glx_pop_current (void *abstract_drawable);
 
+void
+glitz_glx_make_current (void               *abstract_drawable,
+                        glitz_constraint_t constraint);
+
 extern glitz_status_t __internal_linkage
 glitz_glx_make_current_read (void *abstract_surface);
 




More information about the cairo-commit mailing list