From 60a57ea87f74a6457cbdbc85348d4e4af68df569 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 1 Apr 2015 19:48:49 +0100 Subject: Antidropout followup: cope with stroking too. Stroke segments that are horizontal or vertical get the same antidropout treatment as filled rectangles. --- source/fitz/draw-path.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) (limited to 'source/fitz/draw-path.c') diff --git a/source/fitz/draw-path.c b/source/fitz/draw-path.c index 2c0caa50..9956ff45 100644 --- a/source/fitz/draw-path.c +++ b/source/fitz/draw-path.c @@ -268,6 +268,58 @@ fz_add_line(fz_context *ctx, sctx *s, float x0, float y0, float x1, float y1) fz_insert_gel(ctx, s->gel, tx0, ty0, tx1, ty1); } +static void +fz_add_horiz_rect(fz_context *ctx, sctx *s, float x0, float y0, float x1, float y1) +{ + if (s->ctm->b == 0 && s->ctm->c == 0) + { + float tx0 = s->ctm->a * x0 + s->ctm->e; + float ty0 = s->ctm->d * y0 + s->ctm->f; + float tx1 = s->ctm->a * x1 + s->ctm->e; + float ty1 = s->ctm->d * y1 + s->ctm->f; + fz_insert_gel_rect(ctx, s->gel, tx1, ty1, tx0, ty0); + } + else if (s->ctm->a == 0 && s->ctm->d == 0) + { + float tx0 = s->ctm->c * y0 + s->ctm->e; + float ty0 = s->ctm->b * x0 + s->ctm->f; + float tx1 = s->ctm->c * y1 + s->ctm->e; + float ty1 = s->ctm->b * x1 + s->ctm->f; + fz_insert_gel_rect(ctx, s->gel, tx1, ty0, tx0, ty1); + } + else + { + fz_add_line(ctx, s, x0, y0, x1, y0); + fz_add_line(ctx, s, x1, y1, x0, y1); + } +} + +static void +fz_add_vert_rect(fz_context *ctx, sctx *s, float x0, float y0, float x1, float y1) +{ + if (s->ctm->b == 0 && s->ctm->c == 0) + { + float tx0 = s->ctm->a * x0 + s->ctm->e; + float ty0 = s->ctm->d * y0 + s->ctm->f; + float tx1 = s->ctm->a * x1 + s->ctm->e; + float ty1 = s->ctm->d * y1 + s->ctm->f; + fz_insert_gel_rect(ctx, s->gel, tx0, ty1, tx1, ty0); + } + else if (s->ctm->a == 0 && s->ctm->d == 0) + { + float tx0 = s->ctm->c * y0 + s->ctm->e; + float ty0 = s->ctm->b * x0 + s->ctm->f; + float tx1 = s->ctm->c * y1 + s->ctm->e; + float ty1 = s->ctm->b * x1 + s->ctm->f; + fz_insert_gel_rect(ctx, s->gel, tx0, ty0, tx1, ty1); + } + else + { + fz_add_line(ctx, s, x1, y0, x0, y0); + fz_add_line(ctx, s, x0, y1, x1, y1); + } +} + static void fz_add_arc(fz_context *ctx, sctx *s, float xc, float yc, @@ -321,8 +373,19 @@ fz_add_line_stroke(fz_context *ctx, sctx *s, float ax, float ay, float bx, float float dlx = dy * scale; float dly = -dx * scale; - fz_add_line(ctx, s, ax - dlx, ay - dly, bx - dlx, by - dly); - fz_add_line(ctx, s, bx + dlx, by + dly, ax + dlx, ay + dly); + if (0 && dx == 0) + { + fz_add_vert_rect(ctx, s, ax - dlx, ay, bx + dlx, by); + } + else if (dy == 0) + { + fz_add_horiz_rect(ctx, s, ax, ay - dly, bx, by + dly); + } + else + { + fz_add_line(ctx, s, ax - dlx, ay - dly, bx - dlx, by - dly); + fz_add_line(ctx, s, bx + dlx, by + dly, ax + dlx, ay + dly); + } } static void -- cgit v1.2.3