git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
made patch non-verbose
[swftools.git]
/
lib
/
devices
/
swf.c
diff --git
a/lib/devices/swf.c
b/lib/devices/swf.c
index
e7a03ac
..
fb2c341
100644
(file)
--- a/
lib/devices/swf.c
+++ b/
lib/devices/swf.c
@@
-85,6
+85,7
@@
typedef struct _swfoutput_internal
int config_protect;
int config_bboxvars;
int config_disable_polygon_conversion;
int config_protect;
int config_bboxvars;
int config_disable_polygon_conversion;
+ int config_normalize_polygon_positions;
RGBA config_linkcolor;
float config_minlinewidth;
double config_caplinewidth;
RGBA config_linkcolor;
float config_minlinewidth;
double config_caplinewidth;
@@
-177,7
+178,7
@@
static void swf_fillbitmap(gfxdevice_t*dev, gfxline_t*line, gfximage_t*img, gfxm
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, gfxfont_t*font, int glyph, gfxcolor_t*color, gfxmatrix_t*matrix);
static void swf_addfont(gfxdevice_t*dev, gfxfont_t*font);
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, gfxfont_t*font, int glyph, gfxcolor_t*color, gfxmatrix_t*matrix);
static void swf_addfont(gfxdevice_t*dev, gfxfont_t*font);
-static void swf_drawlink(gfxdevice_t*dev, gfxline_t*line, char*action);
+static void swf_drawlink(gfxdevice_t*dev, gfxline_t*line, const 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 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);
@@
-1249,11
+1250,11
@@
void swfoutput_finalize(gfxdevice_t*dev)
i->swf->compressed = 1;
}
i->swf->compressed = 1;
}
- if(i->config_reordertags)
- swf_Optimize(i->swf);
+// if(i->config_reordertags)
+// swf_Optimize(i->swf);
}
}
-int swfresult_save(gfxresult_t*gfx, char*filename)
+int swfresult_save(gfxresult_t*gfx, const char*filename)
{
SWF*swf = (SWF*)gfx->internal;
int fi;
{
SWF*swf = (SWF*)gfx->internal;
int fi;
@@
-1279,7
+1280,7
@@
int swfresult_save(gfxresult_t*gfx, char*filename)
close(fi);
return 0;
}
close(fi);
return 0;
}
-void* swfresult_get(gfxresult_t*gfx, char*name)
+void* swfresult_get(gfxresult_t*gfx, const char*name)
{
SWF*swf = (SWF*)gfx->internal;
if(!strcmp(name, "swf")) {
{
SWF*swf = (SWF*)gfx->internal;
if(!strcmp(name, "swf")) {
@@
-1408,15
+1409,15
@@
static void swfoutput_setlinewidth(gfxdevice_t*dev, double _linewidth)
static void drawlink(gfxdevice_t*dev, ActionTAG*,ActionTAG*, gfxline_t*points, char mouseover);
static void swfoutput_namedlink(gfxdevice_t*dev, char*name, gfxline_t*points);
static void swfoutput_linktopage(gfxdevice_t*dev, int page, gfxline_t*points);
static void drawlink(gfxdevice_t*dev, ActionTAG*,ActionTAG*, gfxline_t*points, char mouseover);
static void swfoutput_namedlink(gfxdevice_t*dev, char*name, gfxline_t*points);
static void swfoutput_linktopage(gfxdevice_t*dev, int page, gfxline_t*points);
-static void swfoutput_linktourl(gfxdevice_t*dev, char*url, gfxline_t*points);
+static void swfoutput_linktourl(gfxdevice_t*dev, const char*url, gfxline_t*points);
-void swfoutput_drawlink(gfxdevice_t*dev, char*url, gfxline_t*points)
+/*void swfoutput_drawlink(gfxdevice_t*dev, char*url, gfxline_t*points)
{
swfoutput_internal*i = (swfoutput_internal*)dev->internal;
dev->drawlink(dev, points, url);
{
swfoutput_internal*i = (swfoutput_internal*)dev->internal;
dev->drawlink(dev, points, url);
-}
+}*/
-void swf_drawlink(gfxdevice_t*dev, gfxline_t*points, char*url)
+void swf_drawlink(gfxdevice_t*dev, gfxline_t*points, const char*url)
{
swfoutput_internal*i = (swfoutput_internal*)dev->internal;
{
swfoutput_internal*i = (swfoutput_internal*)dev->internal;
@@
-1442,7
+1443,7
@@
void swf_drawlink(gfxdevice_t*dev, gfxline_t*points, char*url)
swfoutput_linktourl(dev, url, points);
}
}
swfoutput_linktourl(dev, url, points);
}
}
-void swfoutput_linktourl(gfxdevice_t*dev, char*url, gfxline_t*points)
+void swfoutput_linktourl(gfxdevice_t*dev, const char*url, gfxline_t*points)
{
ActionTAG* actions = 0;
swfoutput_internal*i = (swfoutput_internal*)dev->internal;
{
ActionTAG* actions = 0;
swfoutput_internal*i = (swfoutput_internal*)dev->internal;
@@
-1780,8
+1781,13
@@
int swf_setparameter(gfxdevice_t*dev, const char*name, const char*value)
i->config_internallinkfunction = strdup(value);
} else if(!strcmp(name, "externallinkfunction")) {
i->config_externallinkfunction = strdup(value);
i->config_internallinkfunction = strdup(value);
} else if(!strcmp(name, "externallinkfunction")) {
i->config_externallinkfunction = strdup(value);
+ } else if(!strcmp(name, "linkfunction")) { //sets both internallinkfunction and externallinkfunction
+ i->config_internallinkfunction = strdup(value);
+ i->config_externallinkfunction = strdup(value);
} else if(!strcmp(name, "disable_polygon_conversion")) {
i->config_disable_polygon_conversion = atoi(value);
} else if(!strcmp(name, "disable_polygon_conversion")) {
i->config_disable_polygon_conversion = atoi(value);
+ } else if(!strcmp(name, "normalize_polygon_positions")) {
+ i->config_normalize_polygon_positions = atoi(value);
} else if(!strcmp(name, "insertstop")) {
i->config_insertstoptag = atoi(value);
} else if(!strcmp(name, "protect")) {
} else if(!strcmp(name, "insertstop")) {
i->config_insertstoptag = atoi(value);
} else if(!strcmp(name, "protect")) {
@@
-1816,7
+1822,7
@@
int swf_setparameter(gfxdevice_t*dev, const char*name, const char*value)
} else if(!strcmp(name, "jpegquality")) {
int val = atoi(value);
if(val<0) val=0;
} else if(!strcmp(name, "jpegquality")) {
int val = atoi(value);
if(val<0) val=0;
- if(val>100) val=100;
+ if(val>101) val=101;
i->config_jpegquality = val;
} else if(!strcmp(name, "splinequality")) {
int v = atoi(value);
i->config_jpegquality = val;
} else if(!strcmp(name, "splinequality")) {
int v = atoi(value);
@@
-2072,7
+2078,14
@@
static void swf_startclip(gfxdevice_t*dev, gfxline_t*line)
swf_SetShapeBits(i->tag,shape);
swf_ShapeSetAll(i->tag,shape,UNDEFINED_COORD,UNDEFINED_COORD,0,fsid,0);
i->swflastx = i->swflasty = UNDEFINED_COORD;
swf_SetShapeBits(i->tag,shape);
swf_ShapeSetAll(i->tag,shape,UNDEFINED_COORD,UNDEFINED_COORD,0,fsid,0);
i->swflastx = i->swflasty = UNDEFINED_COORD;
+ i->shapeisempty = 1;
drawgfxline(dev, line);
drawgfxline(dev, line);
+ if(i->shapeisempty) {
+ /* an empty clip shape is equivalent to a shape with no area */
+ moveto(dev, i->tag, line->x, line->y);
+ lineto(dev, i->tag, line->x, line->y);
+ lineto(dev, i->tag, line->x, line->y);
+ }
swf_ShapeSetEnd(i->tag);
swf_ShapeFree(shape);
swf_ShapeSetEnd(i->tag);
swf_ShapeFree(shape);
@@
-2259,17
+2272,17
@@
static void swf_stroke(gfxdevice_t*dev, gfxline_t*line, gfxcoord_t width, gfxcol
msg("<trace> draw as stroke, type=%d dots=%d", type, has_dots);
endtext(dev);
msg("<trace> draw as stroke, type=%d dots=%d", type, has_dots);
endtext(dev);
-#ifdef NORMALIZE_POLYGON_POSITIONS
- endshape(dev);
- double startx = 0, starty = 0;
- if(line && line->type == gfx_moveTo) {
- startx = line->x;
- starty = line->y;
- }
- line = gfxline_move(line, -startx, -starty);
- i->shapeposx = (int)(startx*20);
- i->shapeposy = (int)(starty*20);
-#endif
+ if(i->config_normalize_polygon_positions) {
+ endshape(dev);
+ double startx = 0, starty = 0;
+ if(line && line->type == gfx_moveTo) {
+ startx = line->x;
+ starty = line->y;
+ }
+ line = gfxline_move(line, -startx, -starty);
+ i->shapeposx = (int)(startx*20);
+ i->shapeposy = (int)(starty*20);
+ }
swfoutput_setstrokecolor(dev, color->r, color->g, color->b, color->a);
swfoutput_setlinewidth(dev, width);
swfoutput_setstrokecolor(dev, color->r, color->g, color->b, color->a);
swfoutput_setlinewidth(dev, width);
@@
-2277,9
+2290,9
@@
static void swf_stroke(gfxdevice_t*dev, gfxline_t*line, gfxcoord_t width, gfxcol
stopFill(dev);
drawgfxline(dev, line);
stopFill(dev);
drawgfxline(dev, line);
-#ifdef NORMALIZE_POLYGON_POSITIONS
- free(line); //account for _move
-#endif
+ if(i->config_normalize_polygon_positions) {
+ free(line); //account for _move
+ }
}
static void swf_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
}
static void swf_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
@@
-2296,17
+2309,17
@@
static void swf_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
if(!i->config_ignoredraworder)
endshape(dev);
if(!i->config_ignoredraworder)
endshape(dev);
-#ifdef NORMALIZE_POLYGON_POSITIONS
- endshape(dev);
- double startx = 0, starty = 0;
- if(line && line->type == gfx_moveTo) {
- startx = line->x;
- starty = line->y;
- }
- line = gfxline_move(line, -startx, -starty);
- i->shapeposx = (int)(startx*20);
- i->shapeposy = (int)(starty*20);
-#endif
+ if(i->config_normalize_polygon_positions) {
+ endshape(dev);
+ double startx = 0, starty = 0;
+ if(line && line->type == gfx_moveTo) {
+ startx = line->x;
+ starty = line->y;
+ }
+ line = gfxline_move(line, -startx, -starty);
+ i->shapeposx = (int)(startx*20);
+ i->shapeposy = (int)(starty*20);
+ }
swfoutput_setfillcolor(dev, color->r, color->g, color->b, color->a);
startshape(dev);
swfoutput_setfillcolor(dev, color->r, color->g, color->b, color->a);
startshape(dev);
@@
-2315,9
+2328,9
@@
static void swf_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
drawgfxline(dev, line);
msg("<trace> end of swf_fill (shapeid=%d)", i->shapeid);
drawgfxline(dev, line);
msg("<trace> end of swf_fill (shapeid=%d)", i->shapeid);
-#ifdef NORMALIZE_POLYGON_POSITIONS
- free(line); //account for _move
-#endif
+ if(i->config_normalize_polygon_positions) {
+ free(line); //account for _move
+ }
}
static void swf_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
{
}
static void swf_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
{
@@
-2326,7
+2339,7
@@
static void swf_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*grad
msg("<error> Gradient filling not implemented yet");
}
msg("<error> Gradient filling not implemented yet");
}
-static SWFFONT* gfxfont_to_swffont(gfxfont_t*font, char* id)
+static SWFFONT* gfxfont_to_swffont(gfxfont_t*font, const char* id)
{
SWFFONT*swffont = (SWFFONT*)rfx_calloc(sizeof(SWFFONT));
int t;
{
SWFFONT*swffont = (SWFFONT*)rfx_calloc(sizeof(SWFFONT));
int t;
@@
-2467,7
+2480,7
@@
static void swf_addfont(gfxdevice_t*dev, gfxfont_t*font)
}
}
}
}
-static void swf_switchfont(gfxdevice_t*dev, char*fontid)
+static void swf_switchfont(gfxdevice_t*dev, const char*fontid)
{
swfoutput_internal*i = (swfoutput_internal*)dev->internal;
{
swfoutput_internal*i = (swfoutput_internal*)dev->internal;
@@
-2501,7
+2514,7
@@
static void swf_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyph, gfxcolor_t*
swf_switchfont(dev, font->id); // set the current font
}
setfontscale(dev, matrix->m00, matrix->m01, matrix->m10, matrix->m11);
swf_switchfont(dev, font->id); // set the current font
}
setfontscale(dev, matrix->m00, matrix->m01, matrix->m10, matrix->m11);
-
+
/* printf("%f %f\n", m.m31, m.m32);
{
static int xpos = 40;
/* printf("%f %f\n", m.m31, m.m32);
{
static int xpos = 40;