• Ell's avatar
    Bug 779632 - Clone tool jittering · 6c8ba750
    Ell authored
    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.
gimpsourcecore.c 23.8 KB