[gimp] app: avoid expensive rotated scale calculation when scale_x == scale_y
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: avoid expensive rotated scale calculation when scale_x == scale_y
- Date: Tue, 9 Aug 2016 22:37:40 +0000 (UTC)
commit 26b978d2a8ecf62ffc232e00ac7c1773efb82fc7
Author: Ell <ell_se yahoo com>
Date: Tue Aug 9 22:25:54 2016 +0000
app: avoid expensive rotated scale calculation when scale_x == scale_y
Ditto for the rulers' resolution calculation.
app/display/gimpdisplayshell-rulers.c | 27 ++++++++++++++++++---------
app/display/gimpdisplayshell-scale.c | 2 +-
2 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-rulers.c b/app/display/gimpdisplayshell-rulers.c
index 610a2ae..c92fd6a 100644
--- a/app/display/gimpdisplayshell-rulers.c
+++ b/app/display/gimpdisplayshell-rulers.c
@@ -69,7 +69,6 @@ gimp_display_shell_rulers_update (GimpDisplayShell *shell)
{
gint image_x, image_y;
gdouble res_x, res_y;
- gdouble cos_a, sin_a;
gimp_display_shell_scale_get_image_bounds (shell,
&image_x, &image_y,
@@ -85,18 +84,28 @@ gimp_display_shell_rulers_update (GimpDisplayShell *shell)
gimp_image_get_resolution (image, &res_x, &res_y);
- cos_a = cos (G_PI * shell->rotate_angle / 180.0);
- sin_a = sin (G_PI * shell->rotate_angle / 180.0);
-
- if (shell->dot_for_dot)
+ if (shell->rotate_angle == 0.0 || res_x == res_y)
{
- resolution_x = 1.0 / sqrt (SQR (cos_a / res_x) + SQR (sin_a / res_y));
- resolution_y = 1.0 / sqrt (SQR (cos_a / res_y) + SQR (sin_a / res_x));
+ resolution_x = res_x;
+ resolution_y = res_y;
}
else
{
- resolution_x = sqrt (SQR (res_x * cos_a) + SQR (res_y * sin_a));
- resolution_y = sqrt (SQR (res_y * cos_a) + SQR (res_x * sin_a));
+ gdouble cos_a = cos (G_PI * shell->rotate_angle / 180.0);
+ gdouble sin_a = sin (G_PI * shell->rotate_angle / 180.0);
+
+ if (shell->dot_for_dot)
+ {
+ resolution_x = 1.0 / sqrt (SQR (cos_a / res_x) +
+ SQR (sin_a / res_y));
+ resolution_y = 1.0 / sqrt (SQR (cos_a / res_y) +
+ SQR (sin_a / res_x));
+ }
+ else
+ {
+ resolution_x = sqrt (SQR (res_x * cos_a) + SQR (res_y * sin_a));
+ resolution_y = sqrt (SQR (res_y * cos_a) + SQR (res_x * sin_a));
+ }
}
}
else
diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c
index afdfb7d..d193a15 100644
--- a/app/display/gimpdisplayshell-scale.c
+++ b/app/display/gimpdisplayshell-scale.c
@@ -780,7 +780,7 @@ gimp_display_shell_get_rotated_scale (GimpDisplayShell *shell,
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
- if (shell->rotate_angle == 0.0)
+ if (shell->rotate_angle == 0.0 || shell->scale_x == shell->scale_y)
{
if (scale_x) *scale_x = shell->scale_x;
if (scale_y) *scale_y = shell->scale_y;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]