summaryrefslogtreecommitdiffstats
path: root/src/libnr/nr-gradient.cpp
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2006-06-26 22:00:19 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2006-06-26 22:00:19 +0000
commitd043110d6066db6a02196c5b9286af65c5ccc7a5 (patch)
treebb4db50315a18969d6e37363af119d6d225587d0 /src/libnr/nr-gradient.cpp
parentadd 15(!) missing tutorials (Czech, German, Brazil-Portuguese) to tarball, fi... (diff)
downloadinkscape-d043110d6066db6a02196c5b9286af65c5ccc7a5.tar.gz
inkscape-d043110d6066db6a02196c5b9286af65c5ccc7a5.zip
remove non-portable fast_sqrt; turns out simply sqrt(x*x+y*y) works even faster than hypot and fast_sqrt
(bzr r1300)
Diffstat (limited to 'src/libnr/nr-gradient.cpp')
-rw-r--r--src/libnr/nr-gradient.cpp17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/libnr/nr-gradient.cpp b/src/libnr/nr-gradient.cpp
index 9e9360147..4553eb598 100644
--- a/src/libnr/nr-gradient.cpp
+++ b/src/libnr/nr-gradient.cpp
@@ -114,17 +114,6 @@ nr_rgradient_render_block_end(NRRenderer *r, NRPixBlock *pb, NRPixBlock *m)
nr_blit_pixblock_mask_rgba32(pb, m, (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3]);
}
-float fast_sqrt (float in)
-{
- float x = in;
- float xhalf = 0.5f*x;
- int i = *(int*)&x;
- i = 0x5f3759df - (i >> 1); // This line hides a LOT of math!
- x = *(float*)&i;
- x = x*(1.5f - xhalf*x*x); // repeat this statement for a better approximation
- return x * in;
-}
-
/*
* The archetype is following
*
@@ -161,7 +150,7 @@ nr_rgradient_render_generic_symmetric(NRRGradientRenderer *rgr, NRPixBlock *pb)
NR::Coord gx = rgr->px2gs.c[0] * pb->area.x0 + rgr->px2gs.c[2] * y + rgr->px2gs.c[4];
NR::Coord gy = rgr->px2gs.c[1] * pb->area.x0 + rgr->px2gs.c[3] * y + rgr->px2gs.c[5];
for (int x = pb->area.x0; x < pb->area.x1; x++) {
- float const pos = fast_sqrt((gx*gx) + (gy*gy));
+ NR::Coord const pos = sqrt(((gx*gx) + (gy*gy)));
int idx;
if (rgr->spread == NR_GRADIENT_SPREAD_REFLECT) {
idx = (int) ((long long) pos & NRG_2MASK);
@@ -187,7 +176,7 @@ nr_rgradient_render_generic_symmetric(NRRGradientRenderer *rgr, NRPixBlock *pb)
NR::Coord gx = rgr->px2gs.c[0] * pb->area.x0 + rgr->px2gs.c[2] * y + rgr->px2gs.c[4];
NR::Coord gy = rgr->px2gs.c[1] * pb->area.x0 + rgr->px2gs.c[3] * y + rgr->px2gs.c[5];
for (int x = pb->area.x0; x < pb->area.x1; x++) {
- float pos = fast_sqrt((gx*gx) + (gy*gy));
+ NR::Coord const pos = sqrt(((gx*gx) + (gy*gy)));
int idx;
if (rgr->spread == NR_GRADIENT_SPREAD_REFLECT) {
idx = (int) ((long long) pos & NRG_2MASK);
@@ -232,7 +221,7 @@ nr_rgradient_render_generic_symmetric(NRRGradientRenderer *rgr, NRPixBlock *pb)
NR::Coord gx = rgr->px2gs.c[0] * pb->area.x0 + rgr->px2gs.c[2] * y + rgr->px2gs.c[4];
NR::Coord gy = rgr->px2gs.c[1] * pb->area.x0 + rgr->px2gs.c[3] * y + rgr->px2gs.c[5];
for (int x = pb->area.x0; x < pb->area.x1; x++) {
- NR::Coord const pos = fast_sqrt((gx*gx) + (gy*gy));
+ NR::Coord const pos = sqrt(((gx*gx) + (gy*gy)));
int idx;
if (rgr->spread == NR_GRADIENT_SPREAD_REFLECT) {
idx = (int) ((long long) pos & NRG_2MASK);