mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-24 23:00:09 +01:00
[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:
parent
187e347351
commit
1522fac5c7
1 changed files with 3 additions and 4 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue