git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test function member assignment
[swftools.git]
/
lib
/
devices
/
record.c
diff --git
a/lib/devices/record.c
b/lib/devices/record.c
index
b14d51a
..
a8a0088
100644
(file)
--- a/
lib/devices/record.c
+++ b/
lib/devices/record.c
@@
-40,6
+40,7
@@
typedef struct _internal {
gfxfontlist_t* fontlist;
writer_t w;
typedef struct _internal {
gfxfontlist_t* fontlist;
writer_t w;
+ int cliplevel;
} internal_t;
typedef struct _internal_result {
} internal_t;
typedef struct _internal_result {
@@
-69,7
+70,7
@@
typedef struct _internal_result {
static int record_setparameter(struct _gfxdevice*dev, const char*key, const char*value)
{
internal_t*i = (internal_t*)dev->internal;
static int record_setparameter(struct _gfxdevice*dev, const char*key, const char*value)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: SETPARAM %s %s\n", key, value);
+ msg("<trace> record: %08x SETPARAM %s %s\n", dev, key, value);
writer_writeU8(&i->w, OP_SETPARAM);
writer_writeString(&i->w, key);
writer_writeString(&i->w, value);
writer_writeU8(&i->w, OP_SETPARAM);
writer_writeString(&i->w, key);
writer_writeString(&i->w, value);
@@
-283,7
+284,7
@@
static gfxfont_t*readFont(reader_t*r)
static void record_stroke(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit)
{
internal_t*i = (internal_t*)dev->internal;
static void record_stroke(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: STROKE\n");
+ msg("<trace> record: %08x STROKE\n", dev);
writer_writeU8(&i->w, OP_STROKE);
writer_writeDouble(&i->w, width);
writer_writeDouble(&i->w, miterLimit);
writer_writeU8(&i->w, OP_STROKE);
writer_writeDouble(&i->w, width);
writer_writeDouble(&i->w, miterLimit);
@@
-296,22
+297,27
@@
static void record_stroke(struct _gfxdevice*dev, gfxline_t*line, gfxcoord_t widt
static void record_startclip(struct _gfxdevice*dev, gfxline_t*line)
{
internal_t*i = (internal_t*)dev->internal;
static void record_startclip(struct _gfxdevice*dev, gfxline_t*line)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: STARTCLIP\n");
+ msg("<trace> record: %08x STARTCLIP\n", dev);
writer_writeU8(&i->w, OP_STARTCLIP);
dumpLine(&i->w, line);
writer_writeU8(&i->w, OP_STARTCLIP);
dumpLine(&i->w, line);
+ i->cliplevel++;
}
static void record_endclip(struct _gfxdevice*dev)
{
internal_t*i = (internal_t*)dev->internal;
}
static void record_endclip(struct _gfxdevice*dev)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: ENDCLIP\n");
+ msg("<trace> record: %08x ENDCLIP\n", dev);
writer_writeU8(&i->w, OP_ENDCLIP);
writer_writeU8(&i->w, OP_ENDCLIP);
+ i->cliplevel--;
+ if(i->cliplevel<0) {
+ msg("<error> record: endclip() without startclip()");
+ }
}
static void record_fill(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color)
{
internal_t*i = (internal_t*)dev->internal;
}
static void record_fill(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: FILL\n");
+ msg("<trace> record: %08x FILL\n", dev);
writer_writeU8(&i->w, OP_FILL);
dumpColor(&i->w, color);
dumpLine(&i->w, line);
writer_writeU8(&i->w, OP_FILL);
dumpColor(&i->w, color);
dumpLine(&i->w, line);
@@
-320,7
+326,7
@@
static void record_fill(struct _gfxdevice*dev, gfxline_t*line, gfxcolor_t*color)
static void record_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
{
internal_t*i = (internal_t*)dev->internal;
static void record_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: FILLBITMAP\n");
+ msg("<trace> record: %08x FILLBITMAP\n", dev);
writer_writeU8(&i->w, OP_FILLBITMAP);
dumpImage(&i->w, img);
dumpMatrix(&i->w, matrix);
writer_writeU8(&i->w, OP_FILLBITMAP);
dumpImage(&i->w, img);
dumpMatrix(&i->w, matrix);
@@
-331,7
+337,7
@@
static void record_fillbitmap(struct _gfxdevice*dev, gfxline_t*line, gfximage_t*
static void record_fillgradient(struct _gfxdevice*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
{
internal_t*i = (internal_t*)dev->internal;
static void record_fillgradient(struct _gfxdevice*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: FILLGRADIENT\n");
+ msg("<trace> record: %08x FILLGRADIENT %08x\n", dev, gradient);
writer_writeU8(&i->w, OP_FILLGRADIENT);
writer_writeU8(&i->w, type);
dumpGradient(&i->w, gradient);
writer_writeU8(&i->w, OP_FILLGRADIENT);
writer_writeU8(&i->w, type);
dumpGradient(&i->w, gradient);
@@
-342,10
+348,12
@@
static void record_fillgradient(struct _gfxdevice*dev, gfxline_t*line, gfxgradie
static void record_addfont(struct _gfxdevice*dev, gfxfont_t*font)
{
internal_t*i = (internal_t*)dev->internal;
static void record_addfont(struct _gfxdevice*dev, gfxfont_t*font)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: ADDFONT\n");
- writer_writeU8(&i->w, OP_ADDFONT);
- dumpFont(&i->w, font);
- i->fontlist = gfxfontlist_addfont(i->fontlist, font);
+ msg("<trace> record: %08x ADDFONT %s\n", dev, font->id);
+ if(font && !gfxfontlist_hasfont(i->fontlist, font)) {
+ writer_writeU8(&i->w, OP_ADDFONT);
+ dumpFont(&i->w, font);
+ i->fontlist = gfxfontlist_addfont(i->fontlist, font);
+ }
}
static void record_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
}
static void record_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
@@
-353,10
+361,9
@@
static void record_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr,
internal_t*i = (internal_t*)dev->internal;
if(font && !gfxfontlist_hasfont(i->fontlist, font)) {
record_addfont(dev, font);
internal_t*i = (internal_t*)dev->internal;
if(font && !gfxfontlist_hasfont(i->fontlist, font)) {
record_addfont(dev, font);
- i->fontlist = gfxfontlist_addfont(i->fontlist, font);
}
}
- msg("<trace> record: DRAWCHAR %d\n", glyphnr);
+ msg("<trace> record: %08x DRAWCHAR %d\n", glyphnr, dev);
writer_writeU8(&i->w, OP_DRAWCHAR);
if(font)
writer_writeString(&i->w, font->id);
writer_writeU8(&i->w, OP_DRAWCHAR);
if(font)
writer_writeString(&i->w, font->id);
@@
-370,7
+377,7
@@
static void record_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr,
static void record_startpage(struct _gfxdevice*dev, int width, int height)
{
internal_t*i = (internal_t*)dev->internal;
static void record_startpage(struct _gfxdevice*dev, int width, int height)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: STARTPAGE\n");
+ msg("<trace> record: %08x STARTPAGE\n", dev);
writer_writeU8(&i->w, OP_STARTPAGE);
writer_writeU16(&i->w, width);
writer_writeU16(&i->w, height);
writer_writeU8(&i->w, OP_STARTPAGE);
writer_writeU16(&i->w, width);
writer_writeU16(&i->w, height);
@@
-379,24
+386,24
@@
static void record_startpage(struct _gfxdevice*dev, int width, int height)
static void record_endpage(struct _gfxdevice*dev)
{
internal_t*i = (internal_t*)dev->internal;
static void record_endpage(struct _gfxdevice*dev)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: ENDPAGE\n");
+ msg("<trace> record: %08x ENDPAGE\n", dev);
writer_writeU8(&i->w, OP_ENDPAGE);
}
static void record_drawlink(struct _gfxdevice*dev, gfxline_t*line, const char*action)
{
internal_t*i = (internal_t*)dev->internal;
writer_writeU8(&i->w, OP_ENDPAGE);
}
static void record_drawlink(struct _gfxdevice*dev, gfxline_t*line, const char*action)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: DRAWLINK\n");
+ msg("<trace> record: %08x DRAWLINK\n", dev);
writer_writeU8(&i->w, OP_DRAWLINK);
dumpLine(&i->w, line);
writer_writeString(&i->w, action);
}
writer_writeU8(&i->w, OP_DRAWLINK);
dumpLine(&i->w, line);
writer_writeString(&i->w, action);
}
-static void replay(struct _gfxdevice*recorddev, gfxdevice_t*device, void*data, int length)
+static void replay(struct _gfxdevice*dev, gfxdevice_t*out, void*data, int length)
{
internal_t*i = 0;
{
internal_t*i = 0;
- if(recorddev) {
- i = (internal_t*)recorddev->internal;
+ if(dev) {
+ i = (internal_t*)dev->internal;
}
reader_t r2;
}
reader_t r2;
@@
-408,15
+415,14
@@
static void replay(struct _gfxdevice*recorddev, gfxdevice_t*device, void*data, i
unsigned char op = reader_readU8(r);
switch(op) {
case OP_END:
unsigned char op = reader_readU8(r);
switch(op) {
case OP_END:
- msg("<trace> replay: END");
- return;
+ goto finish;
case OP_SETPARAM: {
msg("<trace> replay: SETPARAM");
char*key;
char*value;
key = reader_readString(r);
value = reader_readString(r);
case OP_SETPARAM: {
msg("<trace> replay: SETPARAM");
char*key;
char*value;
key = reader_readString(r);
value = reader_readString(r);
- device->setparameter(device, key, value);
+ out->setparameter(out, key, value);
free(key);
free(value);
break;
free(key);
free(value);
break;
@@
-425,7
+431,7
@@
static void replay(struct _gfxdevice*recorddev, gfxdevice_t*device, void*data, i
msg("<trace> replay: STARTPAGE");
U16 width = reader_readU16(r);
U16 height = reader_readU16(r);
msg("<trace> replay: STARTPAGE");
U16 width = reader_readU16(r);
U16 height = reader_readU16(r);
- device->startpage(device, width, height);
+ out->startpage(out, width, height);
break;
}
case OP_ENDPAGE: {
break;
}
case OP_ENDPAGE: {
@@
-456,27
+462,27
@@
static void replay(struct _gfxdevice*recorddev, gfxdevice_t*device, void*data, i
case 2: jointtype = gfx_joinBevel; break;
}
gfxline_t* line = readLine(r);
case 2: jointtype = gfx_joinBevel; break;
}
gfxline_t* line = readLine(r);
- device->stroke(device, line, width, &color, captype, jointtype,miterlimit);
+ out->stroke(out, line, width, &color, captype, jointtype,miterlimit);
gfxline_free(line);
break;
}
case OP_STARTCLIP: {
msg("<trace> replay: STARTCLIP");
gfxline_t* line = readLine(r);
gfxline_free(line);
break;
}
case OP_STARTCLIP: {
msg("<trace> replay: STARTCLIP");
gfxline_t* line = readLine(r);
- device->startclip(device, line);
+ out->startclip(out, line);
gfxline_free(line);
break;
}
case OP_ENDCLIP: {
msg("<trace> replay: ENDCLIP");
gfxline_free(line);
break;
}
case OP_ENDCLIP: {
msg("<trace> replay: ENDCLIP");
- device->endclip(device);
+ out->endclip(out);
break;
}
case OP_FILL: {
msg("<trace> replay: FILL");
gfxcolor_t color = readColor(r);
gfxline_t* line = readLine(r);
break;
}
case OP_FILL: {
msg("<trace> replay: FILL");
gfxcolor_t color = readColor(r);
gfxline_t* line = readLine(r);
- device->fill(device, line, &color);
+ out->fill(out, line, &color);
gfxline_free(line);
break;
}
gfxline_free(line);
break;
}
@@
-486,9
+492,11
@@
static void replay(struct _gfxdevice*recorddev, gfxdevice_t*device, void*data, i
gfxmatrix_t matrix = readMatrix(r);
gfxline_t* line = readLine(r);
gfxcxform_t* cxform = readCXForm(r);
gfxmatrix_t matrix = readMatrix(r);
gfxline_t* line = readLine(r);
gfxcxform_t* cxform = readCXForm(r);
- device->fillbitmap(device, line, &img, &matrix, cxform);
+ out->fillbitmap(out, line, &img, &matrix, cxform);
+ gfxline_free(line);
if(cxform)
free(cxform);
if(cxform)
free(cxform);
+ free(img.data);img.data=0;
break;
}
case OP_FILLGRADIENT: {
break;
}
case OP_FILLGRADIENT: {
@@
-504,23
+512,23
@@
static void replay(struct _gfxdevice*recorddev, gfxdevice_t*device, void*data, i
gfxgradient_t*gradient = readGradient(r);
gfxmatrix_t matrix = readMatrix(r);
gfxline_t* line = readLine(r);
gfxgradient_t*gradient = readGradient(r);
gfxmatrix_t matrix = readMatrix(r);
gfxline_t* line = readLine(r);
- device->fillgradient(device, line, gradient, type, &matrix);
+ out->fillgradient(out, line, gradient, type, &matrix);
break;
}
case OP_DRAWLINK: {
msg("<trace> replay: DRAWLINK");
gfxline_t* line = readLine(r);
char* s = reader_readString(r);
break;
}
case OP_DRAWLINK: {
msg("<trace> replay: DRAWLINK");
gfxline_t* line = readLine(r);
char* s = reader_readString(r);
- device->drawlink(device,line,s);
+ out->drawlink(out,line,s);
gfxline_free(line);
free(s);
break;
}
case OP_ADDFONT: {
gfxline_free(line);
free(s);
break;
}
case OP_ADDFONT: {
- msg("<trace> replay: ADDFONT");
+ msg("<trace> replay: ADDFONT out=%08x(%s)", out, out->name);
gfxfont_t*font = readFont(r);
fontlist = gfxfontlist_addfont(fontlist, font);
gfxfont_t*font = readFont(r);
fontlist = gfxfontlist_addfont(fontlist, font);
- device->addfont(device, font);
+ out->addfont(out, font);
break;
}
case OP_DRAWCHAR: {
break;
}
case OP_DRAWCHAR: {
@@
-533,14
+541,19
@@
static void replay(struct _gfxdevice*recorddev, gfxdevice_t*device, void*data, i
msg("<trace> replay: DRAWCHAR font=%s glyph=%d", id, glyph);
gfxcolor_t color = readColor(r);
gfxmatrix_t matrix = readMatrix(r);
msg("<trace> replay: DRAWCHAR font=%s glyph=%d", id, glyph);
gfxcolor_t color = readColor(r);
gfxmatrix_t matrix = readMatrix(r);
- device->drawchar(device, font, glyph, &color, &matrix);
+ out->drawchar(out, font, glyph, &color, &matrix);
free(id);
break;
}
}
}
free(id);
break;
}
}
}
+finish:
r->dealloc(r);
r->dealloc(r);
- gfxfontlist_free(fontlist, 1);
+ /* problem: if we just replayed into a device which stores the
+ font for later use (the record device itself is a nice example),
+ then we can't free it yet */
+ //gfxfontlist_free(fontlist, 1);
+ gfxfontlist_free(fontlist, 0);
}
void gfxresult_record_replay(gfxresult_t*result, gfxdevice_t*device)
{
}
void gfxresult_record_replay(gfxresult_t*result, gfxdevice_t*device)
{
@@
-624,7
+637,11
@@
void gfxdevice_record_flush(gfxdevice_t*dev, gfxdevice_t*out)
static gfxresult_t* record_finish(struct _gfxdevice*dev)
{
internal_t*i = (internal_t*)dev->internal;
static gfxresult_t* record_finish(struct _gfxdevice*dev)
{
internal_t*i = (internal_t*)dev->internal;
- msg("<trace> record: END\n");
+ msg("<trace> record: %08x END", dev);
+
+ if(i->cliplevel) {
+ msg("<error> Warning: unclosed cliplevels");
+ }
writer_writeU8(&i->w, OP_END);
writer_writeU8(&i->w, OP_END);
@@
-656,6
+673,7
@@
void gfxdevice_record_init(gfxdevice_t*dev)
writer_init_growingmemwriter(&i->w, 1048576);
i->fontlist = gfxfontlist_create();
writer_init_growingmemwriter(&i->w, 1048576);
i->fontlist = gfxfontlist_create();
+ i->cliplevel = 0;
dev->setparameter = record_setparameter;
dev->startpage = record_startpage;
dev->setparameter = record_setparameter;
dev->startpage = record_startpage;