Index: obj_poly_draw_helper.c =================================================================== --- obj_poly_draw_helper.c (revision 38727) +++ obj_poly_draw_helper.c (revision 38728) @@ -152,6 +152,7 @@ typedef struct fill_ctx_s { long used; rnd_hid_gc_t gc; + rnd_coord_t mindist; } fill_ctx_t; static void fill_begin_pline(pa_dic_ctx_t *ctx) @@ -164,14 +165,26 @@ { fill_ctx_t *fc = ctx->user_data; + if (rnd_render->gui && (fc->used > 3)) { + rnd_coord_t last2x = fc_x[fc->used-2], last2y = fc_y[fc->used-2]; + rnd_coord_t last1x = fc_x[fc->used-1], last1y = fc_y[fc->used-2]; + + /* optimization: take the last two points and the current one: + last2 -- last1 -- x;y + If last1 is too close to both last2 and x;y then overwrite last1 with + x;y (so there are less points drawn in crowded situations) */ + if ((RND_ABS(last2x - last1x) < fc->mindist) && (RND_ABS(last2y - last1y) < fc->mindist)) { + if ((RND_ABS(x - last1x) < fc->mindist) && (RND_ABS(y - last1y) < fc->mindist)) { + fc->used--; + } + } + } + if (fc->used >= fc_alloced) { fc_alloced = fc->used + 1024; fc_x = realloc(fc_x, fc_alloced * sizeof(rnd_coord_t)); - fc_y = realloc(fc_x, fc_alloced * sizeof(rnd_coord_t)); + fc_y = realloc(fc_y, fc_alloced * sizeof(rnd_coord_t)); } - if (rnd_render->gui) { - TODO("optimize using the last three coords in the array"); - } fc_x[fc->used] = x; fc_y[fc->used] = y; fc->used++; @@ -202,6 +215,7 @@ ctx.user_data = &fc; fc.gc = gc; fc.used = 0; + fc.mindist = rnd_render->coord_per_pix * 2; rnd_pline_solid_clip_box_emit(&ctx, pl); }