summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2015-04-01 19:48:49 +0100
committerRobin Watts <robin.watts@artifex.com>2015-04-06 19:32:02 +0100
commit60a57ea87f74a6457cbdbc85348d4e4af68df569 (patch)
treee5b1f7d5bd5206f1f07ada8e20e6328195c30d8a /source
parent05e491cddf81813977141e6c89a032fd507d8cb1 (diff)
downloadmupdf-60a57ea87f74a6457cbdbc85348d4e4af68df569.tar.xz
Antidropout followup: cope with stroking too.
Stroke segments that are horizontal or vertical get the same antidropout treatment as filled rectangles.
Diffstat (limited to 'source')
-rw-r--r--source/fitz/draw-path.c67
1 files changed, 65 insertions, 2 deletions
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
@@ -269,6 +269,58 @@ fz_add_line(fz_context *ctx, sctx *s, float x0, float y0, float x1, float y1)
}
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,
float x0, float y0,
@@ -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