Bug 460023. Change the glyph dropping safety margin from 2em to 10em. r=vlad
authorBehdad Esfahod <mozilla@behdad.org>
Wed, 28 Jan 2009 22:36:23 +1300
changeset 24332 3c88df5744389465f26f60d423eec4a809ed98fd
parent 24331 4bc1bd14f5a06a37b47a765af144675ba10a492d
child 24333 a6690fa2baba68d4accbbc3a36779c7dc145c398
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad
bugs460023
milestone1.9.2a1pre
Bug 460023. Change the glyph dropping safety margin from 2em to 10em. r=vlad
gfx/cairo/README
gfx/cairo/cairo/src/cairo-gstate.c
gfx/cairo/glyph-safety-margin.patch
--- a/gfx/cairo/README
+++ b/gfx/cairo/README
@@ -35,15 +35,17 @@ win32-ddb-dib.patch: fix for bug 455513;
 qpainter-type.patch: add SURFACE_TYPE_QPAINTER to cairo.h
 
 wince-fixes.patch: stubs out win32 functions we use but are not supported on win32.  Also implements ExtSelectClipRgn in terms of other functions available on wince.
 
 ft-done-face.patch: bug 467874; only destroy FT_Faces created by cairo
 
 wince-fontconfig.patch: bug 462908; fixes required to compile for windows ce.  Also allows for building without fontconfig
 
+gfx/cairo/glyph-safety-margin.patch: Change the glyph dropping safety margin from 2em to 10em for bug 460023.  Upstream commit: 28a72648ba7abe02ebd4df7234424e333b85dc9c.
+
 ==== pixman patches ====
 
 endian.patch: include cairo-platform.h for endian macros
 
 ==== disable printing patch ====
 
 disable-printing.patch:  allows us to use NS_PRINTING to disable printing.
--- a/gfx/cairo/cairo/src/cairo-gstate.c
+++ b/gfx/cairo/cairo/src/cairo-gstate.c
@@ -1724,43 +1724,43 @@ static cairo_status_t
     cairo_matrix_t *font_matrix = &gstate->font_matrix;
     cairo_matrix_t *device_transform = &gstate->target->device_transform;
     cairo_bool_t drop = FALSE;
     double x1 = 0, x2 = 0, y1 = 0, y2 = 0;
     cairo_status_t status;
 
     if (num_transformed_glyphs != NULL) {
 	cairo_rectangle_int_t surface_extents;
-	double scale = _cairo_scaled_font_get_max_scale (gstate->scaled_font);
 
 	drop = TRUE;
 	status = _cairo_gstate_int_clip_extents (gstate, &surface_extents);
 	if (_cairo_status_is_error (status))
 	    return status;
 
 	if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
 	    drop = FALSE; /* unbounded surface */
 	} else {
+	    double scale10 = 10 * _cairo_scaled_font_get_max_scale (gstate->scaled_font);
 	    if (surface_extents.width == 0 || surface_extents.height == 0) {
 	      /* No visible area.  Don't draw anything */
 	      *num_transformed_glyphs = 0;
 	      return CAIRO_STATUS_SUCCESS;
 	    }
 	    /* XXX We currently drop any glyphs that has its position outside
 	     * of the surface boundaries by a safety margin depending on the
 	     * font scale.  This however can fail in extreme cases where the
 	     * font has really long swashes for example...  We can correctly
 	     * handle that by looking the glyph up and using its device bbox
 	     * to device if it's going to be visible, but I'm not inclined to
 	     * do that now.
 	     */
-	    x1 = surface_extents.x - 2*scale;
-	    y1 = surface_extents.y - 2*scale;
-	    x2 = surface_extents.x + surface_extents.width  + scale;
-	    y2 = surface_extents.y + surface_extents.height + scale;
+	    x1 = surface_extents.x - scale10;
+	    y1 = surface_extents.y - scale10;
+	    x2 = surface_extents.x + (int) surface_extents.width  + scale10;
+	    y2 = surface_extents.y + (int) surface_extents.height + scale10;
 	}
 
 	if (!drop)
 	    *num_transformed_glyphs = num_glyphs;
     } else
 	num_transformed_glyphs = &j;
 
 #define KEEP_GLYPH(glyph) (x1 <= glyph.x && glyph.x <= x2 && y1 <= glyph.y && glyph.y <= y2)
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/glyph-safety-margin.patch
@@ -0,0 +1,43 @@
+From 28a72648ba7abe02ebd4df7234424e333b85dc9c Mon Sep 17 00:00:00 2001
+From: Behdad Esfahbod<behdad@behdad.org>
+Date: Tue, 30  Dec  2008  18:48:47  +0000
+Subject: [gstate] Change the glyph dropping safety margin from 2em to 10em
+
+The small margin caused bugs with math fonts.  See:
+https://bugzilla.mozilla.org/show_bug.cgi?id=460023
+---
+diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
+index df7ec5c..c79e799 100644
+--- a/gfx/cairo/cairo/src/cairo-gstate.c
++++ b/gfx/cairo/cairo/src/cairo-gstate.c
+@@ -1804,7 +1804,6 @@ _cairo_gstate_transform_glyphs_to_backend (cairo_gstate_t	*gstate,
+ 
+     if (num_transformed_glyphs != NULL) {
+ 	cairo_rectangle_int_t surface_extents;
+-	double scale = _cairo_scaled_font_get_max_scale (gstate->scaled_font);
+ 
+ 	drop = TRUE;
+ 	status = _cairo_gstate_int_clip_extents (gstate, &surface_extents);
+@@ -1814,6 +1813,7 @@ _cairo_gstate_transform_glyphs_to_backend (cairo_gstate_t	*gstate,
+ 	if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
+ 	    drop = FALSE; /* unbounded surface */
+ 	} else {
++	    double scale10 = 10 * _cairo_scaled_font_get_max_scale (gstate->scaled_font);
+ 	    if (surface_extents.width == 0 || surface_extents.height == 0) {
+ 	      /* No visible area.  Don't draw anything */
+ 	      *num_transformed_glyphs = 0;
+@@ -1827,10 +1827,10 @@ _cairo_gstate_transform_glyphs_to_backend (cairo_gstate_t	*gstate,
+ 	     * to device if it's going to be visible, but I'm not inclined to
+ 	     * do that now.
+ 	     */
+-	    x1 = surface_extents.x - 2*scale;
+-	    y1 = surface_extents.y - 2*scale;
+-	    x2 = surface_extents.x + surface_extents.width  + scale;
+-	    y2 = surface_extents.y + surface_extents.height + scale;
++	    x1 = surface_extents.x - scale10;
++	    y1 = surface_extents.y - scale10;
++	    x2 = surface_extents.x + (int) surface_extents.width  + scale10;
++	    y2 = surface_extents.y + (int) surface_extents.height + scale10;
+ 	}
+ 
+ 	if (!drop)