aboutsummaryrefslogtreecommitdiff
path: root/depends/libxcb-render-util
diff options
context:
space:
mode:
Diffstat (limited to 'depends/libxcb-render-util')
-rw-r--r--depends/libxcb-render-util/xcb/cache.c234
-rw-r--r--depends/libxcb-render-util/xcb/glyph.c293
-rw-r--r--depends/libxcb-render-util/xcb/util.c255
-rw-r--r--depends/libxcb-render-util/xcb/xcb_renderutil.h150
4 files changed, 932 insertions, 0 deletions
diff --git a/depends/libxcb-render-util/xcb/cache.c b/depends/libxcb-render-util/xcb/cache.c
new file mode 100644
index 0000000..c04fb50
--- /dev/null
+++ b/depends/libxcb-render-util/xcb/cache.c
@@ -0,0 +1,234 @@
+/* Copyright © 2006 Jamey Sharp.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the authors or their
+ * institutions shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the authors.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "xcb_renderutil.h"
+#include <stdlib.h>
+#include <pthread.h>
+
+typedef struct connection_cache {
+ struct connection_cache *next; /* keep a linked list */
+ xcb_connection_t *c; /* which display this is */
+ xcb_render_query_version_reply_t *version;
+ xcb_render_query_pict_formats_reply_t *formats;
+} connection_cache;
+
+static struct {
+ pthread_mutex_t lock;
+ connection_cache *head; /* start of the list */
+ connection_cache *cur; /* most recently used */
+} connections = { PTHREAD_MUTEX_INITIALIZER };
+
+/*
+ * If the server is missing support for any of the required depths on
+ * any screen, tell the application that Render is not present.
+ */
+
+#define DEPTH_MASK(d) (1U << ((d) - 1))
+
+/*
+ * Render requires support for depth 1, 4, 8, 24 and 32 pixmaps
+ */
+
+#define REQUIRED_DEPTHS (DEPTH_MASK(1) | \
+ DEPTH_MASK(4) | \
+ DEPTH_MASK(8) | \
+ DEPTH_MASK(24) | \
+ DEPTH_MASK(32))
+
+/* Test each depth not explicitly advertised to see if pixmap creation
+ * succeeds: if it does, that depth is usable. */
+static int
+pixmap_depths_usable (xcb_connection_t *c, uint32_t missing, xcb_pixmap_t pixmap, xcb_drawable_t root)
+{
+ xcb_void_cookie_t create_cookie[32] = { { 0 } };
+ xcb_void_cookie_t free_cookie[32] = { { 0 } };
+ int d;
+ int success = 1;
+ for (d = 1; d <= 32; d++)
+ if (missing & DEPTH_MASK(d))
+ {
+ create_cookie[d - 1] = xcb_create_pixmap_checked (c, d, pixmap, root, 1, 1);
+ free_cookie[d - 1] = xcb_free_pixmap_checked (c, pixmap);
+ if (!create_cookie[d - 1].sequence || !free_cookie[d - 1].sequence)
+ {
+ success = 0;
+ break;
+ }
+ }
+ for (d = 0; d < 32; d++)
+ if (create_cookie[d].sequence || free_cookie[d].sequence)
+ {
+ xcb_generic_error_t *create_error = xcb_request_check (c, create_cookie[d]);
+ xcb_generic_error_t *free_error = xcb_request_check (c, free_cookie[d]);
+ success = success && !create_error;
+ free(create_error);
+ free(free_error);
+ }
+ return success;
+}
+
+static int
+has_required_depths (xcb_connection_t *c)
+{
+ xcb_screen_iterator_t screens;
+ xcb_pixmap_t pixmap = { -1 };
+ for (screens = xcb_setup_roots_iterator(xcb_get_setup(c)); screens.rem; xcb_screen_next(&screens))
+ {
+ xcb_depth_iterator_t depths;
+ uint32_t missing = REQUIRED_DEPTHS;
+ xcb_drawable_t root;
+
+ for (depths = xcb_screen_allowed_depths_iterator(screens.data); depths.rem; xcb_depth_next(&depths))
+ missing &= ~DEPTH_MASK(depths.data->depth);
+ if (!missing)
+ continue;
+
+ /*
+ * Ok, this is ugly. It should be sufficient at this
+ * point to just return false, but Xinerama is broken at
+ * this point and only advertises depths which have an
+ * associated visual. Of course, the other depths still
+ * work, but the only way to find out is to try them.
+ */
+ if (pixmap == -1)
+ pixmap = xcb_generate_id(c);
+ root = screens.data->root;
+ if (!pixmap_depths_usable (c, missing, pixmap, root))
+ return 0;
+ }
+ return 1;
+}
+
+static connection_cache *
+find_or_create_display (xcb_connection_t *c)
+{
+ connection_cache *info;
+ xcb_render_query_version_cookie_t version_cookie;
+ xcb_render_query_pict_formats_cookie_t formats_cookie;
+ int present;
+
+ /*
+ * look for display in list
+ */
+ for (info = connections.head; info; info = info->next)
+ if (info->c == c) {
+ connections.cur = info; /* cache most recently used */
+ return info;
+ }
+
+ /*
+ * don't already have this display: add it.
+ */
+ info = malloc (sizeof (connection_cache));
+ if (!info)
+ return NULL;
+ info->c = c;
+
+ version_cookie = xcb_render_query_version(c, 0, 10);
+ formats_cookie = xcb_render_query_pict_formats(c);
+ xcb_flush(c);
+ present = has_required_depths (c);
+ info->version = xcb_render_query_version_reply(c, version_cookie, 0);
+ info->formats = xcb_render_query_pict_formats_reply(c, formats_cookie, 0);
+
+ if (!present || !info->version || !info->formats)
+ {
+ free(info->version);
+ info->version = 0;
+ free(info->formats);
+ info->formats = 0;
+ }
+ /* Check for the lack of sub-pixel data */
+ else if (info->version->major_version == 0 && info->version->minor_version < 6)
+ info->formats->num_subpixel = 0;
+
+ /*
+ * now, chain it onto the list
+ */
+ info->next = connections.head;
+ connections.head = info;
+ connections.cur = info;
+
+ return info;
+}
+
+static connection_cache *
+find_display (xcb_connection_t *c)
+{
+ connection_cache *info;
+
+ /*
+ * see if this was the most recently accessed display
+ */
+ if ((info = connections.cur) && info->c == c)
+ return info;
+
+ pthread_mutex_lock(&connections.lock);
+ info = find_or_create_display (c);
+ pthread_mutex_unlock(&connections.lock);
+ return info;
+}
+
+const xcb_render_query_version_reply_t *
+xcb_render_util_query_version (xcb_connection_t *c)
+{
+ connection_cache *info = find_display (c);
+ if (!info)
+ return 0;
+ return info->version;
+}
+
+const xcb_render_query_pict_formats_reply_t *
+xcb_render_util_query_formats (xcb_connection_t *c)
+{
+ connection_cache *info = find_display (c);
+ if (!info)
+ return 0;
+ return info->formats;
+}
+
+int
+xcb_render_util_disconnect (xcb_connection_t *c)
+{
+ connection_cache **prev, *cur = NULL;
+ pthread_mutex_lock(&connections.lock);
+ for(prev = &connections.head; *prev; prev = &(*prev)->next)
+ if((*prev)->c == c)
+ {
+ cur = *prev;
+ *prev = cur->next;
+ if(cur == connections.cur)
+ connections.cur = NULL; /* flush cache */
+ free(cur->version);
+ free(cur->formats);
+ free(cur);
+ break;
+ }
+ pthread_mutex_unlock(&connections.lock);
+ return cur != NULL;
+}
diff --git a/depends/libxcb-render-util/xcb/glyph.c b/depends/libxcb-render-util/xcb/glyph.c
new file mode 100644
index 0000000..d19fba6
--- /dev/null
+++ b/depends/libxcb-render-util/xcb/glyph.c
@@ -0,0 +1,293 @@
+/* Copyright © 2006 Ian Osgood
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the authors or their
+ * institutions shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the authors.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "xcb_renderutil.h"
+
+typedef struct _glyph_header_t {
+ uint8_t count;
+ uint8_t pad0[3];
+ int16_t dx, dy;
+} _glyph_header_t;
+
+/* implementation of the opaque stream */
+struct xcb_render_util_composite_text_stream_t {
+ /* state info */
+ uint32_t glyph_size; /* 0 for unset, 1/2/4 for 8/16/32 */
+ xcb_render_glyphset_t initial_glyphset;
+ xcb_render_glyphset_t current_glyphset;
+
+ /* dynamically allocated stream */
+ /* contents are 32-bit aligned, network byte order */
+ size_t stream_len;
+ uint32_t *stream;
+ uint32_t *current;
+};
+
+#define CURRENT_LEN(s) (((char *)s->current - (char *)s->stream))
+
+xcb_render_util_composite_text_stream_t *
+xcb_render_util_composite_text_stream (
+ xcb_render_glyphset_t initial_glyphset,
+ uint32_t total_glyphs,
+ uint32_t total_glyphset_changes )
+{
+ xcb_render_util_composite_text_stream_t *stream;
+ size_t size = 32;
+
+ /* assume worst case: each glyph has its own dx,dy */
+ if (total_glyphs || total_glyphset_changes) {
+ size = total_glyphs * 3 * sizeof(uint32_t)
+ + total_glyphset_changes * 3 * sizeof(uint32_t);
+ }
+
+ stream = malloc(sizeof(xcb_render_util_composite_text_stream_t));
+ if (!stream)
+ return NULL;
+
+ stream->glyph_size = 0;
+ stream->initial_glyphset = initial_glyphset;
+ stream->current_glyphset = initial_glyphset;
+
+ stream->stream_len = size;
+ stream->stream = malloc(size);
+ stream->current = stream->stream;
+
+ return stream;
+}
+
+static void
+_grow_stream( xcb_render_util_composite_text_stream_t *stream, size_t increase )
+{
+ size_t current_len = CURRENT_LEN(stream);
+ if (current_len + increase > stream->stream_len) {
+ uint32_t *s = realloc(stream->stream, 2 * stream->stream_len);
+ if (s != NULL) {
+ stream->stream_len *= 2;
+ stream->stream = s;
+ stream->current = stream->stream + (current_len>>2);
+ }
+ }
+}
+
+void
+xcb_render_util_glyphs_8 (
+ xcb_render_util_composite_text_stream_t *stream,
+ int16_t dx,
+ int16_t dy,
+ uint32_t count,
+ const uint8_t *glyphs )
+{
+ _glyph_header_t header = { count, {0,0,0}, dx, dy };
+
+ if (count > 252) return; /* FIXME */
+
+ if (stream->glyph_size != sizeof(*glyphs)) {
+ if (stream->glyph_size != 0)
+ return;
+ stream->glyph_size = sizeof(*glyphs);
+ }
+ _grow_stream(stream, sizeof(header) + count+3);
+
+ memcpy(stream->current, &header, sizeof(header));
+ stream->current += 2;
+
+ memcpy(stream->current, glyphs, header.count);
+ stream->current += ((int)header.count+3)>>2;
+}
+
+void
+xcb_render_util_glyphs_16 (
+ xcb_render_util_composite_text_stream_t *stream,
+ int16_t dx,
+ int16_t dy,
+ uint32_t count,
+ const uint16_t *glyphs )
+{
+ _glyph_header_t header = { count, {0,0,0}, dx, dy };
+
+ if (count > 254) return; /* FIXME */
+
+ if (stream->glyph_size != sizeof(*glyphs)) {
+ if (stream->glyph_size != 0)
+ return;
+ stream->glyph_size = sizeof(*glyphs);
+ }
+ _grow_stream(stream, sizeof(header) + count*sizeof(*glyphs)+1);
+
+ memcpy(stream->current, &header, sizeof(header));
+ stream->current += 2;
+
+ memcpy(stream->current, glyphs, header.count*sizeof(*glyphs));
+ stream->current += ((int)header.count*sizeof(*glyphs)+3)>>2;
+}
+
+void
+xcb_render_util_glyphs_32 (
+ xcb_render_util_composite_text_stream_t *stream,
+ int16_t dx,
+ int16_t dy,
+ uint32_t count,
+ const uint32_t *glyphs )
+{
+ _glyph_header_t header = { count, {0,0,0}, dx, dy };
+
+ if (count > 254) return; /* FIXME */
+
+ if (stream->glyph_size != sizeof(*glyphs)) {
+ if (stream->glyph_size != 0)
+ return;
+ stream->glyph_size = sizeof(*glyphs);
+ }
+ _grow_stream(stream, sizeof(header) + count*sizeof(*glyphs)+1);
+
+ memcpy(stream->current, &header, sizeof(header));
+ stream->current += 2;
+
+ memcpy(stream->current, glyphs, header.count*sizeof(*glyphs));
+ stream->current += header.count;
+}
+
+/* note: these glyph arrays must be swapped to network byte order */
+
+void
+xcb_render_util_change_glyphset (
+ xcb_render_util_composite_text_stream_t *stream,
+ xcb_render_glyphset_t glyphset )
+{
+ static _glyph_header_t header = { 255, {0,0,0}, 0, 0 };
+
+ if (glyphset == stream->current_glyphset)
+ return;
+
+ _grow_stream(stream, 3*sizeof(uint32_t));
+
+ memcpy(stream->current, &header, sizeof(header));
+ stream->current += 2;
+
+ *stream->current = glyphset;
+ stream->current++;
+
+ stream->current_glyphset = glyphset;
+}
+
+typedef xcb_void_cookie_t
+(*xcb_render_composite_glyphs_func) (xcb_connection_t *c,
+ uint8_t op,
+ xcb_render_picture_t src,
+ xcb_render_picture_t dst,
+ xcb_render_pictformat_t mask_format,
+ xcb_render_glyphset_t glyphset,
+ int16_t src_x,
+ int16_t src_y,
+ uint32_t glyphcmds_len,
+ const uint8_t *glyphcmds);
+
+
+xcb_void_cookie_t
+xcb_render_util_composite_text (
+ xcb_connection_t *xc,
+ uint8_t op,
+ xcb_render_picture_t src,
+ xcb_render_picture_t dst,
+ xcb_render_pictformat_t mask_format,
+ int16_t src_x,
+ int16_t src_y,
+ xcb_render_util_composite_text_stream_t *stream )
+{
+ xcb_render_composite_glyphs_func f;
+
+ switch (stream->glyph_size)
+ {
+ case 1:
+ f = xcb_render_composite_glyphs_8;
+ break;
+ case 2:
+ f = xcb_render_composite_glyphs_16;
+ break;
+ case 4:
+ f = xcb_render_composite_glyphs_32;
+ break;
+ default: /* uninitialized */
+ return xcb_no_operation(xc);
+ }
+ return f(
+ xc, op, src, dst, mask_format,
+ stream->initial_glyphset,
+ src_x, src_y,
+ CURRENT_LEN(stream),
+ (uint8_t *)stream->stream
+ );
+}
+
+xcb_void_cookie_t
+xcb_render_util_composite_text_checked (
+ xcb_connection_t *xc,
+ uint8_t op,
+ xcb_render_picture_t src,
+ xcb_render_picture_t dst,
+ xcb_render_pictformat_t mask_format,
+ int16_t src_x,
+ int16_t src_y,
+ xcb_render_util_composite_text_stream_t *stream )
+{
+ xcb_render_composite_glyphs_func f;
+
+ switch (stream->glyph_size)
+ {
+ case 1:
+ f = xcb_render_composite_glyphs_8_checked;
+ break;
+ case 2:
+ f = xcb_render_composite_glyphs_16_checked;
+ break;
+ case 4:
+ f = xcb_render_composite_glyphs_32_checked;
+ break;
+ default: /* uninitialized */
+ return xcb_no_operation_checked(xc);
+ }
+ return f(
+ xc, op, src, dst, mask_format,
+ stream->initial_glyphset,
+ src_x, src_y,
+ CURRENT_LEN(stream),
+ (uint8_t *)stream->stream
+ );
+}
+
+void
+xcb_render_util_composite_text_free (
+ xcb_render_util_composite_text_stream_t *stream )
+{
+ free(stream->stream);
+ free(stream);
+}
diff --git a/depends/libxcb-render-util/xcb/util.c b/depends/libxcb-render-util/xcb/util.c
new file mode 100644
index 0000000..7666c43
--- /dev/null
+++ b/depends/libxcb-render-util/xcb/util.c
@@ -0,0 +1,255 @@
+/* Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xcb_renderutil.h"
+
+xcb_render_pictvisual_t *
+xcb_render_util_find_visual_format (const xcb_render_query_pict_formats_reply_t *formats,
+ const xcb_visualid_t visual)
+{
+ xcb_render_pictscreen_iterator_t screens;
+ xcb_render_pictdepth_iterator_t depths;
+ xcb_render_pictvisual_iterator_t visuals;
+ if (!formats)
+ return 0;
+ for (screens = xcb_render_query_pict_formats_screens_iterator(formats); screens.rem; xcb_render_pictscreen_next(&screens))
+ for (depths = xcb_render_pictscreen_depths_iterator(screens.data); depths.rem; xcb_render_pictdepth_next(&depths))
+ for (visuals = xcb_render_pictdepth_visuals_iterator(depths.data); visuals.rem; xcb_render_pictvisual_next(&visuals))
+ if (visuals.data->visual == visual)
+ return visuals.data;
+ return 0;
+}
+
+xcb_render_pictforminfo_t *
+xcb_render_util_find_format (const xcb_render_query_pict_formats_reply_t *formats,
+ unsigned long mask,
+ const xcb_render_pictforminfo_t *ptemplate,
+ int count)
+{
+ xcb_render_pictforminfo_iterator_t i;
+ if (!formats)
+ return 0;
+ for (i = xcb_render_query_pict_formats_formats_iterator(formats); i.rem; xcb_render_pictforminfo_next(&i))
+ {
+ if (mask & XCB_PICT_FORMAT_ID)
+ if (ptemplate->id != i.data->id)
+ continue;
+ if (mask & XCB_PICT_FORMAT_TYPE)
+ if (ptemplate->type != i.data->type)
+ continue;
+ if (mask & XCB_PICT_FORMAT_DEPTH)
+ if (ptemplate->depth != i.data->depth)
+ continue;
+ if (mask & XCB_PICT_FORMAT_RED)
+ if (ptemplate->direct.red_shift != i.data->direct.red_shift)
+ continue;
+ if (mask & XCB_PICT_FORMAT_RED_MASK)
+ if (ptemplate->direct.red_mask != i.data->direct.red_mask)
+ continue;
+ if (mask & XCB_PICT_FORMAT_GREEN)
+ if (ptemplate->direct.green_shift != i.data->direct.green_shift)
+ continue;
+ if (mask & XCB_PICT_FORMAT_GREEN_MASK)
+ if (ptemplate->direct.green_mask != i.data->direct.green_mask)
+ continue;
+ if (mask & XCB_PICT_FORMAT_BLUE)
+ if (ptemplate->direct.blue_shift != i.data->direct.blue_shift)
+ continue;
+ if (mask & XCB_PICT_FORMAT_BLUE_MASK)
+ if (ptemplate->direct.blue_mask != i.data->direct.blue_mask)
+ continue;
+ if (mask & XCB_PICT_FORMAT_ALPHA)
+ if (ptemplate->direct.alpha_shift != i.data->direct.alpha_shift)
+ continue;
+ if (mask & XCB_PICT_FORMAT_ALPHA_MASK)
+ if (ptemplate->direct.alpha_mask != i.data->direct.alpha_mask)
+ continue;
+ if (mask & XCB_PICT_FORMAT_COLORMAP)
+ if (ptemplate->colormap != i.data->colormap)
+ continue;
+ if (count-- == 0)
+ return i.data;
+ }
+ return 0;
+}
+
+xcb_render_pictforminfo_t *
+xcb_render_util_find_standard_format (const xcb_render_query_pict_formats_reply_t *formats,
+ xcb_pict_standard_t format)
+{
+ static const struct {
+ xcb_render_pictforminfo_t templ;
+ unsigned long mask;
+ } standardFormats[] = {
+ /* XCB_PICT_STANDARD_ARGB_32 */
+ {
+ {
+ 0, /* id */
+ XCB_RENDER_PICT_TYPE_DIRECT, /* type */
+ 32, /* depth */
+ { 0 }, /* pad */
+ { /* direct */
+ 16, /* direct.red */
+ 0xff, /* direct.red_mask */
+ 8, /* direct.green */
+ 0xff, /* direct.green_mask */
+ 0, /* direct.blue */
+ 0xff, /* direct.blue_mask */
+ 24, /* direct.alpha */
+ 0xff, /* direct.alpha_mask */
+ },
+ 0, /* colormap */
+ },
+ XCB_PICT_FORMAT_TYPE |
+ XCB_PICT_FORMAT_DEPTH |
+ XCB_PICT_FORMAT_RED |
+ XCB_PICT_FORMAT_RED_MASK |
+ XCB_PICT_FORMAT_GREEN |
+ XCB_PICT_FORMAT_GREEN_MASK |
+ XCB_PICT_FORMAT_BLUE |
+ XCB_PICT_FORMAT_BLUE_MASK |
+ XCB_PICT_FORMAT_ALPHA |
+ XCB_PICT_FORMAT_ALPHA_MASK,
+ },
+ /* XCB_PICT_STANDARD_RGB_24 */
+ {
+ {
+ 0, /* id */
+ XCB_RENDER_PICT_TYPE_DIRECT, /* type */
+ 24, /* depth */
+ { 0 }, /* pad */
+ { /* direct */
+ 16, /* direct.red */
+ 0xff, /* direct.red_MASK */
+ 8, /* direct.green */
+ 0xff, /* direct.green_MASK */
+ 0, /* direct.blue */
+ 0xff, /* direct.blue_MASK */
+ 0, /* direct.alpha */
+ 0x00, /* direct.alpha_MASK */
+ },
+ 0, /* colormap */
+ },
+ XCB_PICT_FORMAT_TYPE |
+ XCB_PICT_FORMAT_DEPTH |
+ XCB_PICT_FORMAT_RED |
+ XCB_PICT_FORMAT_RED_MASK |
+ XCB_PICT_FORMAT_GREEN |
+ XCB_PICT_FORMAT_GREEN_MASK |
+ XCB_PICT_FORMAT_BLUE |
+ XCB_PICT_FORMAT_BLUE_MASK |
+ XCB_PICT_FORMAT_ALPHA_MASK,
+ },
+ /* XCB_PICT_STANDARD_A_8 */
+ {
+ {
+ 0, /* id */
+ XCB_RENDER_PICT_TYPE_DIRECT, /* type */
+ 8, /* depth */
+ { 0 }, /* pad */
+ { /* direct */
+ 0, /* direct.red */
+ 0x00, /* direct.red_MASK */
+ 0, /* direct.green */
+ 0x00, /* direct.green_MASK */
+ 0, /* direct.blue */
+ 0x00, /* direct.blue_MASK */
+ 0, /* direct.alpha */
+ 0xff, /* direct.alpha_MASK */
+ },
+ 0, /* colormap */
+ },
+ XCB_PICT_FORMAT_TYPE |
+ XCB_PICT_FORMAT_DEPTH |
+ XCB_PICT_FORMAT_RED_MASK |
+ XCB_PICT_FORMAT_GREEN_MASK |
+ XCB_PICT_FORMAT_BLUE_MASK |
+ XCB_PICT_FORMAT_ALPHA |
+ XCB_PICT_FORMAT_ALPHA_MASK,
+ },
+ /* XCB_PICT_STANDARD_A_4 */
+ {
+ {
+ 0, /* id */
+ XCB_RENDER_PICT_TYPE_DIRECT, /* type */
+ 4, /* depth */
+ { 0 }, /* pad */
+ { /* direct */
+ 0, /* direct.red */
+ 0x00, /* direct.red_MASK */
+ 0, /* direct.green */
+ 0x00, /* direct.green_MASK */
+ 0, /* direct.blue */
+ 0x00, /* direct.blue_MASK */
+ 0, /* direct.alpha */
+ 0x0f, /* direct.alpha_MASK */
+ },
+ 0, /* colormap */
+ },
+ XCB_PICT_FORMAT_TYPE |
+ XCB_PICT_FORMAT_DEPTH |
+ XCB_PICT_FORMAT_RED_MASK |
+ XCB_PICT_FORMAT_GREEN_MASK |
+ XCB_PICT_FORMAT_BLUE_MASK |
+ XCB_PICT_FORMAT_ALPHA |
+ XCB_PICT_FORMAT_ALPHA_MASK,
+ },
+ /* XCB_PICT_STANDARD_A_1 */
+ {
+ {
+ 0, /* id */
+ XCB_RENDER_PICT_TYPE_DIRECT, /* type */
+ 1, /* depth */
+ { 0 }, /* pad */
+ { /* direct */
+ 0, /* direct.red */
+ 0x00, /* direct.red_MASK */
+ 0, /* direct.green */
+ 0x00, /* direct.green_MASK */
+ 0, /* direct.blue */
+ 0x00, /* direct.blue_MASK */
+ 0, /* direct.alpha */
+ 0x01, /* direct.alpha_MASK */
+ },
+ 0, /* colormap */
+ },
+ XCB_PICT_FORMAT_TYPE |
+ XCB_PICT_FORMAT_DEPTH |
+ XCB_PICT_FORMAT_RED_MASK |
+ XCB_PICT_FORMAT_GREEN_MASK |
+ XCB_PICT_FORMAT_BLUE_MASK |
+ XCB_PICT_FORMAT_ALPHA |
+ XCB_PICT_FORMAT_ALPHA_MASK,
+ },
+ };
+
+ if (format < 0 || format >= sizeof(standardFormats) / sizeof(*standardFormats))
+ return 0;
+
+ return xcb_render_util_find_format (formats,
+ standardFormats[format].mask,
+ &standardFormats[format].templ,
+ 0);
+}
diff --git a/depends/libxcb-render-util/xcb/xcb_renderutil.h b/depends/libxcb-render-util/xcb/xcb_renderutil.h
new file mode 100644
index 0000000..77c5b7f
--- /dev/null
+++ b/depends/libxcb-render-util/xcb/xcb_renderutil.h
@@ -0,0 +1,150 @@
+/* Copyright © 2006 Jamey Sharp.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the authors or their
+ * institutions shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the authors.
+ */
+
+#ifndef XCB_RENDERUTIL
+#define XCB_RENDERUTIL
+#include <xcb/render.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum xcb_pict_format_t {
+ XCB_PICT_FORMAT_ID = (1 << 0),
+ XCB_PICT_FORMAT_TYPE = (1 << 1),
+ XCB_PICT_FORMAT_DEPTH = (1 << 2),
+ XCB_PICT_FORMAT_RED = (1 << 3),
+ XCB_PICT_FORMAT_RED_MASK = (1 << 4),
+ XCB_PICT_FORMAT_GREEN = (1 << 5),
+ XCB_PICT_FORMAT_GREEN_MASK = (1 << 6),
+ XCB_PICT_FORMAT_BLUE = (1 << 7),
+ XCB_PICT_FORMAT_BLUE_MASK = (1 << 8),
+ XCB_PICT_FORMAT_ALPHA = (1 << 9),
+ XCB_PICT_FORMAT_ALPHA_MASK = (1 << 10),
+ XCB_PICT_FORMAT_COLORMAP = (1 << 11)
+} xcb_pict_format_t;
+
+typedef enum xcb_pict_standard_t {
+ XCB_PICT_STANDARD_ARGB_32,
+ XCB_PICT_STANDARD_RGB_24,
+ XCB_PICT_STANDARD_A_8,
+ XCB_PICT_STANDARD_A_4,
+ XCB_PICT_STANDARD_A_1
+} xcb_pict_standard_t;
+
+
+xcb_render_pictvisual_t *
+xcb_render_util_find_visual_format (const xcb_render_query_pict_formats_reply_t *formats,
+ const xcb_visualid_t visual);
+
+xcb_render_pictforminfo_t *
+xcb_render_util_find_format (const xcb_render_query_pict_formats_reply_t *formats,
+ unsigned long mask,
+ const xcb_render_pictforminfo_t *ptemplate,
+ int count);
+
+xcb_render_pictforminfo_t *
+xcb_render_util_find_standard_format (const xcb_render_query_pict_formats_reply_t *formats,
+ xcb_pict_standard_t format);
+
+const xcb_render_query_version_reply_t *
+xcb_render_util_query_version (xcb_connection_t *c);
+
+const xcb_render_query_pict_formats_reply_t *
+xcb_render_util_query_formats (xcb_connection_t *c);
+
+int
+xcb_render_util_disconnect (xcb_connection_t *c);
+
+/* wrappers for xcb_render_composite_glyphs_8/16/32 */
+
+typedef struct xcb_render_util_composite_text_stream_t xcb_render_util_composite_text_stream_t;
+
+xcb_render_util_composite_text_stream_t *
+xcb_render_util_composite_text_stream (
+ xcb_render_glyphset_t initial_glyphset,
+ uint32_t total_glyphs,
+ uint32_t total_glyphset_changes );
+
+void
+xcb_render_util_glyphs_8 (
+ xcb_render_util_composite_text_stream_t *stream,
+ int16_t dx,
+ int16_t dy,
+ uint32_t count,
+ const uint8_t *glyphs );
+
+void
+xcb_render_util_glyphs_16 (
+ xcb_render_util_composite_text_stream_t *stream,
+ int16_t dx,
+ int16_t dy,
+ uint32_t count,
+ const uint16_t *glyphs );
+
+void
+xcb_render_util_glyphs_32 (
+ xcb_render_util_composite_text_stream_t *stream,
+ int16_t dx,
+ int16_t dy,
+ uint32_t count,
+ const uint32_t *glyphs );
+
+void
+xcb_render_util_change_glyphset (
+ xcb_render_util_composite_text_stream_t *stream,
+ xcb_render_glyphset_t glyphset );
+
+xcb_void_cookie_t
+xcb_render_util_composite_text (
+ xcb_connection_t *xc,
+ uint8_t op,
+ xcb_render_picture_t src,
+ xcb_render_picture_t dst,
+ xcb_render_pictformat_t mask_format,
+ int16_t src_x,
+ int16_t src_y,
+ xcb_render_util_composite_text_stream_t *stream );
+
+xcb_void_cookie_t
+xcb_render_util_composite_text_checked (
+ xcb_connection_t *xc,
+ uint8_t op,
+ xcb_render_picture_t src,
+ xcb_render_picture_t dst,
+ xcb_render_pictformat_t mask_format,
+ int16_t src_x,
+ int16_t src_y,
+ xcb_render_util_composite_text_stream_t *stream );
+
+void
+xcb_render_util_composite_text_free (
+ xcb_render_util_composite_text_stream_t *stream );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XCB_RENDERUTIL */