[Cogl] [PATCH 1/2] x11: Replace all internal usage of cogl_xlib_get_display()

Damien Lespiau damien.lespiau at gmail.com
Mon Nov 5 05:56:37 PST 2012


From: Damien Lespiau <damien.lespiau at intel.com>

And use the renderer replacement, cogl_xlib_renderer_get_display()
---
 cogl/cogl-xlib.c                      |    6 +++---
 cogl/winsys/cogl-texture-pixmap-x11.c |   22 ++++++++++++++++------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/cogl/cogl-xlib.c b/cogl/cogl-xlib.c
index 53078d9..f68dd2d 100644
--- a/cogl/cogl-xlib.c
+++ b/cogl/cogl-xlib.c
@@ -86,13 +86,13 @@ void
 _cogl_xlib_query_damage_extension (void)
 {
   int damage_error;
+  Display *display;
 
   _COGL_GET_CONTEXT (ctxt, NO_RETVAL);
 
   /* Check whether damage events are supported on this display */
-  if (!XDamageQueryExtension (cogl_xlib_get_display (),
-                              &ctxt->damage_base,
-                              &damage_error))
+  display = cogl_xlib_renderer_get_display (ctxt->display->renderer);
+  if (!XDamageQueryExtension (display, &ctxt->damage_base, &damage_error))
     ctxt->damage_base = -1;
 }
 
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c
index 397cda3..9b72499 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -130,7 +130,7 @@ process_damage_event (CoglTexturePixmapX11 *tex_pixmap,
 
   _COGL_GET_CONTEXT (ctxt, NO_RETVAL);
 
-  display = cogl_xlib_get_display ();
+  display = cogl_xlib_renderer_get_display (ctxt->display->renderer);
 
   COGL_NOTE (TEXTURE_PIXMAP, "Damage event received for %p", tex_pixmap);
 
@@ -248,6 +248,8 @@ set_damage_object_internal (CoglContext *ctx,
                             Damage damage,
                             CoglTexturePixmapX11ReportLevel report_level)
 {
+  Display *display = cogl_xlib_renderer_get_display (ctx->display->renderer);
+
   if (tex_pixmap->damage)
     {
       cogl_xlib_renderer_remove_filter (ctx->display->renderer,
@@ -256,7 +258,7 @@ set_damage_object_internal (CoglContext *ctx,
 
       if (tex_pixmap->damage_owned)
         {
-          XDamageDestroy (cogl_xlib_get_display (), tex_pixmap->damage);
+          XDamageDestroy (display, tex_pixmap->damage);
           tex_pixmap->damage_owned = FALSE;
         }
     }
@@ -277,7 +279,7 @@ cogl_texture_pixmap_x11_new (CoglContext *ctxt,
                              CoglError **error)
 {
   CoglTexturePixmapX11 *tex_pixmap = g_new (CoglTexturePixmapX11, 1);
-  Display *display = cogl_xlib_get_display ();
+  Display *display = cogl_xlib_renderer_get_display (ctxt->display->renderer);
   Window pixmap_root_window;
   int pixmap_x, pixmap_y;
   unsigned int pixmap_border_width;
@@ -366,7 +368,9 @@ try_alloc_shm (CoglTexturePixmapX11 *tex_pixmap)
   XImage *dummy_image;
   Display *display;
 
-  display = cogl_xlib_get_display ();
+  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+  display = cogl_xlib_renderer_get_display (ctx->display->renderer);
 
   if (!XShmQueryExtension (display))
     return;
@@ -481,7 +485,9 @@ _cogl_texture_pixmap_x11_update_image_texture (CoglTexturePixmapX11 *tex_pixmap)
   int src_x, src_y;
   int x, y, width, height;
 
-  display = cogl_xlib_get_display ();
+  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
+  display = cogl_xlib_renderer_get_display (ctx->display->renderer);
   visual = tex_pixmap->visual;
 
   /* If the damage region is empty then there's nothing to do */
@@ -956,8 +962,12 @@ _cogl_texture_pixmap_x11_get_type (CoglTexture *tex)
 static void
 _cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
 {
+  Display *display;
+
   _COGL_GET_CONTEXT (ctxt, NO_RETVAL);
 
+  display = cogl_xlib_renderer_get_display (ctxt->display->renderer);
+
   set_damage_object_internal (ctxt, tex_pixmap, 0, 0);
 
   if (tex_pixmap->image)
@@ -965,7 +975,7 @@ _cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
 
   if (tex_pixmap->shm_info.shmid != -1)
     {
-      XShmDetach (cogl_xlib_get_display (), &tex_pixmap->shm_info);
+      XShmDetach (display, &tex_pixmap->shm_info);
       shmdt (tex_pixmap->shm_info.shmaddr);
       shmctl (tex_pixmap->shm_info.shmid, IPC_RMID, 0);
     }
-- 
1.7.7.5



More information about the Cogl mailing list