X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fdevices%2Frender.c;h=01706211bfa59bb96a25d3c418089aaa5eb98758;hb=fe03062883881dcd0e1b8d65d676433d17973477;hp=88b9ce91275ce9500cc482393806f52a6e7e2939;hpb=b93de056e0b79f57c8f8fe22985b166c7d2c3dc3;p=swftools.git diff --git a/lib/devices/render.c b/lib/devices/render.c index 88b9ce9..0170621 100644 --- a/lib/devices/render.c +++ b/lib/devices/render.c @@ -438,6 +438,7 @@ void fill(gfxdevice_t*dev, fillinfo_t*fill) void fill_solid(gfxdevice_t*dev, gfxcolor_t* color) { fillinfo_t info; + memset(&info, 0, sizeof(info)); info.type = filltype_solid; info.color = color; fill(dev, &info); @@ -476,12 +477,13 @@ void newclip(struct _gfxdevice*dev) memset(c->data, 0, sizeof(U32)*i->bitwidth*i->height2); } -void endclip(struct _gfxdevice*dev) +void endclip(struct _gfxdevice*dev, char removelast) { internal_t*i = (internal_t*)dev->internal; - - if(!i->clipbuf) { - fprintf(stderr, "endclip without any active clip buffers"); + + /* test for at least one cliplevel (the one we created ourselves) */ + if(!i->clipbuf || (!i->clipbuf->next && !removelast)) { + fprintf(stderr, "endclip without any active clip buffers\n"); return; } @@ -502,8 +504,6 @@ void render_stroke(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t width, gfxc }*/ while(line) { - int x1,y1,x2,y2,x3,y3; - if(line->type == gfx_moveTo) { } else if(line->type == gfx_lineTo) { double x1=x*i->zoom,y1=y*i->zoom; @@ -511,7 +511,7 @@ void render_stroke(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t width, gfxc add_solidline(dev, x1, y1, x3, y3, width * i->multiply); fill_solid(dev, color); } else if(line->type == gfx_splineTo) { - int t,parts,qparts; + int t,parts; double xx,yy; double x1=x*i->zoom,y1=y*i->zoom; @@ -568,7 +568,7 @@ static void draw_line(gfxdevice_t*dev, gfxline_t*line) xx=x1; yy=y1; - parts = (int)(sqrt(c)/3); + parts = (int)(sqrt(c)); if(!parts) parts = 1; for(t=1;t<=parts;t++) { @@ -590,6 +590,7 @@ void render_startclip(struct _gfxdevice*dev, gfxline_t*line) { internal_t*i = (internal_t*)dev->internal; fillinfo_t info; + memset(&info, 0, sizeof(info)); newclip(dev); info.type = filltype_clip; draw_line(dev, line); @@ -599,7 +600,7 @@ void render_startclip(struct _gfxdevice*dev, gfxline_t*line) void render_endclip(struct _gfxdevice*dev) { internal_t*i = (internal_t*)dev->internal; - endclip(dev); + endclip(dev, 0); } void render_fill(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color) @@ -621,6 +622,7 @@ void render_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gf draw_line(dev, line); fillinfo_t info; + memset(&info, 0, sizeof(info)); info.type = filltype_bitmap; info.image = img; info.matrix = &m2; @@ -732,6 +734,7 @@ void*render_result_get(gfxresult_t*r, const char*name) i = i->next; if(!i) return 0; + pagenr--; } return gfximage_asXPM(&i->img, 64); } else if(!strncmp(name,"page",4)) { @@ -742,6 +745,7 @@ void*render_result_get(gfxresult_t*r, const char*name) i = i->next; if(!i) return 0; + pagenr--; } return &i->img; } @@ -754,10 +758,15 @@ void render_result_destroy(gfxresult_t*r) while(i) { internal_result_t*next = i->next; free(i->img.data);i->img.data = 0; - free(i); + + /* FIXME memleak + the following rfx_free causes a segfault on WIN32 machines, + if executed */ + //rfx_free(i); + i = next; } - free(r); + rfx_free(r); } gfxresult_t* render_finish(struct _gfxdevice*dev) @@ -876,10 +885,10 @@ void render_endpage(struct _gfxdevice*dev) exit(1); } - endclip(dev); + endclip(dev, 1); while(i->clipbuf) { fprintf(stderr, "Warning: unclosed clip while processing endpage()\n"); - endclip(dev); + endclip(dev, 1); } internal_result_t*ir= (internal_result_t*)rfx_calloc(sizeof(internal_result_t)); @@ -916,7 +925,6 @@ void render_drawlink(struct _gfxdevice*dev, gfxline_t*line, const char*action) void gfxdevice_render_init(gfxdevice_t*dev) { internal_t*i = (internal_t*)rfx_calloc(sizeof(internal_t)); - int y; memset(dev, 0, sizeof(gfxdevice_t)); dev->name = "render";