#include "fitz.h"
static void
fz_tracematrix(fz_matrix ctm)
{
printf("matrix=\"%g %g %g %g %g %g\" ",
ctm.a, ctm.b, ctm.c, ctm.d, ctm.e, ctm.f);
}
static void
fz_tracecolor(fz_colorspace *colorspace, float *color, float alpha)
{
int i;
printf("colorspace=\"%s\" color=\"", colorspace->name);
for (i = 0; i < colorspace->n; i++)
printf("%s%g", i == 0 ? "" : " ", color[i]);
printf("\" ");
if (alpha < 1)
printf("alpha=\"%g\" ", alpha);
}
static void
fz_tracepath(fz_path *path, int indent)
{
float x, y;
int i = 0;
int n;
while (i < path->len)
{
for (n = 0; n < indent; n++)
putchar(' ');
switch (path->els[i++].k)
{
case FZ_MOVETO:
x = path->els[i++].v;
y = path->els[i++].v;
printf("\n", x, y);
break;
case FZ_LINETO:
x = path->els[i++].v;
y = path->els[i++].v;
printf("\n", x, y);
break;
case FZ_CURVETO:
x = path->els[i++].v;
y = path->els[i++].v;
printf("els[i++].v;
y = path->els[i++].v;
printf("x2=\"%g\" y2=\"%g\" ", x, y);
x = path->els[i++].v;
y = path->els[i++].v;
printf("x3=\"%g\" y3=\"%g\" />\n", x, y);
break;
case FZ_CLOSEPATH:
printf("\n");
break;
}
}
}
static void
fz_tracefillpath(void *user, fz_path *path, int evenodd, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
printf("\n");
fz_tracepath(path, 0);
printf("\n");
}
static void
fz_tracestrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
int i;
printf("linewidth);
printf("miterlimit=\"%g\" ", stroke->miterlimit);
printf("linecap=\"%d\" ", stroke->linecap);
printf("linejoin=\"%d\" ", stroke->linejoin);
if (stroke->dashlen)
{
printf("dashphase=\"%g\" dash=\"", stroke->dashphase);
for (i = 0; i < stroke->dashlen; i++)
printf("%g ", stroke->dashlist[i]);
printf("\"");
}
fz_tracecolor(colorspace, color, alpha);
fz_tracematrix(ctm);
printf(">\n");
fz_tracepath(path, 0);
printf("\n");
}
static void
fz_traceclippath(void *user, fz_path *path, int evenodd, fz_matrix ctm)
{
printf("\n");
fz_tracepath(path, 0);
printf("\n");
}
static void
fz_traceclipstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix ctm)
{
printf("\n");
fz_tracepath(path, 0);
printf("\n");
}
static void
fz_tracefilltext(void *user, fz_text *text, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
printf("font->name, text->wmode);
fz_tracecolor(colorspace, color, alpha);
fz_tracematrix(fz_concat(ctm, text->trm));
printf(">\n");
fz_debugtext(text, 0);
printf("\n");
}
static void
fz_tracestroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
printf("font->name, text->wmode);
fz_tracecolor(colorspace, color, alpha);
fz_tracematrix(fz_concat(ctm, text->trm));
printf(">\n");
fz_debugtext(text, 0);
printf("\n");
}
static void
fz_tracecliptext(void *user, fz_text *text, fz_matrix ctm, int accumulate)
{
printf("font->name, text->wmode);
printf("accumulate=\"%d\" ", accumulate);
fz_tracematrix(fz_concat(ctm, text->trm));
printf(">\n");
fz_debugtext(text, 0);
printf("\n");
}
static void
fz_traceclipstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm)
{
printf("font->name, text->wmode);
fz_tracematrix(fz_concat(ctm, text->trm));
printf(">\n");
fz_debugtext(text, 0);
printf("\n");
}
static void
fz_traceignoretext(void *user, fz_text *text, fz_matrix ctm)
{
printf("font->name, text->wmode);
fz_tracematrix(fz_concat(ctm, text->trm));
printf(">\n");
fz_debugtext(text, 0);
printf("\n");
}
static void
fz_tracefillimage(void *user, fz_pixmap *image, fz_matrix ctm, float alpha)
{
printf("\n");
}
static void
fz_tracefillshade(void *user, fz_shade *shade, fz_matrix ctm, float alpha)
{
printf("\n");
}
static void
fz_tracefillimagemask(void *user, fz_pixmap *image, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
printf("\n");
}
static void
fz_traceclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm)
{
printf("\n");
}
static void
fz_tracepopclip(void *user)
{
printf("\n");
}
static void
fz_tracebeginmask(void *user, fz_rect bbox, int luminosity, fz_colorspace *colorspace, float *color)
{
printf("\n");
}
static void
fz_traceendmask(void *user)
{
printf("\n");
}
static void
fz_tracebegingroup(void *user, fz_rect bbox, int isolated, int knockout, fz_blendmode blendmode, float alpha)
{
printf("\n",
bbox.x0, bbox.y0, bbox.x1, bbox.y1,
isolated, knockout, fz_blendnames[blendmode], alpha);
}
static void
fz_traceendgroup(void *user)
{
printf("\n");
}
static void
fz_tracebegintile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm)
{
printf("\n");
}
static void
fz_traceendtile(void *user)
{
printf("\n");
}
fz_device *fz_newtracedevice(void)
{
fz_device *dev = fz_newdevice(nil);
dev->fillpath = fz_tracefillpath;
dev->strokepath = fz_tracestrokepath;
dev->clippath = fz_traceclippath;
dev->clipstrokepath = fz_traceclipstrokepath;
dev->filltext = fz_tracefilltext;
dev->stroketext = fz_tracestroketext;
dev->cliptext = fz_tracecliptext;
dev->clipstroketext = fz_traceclipstroketext;
dev->ignoretext = fz_traceignoretext;
dev->fillshade = fz_tracefillshade;
dev->fillimage = fz_tracefillimage;
dev->fillimagemask = fz_tracefillimagemask;
dev->clipimagemask = fz_traceclipimagemask;
dev->popclip = fz_tracepopclip;
dev->beginmask = fz_tracebeginmask;
dev->endmask = fz_traceendmask;
dev->begingroup = fz_tracebegingroup;
dev->endgroup = fz_traceendgroup;
dev->begintile = fz_tracebegintile;
dev->endtile = fz_traceendtile;
return dev;
}