little optimisation by avoiding some useless recalculation.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2001-10-07 DindinX <dindinx@wanadoo.fr>
|
||||||
|
|
||||||
|
* plug-ins/common/apply_lens.c: little optimisation by avoiding some
|
||||||
|
useless recalculation.
|
||||||
|
|
||||||
2001-10-04 Sven Neumann <sven@gimp.org>
|
2001-10-04 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/widgets/gimpfontselection-dialog.c: inserted some extra checks
|
* app/widgets/gimpfontselection-dialog.c: inserted some extra checks
|
||||||
|
@ -210,25 +210,22 @@ run (gchar *name,
|
|||||||
Ellipsoid formula: x^2/a^2 + y^2/b^2 + z^2/c^2 = 1
|
Ellipsoid formula: x^2/a^2 + y^2/b^2 + z^2/c^2 = 1
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
find_projected_pos (gfloat a,
|
find_projected_pos (gfloat a2,
|
||||||
gfloat b,
|
gfloat b2,
|
||||||
|
gfloat c2,
|
||||||
gfloat x,
|
gfloat x,
|
||||||
gfloat y,
|
gfloat y,
|
||||||
gfloat *projx,
|
gfloat *projx,
|
||||||
gfloat *projy)
|
gfloat *projy)
|
||||||
{
|
{
|
||||||
gfloat c;
|
|
||||||
gfloat n[3];
|
gfloat n[3];
|
||||||
gfloat nxangle, nyangle, theta1, theta2;
|
gfloat nxangle, nyangle, theta1, theta2;
|
||||||
gfloat ri1 = 1.0;
|
gfloat ri1 = 1.0;
|
||||||
gfloat ri2 = lvals.refraction;
|
gfloat ri2 = lvals.refraction;
|
||||||
|
|
||||||
/* PARAM */
|
|
||||||
c = MIN (a, b);
|
|
||||||
|
|
||||||
n[0] = x;
|
n[0] = x;
|
||||||
n[1] = y;
|
n[1] = y;
|
||||||
n[2] = sqrt ((1 - x * x / (a * a) - y * y / (b * b)) * (c * c));
|
n[2] = sqrt ((1 - x * x / a2 - y * y / b2) * c2);
|
||||||
|
|
||||||
nxangle = acos (n[0] / sqrt(n[0] * n[0] + n[2] * n[2]));
|
nxangle = acos (n[0] / sqrt(n[0] * n[0] + n[2] * n[2]));
|
||||||
theta1 = G_PI / 2 - nxangle;
|
theta1 = G_PI / 2 - nxangle;
|
||||||
@ -255,7 +252,7 @@ drawlens (GimpDrawable *drawable)
|
|||||||
guchar *src, *dest;
|
guchar *src, *dest;
|
||||||
gint i, col;
|
gint i, col;
|
||||||
gfloat regionwidth, regionheight, dx, dy, xsqr, ysqr;
|
gfloat regionwidth, regionheight, dx, dy, xsqr, ysqr;
|
||||||
gfloat a, b, asqr, bsqr, x, y;
|
gfloat a, b, c, asqr, bsqr, csqr, x, y;
|
||||||
glong pixelpos, pos;
|
glong pixelpos, pos;
|
||||||
GimpRGB background;
|
GimpRGB background;
|
||||||
guchar bgr_red, bgr_blue, bgr_green;
|
guchar bgr_red, bgr_blue, bgr_green;
|
||||||
@ -271,8 +268,11 @@ drawlens (GimpDrawable *drawable)
|
|||||||
regionheight = y2 - y1;
|
regionheight = y2 - y1;
|
||||||
b = regionheight / 2;
|
b = regionheight / 2;
|
||||||
|
|
||||||
|
c = MIN (a, b);
|
||||||
|
|
||||||
asqr = a * a;
|
asqr = a * a;
|
||||||
bsqr = b * b;
|
bsqr = b * b;
|
||||||
|
csqr = c * c;
|
||||||
|
|
||||||
width = drawable->width;
|
width = drawable->width;
|
||||||
height = drawable->height;
|
height = drawable->height;
|
||||||
@ -296,7 +296,7 @@ drawlens (GimpDrawable *drawable)
|
|||||||
ysqr = dy * dy;
|
ysqr = dy * dy;
|
||||||
if (ysqr < (bsqr - (bsqr * xsqr) / asqr))
|
if (ysqr < (bsqr - (bsqr * xsqr) / asqr))
|
||||||
{
|
{
|
||||||
find_projected_pos (a, b, dx, dy, &x, &y);
|
find_projected_pos (asqr, bsqr, csqr, dx, dy, &x, &y);
|
||||||
y = -y;
|
y = -y;
|
||||||
pos = ((gint) (y + b) * regionwidth + (gint) (x + a)) * bytes;
|
pos = ((gint) (y + b) * regionwidth + (gint) (x + a)) * bytes;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user