[perf] Fix infinite loop in text

The row would wrap-around with the character index, causing an infinite
loop when trying to fill a window of size 512x512 and above.
This commit is contained in:
Chris Wilson 2009-02-03 17:18:53 +00:00
parent 187e347351
commit 1522fac5c7

View file

@ -31,21 +31,20 @@ do_text (cairo_t *cr, int width, int height)
const char text[] = "the jay, pig, fox, zebra and my wolves quack";
int len = strlen (text);
double x, y;
int i = 0;
int i = 0, j = 0;
cairo_perf_timer_start ();
cairo_set_font_size (cr, 9);
do {
cairo_move_to (cr, 0, i * 10);
cairo_move_to (cr, 0, j++ * 10);
cairo_show_text (cr, text + i);
cairo_get_current_point (cr, &x, &y);
while (x < width && cairo_status (cr) == CAIRO_STATUS_SUCCESS) {
cairo_show_text (cr, text);
cairo_get_current_point (cr, &x, &y);
}
i++;
if (i >= len)
if (++i >= len)
i = 0;
} while (y < height && cairo_status (cr) == CAIRO_STATUS_SUCCESS);