GNOME Bugzilla – Bug 419256
Optimize mask buffer size for VBR generated brushes
Last modified: 2014-10-21 17:03:41 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).
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.
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.
Moving this off the 2.4 milestone, it should not block the release.
*** Bug 698551 has been marked as a duplicate of this bug. ***
As bug 698551 shows, this is not only a cosmetic defect.
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(-)
*** Bug 581629 has been marked as a duplicate of this bug. ***