mirror of https://github.com/GNOME/gimp.git
Issue #3247: make consistent generated brush preview.
This is only a temporary solution meant to be backported to gimp-2-10 branch, so that at least the preview now matches how angles always worked in at least the 2.10 series: angles are measured clockwise. Now there is the question that in the documentation of the Brush Editor, it is written that angles are supposed to be counter-clockwise. A solution was proposed to make them so, but only for generated brushes (whereas angles stayed clockwise for other types of brush) which is a very bad inconsistency. Furthermore I find the whole tool options vs. brush editor settings mess quite confusing. Some decision should be made for GIMP 3. For GIMP 2.10 though, this should be an OK fix: no behavior change on-canvas, only making the preview actually match what happens on-canvas (even though it goes against what the docs say but it's probably better than breaking workflows relying on actual on-canvas behavior). Note: this commit is based on an initial proposition by Alx Sa in MR !1119, except that the patch was only working when the preview needed to be scaled. Instead we must go through this brush transformation code path for generated brushes, whatever the scale.
This commit is contained in:
parent
d3d13c71f5
commit
eb7337d5e4
|
@ -282,7 +282,8 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
|
|||
guchar *mask;
|
||||
guchar *buf;
|
||||
gint x, y;
|
||||
gboolean scaled = FALSE;
|
||||
gboolean free_mask = FALSE;
|
||||
gdouble scale = 1.0;
|
||||
|
||||
mask_width = gimp_temp_buf_get_width (mask_buf);
|
||||
mask_height = gimp_temp_buf_get_height (mask_buf);
|
||||
|
@ -291,45 +292,47 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
|
|||
{
|
||||
gdouble ratio_x = (gdouble) width / (gdouble) mask_width;
|
||||
gdouble ratio_y = (gdouble) height / (gdouble) mask_height;
|
||||
gdouble scale = MIN (ratio_x, ratio_y);
|
||||
|
||||
if (scale != 1.0)
|
||||
scale = MIN (ratio_x, ratio_y);
|
||||
}
|
||||
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush) || scale != 1.0)
|
||||
{
|
||||
gimp_brush_begin_use (brush);
|
||||
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush))
|
||||
{
|
||||
gimp_brush_begin_use (brush);
|
||||
GimpBrushGenerated *gen_brush = GIMP_BRUSH_GENERATED (brush);
|
||||
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush))
|
||||
{
|
||||
GimpBrushGenerated *gen_brush = GIMP_BRUSH_GENERATED (brush);
|
||||
mask_buf = gimp_brush_transform_mask (brush, scale,
|
||||
(gimp_brush_generated_get_aspect_ratio (gen_brush) - 1.0) * 20.0 / 19.0,
|
||||
gimp_brush_generated_get_angle (gen_brush) / -360.0,
|
||||
FALSE,
|
||||
gimp_brush_generated_get_hardness (gen_brush));
|
||||
}
|
||||
else
|
||||
{
|
||||
mask_buf = gimp_brush_transform_mask (brush, scale, 0.0, 0.0, FALSE, 1.0);
|
||||
}
|
||||
|
||||
mask_buf = gimp_brush_transform_mask (brush, scale,
|
||||
(gimp_brush_generated_get_aspect_ratio (gen_brush) - 1.0) * 20.0 / 19.0,
|
||||
gimp_brush_generated_get_angle (gen_brush) / 360.0,
|
||||
FALSE,
|
||||
gimp_brush_generated_get_hardness (gen_brush));
|
||||
}
|
||||
else
|
||||
mask_buf = gimp_brush_transform_mask (brush, scale,
|
||||
if (! mask_buf)
|
||||
{
|
||||
mask_buf = gimp_temp_buf_new (1, 1, babl_format ("Y u8"));
|
||||
gimp_temp_buf_data_clear ((GimpTempBuf *) mask_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_temp_buf_ref ((GimpTempBuf *) mask_buf);
|
||||
}
|
||||
|
||||
if (pixmap_buf)
|
||||
pixmap_buf = gimp_brush_transform_pixmap (brush, scale,
|
||||
0.0, 0.0, FALSE, 1.0);
|
||||
|
||||
if (! mask_buf)
|
||||
{
|
||||
mask_buf = gimp_temp_buf_new (1, 1, babl_format ("Y u8"));
|
||||
gimp_temp_buf_data_clear ((GimpTempBuf *) mask_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_temp_buf_ref ((GimpTempBuf *) mask_buf);
|
||||
}
|
||||
mask_width = gimp_temp_buf_get_width (mask_buf);
|
||||
mask_height = gimp_temp_buf_get_height (mask_buf);
|
||||
|
||||
if (pixmap_buf)
|
||||
pixmap_buf = gimp_brush_transform_pixmap (brush, scale,
|
||||
0.0, 0.0, FALSE, 1.0);
|
||||
|
||||
mask_width = gimp_temp_buf_get_width (mask_buf);
|
||||
mask_height = gimp_temp_buf_get_height (mask_buf);
|
||||
|
||||
scaled = TRUE;
|
||||
}
|
||||
free_mask = TRUE;
|
||||
}
|
||||
|
||||
return_buf = gimp_temp_buf_new (mask_width, mask_height,
|
||||
|
@ -377,7 +380,7 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
|
|||
|
||||
gimp_temp_buf_unlock (mask_buf, mask_data);
|
||||
|
||||
if (scaled)
|
||||
if (free_mask)
|
||||
{
|
||||
gimp_temp_buf_unref ((GimpTempBuf *) mask_buf);
|
||||
|
||||
|
|
Loading…
Reference in New Issue