From 68f9077504d387a396efd0af6b8ee4147c3451f3 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 5 Apr 2011 02:30:25 +0200 Subject: Add wrapper functions around device calls. They test for NULL and make the code look nicer. --- draw/draw_path.c | 30 ++++---- fitz/dev_draw.c | 12 ++-- fitz/dev_null.c | 193 ++++++++++++++++++++++++++++++++++++++-------------- fitz/fitz.h | 29 ++++++-- pdf/pdf_build.c | 92 ++++++++++++------------- pdf/pdf_interpret.c | 14 ++-- xps/xps_common.c | 6 +- xps/xps_glyphs.c | 8 +-- xps/xps_gradient.c | 4 +- xps/xps_image.c | 2 +- xps/xps_path.c | 16 ++--- xps/xps_tile.c | 10 +-- 12 files changed, 264 insertions(+), 152 deletions(-) diff --git a/draw/draw_path.c b/draw/draw_path.c index 55e070c9..8aa16212 100644 --- a/draw/draw_path.c +++ b/draw/draw_path.c @@ -69,7 +69,7 @@ bezier(fz_gel *gel, fz_matrix *ctm, float flatness, } void -fz_fill_path(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness) +fz_flatten_fill_path(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness) { float x1, y1, x2, y2, x3, y3; float cx = 0; @@ -203,7 +203,7 @@ fz_add_arc(struct sctx *s, } static void -fz_linestroke(struct sctx *s, fz_point a, fz_point b) +fz_add_line_stroke(struct sctx *s, fz_point a, fz_point b) { float dx = b.x - a.x; float dy = b.y - a.y; @@ -215,7 +215,7 @@ fz_linestroke(struct sctx *s, fz_point a, fz_point b) } static void -fz_linejoin(struct sctx *s, fz_point a, fz_point b, fz_point c) +fz_add_line_join(struct sctx *s, fz_point a, fz_point b, fz_point c) { float miterlimit = s->miterlimit; float linewidth = s->linewidth; @@ -303,7 +303,7 @@ fz_linejoin(struct sctx *s, fz_point a, fz_point b, fz_point c) } static void -fz_linecap(struct sctx *s, fz_point a, fz_point b) +fz_add_line_cap(struct sctx *s, fz_point a, fz_point b) { float flatness = s->flatness; float linewidth = s->linewidth; @@ -355,7 +355,7 @@ fz_linecap(struct sctx *s, fz_point a, fz_point b) } static void -fz_linedot(struct sctx *s, fz_point a) +fz_add_line_dot(struct sctx *s, fz_point a) { float flatness = s->flatness; float linewidth = s->linewidth; @@ -384,12 +384,12 @@ fz_stroke_flush(struct sctx *s) { if (s->sn == 2) { - fz_linecap(s, s->beg[1], s->beg[0]); - fz_linecap(s, s->seg[0], s->seg[1]); + fz_add_line_cap(s, s->beg[1], s->beg[0]); + fz_add_line_cap(s, s->seg[0], s->seg[1]); } else if (s->dot) { - fz_linedot(s, s->beg[0]); + fz_add_line_dot(s, s->beg[0]); } } @@ -416,11 +416,11 @@ fz_stroke_lineto(struct sctx *s, fz_point cur) return; } - fz_linestroke(s, s->seg[s->sn-1], cur); + fz_add_line_stroke(s, s->seg[s->sn-1], cur); if (s->sn == 2) { - fz_linejoin(s, s->seg[0], s->seg[1], cur); + fz_add_line_join(s, s->seg[0], s->seg[1], cur); s->seg[0] = s->seg[1]; s->seg[1] = cur; } @@ -438,13 +438,13 @@ fz_stroke_closepath(struct sctx *s) { fz_stroke_lineto(s, s->beg[0]); if (s->seg[1].x == s->beg[0].x && s->seg[1].y == s->beg[0].y) - fz_linejoin(s, s->seg[0], s->beg[0], s->beg[1]); + fz_add_line_join(s, s->seg[0], s->beg[0], s->beg[1]); else - fz_linejoin(s, s->seg[1], s->beg[0], s->beg[1]); + fz_add_line_join(s, s->seg[1], s->beg[0], s->beg[1]); } else if (s->dot) { - fz_linedot(s, s->beg[0]); + fz_add_line_dot(s, s->beg[0]); } s->seg[0] = s->beg[0]; @@ -511,7 +511,7 @@ fz_stroke_bezier(struct sctx *s, } void -fz_stroke_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth) +fz_flatten_stroke_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth) { struct sctx s; fz_point p0, p1, p2, p3; @@ -698,7 +698,7 @@ fz_dash_bezier(struct sctx *s, } void -fz_dash_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth) +fz_flatten_dash_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth) { struct sctx s; fz_point p0, p1, p2, p3, beg; diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c index e5078f49..05f96f28 100644 --- a/fitz/dev_draw.c +++ b/fitz/dev_draw.c @@ -45,7 +45,7 @@ fz_draw_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm, int i; fz_reset_gel(dev->gel, dev->scissor); - fz_fill_path(dev->gel, path, ctm, flatness); + fz_flatten_fill_path(dev->gel, path, ctm, flatness); fz_sort_gel(dev->gel); bbox = fz_bound_gel(dev->gel); @@ -81,9 +81,9 @@ fz_draw_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matri fz_reset_gel(dev->gel, dev->scissor); if (stroke->dash_len > 0) - fz_dash_path(dev->gel, path, stroke, ctm, flatness, linewidth); + fz_flatten_dash_path(dev->gel, path, stroke, ctm, flatness, linewidth); else - fz_stroke_path(dev->gel, path, stroke, ctm, flatness, linewidth); + fz_flatten_stroke_path(dev->gel, path, stroke, ctm, flatness, linewidth); fz_sort_gel(dev->gel); bbox = fz_bound_gel(dev->gel); @@ -117,7 +117,7 @@ fz_draw_clip_path(void *user, fz_path *path, int even_odd, fz_matrix ctm) } fz_reset_gel(dev->gel, dev->scissor); - fz_fill_path(dev->gel, path, ctm, flatness); + fz_flatten_fill_path(dev->gel, path, ctm, flatness); fz_sort_gel(dev->gel); bbox = fz_bound_gel(dev->gel); @@ -171,9 +171,9 @@ fz_draw_clip_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_ fz_reset_gel(dev->gel, dev->scissor); if (stroke->dash_len > 0) - fz_dash_path(dev->gel, path, stroke, ctm, flatness, linewidth); + fz_flatten_dash_path(dev->gel, path, stroke, ctm, flatness, linewidth); else - fz_stroke_path(dev->gel, path, stroke, ctm, flatness, linewidth); + fz_flatten_stroke_path(dev->gel, path, stroke, ctm, flatness, linewidth); fz_sort_gel(dev->gel); bbox = fz_bound_gel(dev->gel); diff --git a/fitz/dev_null.c b/fitz/dev_null.c index dcb43292..d351c0a0 100644 --- a/fitz/dev_null.c +++ b/fitz/dev_null.c @@ -1,71 +1,164 @@ #include "fitz.h" -static void fz_null_free_user(void *user) {} -static void fz_null_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} -static void fz_null_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} -static void fz_null_clip_path(void *user, fz_path *path, int even_odd, fz_matrix ctm) {} -static void fz_null_clip_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm) {} -static void fz_null_fill_text(void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} -static void fz_null_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} -static void fz_null_clip_text(void *user, fz_text *text, fz_matrix ctm, int accumulate) {} -static void fz_null_clip_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm) {} -static void fz_null_ignore_text(void *user, fz_text *text, fz_matrix ctm) {} -static void fz_null_pop_clip(void *user) {} -static void fz_null_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) {} -static void fz_null_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) {} -static void fz_null_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} -static void fz_null_clip_image_mask(void *user, fz_pixmap *image, fz_matrix ctm) {} -static void fz_null_begin_mask(void *user, fz_rect r, int luminosity, fz_colorspace *colorspace, float *bc) {} -static void fz_null_end_mask(void *user) {} -static void fz_null_begin_group(void *user, fz_rect r, int isolated, int knockout, fz_blendmode blendmode, float alpha) {} -static void fz_null_end_group(void *user) {} -static void fz_null_begin_tile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm) {} -static void fz_null_end_tile(void *user) {} - fz_device * fz_new_device(void *user) { fz_device *dev = fz_malloc(sizeof(fz_device)); memset(dev, 0, sizeof(fz_device)); - dev->hints = 0; - dev->user = user; - dev->free_user = fz_null_free_user; + return dev; +} - dev->fill_path = fz_null_fill_path; - dev->stroke_path = fz_null_stroke_path; - dev->clip_path = fz_null_clip_path; - dev->clip_stroke_path = fz_null_clip_stroke_path; +void +fz_free_device(fz_device *dev) +{ + if (dev->free_user) + dev->free_user(dev->user); + fz_free(dev); +} - dev->fill_text = fz_null_fill_text; - dev->stroke_text = fz_null_stroke_text; - dev->clip_text = fz_null_clip_text; - dev->clip_stroke_text = fz_null_clip_stroke_text; - dev->ignore_text = fz_null_ignore_text; +void +fz_fill_path(fz_device *dev, fz_path *path, int even_odd, fz_matrix ctm, + fz_colorspace *colorspace, float *color, float alpha) +{ + if (dev->fill_path) + dev->fill_path(dev->user, path, even_odd, ctm, colorspace, color, alpha); +} - dev->fill_shade = fz_null_fill_shade; - dev->fill_image = fz_null_fill_image; - dev->fill_image_mask = fz_null_fill_image_mask; - dev->clip_image_mask = fz_null_clip_image_mask; +void +fz_stroke_path(fz_device *dev, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, + fz_colorspace *colorspace, float *color, float alpha) +{ + if (dev->stroke_path) + dev->stroke_path(dev->user, path, stroke, ctm, colorspace, color, alpha); +} - dev->pop_clip = fz_null_pop_clip; +void +fz_clip_path(fz_device *dev, fz_path *path, int even_odd, fz_matrix ctm) +{ + if (dev->clip_path) + dev->clip_path(dev->user, path, even_odd, ctm); +} - dev->begin_mask = fz_null_begin_mask; - dev->end_mask = fz_null_end_mask; - dev->begin_group = fz_null_begin_group; - dev->end_group = fz_null_end_group; +void +fz_clip_stroke_path(fz_device *dev, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm) +{ + if (dev->clip_stroke_path) + dev->clip_stroke_path(dev->user, path, stroke, ctm); +} - dev->begin_tile = fz_null_begin_tile; - dev->end_tile = fz_null_end_tile; +void +fz_fill_text(fz_device *dev, fz_text *text, fz_matrix ctm, + fz_colorspace *colorspace, float *color, float alpha) +{ + if (dev->fill_text) + dev->fill_text(dev->user, text, ctm, colorspace, color, alpha); +} - return dev; +void +fz_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, + fz_colorspace *colorspace, float *color, float alpha) +{ + if (dev->stroke_text) + dev->stroke_text(dev->user, text, stroke, ctm, colorspace, color, alpha); } void -fz_free_device(fz_device *dev) +fz_clip_text(fz_device *dev, fz_text *text, fz_matrix ctm, int accumulate) { - if (dev->free_user) - dev->free_user(dev->user); - fz_free(dev); + if (dev->clip_text) + dev->clip_text(dev->user, text, ctm, accumulate); +} + +void +fz_clip_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm) +{ + if (dev->clip_stroke_text) + dev->clip_stroke_text(dev->user, text, stroke, ctm); +} + +void +fz_ignore_text(fz_device *dev, fz_text *text, fz_matrix ctm) +{ + if (dev->ignore_text) + dev->ignore_text(dev->user, text, ctm); +} + +void +fz_pop_clip(fz_device *dev) +{ + if (dev->pop_clip) + dev->pop_clip(dev->user); +} + +void +fz_fill_shade(fz_device *dev, fz_shade *shade, fz_matrix ctm, float alpha) +{ + if (dev->fill_shade) + dev->fill_shade(dev->user, shade, ctm, alpha); +} + +void +fz_fill_image(fz_device *dev, fz_pixmap *image, fz_matrix ctm, float alpha) +{ + if (dev->fill_image) + dev->fill_image(dev->user, image, ctm, alpha); +} + +void +fz_fill_image_mask(fz_device *dev, fz_pixmap *image, fz_matrix ctm, + fz_colorspace *colorspace, float *color, float alpha) +{ + if (dev->fill_image_mask) + dev->fill_image_mask(dev->user, image, ctm, colorspace, color, alpha); +} + +void +fz_clip_image_mask(fz_device *dev, fz_pixmap *image, fz_matrix ctm) +{ + if (dev->clip_image_mask) + dev->clip_image_mask(dev->user, image, ctm); +} + +void +fz_begin_mask(fz_device *dev, fz_rect area, int luminosity, fz_colorspace *colorspace, float *bc) +{ + if (dev->begin_mask) + dev->begin_mask(dev->user, area, luminosity, colorspace, bc); +} + +void +fz_end_mask(fz_device *dev) +{ + if (dev->end_mask) + dev->end_mask(dev->user); +} + +void +fz_begin_group(fz_device *dev, fz_rect area, int isolated, int knockout, fz_blendmode blendmode, float alpha) +{ + if (dev->begin_group) + dev->begin_group(dev->user, area, isolated, knockout, blendmode, alpha); +} + +void +fz_end_group(fz_device *dev) +{ + if (dev->end_group) + dev->end_group(dev->user); +} + +void +fz_begin_tile(fz_device *dev, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm) +{ + if (dev->begin_tile) + dev->begin_tile(dev->user, area, view, xstep, ystep, ctm); +} + +void +fz_end_tile(fz_device *dev) +{ + if (dev->end_tile) + dev->end_tile(dev->user); } diff --git a/fitz/fitz.h b/fitz/fitz.h index c765da87..f0f3ecdb 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -978,9 +978,9 @@ void fz_free_ael(fz_ael *ael); fz_error fz_scan_convert(fz_gel *gel, fz_ael *ael, int eofill, fz_bbox clip, fz_pixmap *pix, unsigned char *colorbv); -void fz_fill_path(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness); -void fz_stroke_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth); -void fz_dash_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth); +void fz_flatten_fill_path(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness); +void fz_flatten_stroke_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth); +void fz_flatten_dash_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth); /* * The device interface. @@ -1028,13 +1028,32 @@ struct fz_device_s void (*end_tile)(void *); }; +void fz_fill_path(fz_device *dev, fz_path *path, int even_odd, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha); +void fz_stroke_path(fz_device *dev, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha); +void fz_clip_path(fz_device *dev, fz_path *path, int even_odd, fz_matrix ctm); +void fz_clip_stroke_path(fz_device *dev, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm); +void fz_fill_text(fz_device *dev, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha); +void fz_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha); +void fz_clip_text(fz_device *dev, fz_text *text, fz_matrix ctm, int accumulate); +void fz_clip_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm); +void fz_ignore_text(fz_device *dev, fz_text *text, fz_matrix ctm); +void fz_pop_clip(fz_device *dev); +void fz_fill_shade(fz_device *dev, fz_shade *shade, fz_matrix ctm, float alpha); +void fz_fill_image(fz_device *dev, fz_pixmap *image, fz_matrix ctm, float alpha); +void fz_fill_image_mask(fz_device *dev, fz_pixmap *image, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha); +void fz_clip_image_mask(fz_device *dev, fz_pixmap *image, fz_matrix ctm); +void fz_begin_mask(fz_device *dev, fz_rect area, int luminosity, fz_colorspace *colorspace, float *bc); +void fz_end_mask(fz_device *dev); +void fz_begin_group(fz_device *dev, fz_rect area, int isolated, int knockout, fz_blendmode blendmode, float alpha); +void fz_end_group(fz_device *dev); +void fz_begin_tile(fz_device *dev, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm); +void fz_end_tile(fz_device *dev); + fz_device *fz_new_device(void *user); void fz_free_device(fz_device *dev); fz_device *fz_new_trace_device(void); - fz_device *fz_new_bbox_device(fz_bbox *bboxp); - fz_device *fz_new_draw_device(fz_glyph_cache *cache, fz_pixmap *dest); /* diff --git a/pdf/pdf_build.c b/pdf/pdf_build.c index 6908da1a..7218e135 100644 --- a/pdf/pdf_build.c +++ b/pdf/pdf_build.c @@ -211,7 +211,7 @@ pdf_show_pattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what) #ifdef TILE if ((x1 - x0) * (y1 - y0) > 0) { - csi->dev->begin_tile(csi->dev->user, area, pat->bbox, pat->xstep, pat->ystep, ptm); + fz_begin_tile(csi->dev, area, pat->bbox, pat->xstep, pat->ystep, ptm); gstate->ctm = ptm; csi->top_ctm = gstate->ctm; error = pdf_run_csi_buffer(csi, pat->resources, pat->contents); @@ -219,7 +219,7 @@ pdf_show_pattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what) fz_catch(error, "cannot render pattern tile"); while (oldtop < csi->gtop) pdf_grestore(csi); - csi->dev->end_tile(csi->dev->user); + fz_end_tile(csi->dev); } #else { @@ -262,18 +262,18 @@ pdf_begin_group(pdf_csi *csi, fz_rect bbox) gstate->softmask = NULL; - csi->dev->begin_mask(csi->dev->user, bbox, gstate->luminosity, + fz_begin_mask(csi->dev, bbox, gstate->luminosity, softmask->colorspace, gstate->softmask_bc); error = pdf_run_xobject(csi, NULL, softmask, fz_identity); if (error) fz_catch(error, "cannot run softmask"); - csi->dev->end_mask(csi->dev->user); + fz_end_mask(csi->dev); gstate->softmask = softmask; } if (gstate->blendmode != FZ_BLEND_NORMAL) - csi->dev->begin_group(csi->dev->user, bbox, 0, 0, gstate->blendmode, 1); + fz_begin_group(csi->dev, bbox, 0, 0, gstate->blendmode, 1); } static void @@ -282,10 +282,10 @@ pdf_end_group(pdf_csi *csi) pdf_gstate *gstate = csi->gstate + csi->gtop; if (gstate->blendmode != FZ_BLEND_NORMAL) - csi->dev->end_group(csi->dev->user); + fz_end_group(csi->dev); if (gstate->softmask) - csi->dev->pop_clip(csi->dev->user); + fz_pop_clip(csi->dev); } void @@ -298,7 +298,7 @@ pdf_show_shade(pdf_csi *csi, fz_shade *shd) pdf_begin_group(csi, bbox); - csi->dev->fill_shade(csi->dev->user, shd, gstate->ctm, gstate->fill.alpha); + fz_fill_shade(csi->dev, shd, gstate->ctm, gstate->fill.alpha); pdf_end_group(csi); } @@ -315,8 +315,8 @@ pdf_show_image(pdf_csi *csi, fz_pixmap *image) { /* apply blend group even though we skip the softmask */ if (gstate->blendmode != FZ_BLEND_NORMAL) - csi->dev->begin_group(csi->dev->user, bbox, 0, 0, gstate->blendmode, 1); - csi->dev->clip_image_mask(csi->dev->user, image->mask, gstate->ctm); + fz_begin_group(csi->dev, bbox, 0, 0, gstate->blendmode, 1); + fz_clip_image_mask(csi->dev, image->mask, gstate->ctm); } else pdf_begin_group(csi, bbox); @@ -329,37 +329,37 @@ pdf_show_image(pdf_csi *csi, fz_pixmap *image) case PDF_MAT_NONE: break; case PDF_MAT_COLOR: - csi->dev->fill_image_mask(csi->dev->user, image, gstate->ctm, + fz_fill_image_mask(csi->dev, image, gstate->ctm, gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha); break; case PDF_MAT_PATTERN: if (gstate->fill.pattern) { - csi->dev->clip_image_mask(csi->dev->user, image, gstate->ctm); + fz_clip_image_mask(csi->dev, image, gstate->ctm); pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL); - csi->dev->pop_clip(csi->dev->user); + fz_pop_clip(csi->dev); } break; case PDF_MAT_SHADE: if (gstate->fill.shade) { - csi->dev->clip_image_mask(csi->dev->user, image, gstate->ctm); - csi->dev->fill_shade(csi->dev->user, gstate->fill.shade, gstate->ctm, gstate->fill.alpha); - csi->dev->pop_clip(csi->dev->user); + fz_clip_image_mask(csi->dev, image, gstate->ctm); + fz_fill_shade(csi->dev, gstate->fill.shade, gstate->ctm, gstate->fill.alpha); + fz_pop_clip(csi->dev); } break; } } else { - csi->dev->fill_image(csi->dev->user, image, gstate->ctm, gstate->fill.alpha); + fz_fill_image(csi->dev, image, gstate->ctm, gstate->fill.alpha); } if (image->mask) { - csi->dev->pop_clip(csi->dev->user); + fz_pop_clip(csi->dev); if (gstate->blendmode != FZ_BLEND_NORMAL) - csi->dev->end_group(csi->dev->user); + fz_end_group(csi->dev); } else pdf_end_group(csi); @@ -386,7 +386,7 @@ pdf_show_path(pdf_csi *csi, int doclose, int dofill, int dostroke, int even_odd) if (csi->clip) { gstate->clip_depth++; - csi->dev->clip_path(csi->dev->user, path, even_odd, gstate->ctm); + fz_clip_path(csi->dev, path, even_odd, gstate->ctm); csi->clip = 0; } @@ -399,23 +399,23 @@ pdf_show_path(pdf_csi *csi, int doclose, int dofill, int dostroke, int even_odd) case PDF_MAT_NONE: break; case PDF_MAT_COLOR: - csi->dev->fill_path(csi->dev->user, path, even_odd, gstate->ctm, + fz_fill_path(csi->dev, path, even_odd, gstate->ctm, gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha); break; case PDF_MAT_PATTERN: if (gstate->fill.pattern) { - csi->dev->clip_path(csi->dev->user, path, even_odd, gstate->ctm); + fz_clip_path(csi->dev, path, even_odd, gstate->ctm); pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL); - csi->dev->pop_clip(csi->dev->user); + fz_pop_clip(csi->dev); } break; case PDF_MAT_SHADE: if (gstate->fill.shade) { - csi->dev->clip_path(csi->dev->user, path, even_odd, gstate->ctm); - csi->dev->fill_shade(csi->dev->user, gstate->fill.shade, csi->top_ctm, gstate->fill.alpha); - csi->dev->pop_clip(csi->dev->user); + fz_clip_path(csi->dev, path, even_odd, gstate->ctm); + fz_fill_shade(csi->dev, gstate->fill.shade, csi->top_ctm, gstate->fill.alpha); + fz_pop_clip(csi->dev); } break; } @@ -428,23 +428,23 @@ pdf_show_path(pdf_csi *csi, int doclose, int dofill, int dostroke, int even_odd) case PDF_MAT_NONE: break; case PDF_MAT_COLOR: - csi->dev->stroke_path(csi->dev->user, path, &gstate->stroke_state, gstate->ctm, + fz_stroke_path(csi->dev, path, &gstate->stroke_state, gstate->ctm, gstate->stroke.colorspace, gstate->stroke.v, gstate->stroke.alpha); break; case PDF_MAT_PATTERN: if (gstate->stroke.pattern) { - csi->dev->clip_stroke_path(csi->dev->user, path, &gstate->stroke_state, gstate->ctm); + fz_clip_stroke_path(csi->dev, path, &gstate->stroke_state, gstate->ctm); pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_FILL); - csi->dev->pop_clip(csi->dev->user); + fz_pop_clip(csi->dev); } break; case PDF_MAT_SHADE: if (gstate->stroke.shade) { - csi->dev->clip_stroke_path(csi->dev->user, path, &gstate->stroke_state, gstate->ctm); - csi->dev->fill_shade(csi->dev->user, gstate->stroke.shade, csi->top_ctm, gstate->stroke.alpha); - csi->dev->pop_clip(csi->dev->user); + fz_clip_stroke_path(csi->dev, path, &gstate->stroke_state, gstate->ctm); + fz_fill_shade(csi->dev, gstate->stroke.shade, csi->top_ctm, gstate->stroke.alpha); + fz_pop_clip(csi->dev); } break; } @@ -489,13 +489,13 @@ pdf_flush_text(pdf_csi *csi) pdf_begin_group(csi, bbox); if (doinvisible) - csi->dev->ignore_text(csi->dev->user, text, gstate->ctm); + fz_ignore_text(csi->dev, text, gstate->ctm); if (doclip) { if (csi->accumulate < 2) gstate->clip_depth++; - csi->dev->clip_text(csi->dev->user, text, gstate->ctm, csi->accumulate); + fz_clip_text(csi->dev, text, gstate->ctm, csi->accumulate); csi->accumulate = 2; } @@ -506,23 +506,23 @@ pdf_flush_text(pdf_csi *csi) case PDF_MAT_NONE: break; case PDF_MAT_COLOR: - csi->dev->fill_text(csi->dev->user, text, gstate->ctm, + fz_fill_text(csi->dev, text, gstate->ctm, gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha); break; case PDF_MAT_PATTERN: if (gstate->fill.pattern) { - csi->dev->clip_text(csi->dev->user, text, gstate->ctm, 0); + fz_clip_text(csi->dev, text, gstate->ctm, 0); pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL); - csi->dev->pop_clip(csi->dev->user); + fz_pop_clip(csi->dev); } break; case PDF_MAT_SHADE: if (gstate->fill.shade) { - csi->dev->clip_text(csi->dev->user, text, gstate->ctm, 0); - csi->dev->fill_shade(csi->dev->user, gstate->fill.shade, csi->top_ctm, gstate->fill.alpha); - csi->dev->pop_clip(csi->dev->user); + fz_clip_text(csi->dev, text, gstate->ctm, 0); + fz_fill_shade(csi->dev, gstate->fill.shade, csi->top_ctm, gstate->fill.alpha); + fz_pop_clip(csi->dev); } break; } @@ -535,23 +535,23 @@ pdf_flush_text(pdf_csi *csi) case PDF_MAT_NONE: break; case PDF_MAT_COLOR: - csi->dev->stroke_text(csi->dev->user, text, &gstate->stroke_state, gstate->ctm, + fz_stroke_text(csi->dev, text, &gstate->stroke_state, gstate->ctm, gstate->stroke.colorspace, gstate->stroke.v, gstate->stroke.alpha); break; case PDF_MAT_PATTERN: if (gstate->stroke.pattern) { - csi->dev->clip_stroke_text(csi->dev->user, text, &gstate->stroke_state, gstate->ctm); + fz_clip_stroke_text(csi->dev, text, &gstate->stroke_state, gstate->ctm); pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_FILL); - csi->dev->pop_clip(csi->dev->user); + fz_pop_clip(csi->dev); } break; case PDF_MAT_SHADE: if (gstate->stroke.shade) { - csi->dev->clip_stroke_text(csi->dev->user, text, &gstate->stroke_state, gstate->ctm); - csi->dev->fill_shade(csi->dev->user, gstate->stroke.shade, csi->top_ctm, gstate->stroke.alpha); - csi->dev->pop_clip(csi->dev->user); + fz_clip_stroke_text(csi->dev, text, &gstate->stroke_state, gstate->ctm); + fz_fill_shade(csi->dev, gstate->stroke.shade, csi->top_ctm, gstate->stroke.alpha); + fz_pop_clip(csi->dev); } break; } diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c index 3c183b43..908ea504 100644 --- a/pdf/pdf_interpret.c +++ b/pdf/pdf_interpret.c @@ -126,7 +126,7 @@ pdf_grestore(pdf_csi *csi) gs = csi->gstate + csi->gtop; while (clip_depth > gs->clip_depth) { - csi->dev->pop_clip(csi->dev->user); + fz_pop_clip(csi->dev); clip_depth--; } } @@ -145,7 +145,7 @@ pdf_free_csi(pdf_csi *csi) pdf_drop_xobject(csi->gstate[0].softmask); while (csi->gstate[0].clip_depth--) - csi->dev->pop_clip(csi->dev->user); + fz_pop_clip(csi->dev); if (csi->path) fz_free_path(csi->path); if (csi->text) fz_free_text(csi->text); @@ -204,17 +204,17 @@ pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tr gstate->softmask = NULL; popmask = 1; - csi->dev->begin_mask(csi->dev->user, bbox, gstate->luminosity, + fz_begin_mask(csi->dev, bbox, gstate->luminosity, softmask->colorspace, gstate->softmask_bc); error = pdf_run_xobject(csi, resources, softmask, fz_identity); if (error) return fz_rethrow(error, "cannot run softmask"); - csi->dev->end_mask(csi->dev->user); + fz_end_mask(csi->dev); pdf_drop_xobject(softmask); } - csi->dev->begin_group(csi->dev->user, + fz_begin_group(csi->dev, fz_transform_rect(gstate->ctm, xobj->bbox), xobj->isolated, xobj->knockout, gstate->blendmode, gstate->fill.alpha); @@ -256,9 +256,9 @@ pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tr if (xobj->transparency) { - csi->dev->end_group(csi->dev->user); + fz_end_group(csi->dev); if (popmask) - csi->dev->pop_clip(csi->dev->user); + fz_pop_clip(csi->dev); } return fz_okay; diff --git a/xps/xps_common.c b/xps/xps_common.c index 7e7f33e3..17716839 100644 --- a/xps/xps_common.c +++ b/xps/xps_common.c @@ -75,9 +75,9 @@ xps_begin_opacity(xps_context *ctx, fz_matrix ctm, fz_rect area, if (opacity_mask_tag) { - ctx->dev->begin_mask(ctx->dev->user, area, 0, NULL, NULL); + fz_begin_mask(ctx->dev, area, 0, NULL, NULL); xps_parse_brush(ctx, ctm, area, base_uri, dict, opacity_mask_tag); - ctx->dev->end_mask(ctx->dev->user); + fz_end_mask(ctx->dev); } } @@ -94,7 +94,7 @@ xps_end_opacity(xps_context *ctx, char *base_uri, xps_resource *dict, if (opacity_mask_tag) { if (strcmp(xml_tag(opacity_mask_tag), "SolidColorBrush")) - ctx->dev->pop_clip(ctx->dev->user); + fz_pop_clip(ctx->dev); } } diff --git a/xps/xps_glyphs.c b/xps/xps_glyphs.c index 8ae9155a..605938be 100644 --- a/xps/xps_glyphs.c +++ b/xps/xps_glyphs.c @@ -537,7 +537,7 @@ xps_parse_glyphs(xps_context *ctx, fz_matrix ctm, samples[0] = atof(fill_opacity_att); xps_set_color(ctx, colorspace, samples); - ctx->dev->fill_text(ctx->dev->user, text, ctm, + fz_fill_text(ctx->dev, text, ctm, ctx->colorspace, ctx->color, ctx->alpha); } @@ -547,9 +547,9 @@ xps_parse_glyphs(xps_context *ctx, fz_matrix ctm, if (fill_tag) { - ctx->dev->clip_text(ctx->dev->user, text, ctm, 0); + fz_clip_text(ctx->dev, text, ctm, 0); xps_parse_brush(ctx, ctm, area, fill_uri, dict, fill_tag); - ctx->dev->pop_clip(ctx->dev->user); + fz_pop_clip(ctx->dev); } xps_end_opacity(ctx, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); @@ -557,5 +557,5 @@ xps_parse_glyphs(xps_context *ctx, fz_matrix ctm, fz_free_text(text); if (clip_att || clip_tag) - ctx->dev->pop_clip(ctx->dev->user); + fz_pop_clip(ctx->dev); } diff --git a/xps/xps_gradient.c b/xps/xps_gradient.c index 65cb4362..9f560b48 100644 --- a/xps/xps_gradient.c +++ b/xps/xps_gradient.c @@ -235,7 +235,7 @@ xps_draw_one_radial_gradient(xps_context *ctx, fz_matrix ctm, shade->mesh[4] = y1; shade->mesh[5] = r1; - ctx->dev->fill_shade(ctx->dev->user, shade, ctm, 1); + fz_fill_shade(ctx->dev, shade, ctm, 1); fz_drop_shade(shade); } @@ -276,7 +276,7 @@ xps_draw_one_linear_gradient(xps_context *ctx, fz_matrix ctm, shade->mesh[4] = y1; shade->mesh[5] = 0; - ctx->dev->fill_shade(ctx->dev->user, shade, ctm, 1); + fz_fill_shade(ctx->dev, shade, ctm, 1); fz_drop_shade(shade); } diff --git a/xps/xps_image.c b/xps/xps_image.c index 468c6411..4a347435 100644 --- a/xps/xps_image.c +++ b/xps/xps_image.c @@ -47,7 +47,7 @@ xps_paint_image_brush(xps_context *ctx, fz_matrix ctm, fz_rect area, char *base_ fz_matrix im = fz_scale(xs, -ys); im.f = ys; ctm = fz_concat(im, ctm); - ctx->dev->fill_image(ctx->dev->user, pixmap, ctm, ctx->opacity[ctx->opacity_top]); + fz_fill_image(ctx->dev, pixmap, ctm, ctx->opacity[ctx->opacity_top]); } static xps_part * diff --git a/xps/xps_path.c b/xps/xps_path.c index d89cd068..3e76787b 100644 --- a/xps/xps_path.c +++ b/xps/xps_path.c @@ -758,7 +758,7 @@ xps_clip(xps_context *ctx, fz_matrix ctm, xps_resource *dict, char *clip_att, xm path = xps_parse_path_geometry(ctx, dict, clip_tag, 0, &fill_rule); else path = fz_new_path(); - ctx->dev->clip_path(ctx->dev->user, path, fill_rule == 0, ctm); + fz_clip_path(ctx->dev, path, fill_rule == 0, ctm); fz_free_path(path); } @@ -949,7 +949,7 @@ xps_parse_path(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *di samples[0] = atof(fill_opacity_att); xps_set_color(ctx, colorspace, samples); - ctx->dev->fill_path(ctx->dev->user, path, fill_rule == 0, ctm, + fz_fill_path(ctx->dev, path, fill_rule == 0, ctm, ctx->colorspace, ctx->color, ctx->alpha); } @@ -957,9 +957,9 @@ xps_parse_path(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *di { area = fz_bound_path(path, NULL, ctm); - ctx->dev->clip_path(ctx->dev->user, path, fill_rule == 0, ctm); + fz_clip_path(ctx->dev, path, fill_rule == 0, ctm); xps_parse_brush(ctx, ctm, area, fill_uri, dict, fill_tag); - ctx->dev->pop_clip(ctx->dev->user); + fz_pop_clip(ctx->dev); } if (stroke_att) @@ -969,15 +969,15 @@ xps_parse_path(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *di samples[0] = atof(stroke_opacity_att); xps_set_color(ctx, colorspace, samples); - ctx->dev->stroke_path(ctx->dev->user, path, &stroke, ctm, + fz_stroke_path(ctx->dev, path, &stroke, ctm, ctx->colorspace, ctx->color, ctx->alpha); } if (stroke_tag) { - ctx->dev->clip_stroke_path(ctx->dev->user, path, &stroke, ctm); + fz_clip_stroke_path(ctx->dev, path, &stroke, ctm); xps_parse_brush(ctx, ctm, area, stroke_uri, dict, stroke_tag); - ctx->dev->pop_clip(ctx->dev->user); + fz_pop_clip(ctx->dev); } xps_end_opacity(ctx, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); @@ -986,5 +986,5 @@ xps_parse_path(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *di path = NULL; if (clip_att || clip_tag) - ctx->dev->pop_clip(ctx->dev->user); + fz_pop_clip(ctx->dev); } diff --git a/xps/xps_tile.c b/xps/xps_tile.c index eb972fad..d94fb4c8 100644 --- a/xps/xps_tile.c +++ b/xps/xps_tile.c @@ -28,10 +28,10 @@ xps_paint_tiling_brush_clipped(xps_context *ctx, fz_matrix ctm, fz_rect viewbox, fz_lineto(path, viewbox.x1, viewbox.y1); fz_lineto(path, viewbox.x1, viewbox.y0); fz_closepath(path); - ctx->dev->clip_path(ctx->dev->user, path, 0, ctm); + fz_clip_path(ctx->dev, path, 0, ctm); fz_free_path(path); c->func(ctx, ctm, viewbox, c->base_uri, c->dict, c->root, c->user); - ctx->dev->pop_clip(ctx->dev->user); + fz_pop_clip(ctx->dev); } static void @@ -182,11 +182,11 @@ xps_parse_tiling_brush(xps_context *ctx, fz_matrix ctm, fz_rect area, bigview.x1 = bigview.x0 + xstep; bigview.y1 = bigview.y0 + ystep; if (n > 1) - ctx->dev->begin_tile(ctx->dev->user, area, bigview, xstep, ystep, ctm); + fz_begin_tile(ctx->dev, area, bigview, xstep, ystep, ctm); if (n > 0) xps_paint_tiling_brush(ctx, ctm, viewbox, tile_mode, &c); if (n > 1) - ctx->dev->end_tile(ctx->dev->user); + fz_end_tile(ctx->dev); } #else { @@ -316,7 +316,7 @@ xps_parse_canvas(xps_context *ctx, fz_matrix ctm, fz_rect area, char *base_uri, xps_end_opacity(ctx, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); if (clip_att || clip_tag) - ctx->dev->pop_clip(ctx->dev->user); + fz_pop_clip(ctx->dev); if (new_dict) xps_free_resource_dictionary(ctx, new_dict); -- cgit v1.2.3