Bug 400484

Summary: Weird thing where the selection, instant preview and the move tool don't play nice.
Product: [Applications] krita Reporter: wolthera <griffinvalley>
Component: Tools/SelectionAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73, freebox64, halla
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Video showing the problem.

Description wolthera 2018-10-30 15:27:36 UTC
SUMMARY
When finishing moving a selected area, the selection preview moves. With instant preview applied, the selected area then moves as well, but only the area where the selection had moved to, which, is wrong. 

STEPS TO REPRODUCE
1. Have instant preview on.
2. A single layer with image to modify. Perferably a big image.
3. Make a selection.
4. Move said selection with the move tool.
5. Try to deselect. This will get stuck in IP because IP will be processing the move you made.
6. Watch as the selection preview will move in the same direction as you tried to move the pixels(this'll also happen without IP).
7. Watch as consequently the selected area gets moved too.

OBSERVED RESULT
The selection preview moves and then move the wrong part of the layer.

EXPECTED RESULT
No weird selection preview moving, and it certainly not moving the wrong part of the layer.

OTHER

compiled from git 9697760
Comment 1 wolthera 2018-10-30 15:28:31 UTC
Created attachment 115983 [details]
Video showing the problem.

Added a short video showing the issue. I had the hardest time explaining it.
Comment 2 mvowada 2019-01-20 13:10:00 UTC
*** Bug 403371 has been marked as a duplicate of this bug. ***
Comment 3 Halla Rempt 2020-05-15 11:24:50 UTC
MR: https://invent.kde.org/kde/krita/-/merge_requests/336
Comment 4 Dmitry Kazakov 2020-05-21 17:26:25 UTC
Git commit 8f88c50c8f8cb5b08cae33f13d5509c6c510c8bf by Dmitry Kazakov.
Committed on 21/05/2020 at 16:38.
Pushed by dkazakov into branch 'master'.

Fix KisSuspendProjectionUpdatesStrokeStrategy to replay refresh requests as well

When Lod0 stroke executes in the background, all image updates should
be disabled, including fullRefreshAsync() requests.

The patch fixes artifacts when applying multiple Move Tool strokes
sequentially in LodN mode.

M  +24   -2    libs/image/kis_image.cc
M  +1    -0    libs/image/kis_image.h
M  +1    -0    libs/image/kis_image_interfaces.h
M  +9    -0    libs/image/kis_projection_updates_filter.cpp
M  +2    -0    libs/image/kis_projection_updates_filter.h
M  +6    -1    libs/image/kis_simple_update_queue.cpp
M  +2    -1    libs/image/kis_simple_update_queue.h
M  +64   -15   libs/image/kis_suspend_projection_updates_stroke_strategy.cpp
M  +2    -2    libs/image/kis_update_scheduler.cpp
M  +1    -1    libs/image/kis_update_scheduler.h

https://invent.kde.org/graphics/krita/commit/8f88c50c8f8cb5b08cae33f13d5509c6c510c8bf
Comment 5 Dmitry Kazakov 2020-05-22 07:12:05 UTC
The bug is now fixed after merging this MR:
https://invent.kde.org/graphics/krita/-/merge_requests/336
Comment 6 Dmitry Kazakov 2020-06-02 12:02:00 UTC
Git commit ba67c4155932f002951901ffb0f35725dcf78603 by Dmitry Kazakov.
Committed on 02/06/2020 at 10:06.
Pushed by dkazakov into branch 'krita/4.3'.

Fix KisSuspendProjectionUpdatesStrokeStrategy to replay refresh requests as well

When Lod0 stroke executes in the background, all image updates should
be disabled, including fullRefreshAsync() requests.

The patch fixes artifacts when applying multiple Move Tool strokes
sequentially in LodN mode.

M  +24   -2    libs/image/kis_image.cc
M  +1    -0    libs/image/kis_image.h
M  +1    -0    libs/image/kis_image_interfaces.h
M  +9    -0    libs/image/kis_projection_updates_filter.cpp
M  +2    -0    libs/image/kis_projection_updates_filter.h
M  +6    -1    libs/image/kis_simple_update_queue.cpp
M  +2    -1    libs/image/kis_simple_update_queue.h
M  +64   -15   libs/image/kis_suspend_projection_updates_stroke_strategy.cpp
M  +2    -2    libs/image/kis_update_scheduler.cpp
M  +1    -1    libs/image/kis_update_scheduler.h

https://invent.kde.org/graphics/krita/commit/ba67c4155932f002951901ffb0f35725dcf78603
Comment 7 Dmitry Kazakov 2020-06-02 12:02:00 UTC
Git commit d758626daa77b02662e7b417322e1ce0cac0095c by Dmitry Kazakov.
Committed on 02/06/2020 at 10:06.
Pushed by dkazakov into branch 'krita/4.3'.

Fix Move Tool to work correctly with Instant Preview

There were multiple problems:

1) We couldn't search for a "node under cursor" in the GUI thread,
because Lod0 plane may be not ready yet (because currrently running
LodN stroke hasn't finished yet). Therefore, the node selection should
happen in the stroke itself.

2) It leads to the fact that the stroke can be ended without doing
any work (when no nodes are found), hence we now have
MoveStrokeStrategy::sigStrokeStartedEmpty

3) Since we don't have the list of nodes to process before the stroke
is actually started, we cannot properly decide whether we can use LodN
in MoveStrokeStrategy::createLodClone(). Therefore, we use pessimistic
approach there: if the tool uses "layer under cursor" and the image has
at least one non-lod-supporting node (e.g. a shape layer or a selection
mask), then LodN mode is disabled.

4) The patch also fixes a bug in MoveSelectionStrokeStrategy, which
caused it to return wrong handles rect in LodN mode.

M  +10   -0    libs/image/kis_layer_utils.cpp
M  +2    -0    libs/image/kis_layer_utils.h
M  +8    -0    libs/image/kis_lod_transform.h
M  +1    -0    libs/ui/CMakeLists.txt
A  +61   -0    libs/ui/tool/strokes/KisNodeSelectionRecipe.cpp     [License: GPL (v2+)]
A  +47   -0    libs/ui/tool/strokes/KisNodeSelectionRecipe.h     [License: GPL (v2+)]
M  +86   -29   libs/ui/tool/strokes/move_stroke_strategy.cpp
M  +36   -3    libs/ui/tool/strokes/move_stroke_strategy.h
M  +109  -53   plugins/tools/basictools/kis_tool_move.cc
M  +4    -1    plugins/tools/basictools/kis_tool_move.h
M  +12   -1    plugins/tools/basictools/strokes/move_selection_stroke_strategy.cpp

https://invent.kde.org/graphics/krita/commit/d758626daa77b02662e7b417322e1ce0cac0095c