[gegl] panorama-projection: speed up by removing conditionals
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] panorama-projection: speed up by removing conditionals
- Date: Mon, 9 Apr 2018 23:32:28 +0000 (UTC)
commit 09a51b42a63ee88bec35102a727b9535ac7af86b
Author: Øyvind Kolås <pippin gimp org>
Date: Tue Apr 10 01:31:40 2018 +0200
panorama-projection: speed up by removing conditionals
Always doing the math for spin+zoom is faster than checking if we are
spinning and zooming.
operations/common/panorama-projection.c | 45 +++++-------------------------
1 files changed, 8 insertions(+), 37 deletions(-)
---
diff --git a/operations/common/panorama-projection.c b/operations/common/panorama-projection.c
index 23072c3..b3a6007 100644
--- a/operations/common/panorama-projection.c
+++ b/operations/common/panorama-projection.c
@@ -92,8 +92,6 @@ struct _Transform
float in_height;
void (*mapfun) (Transform *transform, float x, float y, float *lon, float *lat);
int reverse;
- int do_spin;
- int do_zoom;
};
/* formulas from:
@@ -110,19 +108,12 @@ gnomonic_xy2ll (Transform *transform, float x, float y,
y -= 0.5f;
x -= transform->xoffset;
- if (transform->do_spin)
{
float tx = x, ty = y;
x = tx * transform->cos_spin - ty * transform->sin_spin;
y = ty * transform->cos_spin + tx * transform->sin_spin;
}
- if (transform->do_zoom)
- {
- x /= transform->zoom;
- y /= transform->zoom;
- }
-
p = sqrtf (x*x+y*y);
c = atan2f (p, 1);
@@ -168,12 +159,6 @@ gnomonic_ll2xy (Transform *transform,
*y = ((transform->cos_tilt * sin_lat -
transform->sin_tilt * cos_lat * cos_lon_minus_pan) / cos_c);
- if (transform->do_zoom)
- {
- *x *= transform->zoom;
- *y *= transform->zoom;
- }
- if (transform->do_spin)
{
float tx = *x, ty = *y;
*x = tx * transform->cos_negspin - ty * transform->sin_negspin;
@@ -207,13 +192,6 @@ stereographic_ll2xy (Transform *transform,
*y = k * ((transform->cos_tilt * sin_lat -
transform->sin_tilt * cos_lat * cos_lon_minus_pan));
- if (transform->do_zoom)
- {
- *x *= transform->zoom;
- *y *= transform->zoom;
- }
-
- if (transform->do_spin)
{
float tx = *x, ty = *y;
*x = tx * transform->cos_negspin - ty * transform->sin_negspin;
@@ -236,19 +214,12 @@ stereographic_xy2ll (Transform *transform,
y -= 0.5f;
x -= transform->xoffset;
- if (transform->do_spin)
{
float tx = x, ty = y;
x = tx * transform->cos_spin - ty * transform->sin_spin;
y = ty * transform->cos_spin + tx * transform->sin_spin;
}
- if (transform->do_zoom)
- {
- x /= transform->zoom;
- y /= transform->zoom;
- }
-
p = sqrtf (x*x+y*y);
c = 2 * atan2f (p / 2, 1);
@@ -312,20 +283,20 @@ static void prepare_transform (Transform *transform,
- transform->do_spin = fabs (spin) > 0.000001 ? 1 : 0;
- transform->do_zoom = fabs (zoom-1.0) > 0.000001 ? 1 : 0;
-
transform->pan = pan;
transform->tilt = tilt;
transform->spin = spin;
- transform->zoom = zoom;
transform->xoffset = xoffset;
transform->sin_tilt = sinf (tilt);
transform->cos_tilt = cosf (tilt);
- transform->sin_spin = sinf (spin);
- transform->cos_spin = cosf (spin);
- transform->sin_negspin = sinf (-spin);
- transform->cos_negspin = cosf (-spin);
+ transform->zoom = zoom;
+
+
+ transform->sin_spin = sinf (spin) * zoom;
+ transform->cos_spin = cosf (spin) * zoom;
+ transform->sin_negspin = sinf (-spin) / zoom;
+ transform->cos_negspin = cosf (-spin) / zoom;
+
transform->width = width;
transform->height = height;
transform->in_width = input_width;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]