[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.
This commit is contained in:
M Joonas Pihlaja 2009-11-29 01:11:29 +02:00
parent b394240941
commit e09b754fdd

View file

@ -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;
}