#include "fitz.h"
static void
fz_trace_matrix(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_trace_trm(fz_matrix trm)
{
printf("trm=\"%g %g %g %g\" ",
trm.a, trm.b, trm.c, trm.d);
}
static void
fz_trace_color(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_trace_path(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->items[i++].k)
{
case FZ_MOVETO:
x = path->items[i++].v;
y = path->items[i++].v;
printf("\n", x, y);
break;
case FZ_LINETO:
x = path->items[i++].v;
y = path->items[i++].v;
printf("\n", x, y);
break;
case FZ_CURVETO:
x = path->items[i++].v;
y = path->items[i++].v;
printf("items[i++].v;
y = path->items[i++].v;
printf("x2=\"%g\" y2=\"%g\" ", x, y);
x = path->items[i++].v;
y = path->items[i++].v;
printf("x3=\"%g\" y3=\"%g\" />\n", x, y);
break;
case FZ_CLOSE_PATH:
printf("\n");
break;
}
}
}
static void
fz_trace_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
printf("\n");
fz_trace_path(path, 0);
printf("\n");
}
static void
fz_trace_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
int i;
printf("linewidth);
printf("miterlimit=\"%g\" ", stroke->miterlimit);
printf("linecap=\"%d,%d,%d\" ", stroke->start_cap, stroke->dash_cap, stroke->end_cap);
printf("linejoin=\"%d\" ", stroke->linejoin);
if (stroke->dash_len)
{
printf("dash_phase=\"%g\" dash=\"", stroke->dash_phase);
for (i = 0; i < stroke->dash_len; i++)
printf("%g ", stroke->dash_list[i]);
printf("\"");
}
fz_trace_color(colorspace, color, alpha);
fz_trace_matrix(ctm);
printf(">\n");
fz_trace_path(path, 0);
printf("\n");
}
static void
fz_trace_clip_path(void *user, fz_path *path, fz_rect *rect, int even_odd, fz_matrix ctm)
{
printf("\n",
rect->x0, rect->y0, rect->x1, rect->y1);
fz_trace_path(path, 0);
printf("\n");
}
static void
fz_trace_clip_stroke_path(void *user, fz_path *path, fz_rect *rect, fz_stroke_state *stroke, fz_matrix ctm)
{
printf("\n");
fz_trace_path(path, 0);
printf("\n");
}
static void
fz_trace_fill_text(void *user, fz_text *text, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
printf("font->name, text->wmode);
fz_trace_color(colorspace, color, alpha);
fz_trace_matrix(ctm);
fz_trace_trm(text->trm);
printf(">\n");
fz_debug_text(text, 0);
printf("\n");
}
static void
fz_trace_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
printf("font->name, text->wmode);
fz_trace_color(colorspace, color, alpha);
fz_trace_matrix(ctm);
fz_trace_trm(text->trm);
printf(">\n");
fz_debug_text(text, 0);
printf("\n");
}
static void
fz_trace_clip_text(void *user, fz_text *text, fz_matrix ctm, int accumulate)
{
printf("font->name, text->wmode);
printf("accumulate=\"%d\" ", accumulate);
fz_trace_matrix(ctm);
fz_trace_trm(text->trm);
printf(">\n");
fz_debug_text(text, 0);
printf("\n");
}
static void
fz_trace_clip_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm)
{
printf("font->name, text->wmode);
fz_trace_matrix(ctm);
fz_trace_trm(text->trm);
printf(">\n");
fz_debug_text(text, 0);
printf("\n");
}
static void
fz_trace_ignore_text(void *user, fz_text *text, fz_matrix ctm)
{
printf("font->name, text->wmode);
fz_trace_matrix(ctm);
fz_trace_trm(text->trm);
printf(">\n");
fz_debug_text(text, 0);
printf("\n");
}
static void
fz_trace_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha)
{
printf("\n");
}
static void
fz_trace_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha)
{
printf("\n");
}
static void
fz_trace_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm,
fz_colorspace *colorspace, float *color, float alpha)
{
printf("\n");
}
static void
fz_trace_clip_image_mask(void *user, fz_pixmap *image, fz_rect *rect, fz_matrix ctm)
{
printf("\n");
}
static void
fz_trace_pop_clip(void *user)
{
printf("\n");
}
static void
fz_trace_begin_mask(void *user, fz_rect bbox, int luminosity, fz_colorspace *colorspace, float *color)
{
printf("\n");
}
static void
fz_trace_end_mask(void *user)
{
printf("\n");
}
static void
fz_trace_begin_group(void *user, fz_rect bbox, int isolated, int knockout, int blendmode, float alpha)
{
printf("\n",
bbox.x0, bbox.y0, bbox.x1, bbox.y1,
isolated, knockout, fz_blendmode_name(blendmode), alpha);
}
static void
fz_trace_end_group(void *user)
{
printf("\n");
}
static void
fz_trace_begin_tile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm)
{
printf("\n");
}
static void
fz_trace_end_tile(void *user)
{
printf("\n");
}
fz_device *fz_new_trace_device(void)
{
fz_device *dev = fz_new_device(NULL);
dev->fill_path = fz_trace_fill_path;
dev->stroke_path = fz_trace_stroke_path;
dev->clip_path = fz_trace_clip_path;
dev->clip_stroke_path = fz_trace_clip_stroke_path;
dev->fill_text = fz_trace_fill_text;
dev->stroke_text = fz_trace_stroke_text;
dev->clip_text = fz_trace_clip_text;
dev->clip_stroke_text = fz_trace_clip_stroke_text;
dev->ignore_text = fz_trace_ignore_text;
dev->fill_shade = fz_trace_fill_shade;
dev->fill_image = fz_trace_fill_image;
dev->fill_image_mask = fz_trace_fill_image_mask;
dev->clip_image_mask = fz_trace_clip_image_mask;
dev->pop_clip = fz_trace_pop_clip;
dev->begin_mask = fz_trace_begin_mask;
dev->end_mask = fz_trace_end_mask;
dev->begin_group = fz_trace_begin_group;
dev->end_group = fz_trace_end_group;
dev->begin_tile = fz_trace_begin_tile;
dev->end_tile = fz_trace_end_tile;
return dev;
}