static void fz_draw_free_user(fz_device *devp) { fz_draw_device *dev = devp->user; fz_context *ctx = dev->ctx; /* pop and free the stacks */ if (dev->top > 0) { fz_draw_state *state = &dev->stack[--dev->top]; fz_warn(ctx, "items left on stack in draw device: %d", dev->top+1); do { if (state[1].mask != state[0].mask) fz_drop_pixmap(ctx, state[1].mask); if (state[1].dest != state[0].dest) fz_drop_pixmap(ctx, state[1].dest); if (state[1].shape != state[0].shape) fz_drop_pixmap(ctx, state[1].shape); state--; } while(--dev->top > 0); } if (dev->stack != &dev->init_stack[0]) fz_free(ctx, dev->stack); fz_free_gel(dev->gel); fz_free(ctx, dev); }
static void fz_draw_free_user(void *user) { fz_draw_device *dev = user; /* TODO: pop and free the stacks */ if (dev->top > 0) fz_warn("items left on stack in draw device: %d", dev->top); fz_free_gel(dev->gel); fz_free(dev); }
static void fz_draw_free_user(fz_context *ctx, void *user) { fz_draw_device *dev = user; /* TODO: pop and free the stacks */ if (dev->top > 0) fz_warn(ctx, "items left on stack in draw device: %d", dev->top); if (dev->stack != &dev->init_stack[0]) fz_free(ctx, dev->stack); fz_free_gel(dev->gel); fz_free(ctx, dev); }
fz_device * fz_new_draw_device(fz_context *ctx, fz_pixmap *dest) { fz_device *dev = NULL; fz_draw_device *ddev = fz_malloc_struct(ctx, fz_draw_device); fz_var(dev); fz_try(ctx) { ddev->gel = fz_new_gel(ctx); ddev->flags = 0; ddev->ctx = ctx; ddev->top = 0; ddev->stack = &ddev->init_stack[0]; ddev->stack_max = STACK_SIZE; ddev->stack[0].dest = dest; ddev->stack[0].shape = NULL; ddev->stack[0].mask = NULL; ddev->stack[0].blendmode = 0; ddev->stack[0].scissor.x0 = dest->x; ddev->stack[0].scissor.y0 = dest->y; ddev->stack[0].scissor.x1 = dest->x + dest->w; ddev->stack[0].scissor.y1 = dest->y + dest->h; dev = fz_new_device(ctx, ddev); } fz_catch(ctx) { fz_free_gel(ddev->gel); fz_free(ctx, ddev); fz_rethrow(ctx); } dev->free_user = fz_draw_free_user; dev->fill_path = fz_draw_fill_path; dev->stroke_path = fz_draw_stroke_path; dev->clip_path = fz_draw_clip_path; dev->clip_stroke_path = fz_draw_clip_stroke_path; dev->fill_text = fz_draw_fill_text; dev->stroke_text = fz_draw_stroke_text; dev->clip_text = fz_draw_clip_text; dev->clip_stroke_text = fz_draw_clip_stroke_text; dev->ignore_text = fz_draw_ignore_text; dev->fill_image_mask = fz_draw_fill_image_mask; dev->clip_image_mask = fz_draw_clip_image_mask; dev->fill_image = fz_draw_fill_image; dev->fill_shade = fz_draw_fill_shade; dev->pop_clip = fz_draw_pop_clip; dev->begin_mask = fz_draw_begin_mask; dev->end_mask = fz_draw_end_mask; dev->begin_group = fz_draw_begin_group; dev->end_group = fz_draw_end_group; dev->begin_tile = fz_draw_begin_tile; dev->end_tile = fz_draw_end_tile; return dev; }