[cairo-commit] 4 commits - src/cairo-xlib-surface.c test/large-font.c test/large-font-ps-ref.png test/large-font-ref.png test/Makefile.am

Behdad Esfahbod behdad at kemper.freedesktop.org
Fri May 23 18:04:47 PDT 2008


 dev/null                 |binary
 src/cairo-xlib-surface.c |   41 +++++++++++++++--------------------------
 test/Makefile.am         |    1 -
 test/large-font-ref.png  |binary
 test/large-font.c        |   20 +++++---------------
 5 files changed, 20 insertions(+), 42 deletions(-)

New commits:
commit c20072c88174a99bf4deb562f5b3bc07cc9e133d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri May 23 20:57:21 2008 -0400

    [cairo-xlib] Upon seeing glyphs with large position, just let fallback handle
    
    This now fixes the large-font test for xlib again.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 6bc8dd1..20dc969 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -3165,8 +3165,6 @@ typedef struct {
 /* compile-time assert that #cairo_xlib_glyph_t is the same size as #cairo_glyph_t */
 typedef int cairo_xlib_glyph_t_size_assertion [sizeof (cairo_xlib_glyph_t) == sizeof (cairo_glyph_t) ? 1 : -1];
 
-#define GLYPH_INDEX_SKIP ((unsigned long) -1)
-
 static cairo_status_t
 _cairo_xlib_surface_emit_glyphs_chunk (cairo_xlib_surface_t *dst,
 				       cairo_xlib_glyph_t *glyphs,
@@ -3229,10 +3227,6 @@ _cairo_xlib_surface_emit_glyphs_chunk (cairo_xlib_surface_t *dst,
     j = 0;
     for (i = 0; i < num_glyphs; i++) {
 
-      /* Skip glyphs marked so */
-      if (glyphs[i].index == GLYPH_INDEX_SKIP)
-	continue;
-
       /* Start a new element for first output glyph, and for glyphs with
        * unexpected position */
       if (!j || glyphs[i].p.i.x || glyphs[i].p.i.y) {
@@ -3339,11 +3333,12 @@ _cairo_xlib_surface_emit_glyphs (cairo_xlib_surface_t *dst,
 	 * may start off the screen but part of it make it to the screen.
 	 * Anyway, we will allow positions in the range -4096..122887.  That
 	 * will buy us a few more years before this stops working.
+	 *
+	 * Update: upon seeing weird glyphs, we just return and let fallback
+	 * code do the job.
 	 */
-	if (((this_x+4096)|(this_y+4096))&~0x3fffu) {
-	    glyphs[i].index = GLYPH_INDEX_SKIP;
-	    continue;
-	}
+	if (((this_x+4096)|(this_y+4096))&~0x3fffu)
+	    break;
 
 	/* Send unsent glyphs to the server */
 	if (_cairo_xlib_scaled_glyph_get_glyphset_info (scaled_glyph) == NULL) {
@@ -3428,22 +3423,18 @@ _cairo_xlib_surface_emit_glyphs (cairo_xlib_surface_t *dst,
 	request_size += width;
     }
 
-    if (num_elts) {
-	/* status may be UNSUPPORTED.  Shouldn't override that to SUCCESS */
-	cairo_status_t status2;
-	status2 = _cairo_xlib_surface_emit_glyphs_chunk (dst, glyphs, num_glyphs,
-							 scaled_font, op, src, attributes,
-							 num_elts, width, glyphset_info);
-	if (status2 != CAIRO_STATUS_SUCCESS)
-	    status = status2;
-    }
+    if (num_elts)
+	status = _cairo_xlib_surface_emit_glyphs_chunk (dst, glyphs, num_glyphs,
+							scaled_font, op, src, attributes,
+							num_elts, width, glyphset_info);
+
     *remaining_glyphs = num_glyphs - i;
+    if (*remaining_glyphs && status == CAIRO_STATUS_SUCCESS)
+	status = CAIRO_INT_STATUS_UNSUPPORTED;
 
     return status;
 }
 
-#undef GLYPH_INDEX_SKIP
-
 static cairo_int_status_t
 _cairo_xlib_surface_show_glyphs (void                *abstract_dst,
 				 cairo_operator_t     op,
commit e55252bd3b3ee8ad07aeda558dd469e98fedd620
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri May 23 20:46:36 2008 -0400

    [cairo-xlib] Shift range of allowed glyph positions
    
    From -1024..15359, to -4096..122887.  This still does not fix the
    large-font test as that uses a 10000 font.  Working on a proper fix
    for glyph dropping now.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index f742a7c..6bc8dd1 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -3337,10 +3337,10 @@ _cairo_xlib_surface_emit_glyphs (cairo_xlib_surface_t *dst,
 	 * negative value of -8192 on the other hand, is absolutely useless.
 	 * Note that we do want to allow some negative positions.  The glyph
 	 * may start off the screen but part of it make it to the screen.
-	 * Anyway, we will allow positions in the range -1024..15359.  That
+	 * Anyway, we will allow positions in the range -4096..122887.  That
 	 * will buy us a few more years before this stops working.
 	 */
-	if (((this_x+1024)|(this_y+1024))&~0x3fffu) {
+	if (((this_x+4096)|(this_y+4096))&~0x3fffu) {
 	    glyphs[i].index = GLYPH_INDEX_SKIP;
 	    continue;
 	}
commit 74818d2b0002d2133a95019265a23a8fd8ba0217
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri May 23 20:43:08 2008 -0400

    [cairo-xlib] Some code reshuffling, in preparation for a fix

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 28f2aba..f742a7c 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -3351,19 +3351,11 @@ _cairo_xlib_surface_emit_glyphs (cairo_xlib_surface_t *dst,
 		                                    scaled_font,
 						    &scaled_glyph);
 	    if (status) {
-	        if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
-		    /* Glyph image too big to send to server.  Flush what we
-		     * got and let fallback code handle the rest.
-		     */
-		    if (num_elts)
-			status = _cairo_xlib_surface_emit_glyphs_chunk (dst, glyphs, i,
-									scaled_font, op, src, attributes,
-									num_elts, width, glyphset_info);
-		    *remaining_glyphs = num_glyphs - i;
-
-		    if (status == CAIRO_STATUS_SUCCESS)
-			status = CAIRO_INT_STATUS_UNSUPPORTED;
-		}
+	        if (status == CAIRO_INT_STATUS_UNSUPPORTED)
+		    /* Break so we flush glyphs so far and let fallback code
+		     * handle the rest */
+		    break;
+
 		return status;
 	    }
 	}
@@ -3436,10 +3428,16 @@ _cairo_xlib_surface_emit_glyphs (cairo_xlib_surface_t *dst,
 	request_size += width;
     }
 
-    if (num_elts)
-	status = _cairo_xlib_surface_emit_glyphs_chunk (dst, glyphs, num_glyphs,
-							scaled_font, op, src, attributes,
-							num_elts, width, glyphset_info);
+    if (num_elts) {
+	/* status may be UNSUPPORTED.  Shouldn't override that to SUCCESS */
+	cairo_status_t status2;
+	status2 = _cairo_xlib_surface_emit_glyphs_chunk (dst, glyphs, num_glyphs,
+							 scaled_font, op, src, attributes,
+							 num_elts, width, glyphset_info);
+	if (status2 != CAIRO_STATUS_SUCCESS)
+	    status = status2;
+    }
+    *remaining_glyphs = num_glyphs - i;
 
     return status;
 }
commit d947ee0ef68cbc371d058b13b98c013b82f794ba
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri May 23 20:41:26 2008 -0400

    [test/large-font] Make the font REALLY LARGE
    
    10000 that is.  xlib fails now again.  Not because of glyph size issues.
    Because we skip rendering any glyphs with positions not in range -1024..15359.
    Working on a fix.

diff --git a/test/Makefile.am b/test/Makefile.am
index f444ff3..0723c23 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -443,7 +443,6 @@ REFERENCE_IMAGES = \
 	infinite-join-ref.png	\
 	infinite-join-ps-ref.png	\
 	large-font-ref.png	\
-	large-font-ps-ref.png	\
 	large-source-ref.png	\
 	leaky-dash-ps-argb32-ref.png	\
 	leaky-dash-ps-rgb24-ref.png	\
diff --git a/test/large-font-ps-ref.png b/test/large-font-ps-ref.png
deleted file mode 100644
index 1dbd7cd..0000000
Binary files a/test/large-font-ps-ref.png and /dev/null differ
diff --git a/test/large-font-ref.png b/test/large-font-ref.png
index 8a555f1..da5c431 100644
Binary files a/test/large-font-ref.png and b/test/large-font-ref.png differ
diff --git a/test/large-font.c b/test/large-font.c
index 7554a3e..85c135d 100644
--- a/test/large-font.c
+++ b/test/large-font.c
@@ -41,9 +41,9 @@
 
 #include "cairo-test.h"
 
-#define WIDTH  400
-#define HEIGHT 200
-#define TEXT_SIZE 160
+#define WIDTH  800
+#define HEIGHT 800
+#define TEXT_SIZE 10000
 
 static cairo_test_draw_function_t draw;
 
@@ -69,19 +69,9 @@ draw (cairo_t *cr, int width, int height)
 			    CAIRO_FONT_WEIGHT_NORMAL);
     cairo_set_font_size (cr, TEXT_SIZE);
 
-    font_options = cairo_font_options_create ();
-
-    cairo_get_font_options (cr, font_options);
-    cairo_font_options_set_hint_metrics (font_options, CAIRO_HINT_METRICS_OFF);
-
-    cairo_set_font_options (cr, font_options);
-    cairo_font_options_destroy (font_options);
-
     cairo_set_source_rgb (cr, 0, 0, 0);
-
-    cairo_set_font_size (cr, 160);
-    cairo_move_to (cr, 5, 160);
-    cairo_show_text (cr, "MoW");
+    cairo_move_to (cr, -TEXT_SIZE / 2, TEXT_SIZE / 2);
+    cairo_show_text (cr, "xW");
 
     return CAIRO_TEST_SUCCESS;
 }


More information about the cairo-commit mailing list