From 3216a4e3d42f335ecc38c6836d8494b747868d9d Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 3 Aug 2011 00:15:55 +0100 Subject: Add (disabled by default) debug code for group blends. Some code that I find useful for debugging the group blending code. --- draw/draw_device.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'draw') diff --git a/draw/draw_device.c b/draw/draw_device.c index 8042ce84..3367c185 100644 --- a/draw/draw_device.c +++ b/draw/draw_device.c @@ -6,6 +6,9 @@ #define STACK_SIZE 96 +/* Enable the following to help debug group blending. */ +#undef DUMP_GROUP_BLENDS + typedef struct fz_draw_device_s fz_draw_device; enum { @@ -38,6 +41,25 @@ struct fz_draw_device_s } stack[STACK_SIZE]; }; +#ifdef DUMP_GROUP_BLENDS +static int group_dump_count = 0; + +static void fz_dump_blend(fz_pixmap *pix, const char *s) +{ + char name[80]; + + if (pix == NULL) + return; + + sprintf(name, "dump%02d.png", group_dump_count); + if (s) + printf("%s%02d", s, group_dump_count); + group_dump_count++; + + fz_write_png(pix, name, (pix->n > 1)); +} +#endif + static void fz_knockout_begin(void *user) { fz_draw_device *dev = user; @@ -1211,6 +1233,22 @@ fz_draw_end_group(void *user) dev->dest = dev->stack[dev->top].dest; dev->scissor = dev->stack[dev->top].scissor; +#ifdef DUMP_GROUP_BLENDS + fz_dump_blend(group, "Blending "); + if (shape) + fz_dump_blend(shape, "/"); + fz_dump_blend(dev->dest, " onto "); + if (dev->shape) + fz_dump_blend(dev->shape, "/"); + if (alpha != 1.0f) + printf(" (alpha %g)", alpha); + if (blendmode != 0) + printf(" (blend %d)", blendmode); + if (isolated != 0) + printf(" (isolated)"); + if (blendmode != 0) + printf(" (knockout)"); +#endif if ((blendmode == 0) && (shape == NULL)) fz_paint_pixmap(dev->dest, group, alpha * 255); else @@ -1225,6 +1263,12 @@ fz_draw_end_group(void *user) } fz_drop_pixmap(shape); } +#ifdef DUMP_GROUP_BLENDS + fz_dump_blend(dev->dest, " to get "); + if (dev->shape) + fz_dump_blend(dev->shape, "/"); + printf("\n"); +#endif } if (dev->blendmode & FZ_BLEND_KNOCKOUT) -- cgit v1.2.3