summaryrefslogtreecommitdiffstats
path: root/gfx/cairo/xlib-flush-glyphs.patch
blob: 78a19d0dd7a3914f36f3709bbf02e94fef9adbab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
diff --git a/gfx/cairo/cairo/src/cairo-xlib-surface.c b/gfx/cairo/cairo/src/cairo-xlib-surface.c
index f0de3c7..e24c962 100644
--- a/gfx/cairo/cairo/src/cairo-xlib-surface.c
+++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c
@@ -50,35 +50,36 @@
 #include "cairo-xlib-private.h"
 #include "cairo-xlib-surface-private.h"
 #include "cairo-clip-private.h"
 #include "cairo-error-private.h"
 #include "cairo-scaled-font-private.h"
 #include "cairo-surface-snapshot-private.h"
 #include "cairo-surface-subsurface-private.h"
 #include "cairo-region-private.h"
+#include "cairo-xlib-xrender-private.h"
 
 #include <X11/Xutil.h> /* for XDestroyImage */
+#include <X11/Xlibint.h> /* for access to XDisplay's innards */
 
 #define XLIB_COORD_MAX 32767
 
 #define DEBUG 0
 
 #if DEBUG
 #define UNSUPPORTED(reason) \
     fprintf (stderr, \
 	     "cairo-xlib: hit unsupported operation %s(), line %d: %s\n", \
 	     __FUNCTION__, __LINE__, reason), \
     CAIRO_INT_STATUS_UNSUPPORTED
 #else
 #define UNSUPPORTED(reason) CAIRO_INT_STATUS_UNSUPPORTED
 #endif
 
 #if DEBUG
-#include <X11/Xlibint.h>
 static void CAIRO_PRINTF_FORMAT (2, 3)
 _x_bread_crumb (Display *dpy,
 		const char *fmt,
 		...)
 {
     xReq *req;
     char buf[2048];
     unsigned int len, len_dwords;
@@ -4313,16 +4314,23 @@ _cairo_xlib_surface_add_glyph (cairo_xlib_display_t *display,
 	}
 	break;
     default:
 	ASSERT_NOT_REACHED;
 	break;
     }
     /* XXX assume X server wants pixman padding. Xft assumes this as well */
 
+    struct _XDisplay *dpy = (struct _XDisplay *) display->display;
+    int req_length = sz_xRenderAddGlyphsReq + 4;
+    if (req_length & 3)
+	req_length += 4 - (req_length & 3);
+    if (dpy->bufptr + req_length > dpy->bufmax)
+	XFlush (display->display);
+
     XRenderAddGlyphs (display->display, glyphset_info->glyphset,
 		      &glyph_index, &glyph_info, 1,
 		      (char *) data,
 		      glyph_surface->stride * glyph_surface->height);
 
     if (data != glyph_surface->data)
 	free (data);