[gimp] Bug 779632 - Clone tool jittering



commit 6c8ba75021d454d5c32655cd9c6de9f44a9417ee
Author: Ell <ell_se yahoo com>
Date:   Mon Apr 3 13:07:13 2017 -0400

    Bug 779632 - Clone tool jittering
    
    The expression `src_offset_x - coords->x + origin->x` is parsed as
    `(src_offset_x - coords->x) + origin->x`; since floating point
    arithmetic is not generally associative, even when
    `coords->x == origin->x` (in particular, when there is no active
    symmetry), it may still yield a different result than plain
    `src_offset_x` if there's not enough precision for the intermediary
    result (which is usually the case when `{origin,coords}->x` is
    noninteger.)  Since `src_offset_x` is an integer, and since the result
    of this expression is rounded to an integer, if the error happens to
    be in the direction of the rounding, it's magnified to a whole pixel,
    which causes visible "jitter".  (Ditto for `src_offset_y` and co.)
    
    Regardless of this issue, we want to individually round `origin->[xy]`
    and `coord->[xy]` down before taking their difference, since the
    original offset is calculated according to rounded-down coordinates.
    This solves the original issue along the way.

 app/paint/gimpsourcecore.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c
index daf7ca6..b271510 100644
--- a/app/paint/gimpsourcecore.c
+++ b/app/paint/gimpsourcecore.c
@@ -454,8 +454,8 @@ gimp_source_core_motion (GimpSourceCore   *source_core,
       if (gimp_source_core_use_source (source_core, options))
         {
           /* When using a source, use the same for every stroke. */
-          src_offset_x = src_offset_x - coords->x + origin->x;
-          src_offset_y = src_offset_y - coords->y + origin->y;
+          src_offset_x += floor (origin->x) - floor (coords->x);
+          src_offset_y += floor (origin->y) - floor (coords->y);
           src_buffer =
             GIMP_SOURCE_CORE_GET_CLASS (source_core)->get_source (source_core,
                                                                   drawable,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]