summaryrefslogtreecommitdiff
path: root/raster
diff options
context:
space:
mode:
authorGlenn Kennard <glenn.kennard@gmail.com>2008-04-19 12:01:33 +0200
committerGlenn Kennard <glenn.kennard@gmail.com>2008-04-19 12:01:33 +0200
commit94a50be10b6a76175d1107c2a92c73f3490d1445 (patch)
tree695bd47bd1e7878d9a7933488dc183cc40140dbd /raster
parent8dfe55b5c063236a80955c38a4f836df39a0a31c (diff)
downloadmupdf-94a50be10b6a76175d1107c2a92c73f3490d1445.tar.xz
Support hairlines (zero-width lines)
Diffstat (limited to 'raster')
-rw-r--r--raster/pathstroke.c8
-rw-r--r--raster/render.c12
2 files changed, 13 insertions, 7 deletions
diff --git a/raster/pathstroke.c b/raster/pathstroke.c
index f1afb825..cafcd663 100644
--- a/raster/pathstroke.c
+++ b/raster/pathstroke.c
@@ -458,7 +458,7 @@ strokebezier(struct sctx *s,
}
fz_error *
-fz_strokepath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness)
+fz_strokepath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness, float linewidth)
{
fz_error *error;
struct sctx s;
@@ -471,7 +471,7 @@ fz_strokepath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness)
s.linecap = path->linecap;
s.linejoin = path->linejoin;
- s.linewidth = path->linewidth * 0.5;
+ s.linewidth = linewidth * 0.5; /* hairlines use a different value from the path value */
s.miterlimit = path->miterlimit;
s.sn = 0;
s.bn = 0;
@@ -653,7 +653,7 @@ dashbezier(struct sctx *s,
}
fz_error *
-fz_dashpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness)
+fz_dashpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness, float linewidth)
{
fz_error *error;
struct sctx s;
@@ -666,7 +666,7 @@ fz_dashpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness)
s.linecap = path->linecap;
s.linejoin = path->linejoin;
- s.linewidth = path->linewidth * 0.5;
+ s.linewidth = linewidth * 0.5;
s.miterlimit = path->miterlimit;
s.sn = 0;
s.bn = 0;
diff --git a/raster/render.c b/raster/render.c
index 4e010179..596bedab 100644
--- a/raster/render.c
+++ b/raster/render.c
@@ -187,8 +187,9 @@ renderpath(fz_renderer *gc, fz_pathnode *path, fz_matrix ctm)
float flatness;
fz_irect gbox;
fz_irect clip;
+ float expansion = fz_matrixexpansion(ctm);
- flatness = 0.3 / fz_matrixexpansion(ctm);
+ flatness = 0.3 / expansion;
if (flatness < 0.1)
flatness = 0.1;
@@ -196,10 +197,15 @@ renderpath(fz_renderer *gc, fz_pathnode *path, fz_matrix ctm)
if (path->paint == FZ_STROKE)
{
+ float lw = path->linewidth;
+ // Check for hairline
+ if (lw * expansion < 0.2) {
+ lw = 1.0f / expansion;
+ }
if (path->dash)
- error = fz_dashpath(gc->gel, path, ctm, flatness);
+ error = fz_dashpath(gc->gel, path, ctm, flatness, lw);
else
- error = fz_strokepath(gc->gel, path, ctm, flatness);
+ error = fz_strokepath(gc->gel, path, ctm, flatness, lw);
}
else
error = fz_fillpath(gc->gel, path, ctm, flatness);