Bug 434309 - New/default brush in MyPaint engine doesn't paint
Summary: New/default brush in MyPaint engine doesn't paint
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Brush engines (show other bugs)
Version: git master (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-11 23:48 UTC by Tiar
Modified: 2021-04-19 22:40 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tiar 2021-03-11 23:48:34 UTC
SUMMARY
When you create a new MyPaint brush using the [+] button, it has everything initialized to 0, which means Opacity and Size is 0 or nearly 0, too. Which means it doesn't paint.

STEPS TO REPRODUCE
1. Go to Brush Editor. Open the left panel.
2. Press the [+] button.
3. Choose the MyPaint engine.

OBSERVED RESULT
The brush doesn't work, because the Opacity is 0.

EXPECTED RESULT
The brush has some sane default values (for example it could be a normal circle brush).

SOFTWARE/OS VERSIONS
SOFTWARE/OS VERSIONS
Krita

 Version: 5.0.0-prealpha (git d3260196b4)
 Languages: pl_PL, pl, pl_PL, pl
 Hidpi: true

Qt

  Version (compiled): 5.11.1
  Version (loaded): 5.11.1

OS Information
Comment 1 Tiar 2021-04-19 22:39:54 UTC
Git commit fef5d652fb62ff36ebb82a721853428c1e154486 by Agata Cacko.
Committed on 19/04/2021 at 22:16.
Pushed by tymond into branch 'master'.

Fix MyPaint default brush to be a brush that paints

Before this commit, if the user created a new MyPaint brush
using the + button in the left panel of the Brush Editor,
it would by default create a brush that doesn't have an ability
to make marks on the canvas (the dab-per-second and dabs-per-radius
are both 0, the opacity is 0, the diameter is very small as well).

This commit adds a default preset for MyPaint that can paint,
and changes the code to make use of that preset.

Note: right now Krita ignores MyPaint's default settings for the brush.
Since all other paintop engines have their default presets in the
.qrc file, it was the easiest way to make MyPaint brush engine work as
well.

M  +32   -1    libs/ui/kis_paintop_box.cc
M  +1    -0    plugins/paintops/defaultpresets/defaultpresets.qrc
A  +245  -0    plugins/paintops/defaultpresets/mypaintbrush.myb
A  +-    --    plugins/paintops/defaultpresets/mypaintbrush_prev.png

https://invent.kde.org/graphics/krita/commit/fef5d652fb62ff36ebb82a721853428c1e154486
Comment 2 Tiar 2021-04-19 22:40:02 UTC
Git commit f449392f477f21902310594f46273ec18cd10dbd by Agata Cacko.
Committed on 19/04/2021 at 22:16.
Pushed by tymond into branch 'master'.

Fix default MyPaint brush being randomly incorrect

Before this commit, if the user wanted to create a MyPaint
brush preset from scratch, they would either get the
standard round MyPaint brush (coming from the mypaintbrush.myb
file in the plugins/paintops/defaultpresets/ directory),
or a much smaller brush with very low spacing. It would be also
impossible to change various details about the brush.

This commit ensures that the user will always get the correct
brush from the .myb file and be able to change its properties.

The reason for that bug was the fact that MyPaint preset loader
would load all the bytes from the current point it peeks to
to the end. However in kis_paintop_box there is a for loop
over all paintoppresets loaders to see if they can read that specific
file. In a generic paintoppreset loader, a few first bytes would be
read, which would result in MyPaint preset loader missing first few
bytes and assuming that the json is incorrect, and hence using
its default options (that low spacing brush) instead of options
supplied in the file.

Because there was no error checking in the MyPaint preset loader,
Krita would assume everything is fine. However because MyPaint
editor handles the changes by changing the json and then supplying it
to the libmypaint brush engine, changing most of the properties wouldn't
work, because the json was always incorrect.

This commit adds moving the beginning of the bytes to read to the
beginning of the file in two locations, both the for loop for loaders
and in the MyPaint presets loader itself. Moreover it adds error
checking to the MyPaint presets loader.

---

Note: if there is no loader or no file found, the preset would not paint,
because, I assume, it takes all the options from the default
values of all the widgets and it means 0 for opacity, dabs per
second etc. It would be best if Krita in such case would use MyPaint
default options, but because Krita's MyPaint library uses the json
version all the time and because I couldn't find a way to extract the
json from a working libmypaint brush, I had to leave it as that.

M  +1    -0    libs/ui/kis_paintop_box.cc
M  +7    -3    plugins/paintops/mypaint/MyPaintPaintOpPreset.cpp

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