[cairo-commit] 2 commits - src/cairo-gstate.c test/a1-mask.c test/large-source.c test/user-font-mask.c

M. Joonas Pihlaja joonas at kemper.freedesktop.org
Sun Nov 29 03:25:21 PST 2009


 src/cairo-gstate.c    |    7 ++++++-
 test/a1-mask.c        |    1 +
 test/large-source.c   |    2 ++
 test/user-font-mask.c |    1 +
 4 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit e09b754fdd43206e1668812be4ff11d25188148c
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sun Nov 29 01:11:29 2009 +0200

    [gstate] Change dash offset normalisation to preserve offsets in range.
    
    We have a test case get-and-set which wants to see whatever it puts
    into a cairo_t come back out again, but at the same time cairo-gstate
    wants to range reduce the dash offset it's given to a sane range.
    This patch changes the range reduction algorithm to always normalize
    to a non-negative dash offset and not touch dash offsets which are
    already in range.

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 672c2da..78faed9 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -547,7 +547,12 @@ _cairo_gstate_set_dash (cairo_gstate_t *gstate, const double *dash, int num_dash
     /* The dashing code doesn't like a negative offset or a big positive
      * offset, so we compute an equivalent offset which is guaranteed to be
      * positive and less than twice the pattern length. */
-    gstate->stroke_style.dash_offset = fmod (offset, dash_total) + dash_total;
+    offset = fmod (offset, dash_total);
+    if (offset < 0.0)
+	offset += dash_total;
+    if (offset <= 0.0)		/* Take care of -0 */
+	offset = 0.0;
+    gstate->stroke_style.dash_offset = offset;
 
     return CAIRO_STATUS_SUCCESS;
 }
commit b394240941dffa263776a62cf42dc9b7e477f7a2
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sun Nov 29 02:48:23 2009 +0200

    [test] Add missing mark_dirty() calls to test cases.
    
    A recent optimisation has added a flag to the image
    surface which is used to track whether the surface
    is clear or not.  This makes it imperative that clients
    call cairo_surface_mark_dirty() if they use cairo to
    allocate their pixel buffers and then proceed to
    initialize them without telling cairo about it.

diff --git a/test/a1-mask.c b/test/a1-mask.c
index 0be1d07..c52aa9d 100644
--- a/test/a1-mask.c
+++ b/test/a1-mask.c
@@ -125,6 +125,7 @@ draw (cairo_t *cr, int dst_width, int dst_height)
 	    dst += stride;
 	}
     }
+    cairo_surface_mark_dirty (surface);
 
     /* Paint background blue */
     cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
diff --git a/test/large-source.c b/test/large-source.c
index b02b493..2b6b84f 100644
--- a/test/large-source.c
+++ b/test/large-source.c
@@ -62,6 +62,7 @@ draw (cairo_t *cr, int width, int height)
 		data[x] = RED_MASK;
 	    data += stride;
 	}
+        cairo_surface_mark_dirty (surface);
     }
 
     cairo_set_source_rgb (cr, 1, 0, 0); /* red */
@@ -81,6 +82,7 @@ draw (cairo_t *cr, int width, int height)
 		data[x] = GREEN_MASK;
 	    data += stride;
 	}
+        cairo_surface_mark_dirty (surface);
     }
 
     cairo_set_source_rgb (cr, 0, 1, 0); /* green */
diff --git a/test/user-font-mask.c b/test/user-font-mask.c
index 6fd40c8..a6d394e 100644
--- a/test/user-font-mask.c
+++ b/test/user-font-mask.c
@@ -126,6 +126,7 @@ test_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
 	*data = CAIRO_BITSWAP8_IF_LITTLE_ENDIAN (byte);
 	data += cairo_image_surface_get_stride (image);
     }
+    cairo_surface_mark_dirty (image);
 
     pattern = cairo_pattern_create_for_surface (image);
     cairo_surface_destroy (image);


More information about the cairo-commit mailing list