summaryrefslogtreecommitdiff
path: root/draw
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-06-19 17:04:04 +0200
committerTor Andersson <tor@ghostscript.com>2010-06-19 17:04:04 +0200
commit8e59d2f0e102476c0dbd897661860666c12e8aa6 (patch)
treeb4ce4ab1eccb87c1771b9a65c8ca6e8c77aea8c7 /draw
parentb058141ef35119f3e0b51c73716abbe235b034e2 (diff)
downloadmupdf-8e59d2f0e102476c0dbd897661860666c12e8aa6.tar.xz
Floats everywhere!
Diffstat (limited to 'draw')
-rw-r--r--draw/glyphcache.c8
-rw-r--r--draw/meshdraw.c4
-rw-r--r--draw/pathscan.c12
-rw-r--r--draw/pathstroke.c54
4 files changed, 39 insertions, 39 deletions
diff --git a/draw/glyphcache.c b/draw/glyphcache.c
index 173d7979..ac148340 100644
--- a/draw/glyphcache.c
+++ b/draw/glyphcache.c
@@ -74,15 +74,15 @@ fz_renderglyph(fz_glyphcache *cache, fz_font *font, int cid, fz_matrix ctm)
key.b = ctm.b * 65536;
key.c = ctm.c * 65536;
key.d = ctm.d * 65536;
- key.e = (ctm.e - floor(ctm.e)) * 256;
- key.f = (ctm.f - floor(ctm.f)) * 256;
+ key.e = (ctm.e - floorf(ctm.e)) * 256;
+ key.f = (ctm.f - floorf(ctm.f)) * 256;
val = fz_hashfind(cache->hash, &key);
if (val)
return fz_keeppixmap(val);
- ctm.e = floor(ctm.e) + key.e / 256.0;
- ctm.f = floor(ctm.f) + key.f / 256.0;
+ ctm.e = floorf(ctm.e) + key.e / 256.0f;
+ ctm.f = floorf(ctm.f) + key.f / 256.0f;
if (font->ftface)
{
diff --git a/draw/meshdraw.c b/draw/meshdraw.c
index 8e876397..e07a1f7d 100644
--- a/draw/meshdraw.c
+++ b/draw/meshdraw.c
@@ -248,8 +248,8 @@ fz_drawtriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox
for (i = 0; i < len; i++)
{
- gel[i][0] = floor(poly[i][0] + 0.5) * 65536; /* trunc and fix */
- gel[i][1] = floor(poly[i][1] + 0.5); /* y is not fixpoint */
+ gel[i][0] = floorf(poly[i][0] + 0.5f) * 65536; /* trunc and fix */
+ gel[i][1] = floorf(poly[i][1] + 0.5f); /* y is not fixpoint */
for (k = 2; k < n; k++)
gel[i][k] = poly[i][k] * 65536; /* fix with precision */
}
diff --git a/draw/pathscan.c b/draw/pathscan.c
index b60eddd6..5a656144 100644
--- a/draw/pathscan.c
+++ b/draw/pathscan.c
@@ -114,10 +114,10 @@ fz_insertgel(fz_gel *gel, float fx0, float fy0, float fx1, float fy1)
int v;
int d;
- int x0 = floor(fx0 * HSCALE);
- int y0 = floor(fy0 * VSCALE);
- int x1 = floor(fx1 * HSCALE);
- int y1 = floor(fy1 * VSCALE);
+ int x0 = floorf(fx0 * HSCALE);
+ int y0 = floorf(fy0 * VSCALE);
+ int x1 = floorf(fx1 * HSCALE);
+ int y1 = floorf(fy1 * VSCALE);
d = cliplerpy(gel->clip.y0, 0, x0, y0, x1, y1, &v);
if (d == OUTSIDE) return;
@@ -439,8 +439,8 @@ static inline void blit(fz_pixmap *pix, int x, int y,
if (image)
{
- int u = (invmat->a * (x + 0.5) + invmat->c * (y + 0.5) + invmat->e) * 65536;
- int v = (invmat->b * (x + 0.5) + invmat->d * (y + 0.5) + invmat->f) * 65536;
+ int u = (invmat->a * (x + 0.5f) + invmat->c * (y + 0.5f) + invmat->e) * 65536;
+ int v = (invmat->b * (x + 0.5f) + invmat->d * (y + 0.5f) + invmat->f) * 65536;
int fa = invmat->a * 65536;
int fb = invmat->b * 65536;
if (argb)
diff --git a/draw/pathstroke.c b/draw/pathstroke.c
index aafa4694..c36fb55b 100644
--- a/draw/pathstroke.c
+++ b/draw/pathstroke.c
@@ -47,22 +47,22 @@ arc(struct sctx *s,
float ox, oy, nx, ny;
int n, i;
- r = fabs(s->linewidth);
- theta = 2 * M_SQRT2 * sqrt(s->flatness / r);
- th0 = atan2(y0, x0);
- th1 = atan2(y1, x1);
+ r = fabsf(s->linewidth);
+ theta = 2 * (float)M_SQRT2 * sqrtf(s->flatness / r);
+ th0 = atan2f(y0, x0);
+ th1 = atan2f(y1, x1);
if (r > 0)
{
if (th0 < th1)
- th0 += M_PI * 2;
- n = ceil((th0 - th1) / theta);
+ th0 += (float)M_PI * 2;
+ n = ceilf((th0 - th1) / theta);
}
else
{
if (th1 < th0)
- th1 += M_PI * 2;
- n = ceil((th1 - th0) / theta);
+ th1 += (float)M_PI * 2;
+ n = ceilf((th1 - th0) / theta);
}
ox = x0;
@@ -70,8 +70,8 @@ arc(struct sctx *s,
for (i = 1; i < n; i++)
{
theta = th0 + (th1 - th0) * i / n;
- nx = cos(theta) * r;
- ny = sin(theta) * r;
+ nx = cosf(theta) * r;
+ ny = sinf(theta) * r;
line(s, xc + ox, yc + oy, xc + nx, yc + ny);
ox = nx;
oy = ny;
@@ -85,7 +85,7 @@ linestroke(struct sctx *s, fz_point a, fz_point b)
{
float dx = b.x - a.x;
float dy = b.y - a.y;
- float scale = s->linewidth / sqrt(dx * dx + dy * dy);
+ float scale = s->linewidth / sqrtf(dx * dx + dy * dy);
float dlx = dy * scale;
float dly = -dx * scale;
line(s, a.x - dlx, a.y - dly, b.x - dlx, b.y - dly);
@@ -118,18 +118,18 @@ linejoin(struct sctx *s, fz_point a, fz_point b, fz_point c)
if (dx1 * dx1 + dy1 * dy1 < FLT_EPSILON)
linejoin = BEVEL;
- scale = linewidth / sqrt(dx0 * dx0 + dy0 * dy0);
+ scale = linewidth / sqrtf(dx0 * dx0 + dy0 * dy0);
dlx0 = dy0 * scale;
dly0 = -dx0 * scale;
- scale = linewidth / sqrt(dx1 * dx1 + dy1 * dy1);
+ scale = linewidth / sqrtf(dx1 * dx1 + dy1 * dy1);
dlx1 = dy1 * scale;
dly1 = -dx1 * scale;
cross = dx1 * dy0 - dx0 * dy1;
- dmx = (dlx0 + dlx1) * 0.5;
- dmy = (dly0 + dly1) * 0.5;
+ dmx = (dlx0 + dlx1) * 0.5f;
+ dmy = (dly0 + dly1) * 0.5f;
dmr2 = dmx * dmx + dmy * dmy;
if (cross * cross < FLT_EPSILON && dx0 * dx1 + dy0 * dy1 >= 0)
@@ -190,7 +190,7 @@ linecap(struct sctx *s, fz_point a, fz_point b)
float dx = b.x - a.x;
float dy = b.y - a.y;
- float scale = linewidth / sqrt(dx * dx + dy * dy);
+ float scale = linewidth / sqrtf(dx * dx + dy * dy);
float dlx = dy * scale;
float dly = -dx * scale;
@@ -200,14 +200,14 @@ linecap(struct sctx *s, fz_point a, fz_point b)
if (linecap == ROUND)
{
int i;
- int n = ceil(M_PI / (2.0 * M_SQRT2 * sqrt(flatness / linewidth)));
+ int n = ceilf((float)M_PI / (2.0f * (float)M_SQRT2 * sqrtf(flatness / linewidth)));
float ox = b.x - dlx;
float oy = b.y - dly;
for (i = 1; i < n; i++)
{
- float theta = M_PI * i / n;
- float cth = cos(theta);
- float sth = sin(theta);
+ float theta = (float)M_PI * i / n;
+ float cth = cosf(theta);
+ float sth = sinf(theta);
float nx = b.x - dlx * cth - dly * sth;
float ny = b.y - dly * cth + dlx * sth;
line(s, ox, oy, nx, ny);
@@ -237,16 +237,16 @@ linedot(struct sctx *s, fz_point a)
{
float flatness = s->flatness;
float linewidth = s->linewidth;
- int n = ceil(M_PI / (M_SQRT2 * sqrt(flatness / linewidth)));
+ int n = ceilf((float)M_PI / ((float)M_SQRT2 * sqrtf(flatness / linewidth)));
float ox = a.x - linewidth;
float oy = a.y;
int i;
for (i = 1; i < n; i++)
{
- float theta = M_PI * 2 * i / n;
- float cth = cos(theta);
- float sth = sin(theta);
+ float theta = (float)M_PI * 2 * i / n;
+ float cth = cosf(theta);
+ float sth = sinf(theta);
float nx = a.x - cth * linewidth;
float ny = a.y + sth * linewidth;
line(s, ox, oy, nx, ny);
@@ -400,7 +400,7 @@ fz_strokepath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm,
s.linecap = stroke->linecap;
s.linejoin = stroke->linejoin;
- s.linewidth = linewidth * 0.5; /* hairlines use a different value from the path value */
+ s.linewidth = linewidth * 0.5f; /* hairlines use a different value from the path value */
s.miterlimit = stroke->miterlimit;
s.sn = 0;
s.bn = 0;
@@ -487,7 +487,7 @@ dashlineto(struct sctx *s, fz_point b)
a = s->cur;
dx = b.x - a.x;
dy = b.y - a.y;
- total = sqrt(dx * dx + dy * dy);
+ total = sqrtf(dx * dx + dy * dy);
used = 0;
while (total - used > s->dashlist[s->offset] - s->phase)
@@ -586,7 +586,7 @@ fz_dashpath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, f
s.linecap = stroke->linecap;
s.linejoin = stroke->linejoin;
- s.linewidth = linewidth * 0.5;
+ s.linewidth = linewidth * 0.5f;
s.miterlimit = stroke->miterlimit;
s.sn = 0;
s.bn = 0;