summaryrefslogtreecommitdiff
path: root/src/cairo-xcb-connection.c
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2014-12-06 16:04:46 +0100
committerUli Schlachter <psychon@znc.in>2015-01-17 20:11:59 +0100
commitb47209a03feeed2172f35a6d79ba1176fedd5e17 (patch)
tree694595b113636933a3f91c7f92ee0bcff0bd4169 /src/cairo-xcb-connection.c
parent02e4efc961be40d266d4df0acaf3271219529017 (diff)
downloadcairo-b47209a03feeed2172f35a6d79ba1176fedd5e17.tar.gz
xcb: Query the display's subpixel order via RENDER
With commit e691d242, the xcb backend started parsing the resources, just like cairo-xlib does. One behavior from cairo-xlib was missing: If no Xft.rgba property was specified, cairo-xlib defaults to the screen's subpixel order. This commit brings that last bit of functionality to cairo-xcb (but currently disabled due to commit e0c0a673). This commits adds a new array to cairo_xcb_connection_t that contains the subpixel order for each screen. There is also a new member in cairo_xcb_screen_t which contains the subpixel order of that screen and which is initialized from the array when the screen is constructed. With this in place, the resource-parsing code can just pick the subpixel order from the screen if needed. Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'src/cairo-xcb-connection.c')
-rw-r--r--src/cairo-xcb-connection.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index 2d51e1449..67897fa4e 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -79,6 +79,7 @@ typedef struct _cairo_xcb_xid {
#define XCB_RENDER_HAS_FILTERS(surface) XCB_RENDER_AT_LEAST((surface), 0, 6)
#define XCB_RENDER_HAS_FILTER_GOOD(surface) FALSE
#define XCB_RENDER_HAS_FILTER_BEST(surface) FALSE
+#define XCB_RENDER_HAS_SUBPIXEL_ORDER(surface) XCB_RENDER_AT_LEAST((surface), 0, 6)
#define XCB_RENDER_HAS_EXTENDED_REPEAT(surface) XCB_RENDER_AT_LEAST((surface), 0, 10)
#define XCB_RENDER_HAS_GRADIENTS(surface) XCB_RENDER_AT_LEAST((surface), 0, 10)
@@ -407,6 +408,15 @@ _cairo_xcb_connection_query_render (cairo_xcb_connection_t *connection)
if (XCB_RENDER_HAS_GRADIENTS (version))
connection->flags |= CAIRO_XCB_RENDER_HAS_GRADIENTS;
+ if (XCB_RENDER_HAS_SUBPIXEL_ORDER (version)) {
+ uint32_t screen;
+ uint32_t *subpixel = xcb_render_query_pict_formats_subpixels(formats);
+
+ /* The spec explicitly allows to have too few entries in the reply... */
+ for (screen = 0; screen < formats->num_subpixel && screen < connection->root->roots_len; screen++)
+ connection->subpixel_orders[screen] = subpixel[screen];
+ }
+
free (version);
status = _cairo_xcb_connection_parse_xrender_formats (connection, formats);
@@ -581,6 +591,7 @@ _device_destroy (void *device)
CAIRO_MUTEX_FINI (connection->shm_mutex);
CAIRO_MUTEX_FINI (connection->screens_mutex);
+ free (connection->subpixel_orders);
free (connection);
}
@@ -684,6 +695,14 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
connection->root = xcb_get_setup (xcb_connection);
connection->render = NULL;
+ connection->subpixel_orders = calloc (connection->root->roots_len, sizeof(*connection->subpixel_orders));
+ if (unlikely (connection->subpixel_orders == NULL)) {
+ CAIRO_MUTEX_UNLOCK (connection->device.mutex);
+ _cairo_xcb_connection_destroy (connection);
+ connection = NULL;
+ goto unlock;
+ }
+
ext = xcb_get_extension_data (xcb_connection, &xcb_render_id);
if (ext != NULL && ext->present) {
status = _cairo_xcb_connection_query_render (connection);