[cairo-commit] glitz/src glitz_agl_info.c, 1.6, 1.7 glitz_agl_surface.c, 1.12, 1.13 glitz_glx_info.c, 1.11, 1.12 glitz_glx_surface.c, 1.14, 1.15 glitz_glxint.h, 1.10, 1.11 glitz_programmatic.c, 1.10, 1.11 glitz_surface.c, 1.15, 1.16

David Reveman commit at pdx.freedesktop.org
Fri Jul 23 17:09:29 PDT 2004


Committed by: davidr

Update of /cvs/cairo/glitz/src
In directory pdx:/tmp/cvs-serv6090/src

Modified Files:
	glitz_agl_info.c glitz_agl_surface.c glitz_glx_info.c 
	glitz_glx_surface.c glitz_glxint.h glitz_programmatic.c 
	glitz_surface.c 
Log Message:
Fixed a few memory leaks and made surface destruction more efficient

Index: glitz_agl_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_info.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glitz_agl_info.c	20 Jul 2004 07:51:14 -0000	1.6
--- glitz_agl_info.c	24 Jul 2004 00:09:27 -0000	1.7
***************
*** 127,134 ****
  
  static void
! glitz_agl_thread_info_destroy (void *p)
  {
!   glitz_agl_thread_info_fini ((glitz_agl_thread_info_t *) p);
!   free (p);
  }
  
--- 127,147 ----
  
  static void
! glitz_agl_thread_info_destroy (glitz_agl_thread_info_t *thread_info)
  {
!   pthread_setspecific (info_tsd, NULL);
!   
!   if (thread_info) {
!     glitz_agl_thread_info_fini (thread_info);
!     free (thread_info);
!   }
! }
! 
! static void
! _tsd_destroy (void *p)
! {
!   if (p) {
!     glitz_agl_thread_info_fini ((glitz_agl_thread_info_t *) p);
!     free (p);
!   }
  }
  
***************
*** 140,144 ****
    
    if (!tsd_initialized) {
!     pthread_key_create (&info_tsd, glitz_agl_thread_info_destroy);
      tsd_initialized = 1;
    }
--- 153,157 ----
    
    if (!tsd_initialized) {
!     pthread_key_create (&info_tsd, _tsd_destroy);
      tsd_initialized = 1;
    }
***************
*** 176,179 ****
--- 189,199 ----
  };
  
+ static void
+ glitz_agl_thread_info_destroy (glitz_agl_thread_info_t *thread_info)
+ {
+   if (thread_info)
+     glitz_agl_thread_info_fini (thread_info);
+ }
+ 
  glitz_agl_thread_info_t *
  glitz_agl_thread_info_get (void)
***************
*** 278,282 ****
      glitz_agl_thread_info_get ();
  
!   glitz_agl_thread_info_fini (info);
  }
  slim_hidden_def(glitz_agl_fini);
--- 298,302 ----
      glitz_agl_thread_info_get ();
  
!   glitz_agl_thread_info_destroy (info);
  }
  slim_hidden_def(glitz_agl_fini);

Index: glitz_agl_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_surface.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** glitz_agl_surface.c	20 Jul 2004 07:51:14 -0000	1.12
--- glitz_agl_surface.c	24 Jul 2004 00:09:27 -0000	1.13
***************
*** 312,337 ****
  {
    glitz_agl_surface_t *surface = (glitz_agl_surface_t *) abstract_surface;
!   AGLContext context = aglGetCurrentContext ();
    
!   if (context == surface->context->context) {
!     if (surface->pbuffer) {
!       AGLPbuffer pbuffer;
!       GLuint unused;
!       
!       aglGetPBuffer (context, &pbuffer, &unused, &unused, &unused);
!       
!       if (pbuffer == surface->pbuffer)
!         glitz_agl_context_make_current (surface, 0);
!     } else if (surface->drawable) {
!       if (aglGetDrawable (context) == surface->drawable)
!         glitz_agl_context_make_current (surface, 0);
      }
    }
    
-   if (surface->pbuffer)
-     glitz_agl_pbuffer_destroy (surface->pbuffer);
-   
-   glitz_surface_fini (&surface->base);
-   
    free (surface);
  }
--- 312,340 ----
  {
    glitz_agl_surface_t *surface = (glitz_agl_surface_t *) abstract_surface;
! 
!   glitz_surface_fini (&surface->base);
    
!   if (surface->drawable || surface->pbuffer) {
!     AGLContext context = aglGetCurrentContext ();
!     
!     if (context == surface->context->context) { 
!       if (surface->pbuffer) {
!         AGLPbuffer pbuffer;
!         GLuint unused;
!         
!         aglGetPBuffer (context, &pbuffer, &unused, &unused, &unused);
!         
!         if (pbuffer == surface->pbuffer)
!           glitz_agl_context_make_current (surface, 0);
!       } else {
!         if (aglGetDrawable (context) == surface->drawable)
!           glitz_agl_context_make_current (surface, 0);
!       }
      }
+     
+     if (surface->pbuffer)
+       glitz_agl_pbuffer_destroy (surface->pbuffer);
    }
    
    free (surface);
  }

Index: glitz_glx_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_info.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** glitz_glx_info.c	20 Jul 2004 07:51:14 -0000	1.11
--- glitz_glx_info.c	24 Jul 2004 00:09:27 -0000	1.12
***************
*** 210,217 ****
  
  static void
! glitz_glx_thread_info_destroy (void *p)
  {
!   glitz_glx_thread_info_fini ((glitz_glx_thread_info_t *) p);
!   free (p);
  }
  
--- 210,230 ----
  
  static void
! glitz_glx_thread_info_destroy (glitz_glx_thread_info_t *thread_info)
  {
!   xthread_set_specific (info_tsd, NULL);
!   
!   if (thread_info) {
!     glitz_glx_thread_info_fini (thread_info);
!     free (thread_info);
!   }
! }
! 
! static void
! _tsd_destroy (void *p)
! {
!   if (p) {
!     glitz_glx_thread_info_fini ((glitz_glx_thread_info_t *) p);
!     free (p);
!   }
  }
  
***************
*** 223,227 ****
      
    if (!tsd_initialized) {
!     xthread_key_create (&info_tsd, glitz_glx_thread_info_destroy);
      tsd_initialized = 1;
    }
--- 236,240 ----
      
    if (!tsd_initialized) {
!     xthread_key_create (&info_tsd, _tsd_destroy);
      tsd_initialized = 1;
    }
***************
*** 265,274 ****
  };
  
  static glitz_glx_thread_info_t *
  glitz_glx_thread_info_get (char *gl_library)
  {
    if (!thread_info.glx.need_lookup) {
!     if (gl_library)
!       thread_info->gl_library = strdup (gl_library);
      
      glitz_glx_proc_address_lookup (&thread_info);
--- 278,301 ----
  };
  
+ static void
+ glitz_glx_thread_info_destroy (glitz_glx_thread_info_t *thread_info)
+ {
+   if (thread_info)
+     glitz_glx_thread_info_fini (thread_info);
+ }
+ 
  static glitz_glx_thread_info_t *
  glitz_glx_thread_info_get (char *gl_library)
  {
    if (!thread_info.glx.need_lookup) {
!     if (gl_library) {
!       int len = strlen (gl_library);
!       
!       thread_info->gl_library = malloc (len + 1);
!       if (thread_info->gl_library) {
!         memcpy (thread_info->gl_library, gl_library, len);
!         thread_info->gl_library[len] = '\0';
!       }
!     }
      
      glitz_glx_proc_address_lookup (&thread_info);
***************
*** 351,361 ****
    
    if (vinfo) {
      win_attrib.background_pixel = 0;
      win_attrib.border_pixel = 0;
      win_attrib.event_mask = StructureNotifyMask | ExposureMask;
!     win_attrib.colormap = XCreateColormap (display,
!                                            RootWindow (display, screen),
!                                            vinfo->visual, AllocNone);
!   
      screen_info->root_drawable =
        XCreateWindow (display, RootWindow (display, screen),
--- 378,389 ----
    
    if (vinfo) {
+     screen_info->root_colormap = XCreateColormap (display,
+                                                   RootWindow (display, screen),
+                                                   vinfo->visual, AllocNone);
      win_attrib.background_pixel = 0;
      win_attrib.border_pixel = 0;
      win_attrib.event_mask = StructureNotifyMask | ExposureMask;
!     win_attrib.colormap = screen_info->root_colormap;
! 
      screen_info->root_drawable =
        XCreateWindow (display, RootWindow (display, screen),
***************
*** 486,489 ****
--- 514,520 ----
      XDestroyWindow (display, screen_info->root_drawable);
  
+   if (screen_info->root_colormap)
+     XFreeColormap (display, screen_info->root_colormap);
+ 
    free (screen_info);
  }
***************
*** 502,506 ****
      glitz_glx_thread_info_get (NULL);
  
!   glitz_glx_thread_info_fini (info);
  }
  slim_hidden_def(glitz_glx_fini);
--- 533,537 ----
      glitz_glx_thread_info_get (NULL);
  
!   glitz_glx_thread_info_destroy (info);
  }
  slim_hidden_def(glitz_glx_fini);

Index: glitz_glx_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_surface.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** glitz_glx_surface.c	20 Jul 2004 07:51:14 -0000	1.14
--- glitz_glx_surface.c	24 Jul 2004 00:09:27 -0000	1.15
***************
*** 359,376 ****
    glitz_glx_surface_t *surface = (glitz_glx_surface_t *) abstract_surface;
  
!   glitz_surface_push_current (&surface->base, GLITZ_CN_ANY_CONTEXT_CURRENT);
! 
!   if (surface->pbuffer)
!     glitz_glx_pbuffer_destroy (surface->screen_info->display_info,
!                                surface->pbuffer);
    
!   glitz_surface_pop_current (&surface->base);
! 
!   if (glXGetCurrentDrawable () == surface->drawable) {
      surface->drawable = None;
      glitz_glx_context_make_current (surface, 0);
    }
!   
!   glitz_surface_fini (&surface->base);
    
    free (surface);
--- 359,373 ----
    glitz_glx_surface_t *surface = (glitz_glx_surface_t *) abstract_surface;
  
!   glitz_surface_fini (&surface->base);
    
!   if (surface->drawable &&
!       (glXGetCurrentDrawable () == surface->drawable)) {
      surface->drawable = None;
      glitz_glx_context_make_current (surface, 0);
    }
! 
!   if (surface->pbuffer)
!     glitz_glx_pbuffer_destroy (surface->screen_info->display_info,
!                                surface->pbuffer);
    
    free (surface);

Index: glitz_glxint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glxint.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** glitz_glxint.h	20 Jul 2004 07:51:14 -0000	1.10
--- glitz_glxint.h	24 Jul 2004 00:09:27 -0000	1.11
***************
*** 119,122 ****
--- 119,123 ----
    glitz_glx_context_t root_context;
    GLXDrawable root_drawable;
+   Colormap root_colormap;
  
    long int feature_mask;

Index: glitz_programmatic.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_programmatic.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** glitz_programmatic.c	20 Jul 2004 07:51:14 -0000	1.10
--- glitz_programmatic.c	24 Jul 2004 00:09:27 -0000	1.11
***************
*** 141,144 ****
--- 141,145 ----
      surface->base.texture.height = MAXSHORT;
    surface->base.texture.repeatable = surface->base.texture.repeat = 1;
+   surface->base.texture.allocated = 1;
    surface->matrix = identity;
    

Index: glitz_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_surface.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** glitz_surface.c	20 Jul 2004 07:51:14 -0000	1.15
--- glitz_surface.c	24 Jul 2004 00:09:27 -0000	1.16
***************
*** 80,85 ****
  glitz_surface_fini (glitz_surface_t *surface)
  {
!   if (surface->gl)
      glitz_texture_fini (surface->gl, &surface->texture);
    
    if (surface->transform)
--- 80,88 ----
  glitz_surface_fini (glitz_surface_t *surface)
  {
!   if (surface->texture.name) {
!     glitz_surface_push_current (surface, GLITZ_CN_ANY_CONTEXT_CURRENT);
      glitz_texture_fini (surface->gl, &surface->texture);
+     glitz_surface_pop_current (surface);
+   }
    
    if (surface->transform)




More information about the cairo-commit mailing list