app: avoid expensive rotated scale calculation when scale_x == scale_y
Ditto for the rulers' resolution calculation.
This commit is contained in:
@ -69,7 +69,6 @@ gimp_display_shell_rulers_update (GimpDisplayShell *shell)
|
|||||||
{
|
{
|
||||||
gint image_x, image_y;
|
gint image_x, image_y;
|
||||||
gdouble res_x, res_y;
|
gdouble res_x, res_y;
|
||||||
gdouble cos_a, sin_a;
|
|
||||||
|
|
||||||
gimp_display_shell_scale_get_image_bounds (shell,
|
gimp_display_shell_scale_get_image_bounds (shell,
|
||||||
&image_x, &image_y,
|
&image_x, &image_y,
|
||||||
@ -85,13 +84,22 @@ gimp_display_shell_rulers_update (GimpDisplayShell *shell)
|
|||||||
|
|
||||||
gimp_image_get_resolution (image, &res_x, &res_y);
|
gimp_image_get_resolution (image, &res_x, &res_y);
|
||||||
|
|
||||||
cos_a = cos (G_PI * shell->rotate_angle / 180.0);
|
if (shell->rotate_angle == 0.0 || res_x == res_y)
|
||||||
sin_a = sin (G_PI * shell->rotate_angle / 180.0);
|
{
|
||||||
|
resolution_x = res_x;
|
||||||
|
resolution_y = res_y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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)
|
if (shell->dot_for_dot)
|
||||||
{
|
{
|
||||||
resolution_x = 1.0 / sqrt (SQR (cos_a / res_x) + SQR (sin_a / res_y));
|
resolution_x = 1.0 / sqrt (SQR (cos_a / res_x) +
|
||||||
resolution_y = 1.0 / sqrt (SQR (cos_a / res_y) + SQR (sin_a / res_x));
|
SQR (sin_a / res_y));
|
||||||
|
resolution_y = 1.0 / sqrt (SQR (cos_a / res_y) +
|
||||||
|
SQR (sin_a / res_x));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -99,6 +107,7 @@ gimp_display_shell_rulers_update (GimpDisplayShell *shell)
|
|||||||
resolution_y = sqrt (SQR (res_y * cos_a) + SQR (res_x * sin_a));
|
resolution_y = sqrt (SQR (res_y * cos_a) + SQR (res_x * sin_a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
image_width = shell->disp_width;
|
image_width = shell->disp_width;
|
||||||
|
@ -780,7 +780,7 @@ gimp_display_shell_get_rotated_scale (GimpDisplayShell *shell,
|
|||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (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_x) *scale_x = shell->scale_x;
|
||||||
if (scale_y) *scale_y = shell->scale_y;
|
if (scale_y) *scale_y = shell->scale_y;
|
||||||
|
Reference in New Issue
Block a user