summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-05-25 00:35:04 +0000
committerBehdad Esfahbod <behdad@behdad.org>2019-07-18 14:38:47 -0700
commite4a79db0108be6a2b06dfce51a44bcbdead66ebd (patch)
tree3100552be8c16d2ba0213801b5be39e0a85ee9be
parent6fd4222ab00c3b93f038172a8c9d48375c5f86f0 (diff)
xlib compositor: Support subpixel positioning
As for the image compository, support a 4x4 subpixel grid.
-rw-r--r--src/cairo-xlib-render-compositor.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/cairo-xlib-render-compositor.c b/src/cairo-xlib-render-compositor.c
index 0db59a8a6..bce0ff6db 100644
--- a/src/cairo-xlib-render-compositor.c
+++ b/src/cairo-xlib-render-compositor.c
@@ -1074,8 +1074,7 @@ _cairo_xlib_glyph_fini (cairo_scaled_glyph_private_t *glyph_private,
to_free->count = 0;
}
- to_free->indices[to_free->count++] =
- _cairo_scaled_glyph_index (glyph);
+ to_free->indices[to_free->count++] = glyph->hash_entry.hash;
}
cairo_list_del (&glyph_private->link);
@@ -1193,7 +1192,7 @@ _cairo_xlib_surface_add_glyph (cairo_xlib_display_t *display,
cairo_bool_t already_had_glyph_surface;
cairo_xlib_font_glyphset_t *info;
- glyph_index = _cairo_scaled_glyph_index (glyph);
+ glyph_index = glyph->hash_entry.hash;
/* check to see if we have a pending XRenderFreeGlyph for this glyph */
info = find_pending_free_glyph (display, font, glyph_index, glyph_surface);
@@ -1570,6 +1569,9 @@ check_composite_glyphs (const cairo_composite_rectangles_t *extents,
* enough room for padding */
#define _cairo_sz_xGlyphElt (sz_xGlyphElt + 4)
+#define PHASE(x) ((int)(floor (4 * (x + 0.125)) - 4 * floor (x + 0.125)))
+#define POSITION(x) ((int) floor (x + 0.125))
+
static cairo_int_status_t
composite_glyphs (void *surface,
cairo_operator_t op,
@@ -1605,9 +1607,15 @@ composite_glyphs (void *surface,
op = _render_operator (op),
_cairo_xlib_surface_ensure_picture (dst);
for (i = 0; i < num_glyphs; i++) {
+ int xphase, yphase;
int this_x, this_y;
int old_width;
+ xphase = PHASE(glyphs[i].d.x);
+ yphase = PHASE(glyphs[i].d.y);
+
+ glyphs[i].index |= (xphase << 24) | (yphase << 26);
+
status = _cairo_scaled_glyph_lookup (info->font,
glyphs[i].index,
CAIRO_SCALED_GLYPH_INFO_METRICS,
@@ -1615,8 +1623,8 @@ composite_glyphs (void *surface,
if (unlikely (status))
return status;
- this_x = _cairo_lround (glyphs[i].d.x);
- this_y = _cairo_lround (glyphs[i].d.y);
+ this_x = POSITION (glyphs[i].d.x);
+ this_y = POSITION (glyphs[i].d.y);
/* Send unsent glyphs to the server */
if (glyph->dev_private_key != display) {