Bug 424233

Summary: Moving layers while using the wrap around tool cuts off the image/distorts it
Product: [Applications] krita Reporter: Tayla <taylawilsonap2>
Component: Layer StackAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: minor CC: ahab.greybeard, dimula73
Priority: NOR    
Version: 4.3.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Attachments: Illustration of Wrap artifacts after Moves

Description Tayla 2020-07-15 13:33:26 UTC
SUMMARY
Moving layers while using the wrap around tool cuts off the image/distorts it

STEPS TO REPRODUCE
1. Add image/layer from one file to another
2. Wrap the layer
3. Select the move tool and move it out of bounds of the original image
4. Occasionally it may work first time, but if you keep moving it, it eventually glitches

OBSERVED RESULT
Cut off/distorted/disappeared image

EXPECTED RESULT
Seamless pattern with no flaws

SOFTWARE/OS VERSIONS
Windows: 10 Home
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
It can also affect a drawn file, but doesn't appear to affect simple drawings
Comment 1 Ahab Greybeard 2020-07-16 09:27:57 UTC
Created attachment 130166 [details]
Illustration of Wrap artifacts after Moves

I can confirm that this happens for all appimages from verison 4.2.0 to a recent 5.0.0 prealpha.

I attach a .zipped collection of screenshots to illustrate some points.

As has been noted, it can happen when performing large distance moves while the view is in Wrap Around Mode.
This happens rarely and you do need to do lots of fast large distance moves. These moves take time to perform (depending on PC-graphics speed/power).
-----------------------------------

However, a very quick way to see it happen is to have off-canvas content in an original image.

1-red-tiled.png shows a Wrapped view of a simple painted image that has a small amount of off-canvas content, caused by 'accidentally' painting too close to the edge of the canvas. This is not visible as would be expected.

After a very small move then the screen shows 2-red-tiled-after-move.png.
-----------------------------------

For the cases where there is no off-canvas content originally, I think that off-canvas content is introduced in a way that creates artifacts after rapid long distance moves:

3-rose-artifacts.png shows the end-result of this with Wrap mode turned off after the artifacts appear.
4-rose-off-canvas.png shows the result after doing Image -> Trim to Current Layer to reveal the off-canvas content.
-----------------------------------

With Wrap mode on, you can paint 'attractive' well tiled images as shown in 5-blue-nice-pattern.
Such an image does not have off-canvas content.

A small move perfomed with Wrap on will introduce off-canvas content but this does not affect the Wrapped image or Wrapped moves.
Longer distance moves introduce more off-canvas content of a fragmented nature which still doesn't affect the Wrapped view.

Eventually, if you do repeated rapid large distance moves with Wrap on, you can get artifacts as seen in 6-blue-pattern-moved-lots.png
7-blue-off-canvas.png shows the off-canvas content at that stage.
-----------------------------------

One possible solution may be to perform a Trim to Image Size before implementing wrap mode and after moves during wrap mode.
Ideally, the introduced off-canvas content not be created in the first place.
Comment 2 Dmitry Kazakov 2020-08-13 22:42:36 UTC
Git commit b120f70920778a4ad32639319fed0ee5396cf35a by Dmitry Kazakov.
Committed on 13/08/2020 at 22:39.
Pushed by dkazakov into branch 'krita/4.3'.

Fix artifacts when using Move Tool in WrapAround mode

The paint device cache should be reset when wrap-around mode is
changed. The artifacts appeared because
KisPaintDeviceWrappedStrategy::move() received non-WA exactBounds()
of the device, which caused it to do the move incorrectly.

M  +83   -6    libs/image/kis_lock_free_cache.h
M  +7    -7    libs/image/kis_paint_device_cache.h
M  +1    -1    libs/image/tests/kis_paint_device_test.cpp

https://invent.kde.org/graphics/krita/commit/b120f70920778a4ad32639319fed0ee5396cf35a
Comment 3 Dmitry Kazakov 2020-08-13 22:44:29 UTC
Git commit 165bea5feb803fa61a9c89baafe7716075a15cab by Dmitry Kazakov.
Committed on 13/08/2020 at 22:44.
Pushed by dkazakov into branch 'master'.

Fix artifacts when using Move Tool in WrapAround mode

The paint device cache should be reset when wrap-around mode is
changed. The artifacts appeared because
KisPaintDeviceWrappedStrategy::move() received non-WA exactBounds()
of the device, which caused it to do the move incorrectly.

M  +83   -6    libs/image/kis_lock_free_cache.h
M  +7    -7    libs/image/kis_paint_device_cache.h
M  +1    -1    libs/image/tests/kis_paint_device_test.cpp

https://invent.kde.org/graphics/krita/commit/165bea5feb803fa61a9c89baafe7716075a15cab