After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 419256 - Optimize mask buffer size for VBR generated brushes
Optimize mask buffer size for VBR generated brushes
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
git master
Other All
: Normal trivial
: 2.10
Assigned To: GIMP Bugs
GIMP Bugs
: 581629 698551 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-03-17 09:09 UTC by Martin Nordholts
Modified: 2014-10-21 17:03 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Martin Nordholts 2007-03-17 09:09:02 UTC
After fixing bug #157506 it became evident that the size of the mask buffer allocated for VBR brushes is slightly larger than necessary. For a e.g. 0.5 radius brush the allocated mask buffer is 3x3 pixels, causing a 1 pixel-in-diameter-brush to be presented as having a 3x3 size in the Brushes dialog.

The problem lies in the way the mask buffer size is allocated for generated
brushes (code from gimp_brush_generated_get_half_size()):

    case GIMP_BRUSH_GENERATED_CIRCLE:
      *half_width  = ceil (sqrt (x_axis.x * x_axis.x + y_axis.x * y_axis.x));
      *half_height = ceil (sqrt (x_axis.y * x_axis.y + y_axis.y * y_axis.y));
      break;

For a 0.5 radius brush, *half_width and *half_height will both be 1 on the
break, causing a 3x3 mask buffer to be allocated later on through (code from
gimp_brush_generated_calc()):

  mask = temp_buf_new (half_width  * 2 + 1,
                       half_height * 2 + 1,
                       1, half_width, half_height, NULL);

Since I consider this a minor issue, (I personally doesn't care of the size of
the buffer as long as the brush width is what I want,) I will concentrate on
other 2.4 milestone bugs and let someone else handle this, at least until there
are no other 2.4 bugs left of which I have contributions to make.

Fixing this should involve a single-file patch (for app/core/gimpbrushgenerated.c),
given that the algorithm can be easily modified to handle the smaller buffer
size (of which I'm not sure).
Comment 1 Sven Neumann 2007-03-19 07:42:32 UTC
I am not even sure if we need to optimize things here. We probably just need to change the way the width/height as displayed in the UI are calculated.
Comment 2 Martin Nordholts 2007-03-19 15:12:38 UTC
That is one possible solution, but it would in essence only be a hack, which is likely to be the base for additional special-case code as time goes by, and hacks are not fun to maintain.
Comment 3 Sven Neumann 2007-05-05 20:21:59 UTC
Moving this off the 2.4 milestone, it should not block the release.
Comment 4 Michael Natterer 2013-05-13 00:23:19 UTC
*** Bug 698551 has been marked as a duplicate of this bug. ***
Comment 5 Michael Natterer 2013-05-13 00:24:02 UTC
As bug 698551 shows, this is not only a cosmetic defect.
Comment 6 Michael Natterer 2014-10-21 10:58:52 UTC
Fixed in master:

commit 9dc13116ae9d576d1546728be6ab493764f777f3
Author: Michael Natterer <mitch@gimp.org>
Date:   Tue Oct 21 12:31:24 2014 +0200

    Bug 419256 - Optimize mask buffer size for VBR generated brushes
    
    Change gimp_brush_generated_get_half_size() to get_size() and
    calculate its exact size in float. This is really a minor change that
    seems to work well.

 app/core/gimpbrushgenerated.c | 127 +++++++++++++++++++++++++++++--------------------------
 1 file changed, 66 insertions(+), 61 deletions(-)
Comment 7 Michael Natterer 2014-10-21 17:03:41 UTC
*** Bug 581629 has been marked as a duplicate of this bug. ***