Bug 410163

Summary: Moving a file layer with a transform mask attached - green box indicator is not right when moving
Product: [Applications] krita Reporter: Bastien Bouquin <bastienbouquin>
Component: Resize/Scale Image/LayerAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: griffinvalley
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: the png used for the file layer
the result

Description Bastien Bouquin 2019-07-24 15:47:35 UTC
Created attachment 121704 [details]
the png used for the file layer

SUMMARY


STEPS TO REPRODUCE
0. Create a 1000*2000 file
1. Add a file layer with a png image (attached)
2. Add a transform mask to that layer
3. Move the layer

OBSERVED RESULT

The green box surrounding the layer when moving the layer is randomly placed and it's size does not correspond to the size of the layer

EXPECTED RESULT

The green box's size should match the layer's size and position

SOFTWARE/OS VERSIONS
Arch linux: latest 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Bastien Bouquin 2019-07-24 15:49:15 UTC
Created attachment 121705 [details]
the result
Comment 2 Bastien Bouquin 2019-07-24 15:51:07 UTC
I forgot a step, sorry.
The transform mask needs to be scaled down.
But it seems that every transformation is giving a different green box rendering
Comment 3 wolthera 2019-07-28 11:48:32 UTC
This one is quite tricky, the long and short of it is that in KisLayer::layerExtentImpl(bool needExactBounds) for some reason the transforms of transform layers is not applied.

Right now it is getting this data from node->exactBounds(); in KisToolMove::initHandles, node->exactBounds() calls exactbounds in the given node, which most of the case ends up within KisLayer. I'm going to check what I can do, but if I cannot figure it out someone smarter will need to take over.
Comment 4 wolthera 2019-07-28 12:11:17 UTC
Nope, too tricky.

Things I tried:

1. Using the bounds of the paint device. This didn't make a difference.
2. using the bounds of the projection of the node. This lead to a weird offset, probably because the masks themselves also get 'moved'.
3. Tried to add an extend to transformation masks, but of course, that function only exists for colorize masks.

I think this'll need someone who actually understands the transform masks.
Comment 5 Dmitry Kazakov 2019-11-19 13:39:09 UTC
Git commit e37f64c44483170ae33154c02c079e56ac78f9ca by Dmitry Kazakov.
Committed on 19/11/2019 at 13:36.
Pushed by dkazakov into branch 'master'.

Fix outline in Move Tool, when a layer has a Transform Mask

We need to take layer's masks' change rect into account. We cannot
use normal changeRect() call, because it never shrinks the update rect
and adds projection device bounds (obviously, because it is supposed
to render stuff and not just shwo a decoration).

That is why the patch introduces KisLayer::tightUserVisibleBounds(), which
calculates tight bounding rect of the layer, taking all the masks into
account.

M  +5    -0    libs/image/kis_abstract_projection_plane.cpp
M  +8    -1    libs/image/kis_abstract_projection_plane.h
M  +15   -0    libs/image/kis_layer.cc
M  +8    -0    libs/image/kis_layer.h
M  +5    -0    libs/image/kis_layer_projection_plane.cpp
M  +1    -0    libs/image/kis_layer_projection_plane.h
M  +2    -2    libs/image/kis_layer_utils.cpp
M  +1    -1    libs/image/kis_layer_utils.h
M  +5    -0    libs/image/kis_mask_projection_plane.cpp
M  +1    -0    libs/image/kis_mask_projection_plane.h
M  +10   -0    libs/image/layerstyles/kis_layer_style_filter_projection_plane.cpp
M  +1    -0    libs/image/layerstyles/kis_layer_style_filter_projection_plane.h
M  +12   -0    libs/image/layerstyles/kis_layer_style_projection_plane.cpp
M  +1    -0    libs/image/layerstyles/kis_layer_style_projection_plane.h
M  +1    -1    libs/ui/tool/strokes/move_stroke_strategy.cpp
M  +1    -1    plugins/tools/basictools/KisMoveBoundsCalculationJob.cpp

https://invent.kde.org/kde/krita/commit/e37f64c44483170ae33154c02c079e56ac78f9ca