[cairo] [PATCH] xcb: Query the display's subpixel order via RENDER

Uli Schlachter psychon at znc.in
Sat Dec 6 08:10:33 PST 2014


Am 06.12.2014 um 16:13 schrieb Uli Schlachter:
[...]
> +static int _get_screen_index(cairo_xcb_connection_t *xcb_connection,
> +			     xcb_screen_t *xcb_screen)
> +{
> +    int idx = 0;
> +    xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_connection->root);
> +    for (; iter.rem; xcb_screen_next(&iter), idx++)
> +	if (iter.data == xcb_screen)
> +	    return idx;
> +
> +    ASSERT_NOT_REACHED;
> +}
[...]

If only things were so easy...

I changed the "if" in this function to:

  if (iter.data->root == xcb_screen->root)

The reason for this is left as an exercise for the reader.
Oh and I also have another, completely unrelated patch.

Cheers,
Uli


>From c068f67ecaa5d756fcad249fea3745daae65d210 Mon Sep 17 00:00:00 2001
From: Uli Schlachter <psychon at znc.in>
Date: Sat, 6 Dec 2014 17:04:07 +0100
Subject: [PATCH] xlib-xcb: Don't be lazy and use the real xcb_screen_t

Signed-off-by: Uli Schlachter <psychon at znc.in>
---
 src/cairo-xlib-xcb-surface.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/src/cairo-xlib-xcb-surface.c b/src/cairo-xlib-xcb-surface.c
index 9c0d4b4..af3e155 100644
--- a/src/cairo-xlib-xcb-surface.c
+++ b/src/cairo-xlib-xcb-surface.c
@@ -519,21 +519,6 @@ cairo_xlib_surface_create (Display     *dpy,
 								     width, height));
 }
 
-cairo_surface_t *
-cairo_xlib_surface_create_for_bitmap (Display  *dpy,
-				      Pixmap	bitmap,
-				      Screen   *scr,
-				      int	width,
-				      int	height)
-{
-    return _cairo_xlib_xcb_surface_create (dpy, scr, NULL, NULL,
-					   cairo_xcb_surface_create_for_bitmap (XGetXCBConnection (dpy),
-										(xcb_screen_t *) scr,
-										bitmap,
-										width, height));
-}
-
-#if CAIRO_HAS_XLIB_XRENDER_SURFACE
 static xcb_screen_t *
 _cairo_xcb_screen_from_root (xcb_connection_t *connection,
 			     xcb_window_t id)
@@ -548,6 +533,24 @@ _cairo_xcb_screen_from_root (xcb_connection_t *connection,
 
     return NULL;
 }
+
+cairo_surface_t *
+cairo_xlib_surface_create_for_bitmap (Display  *dpy,
+				      Pixmap	bitmap,
+				      Screen   *scr,
+				      int	width,
+				      int	height)
+{
+    xcb_connection_t *connection = XGetXCBConnection (dpy);
+    xcb_screen_t *screen = _cairo_xcb_screen_from_root (connection, (xcb_window_t) scr->root);
+    return _cairo_xlib_xcb_surface_create (dpy, scr, NULL, NULL,
+					   cairo_xcb_surface_create_for_bitmap (connection,
+										screen,
+										bitmap,
+										width, height));
+}
+
+#if CAIRO_HAS_XLIB_XRENDER_SURFACE
 cairo_surface_t *
 cairo_xlib_surface_create_with_xrender_format (Display		    *dpy,
 					       Drawable		    drawable,
-- 
2.1.3



More information about the cairo mailing list