diff -ru ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairo-gstate-private.h cairo/src/cairo-gstate-private.h --- ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairo-gstate-private.h 2005-05-06 21:55:23.000000000 -0700 +++ cairo/src/cairo-gstate-private.h 2005-06-01 22:19:22.000000000 -0700 @@ -52,6 +52,8 @@ double *dash; int num_dashes; double dash_offset; + double max_dash_length; + double fraction_dash_lit; char *font_family; /* NULL means CAIRO_FONT_FAMILY_DEFAULT; */ cairo_font_slant_t font_slant; Only in cairo/src: cairo-gstate-private.h~ diff -ru ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairo-gstate.c cairo/src/cairo-gstate.c --- ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairo-gstate.c 2005-05-12 10:59:01.000000000 -0700 +++ cairo/src/cairo-gstate.c 2005-06-01 22:15:34.000000000 -0700 @@ -101,6 +101,8 @@ gstate->dash = NULL; gstate->num_dashes = 0; gstate->dash_offset = 0.0; + gstate->max_dash_length = 0.0; + gstate->fraction_dash_lit = 0.0; gstate->scaled_font = NULL; gstate->font_face = NULL; @@ -509,6 +511,9 @@ cairo_status_t _cairo_gstate_set_dash (cairo_gstate_t *gstate, double *dash, int num_dashes, double offset) { + double length = 0.0, lit = 0.0; + int i; + if (gstate->dash) { free (gstate->dash); gstate->dash = NULL; @@ -521,6 +526,16 @@ gstate->num_dashes = 0; return CAIRO_STATUS_NO_MEMORY; } + + gstate->max_dash_length = 0.0; + for (i = 0; i < num_dashes; i++) { + gstate->max_dash_length = MAX(dash[i], gstate->max_dash_length); + + if (!(i & 1)) + lit += dash[i]; + length += dash[i]; + } + gstate->fraction_dash_lit = lit/length; } memcpy (gstate->dash, dash, gstate->num_dashes * sizeof (double)); @@ -954,11 +969,30 @@ return status; } +static cairo_bool_t +_dashes_invisible (cairo_gstate_t *gstate) +{ + if (gstate->dash) { + double min, max; + + _cairo_matrix_compute_expansion_factors (&gstate->ctm, &min, &max); + + /* Quick and dirty applicaton of Nyquist sampling limit */ + + if (min * gstate->max_dash_length < 0.5f) + return TRUE; + } + + return FALSE; +} + cairo_status_t _cairo_gstate_stroke (cairo_gstate_t *gstate, cairo_path_fixed_t *path) { cairo_status_t status; cairo_traps_t traps; + double *dash = NULL; + double alpha = 0.0; if (gstate->surface->level != gstate->surface_level) return CAIRO_STATUS_BAD_NESTING; @@ -966,15 +1000,21 @@ if (gstate->line_width <= 0.0) return CAIRO_STATUS_SUCCESS; + if (_dashes_invisible(gstate)) { + dash = gstate->dash; + gstate->dash = NULL; + + /* alpha = gstate->alpha; */ + /* gstate->alpha *= gstate->fraction_dash_lit; */ + } + _cairo_pen_init (&gstate->pen_regular, gstate->line_width / 2.0, gstate); _cairo_traps_init (&traps); status = _cairo_path_fixed_stroke_to_traps (path, gstate, &traps); - if (status) { - _cairo_traps_fini (&traps); - return status; - } + if (status) + goto BAIL; _cairo_gstate_clip_and_composite_trapezoids (gstate, gstate->source, @@ -982,9 +1022,15 @@ gstate->surface, &traps); +BAIL: _cairo_traps_fini (&traps); - return CAIRO_STATUS_SUCCESS; + if (dash) { + gstate->dash = dash; + /* gstate->alpha = alpha; */ + } + + return status; } cairo_status_t @@ -1514,7 +1560,13 @@ cairo_status_t status; cairo_traps_t traps; cairo_box_t extents; - + double *dash = NULL; + + if (_dashes_invisible(gstate)) { + dash = gstate->dash; + gstate->dash = NULL; + } + _cairo_pen_init (&gstate->pen_regular, gstate->line_width / 2.0, gstate); _cairo_traps_init (&traps); @@ -1535,6 +1587,9 @@ BAIL: _cairo_traps_fini (&traps); + + if (dash) + gstate->dash = dash; return status; } Only in cairo/src: cairo-gstate.c~ diff -ru ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairo-matrix.c cairo/src/cairo-matrix.c --- ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairo-matrix.c 2005-05-09 08:50:27.000000000 -0700 +++ cairo/src/cairo-matrix.c 2005-06-01 22:19:54.000000000 -0700 @@ -559,6 +559,29 @@ return CAIRO_STATUS_SUCCESS; } +/* Compute the min/max expansion factors. See the comment in + * cairo-pen.c for the derivation */ +cairo_status_t +_cairo_matrix_compute_expansion_factors (const cairo_matrix_t *matrix, + double *min, double *max) +{ + double a = matrix->xx, b = matrix->yx; + double c = matrix->xy, d = matrix->yy; + + double i = a*a + c*c; + double j = b*b + d*d; + + double f = 0.5 * (i + j); + double g = 0.5 * (i - j); + double h = a*b + c*d; + + *max = sqrt (f + sqrt (g*g+h*h)); + + *min = sqrt (f - sqrt (g*g+h*h)); + + return CAIRO_STATUS_SUCCESS; +} + cairo_bool_t _cairo_matrix_is_integer_translation(const cairo_matrix_t *mat, int *itx, int *ity) diff -ru ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairo-pen.c cairo/src/cairo-pen.c --- ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairo-pen.c 2005-05-06 21:55:23.000000000 -0700 +++ cairo/src/cairo-pen.c 2005-06-01 22:18:51.000000000 -0700 @@ -374,32 +374,15 @@ double radius, cairo_matrix_t *matrix) { - double a = matrix->xx, b = matrix->yx; - double c = matrix->xy, d = matrix->yy; + double min, max, major_axis; + int num_vertices; - double i = a*a + c*c; - double j = b*b + d*d; - - double f = 0.5 * (i + j); - double g = 0.5 * (i - j); - double h = a*b + c*d; - - /* - * compute major and minor axes lengths for - * a pen with the specified radius - */ - - double major_axis = radius * sqrt (f + sqrt (g*g+h*h)); - - /* - * we don't need the minor axis length, which is - * double min = radius * sqrt (f - sqrt (g*g+h*h)); - */ + _cairo_matrix_compute_expansion_factors (matrix, &min, &max); + major_axis = radius * max; /* * compute number of vertices needed */ - int num_vertices; /* Where tolerance / M is > 1, we use 4 points */ if (tolerance >= major_axis) { Only in cairo/src: cairo-pen.c~ diff -ru ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairo-wideint.h cairo/src/cairo-wideint.h --- ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairo-wideint.h 2005-05-10 14:55:37.000000000 -0700 +++ cairo/src/cairo-wideint.h 2005-06-01 22:07:43.000000000 -0700 @@ -45,7 +45,7 @@ #elif HAVE_SYS_INT_TYPES_H # include #else -#error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.) +# include "mozstdint.h" #endif /* diff -ru ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairoint.h cairo/src/cairoint.h --- ../../../../../cairo-cvs/dist/cairo-0.5.0/src/cairoint.h 2005-05-17 06:17:45.000000000 -0700 +++ cairo/src/cairoint.h 2005-06-01 22:19:46.000000000 -0700 @@ -1638,6 +1638,9 @@ _cairo_matrix_compute_scale_factors (const cairo_matrix_t *matrix, double *sx, double *sy, int x_major); +cairo_private cairo_status_t +_cairo_matrix_compute_expansion_factors (const cairo_matrix_t *matrix, double *min, double *max); + cairo_private cairo_bool_t _cairo_matrix_is_integer_translation(const cairo_matrix_t *matrix, int *itx, int *ity); Only in cairo/src: cairoint.h~