summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c8a5d6b)
raw | patch | inline | side by side (parent: c8a5d6b)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Mon, 26 Jun 2006 22:00:19 +0000 (22:00 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Mon, 26 Jun 2006 22:00:19 +0000 (22:00 +0000) |
src/libnr/nr-gradient.cpp | patch | blob | history |
index 9e9360147298475572fbc0ebe0c7a2514a5a2b43..4553eb598d84a4f2a8437903e8e50b14b241465a 100644 (file)
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
*
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);
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);
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);