app: make sure the display is not rotated by a very small angle

gimp_display_shell_rotate_update_transform(): reliably set rotation to
0.0 using an epsilon of 1e-3.
This commit is contained in:
Michael Natterer 2019-07-25 12:45:21 +02:00
parent c144cf69de
commit 7ddf40b78b
1 changed files with 9 additions and 7 deletions

View File

@ -36,6 +36,9 @@
#include "gimpdisplayshell-transform.h"
#define ANGLE_EPSILON 1e-3
/* local function prototypes */
static void gimp_display_shell_save_viewport_center (GimpDisplayShell *shell,
@ -168,8 +171,12 @@ gimp_display_shell_rotate_update_transform (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_free (shell->rotate_transform);
g_free (shell->rotate_untransform);
g_clear_pointer (&shell->rotate_transform, g_free);
g_clear_pointer (&shell->rotate_untransform, g_free);
if (fabs (shell->rotate_angle) < ANGLE_EPSILON ||
fabs (360.0 - shell->rotate_angle) < ANGLE_EPSILON)
shell->rotate_angle = 0.0;
if ((shell->rotate_angle != 0.0 ||
shell->flip_horizontally ||
@ -205,11 +212,6 @@ gimp_display_shell_rotate_update_transform (GimpDisplayShell *shell)
*shell->rotate_untransform = *shell->rotate_transform;
cairo_matrix_invert (shell->rotate_untransform);
}
else
{
shell->rotate_transform = NULL;
shell->rotate_untransform = NULL;
}
}