win32 compile fixes
[swftools.git] / lib / devices / arts.c
index 98aed19..ca03a80 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <memory.h>
+#include <string.h>
+#include <math.h>
 #include "../mem.h"
 #include "../gfxdevice.h"
 #include "../gfxtools.h"
 #include "../art/libart.h"
-#include "artsutils.c"
+#include "arts.h"
+#include "artsutils.h"
 
 typedef struct _clip {
     ArtSVP*svp;
@@ -40,7 +45,8 @@ typedef struct _internal {
     ArtSVP*svpunion;
 } internal_t;
 
-static int verbose = 1;
+static int verbose = 0;
+
 static void dbg(char*format, ...)
 {
     if(!verbose)
@@ -145,6 +151,20 @@ void arts_fill(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color)
     internal_t*i = (internal_t*)dev->internal;
     ArtSVP* svp = gfxfillToSVP(line, 1);
     
+    if (svp->n_segs > 500)
+    {
+       int lineParts = 0;
+       gfxline_t* lineCursor = line;
+       while(lineCursor != NULL)
+       {
+           if(lineCursor->type != gfx_moveTo) ++lineParts;
+           lineCursor = lineCursor->next;
+       }
+       fprintf(stderr, "arts_fill abandonning shape with %d segments (%d line parts)\n", svp->n_segs, lineParts);
+       art_svp_free(svp);
+       return;
+    }
+
     svp = art_svp_rewind_uncrossed(art_svp_uncross(svp),ART_WIND_RULE_ODDEVEN); /*FIXME*/
 
     if(i->clip) {
@@ -164,6 +184,7 @@ void arts_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gfxm
     dbg("arts_fillbitmap");
     internal_t*i = (internal_t*)dev->internal;
     ArtSVP* svp = gfxfillToSVP(line, 1);
+
     if(i->clip) {
        ArtSVP*old = svp;
        svp = art_svp_intersect(svp, i->clip->svp);
@@ -203,6 +224,8 @@ void arts_addfont(struct _gfxdevice*dev, gfxfont_t*font)
 void arts_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
 {
     dbg("arts_drawchar");
+    if(!font)
+       return;
     internal_t*i = (internal_t*)dev->internal;
     gfxline_t*glyph = gfxline_clone(font->glyphs[glyphnr].line);
     gfxline_transform(glyph, matrix);
@@ -235,7 +258,7 @@ void arts_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr, gfxcolor_
     gfxline_free(glyph);
 }
 
-void arts_drawlink(struct _gfxdevice*dev, gfxline_t*line, char*action)
+void arts_drawlink(struct _gfxdevice*dev, gfxline_t*line, const char*action)
 {
     dbg("arts_drawlink");
     internal_t*i = (internal_t*)dev->internal;
@@ -319,6 +342,6 @@ void gfxdevice_union_init(gfxdevice_t*dev,gfxdevice_t*out)
     dev->finish = arts_finish;
 
     i->out = out;
-    i->svpunion = gfxstrokeToSVP(0, 0, 0, 0, 0);
+    i->svpunion = gfxstrokeToSVP(0, 0, gfx_capButt, gfx_joinMiter, 0);
 }