[perf] Reset the path after each spiral

Oops we were accumulating paths during each spiral iteration and so the
tests were getting slower and slower and slower...

[And fix a couple of other instances of path accumulation.]
This commit is contained in:
Chris Wilson 2009-08-13 23:23:41 +01:00
parent fddfe4973f
commit 54b2935c38
3 changed files with 5 additions and 0 deletions

View file

@ -61,6 +61,7 @@ draw_random (cairo_t *cr, cairo_fill_rule_t fill_rule,
cairo_set_fill_rule (cr, fill_rule); cairo_set_fill_rule (cr, fill_rule);
cairo_set_source_rgb (cr, 1, 0, 0); cairo_set_source_rgb (cr, 1, 0, 0);
cairo_new_path (cr);
cairo_move_to (cr, 0, 0); cairo_move_to (cr, 0, 0);
for (i = 0; i < NUM_SEGMENTS; i++) for (i = 0; i < NUM_SEGMENTS; i++)
cairo_line_to (cr, x[i], y[i]); cairo_line_to (cr, x[i], y[i]);
@ -98,6 +99,7 @@ draw_random_curve (cairo_t *cr, cairo_fill_rule_t fill_rule,
cairo_set_fill_rule (cr, fill_rule); cairo_set_fill_rule (cr, fill_rule);
cairo_set_source_rgb (cr, 1, 0, 0); cairo_set_source_rgb (cr, 1, 0, 0);
cairo_new_path (cr);
cairo_move_to (cr, 0, 0); cairo_move_to (cr, 0, 0);
for (i = 0; i < NUM_SEGMENTS; i++) { for (i = 0; i < NUM_SEGMENTS; i++) {
cairo_curve_to (cr, cairo_curve_to (cr,

View file

@ -89,6 +89,7 @@ draw_spiral (cairo_t *cr,
cairo_set_fill_rule (cr, fill_rule); cairo_set_fill_rule (cr, fill_rule);
cairo_set_source_rgb (cr, 1, 0, 0); cairo_set_source_rgb (cr, 1, 0, 0);
cairo_new_path (cr);
cairo_move_to (cr, x[0], y[0]); cairo_move_to (cr, x[0], y[0]);
for (i = 1; i < n; i++) { for (i = 1; i < n; i++) {
cairo_line_to (cr, x[i], y[i]); cairo_line_to (cr, x[i], y[i]);

View file

@ -97,6 +97,8 @@ do_world_map (cairo_t *cr, int width, int height, int loops)
break; break;
e++; e++;
} }
cairo_new_path (cr);
} }
cairo_perf_timer_stop (); cairo_perf_timer_stop ();