[cairo-commit] src/cairo-analysis-surface.c src/cairo-surface.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Jul 2 16:22:28 PDT 2008


 src/cairo-analysis-surface.c |   47 +++++++++++++++++++++++++++++++------------
 src/cairo-surface.c          |    8 ++++---
 2 files changed, 39 insertions(+), 16 deletions(-)

New commits:
commit 85de817e097c83136fdf827c9202416c02d72bbb
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jul 2 19:21:50 2008 -0400

    [analysis-surface] Fallback between show_glyphs and show_text_glyphs
    
    This is needed because analysis-surface takes any UNSUPPORTED returns
    as a signal for using image fallbacks.  So the fallback mechanism in
    _cairo_surface_show_text_glyphs() is not enough.  Reported by Adrian
    Johnson.

diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index 12115a6..b847484 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -563,14 +563,23 @@ _cairo_analysis_surface_show_glyphs (void		  *abstract_surface,
     cairo_status_t	     status, backend_status;
     cairo_rectangle_int_t    extents, glyph_extents;
 
-    if (!surface->target->backend->show_glyphs)
-	backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
-    else
+    /* Adapted from _cairo_surface_show_glyphs */
+    if (surface->target->backend->show_glyphs)
 	backend_status = (*surface->target->backend->show_glyphs) (surface->target, op,
 								   source,
 								   glyphs, num_glyphs,
 								   scaled_font,
 								   remaining_glyphs);
+    else if (surface->target->backend->show_text_glyphs)
+	backend_status = surface->target->backend->show_text_glyphs (surface, op,
+								     source,
+								     NULL, 0,
+								     glyphs, num_glyphs,
+								     NULL, 0,
+								     FALSE,
+								     scaled_font);
+    else
+	backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
 
     if (backend_status == CAIRO_INT_STATUS_ANALYZE_META_SURFACE_PATTERN)
 	backend_status = _cairo_analysis_surface_analyze_meta_surface_pattern (surface,
@@ -632,16 +641,28 @@ _cairo_analysis_surface_show_text_glyphs (void			    *abstract_surface,
     cairo_status_t	     status, backend_status;
     cairo_rectangle_int_t    extents, glyph_extents;
 
-    if (!surface->target->backend->show_text_glyphs)
-	backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
-    else
-	backend_status = (*surface->target->backend->show_text_glyphs) (surface->target, op,
-									source,
-									utf8, utf8_len,
-									glyphs, num_glyphs,
-									clusters, num_clusters,
-									backward,
-									scaled_font);
+    /* Adapted from _cairo_surface_show_glyphs */
+    backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
+    if (surface->target->backend->show_text_glyphs)
+	backend_status = surface->target->backend->show_text_glyphs (surface->target, op,
+								     source,
+								     utf8, utf8_len,
+								     glyphs, num_glyphs,
+								     clusters, num_clusters,
+								     backward,
+								     scaled_font);
+    if (backend_status == CAIRO_INT_STATUS_UNSUPPORTED && surface->target->backend->show_glyphs) {
+	int remaining_glyphs = num_glyphs;
+	backend_status = surface->target->backend->show_glyphs (surface, op,
+								source,
+								glyphs, num_glyphs,
+								scaled_font,
+								&remaining_glyphs);
+	glyphs += num_glyphs - remaining_glyphs;
+	num_glyphs = remaining_glyphs;
+	if (remaining_glyphs == 0)
+	    backend_status = CAIRO_STATUS_SUCCESS;
+    }
 
     if (backend_status == CAIRO_INT_STATUS_ANALYZE_META_SURFACE_PATTERN)
 	backend_status = _cairo_analysis_surface_analyze_meta_surface_pattern (surface,
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index bceb7a3..ce8b890 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -2215,6 +2215,8 @@ _cairo_surface_show_text_glyphs (cairo_surface_t	    *surface,
 
     status = CAIRO_INT_STATUS_UNSUPPORTED;
 
+    /* The logic here is duplicated in _cairo_analysis_surface show_glyphs and
+     * show_text_glyphs.  Keep in synch. */
     if (clusters) {
 	/* A real show_text_glyphs call.  Try show_text_glyphs backend
 	 * method first */
@@ -2234,7 +2236,7 @@ _cairo_surface_show_text_glyphs (cairo_surface_t	    *surface,
 						    &remaining_glyphs);
 	    glyphs += num_glyphs - remaining_glyphs;
 	    num_glyphs = remaining_glyphs;
-	    if (remaining_glyphs == 0)
+	    if (status == CAIRO_INT_STATUS_UNSUPPORTED && remaining_glyphs == 0)
 		status = CAIRO_STATUS_SUCCESS;
 	}
     } else {
@@ -2247,13 +2249,13 @@ _cairo_surface_show_text_glyphs (cairo_surface_t	    *surface,
 						    &remaining_glyphs);
 	    glyphs += num_glyphs - remaining_glyphs;
 	    num_glyphs = remaining_glyphs;
-	    if (remaining_glyphs == 0)
+	    if (status == CAIRO_INT_STATUS_UNSUPPORTED && remaining_glyphs == 0)
 		status = CAIRO_STATUS_SUCCESS;
 	} else if (surface->backend->show_text_glyphs) {
 	    /* Intentionally only try show_text_glyphs method for show_glyphs
 	     * calls if backend does not have show_glyphs.  If backend has
 	     * both methods implemented, we don't fallback from show_glyphs to
-	     * show_text_glyphs, and hence the backend an assume in its
+	     * show_text_glyphs, and hence the backend can assume in its
 	     * show_text_glyphs call that clusters is not NULL (which also
 	     * implies that UTF-8 is not NULL, unless the text is
 	     * zero-length).


More information about the cairo-commit mailing list