| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781 |
- #include "fitz-internal.h"
- typedef struct fz_display_node_s fz_display_node;
- #define STACK_SIZE 96
- typedef enum fz_display_command_e
- {
- FZ_CMD_FILL_PATH,
- FZ_CMD_STROKE_PATH,
- FZ_CMD_CLIP_PATH,
- FZ_CMD_CLIP_STROKE_PATH,
- FZ_CMD_FILL_TEXT,
- FZ_CMD_STROKE_TEXT,
- FZ_CMD_CLIP_TEXT,
- FZ_CMD_CLIP_STROKE_TEXT,
- FZ_CMD_IGNORE_TEXT,
- FZ_CMD_FILL_SHADE,
- FZ_CMD_FILL_IMAGE,
- FZ_CMD_FILL_IMAGE_MASK,
- FZ_CMD_CLIP_IMAGE_MASK,
- FZ_CMD_POP_CLIP,
- FZ_CMD_BEGIN_MASK,
- FZ_CMD_END_MASK,
- FZ_CMD_BEGIN_GROUP,
- FZ_CMD_END_GROUP,
- FZ_CMD_BEGIN_TILE,
- FZ_CMD_END_TILE
- } fz_display_command;
- struct fz_display_node_s
- {
- fz_display_command cmd;
- fz_display_node *next;
- fz_rect rect;
- union {
- fz_path *path;
- fz_text *text;
- fz_shade *shade;
- fz_image *image;
- int blendmode;
- } item;
- fz_stroke_state *stroke;
- int flag; /* even_odd, accumulate, isolated/knockout... */
- fz_matrix ctm;
- fz_colorspace *colorspace;
- float alpha;
- float color[FZ_MAX_COLORS];
- };
- struct fz_display_list_s
- {
- fz_display_node *first;
- fz_display_node *last;
- int len;
- int top;
- struct {
- fz_rect *update;
- fz_rect rect;
- } stack[STACK_SIZE];
- int tiled;
- };
- enum { ISOLATED = 1, KNOCKOUT = 2 };
- static fz_display_node *
- fz_new_display_node(fz_context *ctx, fz_display_command cmd, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
- {
- fz_display_node *node;
- int i;
- node = fz_malloc_struct(ctx, fz_display_node);
- node->cmd = cmd;
- node->next = NULL;
- node->rect = fz_empty_rect;
- node->item.path = NULL;
- node->stroke = NULL;
- node->flag = 0;
- node->ctm = *ctm;
- if (colorspace)
- {
- node->colorspace = fz_keep_colorspace(ctx, colorspace);
- if (color)
- {
- for (i = 0; i < node->colorspace->n; i++)
- node->color[i] = color[i];
- }
- }
- else
- {
- node->colorspace = NULL;
- }
- node->alpha = alpha;
- return node;
- }
- static void
- fz_append_display_node(fz_display_list *list, fz_display_node *node)
- {
- switch (node->cmd)
- {
- case FZ_CMD_CLIP_PATH:
- case FZ_CMD_CLIP_STROKE_PATH:
- case FZ_CMD_CLIP_IMAGE_MASK:
- if (list->top < STACK_SIZE)
- {
- list->stack[list->top].update = &node->rect;
- list->stack[list->top].rect = fz_empty_rect;
- }
- list->top++;
- break;
- case FZ_CMD_END_MASK:
- case FZ_CMD_CLIP_TEXT:
- case FZ_CMD_CLIP_STROKE_TEXT:
- if (list->top < STACK_SIZE)
- {
- list->stack[list->top].update = NULL;
- list->stack[list->top].rect = fz_empty_rect;
- }
- list->top++;
- break;
- case FZ_CMD_BEGIN_TILE:
- list->tiled++;
- if (list->top > 0 && list->top <= STACK_SIZE)
- {
- list->stack[list->top-1].rect = fz_infinite_rect;
- }
- break;
- case FZ_CMD_END_TILE:
- list->tiled--;
- break;
- case FZ_CMD_END_GROUP:
- break;
- case FZ_CMD_POP_CLIP:
- if (list->top > STACK_SIZE)
- {
- list->top--;
- node->rect = fz_infinite_rect;
- }
- else if (list->top > 0)
- {
- fz_rect *update;
- list->top--;
- update = list->stack[list->top].update;
- if (list->tiled == 0)
- {
- if (update)
- {
- fz_intersect_rect(update, &list->stack[list->top].rect);
- node->rect = *update;
- }
- else
- node->rect = list->stack[list->top].rect;
- }
- else
- node->rect = fz_infinite_rect;
- }
- /* fallthrough */
- default:
- if (list->top > 0 && list->tiled == 0 && list->top <= STACK_SIZE)
- fz_union_rect(&list->stack[list->top-1].rect, &node->rect);
- break;
- }
- if (!list->first)
- {
- list->first = node;
- list->last = node;
- }
- else
- {
- list->last->next = node;
- list->last = node;
- }
- list->len++;
- }
- static void
- fz_free_display_node(fz_context *ctx, fz_display_node *node)
- {
- switch (node->cmd)
- {
- case FZ_CMD_FILL_PATH:
- case FZ_CMD_STROKE_PATH:
- case FZ_CMD_CLIP_PATH:
- case FZ_CMD_CLIP_STROKE_PATH:
- fz_free_path(ctx, node->item.path);
- break;
- case FZ_CMD_FILL_TEXT:
- case FZ_CMD_STROKE_TEXT:
- case FZ_CMD_CLIP_TEXT:
- case FZ_CMD_CLIP_STROKE_TEXT:
- case FZ_CMD_IGNORE_TEXT:
- fz_free_text(ctx, node->item.text);
- break;
- case FZ_CMD_FILL_SHADE:
- fz_drop_shade(ctx, node->item.shade);
- break;
- case FZ_CMD_FILL_IMAGE:
- case FZ_CMD_FILL_IMAGE_MASK:
- case FZ_CMD_CLIP_IMAGE_MASK:
- fz_drop_image(ctx, node->item.image);
- break;
- case FZ_CMD_POP_CLIP:
- case FZ_CMD_BEGIN_MASK:
- case FZ_CMD_END_MASK:
- case FZ_CMD_BEGIN_GROUP:
- case FZ_CMD_END_GROUP:
- case FZ_CMD_BEGIN_TILE:
- case FZ_CMD_END_TILE:
- break;
- }
- if (node->stroke)
- fz_drop_stroke_state(ctx, node->stroke);
- if (node->colorspace)
- fz_drop_colorspace(ctx, node->colorspace);
- fz_free(ctx, node);
- }
- static void
- fz_list_fill_path(fz_device *dev, fz_path *path, int even_odd, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
- {
- fz_display_node *node;
- fz_context *ctx = dev->ctx;
- node = fz_new_display_node(ctx, FZ_CMD_FILL_PATH, ctm, colorspace, color, alpha);
- fz_try(ctx)
- {
- fz_bound_path(dev->ctx, path, NULL, ctm, &node->rect);
- node->item.path = fz_clone_path(dev->ctx, path);
- node->flag = even_odd;
- }
- fz_catch(ctx)
- {
- fz_free_display_node(ctx, node);
- fz_rethrow(ctx);
- }
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_stroke_path(fz_device *dev, fz_path *path, fz_stroke_state *stroke,
- const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha)
- {
- fz_display_node *node;
- fz_context *ctx = dev->ctx;
- node = fz_new_display_node(ctx, FZ_CMD_STROKE_PATH, ctm, colorspace, color, alpha);
- fz_try(ctx)
- {
- fz_bound_path(dev->ctx, path, stroke, ctm, &node->rect);
- node->item.path = fz_clone_path(dev->ctx, path);
- node->stroke = fz_keep_stroke_state(dev->ctx, stroke);
- }
- fz_catch(ctx)
- {
- fz_free_display_node(ctx, node);
- fz_rethrow(ctx);
- }
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_clip_path(fz_device *dev, fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm)
- {
- fz_display_node *node;
- fz_context *ctx = dev->ctx;
- node = fz_new_display_node(ctx, FZ_CMD_CLIP_PATH, ctm, NULL, NULL, 0);
- fz_try(ctx)
- {
- fz_bound_path(dev->ctx, path, NULL, ctm, &node->rect);
- if (rect)
- fz_intersect_rect(&node->rect, rect);
- node->item.path = fz_clone_path(dev->ctx, path);
- node->flag = even_odd;
- }
- fz_catch(ctx)
- {
- fz_free_display_node(ctx, node);
- fz_rethrow(ctx);
- }
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_clip_stroke_path(fz_device *dev, fz_path *path, const fz_rect *rect, fz_stroke_state *stroke, const fz_matrix *ctm)
- {
- fz_display_node *node;
- fz_context *ctx = dev->ctx;
- node = fz_new_display_node(ctx, FZ_CMD_CLIP_STROKE_PATH, ctm, NULL, NULL, 0);
- fz_try(ctx)
- {
- fz_bound_path(dev->ctx, path, stroke, ctm, &node->rect);
- if (rect)
- fz_intersect_rect(&node->rect, rect);
- node->item.path = fz_clone_path(dev->ctx, path);
- node->stroke = fz_keep_stroke_state(dev->ctx, stroke);
- }
- fz_catch(ctx)
- {
- fz_free_display_node(ctx, node);
- fz_rethrow(ctx);
- }
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_fill_text(fz_device *dev, fz_text *text, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
- {
- fz_display_node *node;
- fz_context *ctx = dev->ctx;
- node = fz_new_display_node(ctx, FZ_CMD_FILL_TEXT, ctm, colorspace, color, alpha);
- fz_try(ctx)
- {
- fz_bound_text(dev->ctx, text, ctm, &node->rect);
- node->item.text = fz_clone_text(dev->ctx, text);
- }
- fz_catch(ctx)
- {
- fz_free_display_node(ctx, node);
- fz_rethrow(ctx);
- }
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
- {
- fz_display_node *node;
- fz_context *ctx = dev->ctx;
- node = fz_new_display_node(ctx, FZ_CMD_STROKE_TEXT, ctm, colorspace, color, alpha);
- node->item.text = NULL;
- fz_try(ctx)
- {
- fz_bound_text(dev->ctx, text, ctm, &node->rect);
- fz_adjust_rect_for_stroke(&node->rect, stroke, ctm);
- node->item.text = fz_clone_text(dev->ctx, text);
- node->stroke = fz_keep_stroke_state(dev->ctx, stroke);
- }
- fz_catch(ctx)
- {
- fz_free_display_node(ctx, node);
- fz_rethrow(ctx);
- }
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_clip_text(fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate)
- {
- fz_display_node *node;
- fz_context *ctx = dev->ctx;
- node = fz_new_display_node(ctx, FZ_CMD_CLIP_TEXT, ctm, NULL, NULL, 0);
- fz_try(ctx)
- {
- fz_bound_text(dev->ctx, text, ctm, &node->rect);
- node->item.text = fz_clone_text(dev->ctx, text);
- node->flag = accumulate;
- /* when accumulating, be conservative about culling */
- if (accumulate)
- node->rect = fz_infinite_rect;
- }
- fz_catch(ctx)
- {
- fz_free_display_node(ctx, node);
- fz_rethrow(ctx);
- }
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_clip_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm)
- {
- fz_display_node *node;
- fz_context *ctx = dev->ctx;
- node = fz_new_display_node(ctx, FZ_CMD_CLIP_STROKE_TEXT, ctm, NULL, NULL, 0);
- fz_try(ctx)
- {
- fz_bound_text(dev->ctx, text, ctm, &node->rect);
- fz_adjust_rect_for_stroke(&node->rect, stroke, ctm);
- node->item.text = fz_clone_text(dev->ctx, text);
- node->stroke = fz_keep_stroke_state(dev->ctx, stroke);
- }
- fz_catch(ctx)
- {
- fz_free_display_node(ctx, node);
- fz_rethrow(ctx);
- }
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_ignore_text(fz_device *dev, fz_text *text, const fz_matrix *ctm)
- {
- fz_display_node *node;
- fz_context *ctx = dev->ctx;
- node = fz_new_display_node(ctx, FZ_CMD_IGNORE_TEXT, ctm, NULL, NULL, 0);
- fz_try(ctx)
- {
- fz_bound_text(dev->ctx, text, ctm, &node->rect);
- node->item.text = fz_clone_text(dev->ctx, text);
- }
- fz_catch(ctx)
- {
- fz_free_display_node(ctx, node);
- fz_rethrow(ctx);
- }
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_pop_clip(fz_device *dev)
- {
- fz_display_node *node;
- node = fz_new_display_node(dev->ctx, FZ_CMD_POP_CLIP, &fz_identity, NULL, NULL, 0);
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_fill_shade(fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha)
- {
- fz_display_node *node;
- fz_context *ctx = dev->ctx;
- node = fz_new_display_node(ctx, FZ_CMD_FILL_SHADE, ctm, NULL, NULL, alpha);
- fz_bound_shade(ctx, shade, ctm, &node->rect);
- node->item.shade = fz_keep_shade(ctx, shade);
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_fill_image(fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha)
- {
- fz_display_node *node;
- node = fz_new_display_node(dev->ctx, FZ_CMD_FILL_IMAGE, ctm, NULL, NULL, alpha);
- node->rect = fz_unit_rect;
- fz_transform_rect(&node->rect, ctm);
- node->item.image = fz_keep_image(dev->ctx, image);
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_fill_image_mask(fz_device *dev, fz_image *image, const fz_matrix *ctm,
- fz_colorspace *colorspace, float *color, float alpha)
- {
- fz_display_node *node;
- node = fz_new_display_node(dev->ctx, FZ_CMD_FILL_IMAGE_MASK, ctm, colorspace, color, alpha);
- node->rect = fz_unit_rect;
- fz_transform_rect(&node->rect, ctm);
- node->item.image = fz_keep_image(dev->ctx, image);
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_clip_image_mask(fz_device *dev, fz_image *image, const fz_rect *rect, const fz_matrix *ctm)
- {
- fz_display_node *node;
- node = fz_new_display_node(dev->ctx, FZ_CMD_CLIP_IMAGE_MASK, ctm, NULL, NULL, 0);
- node->rect = fz_unit_rect;
- fz_transform_rect(&node->rect, ctm);
- if (rect)
- fz_intersect_rect(&node->rect, rect);
- node->item.image = fz_keep_image(dev->ctx, image);
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_begin_mask(fz_device *dev, const fz_rect *rect, int luminosity, fz_colorspace *colorspace, float *color)
- {
- fz_display_node *node;
- node = fz_new_display_node(dev->ctx, FZ_CMD_BEGIN_MASK, &fz_identity, colorspace, color, 0);
- node->rect = *rect;
- node->flag = luminosity;
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_end_mask(fz_device *dev)
- {
- fz_display_node *node;
- node = fz_new_display_node(dev->ctx, FZ_CMD_END_MASK, &fz_identity, NULL, NULL, 0);
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_begin_group(fz_device *dev, const fz_rect *rect, int isolated, int knockout, int blendmode, float alpha)
- {
- fz_display_node *node;
- node = fz_new_display_node(dev->ctx, FZ_CMD_BEGIN_GROUP, &fz_identity, NULL, NULL, alpha);
- node->rect = *rect;
- node->item.blendmode = blendmode;
- node->flag |= isolated ? ISOLATED : 0;
- node->flag |= knockout ? KNOCKOUT : 0;
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_end_group(fz_device *dev)
- {
- fz_display_node *node;
- node = fz_new_display_node(dev->ctx, FZ_CMD_END_GROUP, &fz_identity, NULL, NULL, 0);
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_begin_tile(fz_device *dev, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *ctm)
- {
- fz_display_node *node;
- node = fz_new_display_node(dev->ctx, FZ_CMD_BEGIN_TILE, ctm, NULL, NULL, 0);
- node->rect = *area;
- node->color[0] = xstep;
- node->color[1] = ystep;
- node->color[2] = view->x0;
- node->color[3] = view->y0;
- node->color[4] = view->x1;
- node->color[5] = view->y1;
- fz_append_display_node(dev->user, node);
- }
- static void
- fz_list_end_tile(fz_device *dev)
- {
- fz_display_node *node;
- node = fz_new_display_node(dev->ctx, FZ_CMD_END_TILE, &fz_identity, NULL, NULL, 0);
- fz_append_display_node(dev->user, node);
- }
- fz_device *
- fz_new_list_device(fz_context *ctx, fz_display_list *list)
- {
- fz_device *dev = fz_new_device(ctx, list);
- dev->fill_path = fz_list_fill_path;
- dev->stroke_path = fz_list_stroke_path;
- dev->clip_path = fz_list_clip_path;
- dev->clip_stroke_path = fz_list_clip_stroke_path;
- dev->fill_text = fz_list_fill_text;
- dev->stroke_text = fz_list_stroke_text;
- dev->clip_text = fz_list_clip_text;
- dev->clip_stroke_text = fz_list_clip_stroke_text;
- dev->ignore_text = fz_list_ignore_text;
- dev->fill_shade = fz_list_fill_shade;
- dev->fill_image = fz_list_fill_image;
- dev->fill_image_mask = fz_list_fill_image_mask;
- dev->clip_image_mask = fz_list_clip_image_mask;
- dev->pop_clip = fz_list_pop_clip;
- dev->begin_mask = fz_list_begin_mask;
- dev->end_mask = fz_list_end_mask;
- dev->begin_group = fz_list_begin_group;
- dev->end_group = fz_list_end_group;
- dev->begin_tile = fz_list_begin_tile;
- dev->end_tile = fz_list_end_tile;
- return dev;
- }
- fz_display_list *
- fz_new_display_list(fz_context *ctx)
- {
- fz_display_list *list = fz_malloc_struct(ctx, fz_display_list);
- list->first = NULL;
- list->last = NULL;
- list->len = 0;
- list->top = 0;
- list->tiled = 0;
- return list;
- }
- void
- fz_free_display_list(fz_context *ctx, fz_display_list *list)
- {
- fz_display_node *node;
- if (list == NULL)
- return;
- node = list->first;
- while (node)
- {
- fz_display_node *next = node->next;
- fz_free_display_node(ctx, node);
- node = next;
- }
- fz_free(ctx, list);
- }
- void
- fz_run_display_list(fz_display_list *list, fz_device *dev, const fz_matrix *top_ctm, const fz_rect *scissor, fz_cookie *cookie)
- {
- fz_display_node *node;
- fz_matrix ctm;
- int clipped = 0;
- int tiled = 0;
- int empty;
- int progress = 0;
- fz_context *ctx = dev->ctx;
- if (!scissor)
- scissor = &fz_infinite_rect;
- if (cookie)
- {
- cookie->progress_max = list->len;
- cookie->progress = 0;
- }
- for (node = list->first; node; node = node->next)
- {
- /* Check the cookie for aborting */
- if (cookie)
- {
- if (cookie->abort)
- break;
- cookie->progress = progress++;
- }
- /* cull objects to draw using a quick visibility test */
- if (tiled || node->cmd == FZ_CMD_BEGIN_TILE || node->cmd == FZ_CMD_END_TILE)
- {
- empty = 0;
- }
- else
- {
- fz_rect rect = node->rect;
- fz_intersect_rect(fz_transform_rect(&rect, top_ctm), scissor);
- empty = fz_is_empty_rect(&rect);
- }
- if (clipped || empty)
- {
- switch (node->cmd)
- {
- case FZ_CMD_CLIP_PATH:
- case FZ_CMD_CLIP_STROKE_PATH:
- case FZ_CMD_CLIP_STROKE_TEXT:
- case FZ_CMD_CLIP_IMAGE_MASK:
- case FZ_CMD_BEGIN_MASK:
- case FZ_CMD_BEGIN_GROUP:
- clipped++;
- continue;
- case FZ_CMD_CLIP_TEXT:
- /* Accumulated text has no extra pops */
- if (node->flag != 2)
- clipped++;
- continue;
- case FZ_CMD_POP_CLIP:
- case FZ_CMD_END_GROUP:
- if (!clipped)
- goto visible;
- clipped--;
- continue;
- case FZ_CMD_END_MASK:
- if (!clipped)
- goto visible;
- continue;
- default:
- continue;
- }
- }
- visible:
- fz_concat(&ctm, &node->ctm, top_ctm);
- fz_try(ctx)
- {
- switch (node->cmd)
- {
- case FZ_CMD_FILL_PATH:
- fz_fill_path(dev, node->item.path, node->flag, &ctm,
- node->colorspace, node->color, node->alpha);
- break;
- case FZ_CMD_STROKE_PATH:
- fz_stroke_path(dev, node->item.path, node->stroke, &ctm,
- node->colorspace, node->color, node->alpha);
- break;
- case FZ_CMD_CLIP_PATH:
- {
- fz_rect rect = node->rect;
- fz_transform_rect(&rect, top_ctm);
- fz_clip_path(dev, node->item.path, &rect, node->flag, &ctm);
- break;
- }
- case FZ_CMD_CLIP_STROKE_PATH:
- {
- fz_rect rect = node->rect;
- fz_transform_rect(&rect, top_ctm);
- fz_clip_stroke_path(dev, node->item.path, &rect, node->stroke, &ctm);
- break;
- }
- case FZ_CMD_FILL_TEXT:
- fz_fill_text(dev, node->item.text, &ctm,
- node->colorspace, node->color, node->alpha);
- break;
- case FZ_CMD_STROKE_TEXT:
- fz_stroke_text(dev, node->item.text, node->stroke, &ctm,
- node->colorspace, node->color, node->alpha);
- break;
- case FZ_CMD_CLIP_TEXT:
- fz_clip_text(dev, node->item.text, &ctm, node->flag);
- break;
- case FZ_CMD_CLIP_STROKE_TEXT:
- fz_clip_stroke_text(dev, node->item.text, node->stroke, &ctm);
- break;
- case FZ_CMD_IGNORE_TEXT:
- fz_ignore_text(dev, node->item.text, &ctm);
- break;
- case FZ_CMD_FILL_SHADE:
- fz_fill_shade(dev, node->item.shade, &ctm, node->alpha);
- break;
- case FZ_CMD_FILL_IMAGE:
- fz_fill_image(dev, node->item.image, &ctm, node->alpha);
- break;
- case FZ_CMD_FILL_IMAGE_MASK:
- fz_fill_image_mask(dev, node->item.image, &ctm,
- node->colorspace, node->color, node->alpha);
- break;
- case FZ_CMD_CLIP_IMAGE_MASK:
- {
- fz_rect rect = node->rect;
- fz_transform_rect(&rect, top_ctm);
- fz_clip_image_mask(dev, node->item.image, &rect, &ctm);
- break;
- }
- case FZ_CMD_POP_CLIP:
- fz_pop_clip(dev);
- break;
- case FZ_CMD_BEGIN_MASK:
- {
- fz_rect rect = node->rect;
- fz_transform_rect(&rect, top_ctm);
- fz_begin_mask(dev, &rect, node->flag, node->colorspace, node->color);
- break;
- }
- case FZ_CMD_END_MASK:
- fz_end_mask(dev);
- break;
- case FZ_CMD_BEGIN_GROUP:
- {
- fz_rect rect = node->rect;
- fz_transform_rect(&rect, top_ctm);
- fz_begin_group(dev, &rect,
- (node->flag & ISOLATED) != 0, (node->flag & KNOCKOUT) != 0,
- node->item.blendmode, node->alpha);
- break;
- }
- case FZ_CMD_END_GROUP:
- fz_end_group(dev);
- break;
- case FZ_CMD_BEGIN_TILE:
- {
- fz_rect rect;
- tiled++;
- rect.x0 = node->color[2];
- rect.y0 = node->color[3];
- rect.x1 = node->color[4];
- rect.y1 = node->color[5];
- fz_begin_tile(dev, &node->rect, &rect, node->color[0], node->color[1], &ctm);
- break;
- }
- case FZ_CMD_END_TILE:
- tiled--;
- fz_end_tile(dev);
- break;
- }
- }
- fz_catch(ctx)
- {
- /* Swallow the error */
- if (cookie)
- cookie->errors++;
- fz_warn(ctx, "Ignoring error during interpretation");
- }
- }
- }
|