X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fgfxpoly%2Fconvert.c;h=dae58b6c6932272aaaec9eca73e6a6141c7c1414;hb=445a7e494abd92243be4f21028c609beb99e4322;hp=64cef43fa3bdf47b41552ff616a3f1c60b24bdd2;hpb=3c6c2c2a98a273483285119b9cc0b782aa8a79c8;p=swftools.git diff --git a/lib/gfxpoly/convert.c b/lib/gfxpoly/convert.c index 64cef43..dae58b6 100644 --- a/lib/gfxpoly/convert.c +++ b/lib/gfxpoly/convert.c @@ -12,12 +12,13 @@ static inline int32_t convert_coord(double x, double z) { - /* we clamp to 31 bit instead of 32 bit because we use - a (x1-x2) shortcut when comparing coordinates + /* we clamp to 26 bit because: + a) we use a (x1-x2) shortcut when comparing coordinates + b) we need to be able to multiply two coordinates and store them in a double w/o loss of precision */ x *= z; - if(x < -0x40000000) x = -0x40000000; - if(x > 0x3fffffff) x = 0x3fffffff; + if(x < -0x2000000) x = -0x2000000; + if(x > 0x1ffffff) x = 0x1ffffff; return ceil(x); } @@ -446,6 +447,9 @@ gfxline_t*gfxline_from_gfxpoly(gfxpoly_t*poly) pos = stroke->num_points-1; incr = -1; } + /* TODO: keeping the up/down order intact increases the polygon size + considerably. If this is going to be an even/odd polygon, + we could ignore it and save some space */ if(last.x != stroke->points[pos].x || last.y != stroke->points[pos].y) { l[count].x = stroke->points[pos].x * poly->gridsize; l[count].y = stroke->points[pos].y * poly->gridsize;