+ SWFFONT *swffont;
+ fontlist_t*next;
+};
+
+typedef long int twip;
+
+struct swfmatrix {
+ double m11,m12,m21,m22,m31,m32;
+};
+
+typedef struct _swfoutput_internal
+{
+ gfxdevice_t*dev; // the gfxdevice object where this internal struct resides
+
+ double config_dumpfonts;
+ double config_ppmsubpixels;
+ double config_jpegsubpixels;
+ int config_opennewwindow;
+ int config_ignoredraworder;
+ int config_drawonlyshapes;
+ int config_jpegquality;
+ int config_storeallcharacters;
+ int config_enablezlib;
+ int config_insertstoptag;
+ int config_flashversion;
+ int config_splinemaxerror;
+ int config_fontsplinemaxerror;
+ int config_filloverlap;
+ int config_protect;
+ int config_bboxvars;
+ float config_minlinewidth;
+ double config_caplinewidth;
+
+ SWF* swf;
+
+ fontlist_t* fontlist;
+
+ char storefont;
+
+ MATRIX page_matrix;
+
+ TAG *tag;
+ int currentswfid;
+ int depth;
+ int startdepth;
+ int linewidth;
+
+ SHAPE* shape;
+ int shapeid;
+ int textid;
+
+ int fillstyleid;
+ int linestyleid;
+ int swflastx;
+ int swflasty;
+ int lastwasfill;
+ int shapeisempty;
+ char fill;
+ int min_x,max_x;
+ int min_y,max_y;
+ TAG* cliptags[128];
+ int clipshapes[128];
+ U32 clipdepths[128];
+ int clippos;
+
+ /* image cache */
+ int pic_xids[1024];
+ int pic_yids[1024];
+ int pic_ids[1024];
+ int pic_width[1024];
+ int pic_height[1024];
+ int picpos;
+
+ int frameno;
+ int lastframeno;
+
+ char fillstylechanged;
+
+ int jpeg; //next image type
+
+ int bboxrectpos;
+ SRECT bboxrect;
+
+ chardata_t chardata[CHARDATAMAX];
+ int chardatapos;
+ int firstpage;
+ char pagefinished;
+
+ char overflow;
+
+ MATRIX fontmatrix;
+ double fontm11,fontm12,fontm21,fontm22;
+ SWFFONT *swffont;
+ RGBA strokergb;
+ RGBA fillrgb;
+ int drawmode;
+
+} swfoutput_internal;
+
+static void swf_fillbitmap(gfxdevice_t*driver, gfxline_t*line, gfximage_t*img, gfxmatrix_t*move, gfxcxform_t*cxform);
+static int swf_setparameter(gfxdevice_t*driver, const char*key, const char*value);
+static void swf_drawstroke(gfxdevice_t*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit);
+static void swf_startclip(gfxdevice_t*dev, gfxline_t*line);
+static void swf_endclip(gfxdevice_t*dev);
+static void swf_stroke(gfxdevice_t*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit);
+static void swf_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color);
+static void swf_fillbitmap(gfxdevice_t*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform);
+static void swf_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix);
+static void swf_drawchar(gfxdevice_t*dev, char*fontid, int glyph, gfxcolor_t*color, gfxmatrix_t*matrix);
+static void swf_addfont(gfxdevice_t*dev, char*fontid, gfxfont_t*font);
+static void swf_drawlink(gfxdevice_t*dev, gfxline_t*line, char*action);
+static void swf_startframe(gfxdevice_t*dev, int width, int height);
+static void swf_endframe(gfxdevice_t*dev);
+static gfxresult_t* swf_finish(gfxdevice_t*driver);
+
+static swfoutput_internal* init_internal_struct()
+{
+ swfoutput_internal*i = (swfoutput_internal*)malloc(sizeof(swfoutput_internal));
+ memset(i, 0, sizeof(swfoutput_internal));
+
+ i->storefont = 0;
+ i->currentswfid = 0;
+ i->depth = 0;
+ i->overflow = 0;
+ i->startdepth = 0;
+ i->linewidth = 0;
+ i->shapeid = -1;
+ i->textid = -1;
+ i->frameno = 0;
+ i->lastframeno = 0;
+
+ i->fillstyleid;
+ i->linestyleid;
+ i->swflastx=0;
+ i->swflasty=0;
+ i->lastwasfill = 0;
+ i->shapeisempty = 1;
+ i->fill = 0;
+ i->clippos = 0;
+
+ i->fillstylechanged = 0;
+
+ i->bboxrectpos = -1;
+ i->chardatapos = 0;
+ i->firstpage = 1;
+ i->pagefinished = 1;
+
+ i->config_dumpfonts=0;
+ i->config_ppmsubpixels=0;
+ i->config_jpegsubpixels=0;
+ i->config_opennewwindow=1;
+ i->config_ignoredraworder=0;
+ i->config_drawonlyshapes=0;
+ i->config_jpegquality=85;
+ i->config_storeallcharacters=0;
+ i->config_enablezlib=0;
+ i->config_insertstoptag=0;
+ i->config_flashversion=5;
+ i->config_splinemaxerror=1;
+ i->config_fontsplinemaxerror=1;
+ i->config_filloverlap=0;
+ i->config_protect=0;
+ i->config_bboxvars=0;
+ i->config_minlinewidth=0.05;
+ i->config_caplinewidth=1;
+
+ return i;
+};
+
+static int id_error = 0;
+
+static U16 getNewID(gfxdevice_t* dev)
+{
+ swfoutput_internal*i = (swfoutput_internal*)dev->internal;
+ if(i->currentswfid == 65535) {
+ if(!id_error)
+ msg("<error> ID Table overflow");
+ id_error=1;
+ i->overflow = 1;
+ }
+ return ++i->currentswfid;
+}
+static U16 getNewDepth(gfxdevice_t* dev)
+{
+ swfoutput_internal*i = (swfoutput_internal*)dev->internal;
+ if(i->depth == 65535) {
+ if(!id_error)
+ msg("<error> Depth Table overflow");
+ id_error=1;
+ i->overflow = 1;
+ }
+ return ++i->depth;