Bug 436485 - Filter layer "Halftone" broken when working with pattern
Summary: Filter layer "Halftone" broken when working with pattern
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Resource Management (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Halla Rempt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-02 09:31 UTC by grum999
Modified: 2021-05-03 09:25 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
step 01 (9.05 KB, image/png)
2021-05-02 09:31 UTC, grum999
Details
step 02b (4.15 KB, image/png)
2021-05-02 09:31 UTC, grum999
Details
step 02a (89.29 KB, image/png)
2021-05-02 09:32 UTC, grum999
Details
step 04 (1.33 KB, image/png)
2021-05-02 09:32 UTC, grum999
Details
step 05 (52.56 KB, image/png)
2021-05-02 09:33 UTC, grum999
Details

Note You need to log in before you can comment on or make changes to this bug.
Description grum999 2021-05-02 09:31:22 UTC
Created attachment 138076 [details]
step 01

SUMMARY

In Krita 5.0.0-prealpha (git d2806ec), "Halftone" filter layer/filter mask doesn't work properly with patterns.


STEPS TO REPRODUCE

METHOD 1
========

1) create a document, set a content (here a gradient)
[screen shot model_pattern_ko01.png]

2) Add a Filter layer (or a Filter mask, problem is the same)
[screen shot model_pattern_ko02a.png]
   - Filter type: Halftone
   - Mode: Intensity (but problem occurs whatever the mode is)
   - Screen generator: pattern
        - Choose a pattern different than default pattern: DITH 0404 WAVE
   - Apply
Result is [screen shot model_pattern_ko02b.png]


3) Save document 

4) Open document 
    Pattern is not applied
    [screen shot model_pattern_ko04.png]
    
    Terminal output:
    ```
    PatternGeneratorConfiguration::pattern "DITH 0404 WAVE"
    LocalResourceSource::resourceForName "DITH 0404 WAVE"
    ```

5) Open filter layer properties
    Everything seems OK
    [screen shot model_pattern_ko04.png]
    
    Terminal output:
    ```
    KisWdgPattern::setConfiguration(); "DITH 0404 WAVE"
    ```
    
6) Change pattern (example "DITH 0404 WAV2")
    New pattern is applied
    Reapply previous pattern, it's applied
    
    Terminal output:
    ```
    KisWdgPattern::configuration() [RESOURCE] Name: "DITH 0404 WAV2" Version: 0 Filename: "DITH_0404_WAV2.pat" Valid: true Storage: "/home/grum/.local/share/krita/"
    PatternGeneratorConfiguration::pattern "DITH 0404 WAV2"
    PatternGeneratorConfiguration::pattern "DITH 0404 WAV2"
    PatternGeneratorConfiguration::pattern "DITH 0404 WAV2"
    LocalResourceSource::resourceForName "DITH 0404 WAV2"
    KisWdgPattern::configuration() [RESOURCE] Name: "DITH 0404 WAVE" Version: 0 Filename: "DITH_0404_WAVE.pat" Valid: true Storage: "/home/grum/.local/share/krita/"
    PatternGeneratorConfiguration::pattern "DITH 0404 WAVE"
    PatternGeneratorConfiguration::pattern "DITH 0404 WAVE"
    PatternGeneratorConfiguration::pattern "DITH 0404 WAVE"
    LocalResourceSource::resourceForName "DITH 0404 WAVE"
    ```


Krita 4.4.3: everything is fine when opening document, filter is applied as expected
Krita 5.0.0: do not work, when opening document filter is not properly applied with pattern



Note: on a fill layer using pattern, there's no problem 



METHOD 2
========

1) create a document, set a content (here a gradient)
[screen shot model_pattern_ko01.png]

2) in scripter, execute following code:
```
from krita import *

doc=Krita.instance().activeDocument()

filterConfig=InfoObject()
filterConfig.setProperties({
        'intensity_generator': 'pattern',
        'intensity_generator_pattern_pattern': 'DITH 0404 WAVE',
        'mode': 'intensity'
    })

filter=Filter()
filter.setName('halftone')
filter.setConfiguration(filterConfig)

selection=Selection()
selection.select(0,0,doc.width(), doc.height(),255)

filterLayer=doc.createFilterLayer("Testing filter", filter, selection)

doc.rootNode().addChildNode(filterLayer, None)
doc.refreshProjection()
```

Do not work, same result than in method 1 after opening document
[screen shot model_pattern_ko04.png]


Terminal output:
```
PatternGeneratorConfiguration::pattern "DITH 0404 WAVE"
LocalResourceSource::resourceForName "DITH 0404 WAVE"
PatternGeneratorConfiguration::pattern "DITH 0404 WAVE"
LocalResourceSource::resourceForName "DITH 0404 WAVE"
```

Additionaly, if the following statement is added, it doesn't change anything to final result and terminal output is
```
PatternGeneratorConfiguration::pattern "DITH 0404 WAVE"
LocalResourceSource::resourceForName "DITH 0404 WAVE"
SAFE ASSERT (krita): "filterConfig" in file /home/appimage/workspace/Krita_Nightly_Appimage_Build/krita/plugins/filters/halftone/KisHalftoneFilter.cpp, line 57
PatternGeneratorConfiguration::pattern "DITH 0404 WAVE"
LocalResourceSource::resourceForName "DITH 0404 WAVE"
PatternGeneratorConfiguration::pattern "DITH 0404 WAVE"
LocalResourceSource::resourceForName "DITH 0404 WAVE"
```

Note: Krita 4.4.3: everything is fine, filter layer is properly and immediately applied as expected





OBSERVED RESULT
-> Detailled in STEPS TO REPRODUCE


EXPECTED RESULT
- When opening a document, filter layer should be applied properly
- When using scripting, filter layer should be applied properly



SOFTWARE/OS VERSIONS
Krita
 Version: 5.0.0-prealpha (git d2806ec)
 Languages: en_GB, en, fr, fr_FR, fr
 Hidpi: false

Qt
  Version (compiled): 5.12.9
  Version (loaded): 5.12.9

OS Information
  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 4.19.0-16-amd64
  Pretty Productname: Debian GNU/Linux 10 (buster)
  Product Type: debian
  Product Version: 10
  Desktop: KDE
Comment 1 grum999 2021-05-02 09:31:51 UTC
Created attachment 138077 [details]
step 02b
Comment 2 grum999 2021-05-02 09:32:12 UTC
Created attachment 138078 [details]
step 02a
Comment 3 grum999 2021-05-02 09:32:41 UTC
Created attachment 138079 [details]
step 04
Comment 4 grum999 2021-05-02 09:33:07 UTC
Created attachment 138080 [details]
step 05
Comment 5 grum999 2021-05-02 09:35:22 UTC
urgh...

I can't edit initial description 

model_pattern_ko01.png=step 01
model_pattern_ko02a.png=step 02a
model_pattern_ko02b.png=step 02b
model_pattern_ko04.png=step 04
model_pattern_ko05.png=step 05
:-)

Grum999
Comment 6 Halla Rempt 2021-05-03 09:25:56 UTC
Git commit 72c3f42e1580dd7a0af41815e587c2edfa0c15cc by Halla Rempt, on behalf of Deif Lou.
Committed on 03/05/2021 at 08:50.
Pushed by dkazakov into branch 'master'.

Fix handling of resources in halftone filter

M  +31   -19   plugins/filters/halftone/KisHalftoneFilterConfiguration.cpp
M  +0    -3    plugins/filters/halftone/KisHalftoneFilterConfiguration.h

https://invent.kde.org/graphics/krita/commit/72c3f42e1580dd7a0af41815e587c2edfa0c15cc