Bug 419240

Summary: [selection] Ant-marching decoration on inverted selection has many artifacts
Product: [Applications] krita Reporter: David REVOY <info>
Component: Tools/SelectionAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: ahab.greybeard, halla
Priority: NOR    
Version: 4.2.9-beta1   
Target Milestone: ---   
Platform: Appimage   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: ^ gif-animation of the bug, inverting selection on the silhouettes of characters.
inverted-ragged-selection

Description David REVOY 2020-03-25 17:05:16 UTC
Created attachment 127011 [details]
^ gif-animation of the bug, inverting selection on the silhouettes of characters.

Hi,
I'm not sure if this one is a regression or have been around all this time; I remember seeing tiny glitch (eg. a single horyzontal line) but it looks like this is another level now. The marching-ants decoration on inverted selection has many articfacts: clusters of black&white noises; many horyzontal lines crossing the canvas, etc... (gif in attachement)

To reproduce:
=============
1. Open a new canvas on Krita, create an empty transparent layer.
2. Take a brush with a texture, paint a shape and fill it manually.
3. Over the layer stack docker, right click on the layer with the painted shape and select "Select Opaque (Replace)" feature.
4. Go to the top menu; Select > Invert Selection
5. If no effect happens, switch between discrete zoom (33%,50%,67%,25%, back and forth) with mouse wheel until glitch appears.

Observed:
=========
While the original selection of the shape with ant-marching decoration was comfortable to work with; the inverted representation makes it difficult: clusters of black&white noises; many horyzontal lines crossing the canvas, etc... (gif in attachement)
Comment 1 Ahab Greybeard 2020-03-25 19:08:20 UTC
Created attachment 127015 [details]
inverted-ragged-selection

I can reproduce this for the 4.2.9 beta1 appimage and the 4.2.8 appimage.

It seems to be caused by the complexity/raggedness of the selection outline.
See attachment "inverted-ragged-selection".

It can be stopped by re-inverting the selection.
It can  be stopped by turning Graphics Acceleration off but not by turning Instant Preview off.
Comment 2 Dmitry Kazakov 2020-05-07 12:39:55 UTC
It looks like a bug in Qt's code in rendering dashes pens with multiple subpaths. Splitting the path into subpolygons fixes the issue.
Comment 3 Dmitry Kazakov 2020-05-08 12:45:40 UTC

*** This bug has been marked as a duplicate of bug 413220 ***
Comment 4 Dmitry Kazakov 2020-05-08 17:18:49 UTC
Git commit c15d8888c3d793a31c914ffb80a5b38a1f2846ad by Dmitry Kazakov.
Committed on 08/05/2020 at 17:18.
Pushed by dkazakov into branch 'master'.

Fix artifacts when rendering complex selection outlines

It happens because of a bug in opengl-based stroking algorithm in Qt.
And it happens only when one tries to draw a path with multiple
subpaths. The easiest workaround for this bug without patching Qt is
to manually split a multi-subpath path into QPainterPath objects with
only one subpath in each.

It might happen that the resulting subpath generated by the QDashStroker
will have no lines at all. It happens when further LineToElement items
compare as equal to the starting MoveToElement when compared in 'float'
space. In such case QTriangulatingStroker::process() skips LineTo elements
and the vertexBuffer ends up with unconnected vertices, which generate
unwanted triangles.
Related: bug 413220

A  +80   -0    3rdparty/ext_qt/0100-Fix-artifacts-when-rendering-multisubpath-dashed-QPa.patch
M  +5    -0    3rdparty/ext_qt/CMakeLists.txt

https://invent.kde.org/kde/krita/commit/c15d8888c3d793a31c914ffb80a5b38a1f2846ad
Comment 5 Dmitry Kazakov 2020-05-08 17:19:29 UTC
Git commit 8208fa254321232105a231fc517541e98c747216 by Dmitry Kazakov.
Committed on 08/05/2020 at 17:19.
Pushed by dkazakov into branch 'krita/4.3'.

Fix artifacts when rendering complex selection outlines

It happens because of a bug in opengl-based stroking algorithm in Qt.
And it happens only when one tries to draw a path with multiple
subpaths. The easiest workaround for this bug without patching Qt is
to manually split a multi-subpath path into QPainterPath objects with
only one subpath in each.

It might happen that the resulting subpath generated by the QDashStroker
will have no lines at all. It happens when further LineToElement items
compare as equal to the starting MoveToElement when compared in 'float'
space. In such case QTriangulatingStroker::process() skips LineTo elements
and the vertexBuffer ends up with unconnected vertices, which generate
unwanted triangles.
Related: bug 413220

A  +80   -0    3rdparty/ext_qt/0100-Fix-artifacts-when-rendering-multisubpath-dashed-QPa.patch
M  +5    -0    3rdparty/ext_qt/CMakeLists.txt

https://invent.kde.org/kde/krita/commit/8208fa254321232105a231fc517541e98c747216