[gimp] app: add support for brush reflection



commit a0b73420ec0afa8f25b8850963ebb699b2c2bed1
Author: Ell <ell_se yahoo com>
Date:   Fri Dec 22 16:53:56 2017 -0500

    app: add support for brush reflection
    
    Add support for reflecting brushes as part of their transformation.
    The reflection is performed as the last step of the transformation,
    across the vertical axis.
    
    The option to reflect the brush is not exposed in the UI, or
    through the PDB, but is intended to be used for linking the brush
    transformation to the view transformation, in the next commit.

 app/core/gimpbrush-boundary.c  |   14 +++++++++-----
 app/core/gimpbrush-boundary.h  |    1 +
 app/core/gimpbrush-transform.c |   18 +++++++++++++-----
 app/core/gimpbrush-transform.h |    4 ++++
 app/core/gimpbrush.c           |   34 ++++++++++++++++++++++------------
 app/core/gimpbrush.h           |    8 ++++++++
 app/core/gimpbrushcache.c      |    5 +++++
 app/core/gimpbrushcache.h      |    2 ++
 app/core/gimpbrushgenerated.c  |   16 ++++++++++++++++
 app/paint/gimpbrushcore.c      |    8 ++++++--
 app/paint/gimpbrushcore.h      |    3 ++-
 app/paint/gimppaintoptions.c   |    2 +-
 app/tools/gimpbrushtool.c      |    1 +
 13 files changed, 90 insertions(+), 26 deletions(-)
---
diff --git a/app/core/gimpbrush-boundary.c b/app/core/gimpbrush-boundary.c
index a9efbec..81b3aca 100644
--- a/app/core/gimpbrush-boundary.c
+++ b/app/core/gimpbrush-boundary.c
@@ -35,12 +35,14 @@ gimp_brush_transform_boundary_exact (GimpBrush *brush,
                                      gdouble    scale,
                                      gdouble    aspect_ratio,
                                      gdouble    angle,
+                                     gboolean   reflect,
                                      gdouble    hardness)
 {
   const GimpTempBuf *mask;
 
   mask = gimp_brush_transform_mask (brush, NULL,
-                                    scale, aspect_ratio, angle, hardness);
+                                    scale, aspect_ratio,
+                                    angle, reflect, hardness);
 
   if (mask)
     {
@@ -94,11 +96,12 @@ gimp_brush_transform_boundary_approx (GimpBrush *brush,
                                       gdouble    scale,
                                       gdouble    aspect_ratio,
                                       gdouble    angle,
+                                      gboolean   reflect,
                                       gdouble    hardness)
 {
   return gimp_brush_transform_boundary_exact (brush,
                                               scale, aspect_ratio,
-                                              angle, hardness);
+                                              angle, reflect, hardness);
 }
 
 GimpBezierDesc *
@@ -106,21 +109,22 @@ gimp_brush_real_transform_boundary (GimpBrush *brush,
                                     gdouble    scale,
                                     gdouble    aspect_ratio,
                                     gdouble    angle,
+                                    gboolean   reflect,
                                     gdouble    hardness,
                                     gint      *width,
                                     gint      *height)
 {
-  gimp_brush_transform_size (brush, scale, aspect_ratio, angle,
+  gimp_brush_transform_size (brush, scale, aspect_ratio, reflect, angle,
                              width, height);
 
   if (*width < 256 && *height < 256)
     {
       return gimp_brush_transform_boundary_exact (brush,
                                                   scale, aspect_ratio,
-                                                  angle, hardness);
+                                                  angle, reflect, hardness);
     }
 
   return gimp_brush_transform_boundary_approx (brush,
                                                scale, aspect_ratio,
-                                               angle, hardness);
+                                               angle, reflect, hardness);
 }
diff --git a/app/core/gimpbrush-boundary.h b/app/core/gimpbrush-boundary.h
index b276c83..96bbd83 100644
--- a/app/core/gimpbrush-boundary.h
+++ b/app/core/gimpbrush-boundary.h
@@ -23,6 +23,7 @@ GimpBezierDesc * gimp_brush_real_transform_boundary (GimpBrush *brush,
                                                      gdouble    scale,
                                                      gdouble    aspect_ratio,
                                                      gdouble    angle,
+                                                     gboolean   reflect,
                                                      gdouble    hardness,
                                                      gint      *width,
                                                      gint      *height);
diff --git a/app/core/gimpbrush-transform.c b/app/core/gimpbrush-transform.c
index f8af255..e1e9fd4 100644
--- a/app/core/gimpbrush-transform.c
+++ b/app/core/gimpbrush-transform.c
@@ -62,6 +62,7 @@ gimp_brush_real_transform_size (GimpBrush *brush,
                                 gdouble    scale,
                                 gdouble    aspect_ratio,
                                 gdouble    angle,
+                                gboolean   reflect,
                                 gint      *width,
                                 gint      *height)
 {
@@ -70,7 +71,7 @@ gimp_brush_real_transform_size (GimpBrush *brush,
 
   gimp_brush_transform_matrix (gimp_brush_get_width  (brush),
                                gimp_brush_get_height (brush),
-                               scale, aspect_ratio, angle, &matrix);
+                               scale, aspect_ratio, angle, reflect, &matrix);
 
   gimp_brush_transform_bounding_box (brush, &matrix, &x, &y, width, height);
 }
@@ -106,6 +107,7 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
                                 gdouble    scale,
                                 gdouble    aspect_ratio,
                                 gdouble    angle,
+                                gboolean   reflect,
                                 gdouble    hardness)
 {
   GimpTempBuf  *result;
@@ -180,7 +182,7 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
   src_height = gimp_brush_get_height (brush);
 
   gimp_brush_transform_matrix (src_width, src_height,
-                               scale, aspect_ratio, angle, &matrix);
+                               scale, aspect_ratio, angle, reflect, &matrix);
 
   if (gimp_matrix3_is_identity (&matrix) && hardness == 1.0)
     return gimp_temp_buf_copy (source);
@@ -202,7 +204,8 @@ gimp_brush_real_transform_mask (GimpBrush *brush,
       gint        unrotated_dest_height;
 
       gimp_brush_transform_matrix (src_width, src_height,
-                                   scale, aspect_ratio, 1.0, &unrotated_matrix);
+                                   scale, aspect_ratio, 0.0, FALSE,
+                                   &unrotated_matrix);
 
       gimp_brush_transform_bounding_box (brush, &unrotated_matrix,
                                          &unrotated_x, &unrotated_y,
@@ -397,6 +400,7 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
                                   gdouble    scale,
                                   gdouble    aspect_ratio,
                                   gdouble    angle,
+                                  gboolean   reflect,
                                   gdouble    hardness)
 {
   GimpTempBuf  *result;
@@ -471,7 +475,7 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
   src_height = gimp_brush_get_height (brush);
 
   gimp_brush_transform_matrix (src_width, src_height,
-                               scale, aspect_ratio, angle, &matrix);
+                               scale, aspect_ratio, angle, reflect, &matrix);
 
   if (gimp_matrix3_is_identity (&matrix) && hardness == 1.0)
     return gimp_temp_buf_copy (source);
@@ -494,7 +498,8 @@ gimp_brush_real_transform_pixmap (GimpBrush *brush,
       gint        unrotated_dest_height;
 
       gimp_brush_transform_matrix (src_width, src_height,
-                                   scale, aspect_ratio, 1.0, &unrotated_matrix);
+                                   scale, aspect_ratio, 0.0, FALSE,
+                                   &unrotated_matrix);
 
       gimp_brush_transform_bounding_box (brush, &unrotated_matrix,
                                          &unrotated_x, &unrotated_y,
@@ -665,6 +670,7 @@ gimp_brush_transform_matrix (gdouble      width,
                              gdouble      scale,
                              gdouble      aspect_ratio,
                              gdouble      angle,
+                             gboolean     reflect,
                              GimpMatrix3 *matrix)
 {
   const gdouble center_x = width  / 2;
@@ -687,6 +693,8 @@ gimp_brush_transform_matrix (gdouble      width,
   gimp_matrix3_scale (matrix, scale_x, scale_y);
   gimp_matrix3_translate (matrix, - center_x * scale_x, - center_y * scale_y);
   gimp_matrix3_rotate (matrix, -2 * G_PI * angle);
+  if (reflect)
+    gimp_matrix3_scale (matrix, -1.0, 1.0);
   gimp_matrix3_translate (matrix, center_x * scale_x, center_y * scale_y);
 }
 
diff --git a/app/core/gimpbrush-transform.h b/app/core/gimpbrush-transform.h
index 4f4ac62..8f1078d 100644
--- a/app/core/gimpbrush-transform.h
+++ b/app/core/gimpbrush-transform.h
@@ -27,17 +27,20 @@ void          gimp_brush_real_transform_size   (GimpBrush   *brush,
                                                 gdouble      scale,
                                                 gdouble      aspect_ratio,
                                                 gdouble      angle,
+                                                gboolean     reflect,
                                                 gint        *scaled_width,
                                                 gint        *scaled_height);
 GimpTempBuf * gimp_brush_real_transform_mask   (GimpBrush   *brush,
                                                 gdouble      scale,
                                                 gdouble      aspect_ratio,
                                                 gdouble      angle,
+                                                gboolean     reflect,
                                                 gdouble      hardness);
 GimpTempBuf * gimp_brush_real_transform_pixmap (GimpBrush   *brush,
                                                 gdouble      scale,
                                                 gdouble      aspect_ratio,
                                                 gdouble      angle,
+                                                gboolean     reflect,
                                                 gdouble      hardness);
 
 void          gimp_brush_transform_matrix      (gdouble      width,
@@ -45,6 +48,7 @@ void          gimp_brush_transform_matrix      (gdouble      width,
                                                 gdouble      scale,
                                                 gdouble      aspect_ratio,
                                                 gdouble      angle,
+                                                gboolean     reflect,
                                                 GimpMatrix3 *matrix);
 
 
diff --git a/app/core/gimpbrush.c b/app/core/gimpbrush.c
index 01a8166..354824a 100644
--- a/app/core/gimpbrush.c
+++ b/app/core/gimpbrush.c
@@ -298,11 +298,12 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
                mask_buf = gimp_brush_transform_mask (brush, NULL, 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, NULL, scale,
-                                                  0.0, 0.0, 1.0);
+                                                  0.0, 0.0, FALSE, 1.0);
 
           if (! mask_buf)
             {
@@ -316,7 +317,7 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
 
           if (pixmap_buf)
             pixmap_buf = gimp_brush_transform_pixmap (brush, NULL, scale,
-                                                      0.0, 0.0, 1.0);
+                                                      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);
@@ -572,6 +573,7 @@ gimp_brush_transform_size (GimpBrush     *brush,
                            gdouble        scale,
                            gdouble        aspect_ratio,
                            gdouble        angle,
+                           gboolean       reflect,
                            gint          *width,
                            gint          *height)
 {
@@ -591,7 +593,7 @@ gimp_brush_transform_size (GimpBrush     *brush,
     }
 
   GIMP_BRUSH_GET_CLASS (brush)->transform_size (brush,
-                                                scale, aspect_ratio, angle,
+                                                scale, aspect_ratio, angle, reflect,
                                                 width, height);
 }
 
@@ -601,6 +603,7 @@ gimp_brush_transform_mask (GimpBrush *brush,
                            gdouble    scale,
                            gdouble    aspect_ratio,
                            gdouble    angle,
+                           gboolean   reflect,
                            gdouble    hardness)
 {
   const GimpTempBuf *mask;
@@ -612,12 +615,12 @@ gimp_brush_transform_mask (GimpBrush *brush,
   g_return_val_if_fail (scale > 0.0, NULL);
 
   gimp_brush_transform_size (brush,
-                             scale, aspect_ratio, angle,
+                             scale, aspect_ratio, reflect, angle,
                              &width, &height);
 
   mask = gimp_brush_cache_get (brush->priv->mask_cache,
                                op, width, height,
-                               scale, aspect_ratio, angle, hardness);
+                               scale, aspect_ratio, angle, reflect, hardness);
 
   if (! mask)
     {
@@ -635,6 +638,7 @@ gimp_brush_transform_mask (GimpBrush *brush,
                                                              1.0,
                                                              0.0,
                                                              0.0,
+                                                             FALSE,
                                                              hardness);
            brush->priv->blur_hardness = hardness;
         }
@@ -649,6 +653,7 @@ gimp_brush_transform_mask (GimpBrush *brush,
                                                            scale,
                                                            aspect_ratio,
                                                            angle,
+                                                           reflect,
                                                            effective_hardness);
 
       if (op)
@@ -682,7 +687,7 @@ gimp_brush_transform_mask (GimpBrush *brush,
       gimp_brush_cache_add (brush->priv->mask_cache,
                             (gpointer) mask,
                             op, width, height,
-                            scale, aspect_ratio, angle, effective_hardness);
+                            scale, aspect_ratio, angle, reflect, effective_hardness);
     }
 
   return mask;
@@ -694,6 +699,7 @@ gimp_brush_transform_pixmap (GimpBrush *brush,
                              gdouble    scale,
                              gdouble    aspect_ratio,
                              gdouble    angle,
+                             gboolean   reflect,
                              gdouble    hardness)
 {
   const GimpTempBuf *pixmap;
@@ -706,12 +712,12 @@ gimp_brush_transform_pixmap (GimpBrush *brush,
   g_return_val_if_fail (scale > 0.0, NULL);
 
   gimp_brush_transform_size (brush,
-                             scale, aspect_ratio, angle,
+                             scale, aspect_ratio, angle, reflect,
                              &width, &height);
 
   pixmap = gimp_brush_cache_get (brush->priv->pixmap_cache,
                                  op, width, height,
-                                 scale, aspect_ratio, angle, hardness);
+                                 scale, aspect_ratio, angle, reflect, hardness);
 
   if (! pixmap)
     {
@@ -725,6 +731,7 @@ gimp_brush_transform_pixmap (GimpBrush *brush,
                                                                   1.0,
                                                                   0.0,
                                                                   0.0,
+                                                                  FALSE,
                                                                   hardness);
          brush->priv->blur_hardness = hardness;
        }
@@ -738,6 +745,7 @@ gimp_brush_transform_pixmap (GimpBrush *brush,
                                                                scale,
                                                                aspect_ratio,
                                                                angle,
+                                                               reflect,
                                                                effective_hardness);
 
       if (op)
@@ -770,7 +778,7 @@ gimp_brush_transform_pixmap (GimpBrush *brush,
       gimp_brush_cache_add (brush->priv->pixmap_cache,
                             (gpointer) pixmap,
                             op, width, height,
-                            scale, aspect_ratio, angle, effective_hardness);
+                            scale, aspect_ratio, angle, reflect, effective_hardness);
     }
 
   return pixmap;
@@ -781,6 +789,7 @@ gimp_brush_transform_boundary (GimpBrush *brush,
                                gdouble    scale,
                                gdouble    aspect_ratio,
                                gdouble    angle,
+                               gboolean   reflect,
                                gdouble    hardness,
                                gint      *width,
                                gint      *height)
@@ -793,12 +802,12 @@ gimp_brush_transform_boundary (GimpBrush *brush,
   g_return_val_if_fail (height != NULL, NULL);
 
   gimp_brush_transform_size (brush,
-                             scale, aspect_ratio, angle,
+                             scale, aspect_ratio, angle, reflect,
                              width, height);
 
   boundary = gimp_brush_cache_get (brush->priv->boundary_cache,
                                    NULL, *width, *height,
-                                   scale, aspect_ratio, angle, hardness);
+                                   scale, aspect_ratio, angle, reflect, hardness);
 
   if (! boundary)
     {
@@ -806,6 +815,7 @@ gimp_brush_transform_boundary (GimpBrush *brush,
                                                                    scale,
                                                                    aspect_ratio,
                                                                    angle,
+                                                                   reflect,
                                                                    hardness,
                                                                    width,
                                                                    height);
@@ -820,7 +830,7 @@ gimp_brush_transform_boundary (GimpBrush *brush,
         gimp_brush_cache_add (brush->priv->boundary_cache,
                               (gpointer) boundary,
                               NULL, *width, *height,
-                              scale, aspect_ratio, angle, hardness);
+                              scale, aspect_ratio, angle, reflect, hardness);
     }
 
   return boundary;
diff --git a/app/core/gimpbrush.h b/app/core/gimpbrush.h
index 66ad4e6..aaa0c32 100644
--- a/app/core/gimpbrush.h
+++ b/app/core/gimpbrush.h
@@ -58,22 +58,26 @@ struct _GimpBrushClass
                                            gdouble           scale,
                                            gdouble           aspect_ratio,
                                            gdouble           angle,
+                                           gboolean          reflect,
                                            gint             *width,
                                            gint             *height);
   GimpTempBuf    * (* transform_mask)     (GimpBrush        *brush,
                                            gdouble           scale,
                                            gdouble           aspect_ratio,
                                            gdouble           angle,
+                                           gboolean          reflect,
                                            gdouble           hardness);
   GimpTempBuf    * (* transform_pixmap)   (GimpBrush        *brush,
                                            gdouble           scale,
                                            gdouble           aspect_ratio,
                                            gdouble           angle,
+                                           gboolean          reflect,
                                            gdouble           hardness);
   GimpBezierDesc * (* transform_boundary) (GimpBrush        *brush,
                                            gdouble           scale,
                                            gdouble           aspect_ratio,
                                            gdouble           angle,
+                                           gboolean          reflect,
                                            gdouble           hardness,
                                            gint             *width,
                                            gint             *height);
@@ -106,6 +110,7 @@ void                   gimp_brush_transform_size     (GimpBrush        *brush,
                                                       gdouble           scale,
                                                       gdouble           aspect_ratio,
                                                       gdouble           angle,
+                                                      gboolean          reflect,
                                                       gint             *width,
                                                       gint             *height);
 const GimpTempBuf    * gimp_brush_transform_mask     (GimpBrush        *brush,
@@ -113,17 +118,20 @@ const GimpTempBuf    * gimp_brush_transform_mask     (GimpBrush        *brush,
                                                       gdouble           scale,
                                                       gdouble           aspect_ratio,
                                                       gdouble           angle,
+                                                      gboolean          reflect,
                                                       gdouble           hardness);
 const GimpTempBuf    * gimp_brush_transform_pixmap   (GimpBrush        *brush,
                                                       GeglNode         *op,
                                                       gdouble           scale,
                                                       gdouble           aspect_ratio,
                                                       gdouble           angle,
+                                                      gboolean          reflect,
                                                       gdouble           hardness);
 const GimpBezierDesc * gimp_brush_transform_boundary (GimpBrush        *brush,
                                                       gdouble           scale,
                                                       gdouble           aspect_ratio,
                                                       gdouble           angle,
+                                                      gboolean          reflect,
                                                       gdouble           hardness,
                                                       gint             *width,
                                                       gint             *height);
diff --git a/app/core/gimpbrushcache.c b/app/core/gimpbrushcache.c
index 45ad497..ab7677a 100644
--- a/app/core/gimpbrushcache.c
+++ b/app/core/gimpbrushcache.c
@@ -51,6 +51,7 @@ struct _GimpBrushCacheUnit
   gdouble   scale;
   gdouble   aspect_ratio;
   gdouble   angle;
+  gboolean  reflect;
   gdouble   hardness;
   GeglNode *op;
 };
@@ -206,6 +207,7 @@ gimp_brush_cache_get (GimpBrushCache *cache,
                       gdouble         scale,
                       gdouble         aspect_ratio,
                       gdouble         angle,
+                      gboolean        reflect,
                       gdouble         hardness)
 {
   GList *iter;
@@ -222,6 +224,7 @@ gimp_brush_cache_get (GimpBrushCache *cache,
           unit->scale        == scale        &&
           unit->aspect_ratio == aspect_ratio &&
           unit->angle        == angle        &&
+          unit->reflect      == reflect      &&
           unit->hardness     == hardness     &&
           unit->op           == op)
         {
@@ -254,6 +257,7 @@ gimp_brush_cache_add (GimpBrushCache *cache,
                       gdouble         scale,
                       gdouble         aspect_ratio,
                       gdouble         angle,
+                      gboolean        reflect,
                       gdouble         hardness)
 {
   GList              *iter;
@@ -292,6 +296,7 @@ gimp_brush_cache_add (GimpBrushCache *cache,
   unit->scale        = scale;
   unit->aspect_ratio = aspect_ratio;
   unit->angle        = angle;
+  unit->reflect      = reflect;
   unit->hardness     = hardness;
   unit->op           = op;
 
diff --git a/app/core/gimpbrushcache.h b/app/core/gimpbrushcache.h
index 6fa48ec..ace68c3 100644
--- a/app/core/gimpbrushcache.h
+++ b/app/core/gimpbrushcache.h
@@ -68,6 +68,7 @@ gconstpointer    gimp_brush_cache_get      (GimpBrushCache *cache,
                                             gdouble         scale,
                                             gdouble         aspect_ratio,
                                             gdouble         angle,
+                                            gboolean        reflect,
                                             gdouble         hardness);
 void             gimp_brush_cache_add      (GimpBrushCache *cache,
                                             gpointer        data,
@@ -77,6 +78,7 @@ void             gimp_brush_cache_add      (GimpBrushCache *cache,
                                             gdouble         scale,
                                             gdouble         aspect_ratio,
                                             gdouble         angle,
+                                            gboolean        reflect,
                                             gdouble         hardness);
 
 
diff --git a/app/core/gimpbrushgenerated.c b/app/core/gimpbrushgenerated.c
index 78e06ac..5f679b6 100644
--- a/app/core/gimpbrushgenerated.c
+++ b/app/core/gimpbrushgenerated.c
@@ -71,12 +71,14 @@ static void          gimp_brush_generated_transform_size(GimpBrush    *gbrush,
                                                          gdouble       scale,
                                                          gdouble       aspect_ratio,
                                                          gdouble       angle,
+                                                         gboolean      reflect,
                                                          gint         *width,
                                                          gint         *height);
 static GimpTempBuf * gimp_brush_generated_transform_mask(GimpBrush    *gbrush,
                                                          gdouble       scale,
                                                          gdouble       aspect_ratio,
                                                          gdouble       angle,
+                                                         gboolean      reflect,
                                                          gdouble       hardness);
 
 static GimpTempBuf * gimp_brush_generated_calc          (GimpBrushGenerated      *brush,
@@ -86,6 +88,7 @@ static GimpTempBuf * gimp_brush_generated_calc          (GimpBrushGenerated
                                                          gfloat                   hardness,
                                                          gfloat                   aspect_ratio,
                                                          gfloat                   angle,
+                                                         gboolean                 reflect,
                                                          GimpVector2             *xaxis,
                                                          GimpVector2             *yaxis);
 static void          gimp_brush_generated_get_size      (GimpBrushGenerated      *gbrush,
@@ -95,6 +98,7 @@ static void          gimp_brush_generated_get_size      (GimpBrushGenerated
                                                          gfloat                   hardness,
                                                          gfloat                   aspect_ratio,
                                                          gdouble                  angle_in_degrees,
+                                                         gboolean                 reflect,
                                                          gint                    *width,
                                                          gint                    *height,
                                                          gdouble                 *_s,
@@ -264,6 +268,7 @@ gimp_brush_generated_dirty (GimpData *data)
                                                   brush->hardness,
                                                   brush->aspect_ratio,
                                                   brush->angle,
+                                                  FALSE,
                                                   &gbrush->priv->x_axis,
                                                   &gbrush->priv->y_axis);
 
@@ -303,6 +308,7 @@ gimp_brush_generated_transform_size (GimpBrush *gbrush,
                                      gdouble    scale,
                                      gdouble    aspect_ratio,
                                      gdouble    angle,
+                                     gboolean   reflect,
                                      gint      *width,
                                      gint      *height)
 {
@@ -329,6 +335,7 @@ gimp_brush_generated_transform_size (GimpBrush *gbrush,
                                  brush->hardness,
                                  ratio,
                                  angle,
+                                 reflect,
                                  width, height,
                                  NULL, NULL, NULL, NULL);
 }
@@ -338,6 +345,7 @@ gimp_brush_generated_transform_mask (GimpBrush *gbrush,
                                      gdouble    scale,
                                      gdouble    aspect_ratio,
                                      gdouble    angle,
+                                     gboolean   reflect,
                                      gdouble    hardness)
 {
   GimpBrushGenerated *brush  = GIMP_BRUSH_GENERATED (gbrush);
@@ -359,6 +367,7 @@ gimp_brush_generated_transform_mask (GimpBrush *gbrush,
   if (scale    == 1.0                 &&
       ratio    == brush->aspect_ratio &&
       angle    == brush->angle        &&
+      reflect  == FALSE               &&
       hardness == brush->hardness)
     {
       return gimp_temp_buf_copy (gimp_brush_get_mask (gbrush));
@@ -371,6 +380,7 @@ gimp_brush_generated_transform_mask (GimpBrush *gbrush,
                                     hardness,
                                     ratio,
                                     angle,
+                                    reflect,
                                     NULL, NULL);
 }
 
@@ -458,6 +468,7 @@ gimp_brush_generated_calc (GimpBrushGenerated      *brush,
                            gfloat                   hardness,
                            gfloat                   aspect_ratio,
                            gfloat                   angle,
+                           gboolean                 reflect,
                            GimpVector2             *xaxis,
                            GimpVector2             *yaxis)
 {
@@ -481,6 +492,7 @@ gimp_brush_generated_calc (GimpBrushGenerated      *brush,
                                  hardness,
                                  aspect_ratio,
                                  angle,
+                                 reflect,
                                  &width, &height,
                                  &s, &c, &x_axis, &y_axis);
 
@@ -573,6 +585,7 @@ gimp_brush_generated_get_size (GimpBrushGenerated      *gbrush,
                                gfloat                   hardness,
                                gfloat                   aspect_ratio,
                                gdouble                  angle_in_degrees,
+                               gboolean                 reflect,
                                gint                    *width,
                                gint                    *height,
                                gdouble                 *_s,
@@ -602,6 +615,9 @@ gimp_brush_generated_get_size (GimpBrushGenerated      *gbrush,
   s = sin (gimp_deg_to_rad (angle_in_degrees));
   c = cos (gimp_deg_to_rad (angle_in_degrees));
 
+  if (reflect)
+    c = -c;
+
   short_radius = radius / aspect_ratio;
 
   x_axis.x =        c * radius;
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index 8713707..ba33089 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -816,7 +816,8 @@ gimp_brush_core_get_paint_buffer (GimpPaintCore    *paint_core,
   gint           brush_width, brush_height;
 
   gimp_brush_transform_size (core->brush,
-                             core->scale, core->aspect_ratio, core->angle,
+                             core->scale, core->aspect_ratio,
+                             core->angle, core->reflect,
                              &brush_width, &brush_height);
 
   if (paint_width)
@@ -1402,6 +1403,7 @@ gimp_brush_core_transform_mask (GimpBrushCore *core,
                                     core->scale,
                                     core->aspect_ratio,
                                     core->angle,
+                                    core->reflect,
                                     core->hardness);
 
   if (mask == core->transform_brush)
@@ -1429,6 +1431,7 @@ gimp_brush_core_transform_pixmap (GimpBrushCore *core,
                                         core->scale,
                                         core->aspect_ratio,
                                         core->angle,
+                                        core->reflect,
                                         core->hardness);
 
   if (pixmap == core->transform_pixmap)
@@ -1511,8 +1514,9 @@ gimp_brush_core_eval_transform_dynamics (GimpBrushCore     *core,
   else
     core->scale = -1;
 
-  core->angle        = paint_options->brush_angle;
   core->aspect_ratio = paint_options->brush_aspect_ratio;
+  core->angle        = paint_options->brush_angle;
+  core->reflect      = FALSE;
   core->hardness     = paint_options->brush_hardness;
 
   if (! GIMP_IS_DYNAMICS (core->dynamics))
diff --git a/app/paint/gimpbrushcore.h b/app/paint/gimpbrushcore.h
index 6e04b0d..aa20a51 100644
--- a/app/paint/gimpbrushcore.h
+++ b/app/paint/gimpbrushcore.h
@@ -46,9 +46,10 @@ struct _GimpBrushCore
   GimpDynamics      *dynamics;
   gdouble            spacing;
   gdouble            scale;
+  gdouble            aspect_ratio;
   gdouble            angle;
+  gboolean           reflect;
   gdouble            hardness;
-  gdouble            aspect_ratio;
 
   /*  brush buffers  */
   GimpTempBuf       *pressure_brush;
diff --git a/app/paint/gimppaintoptions.c b/app/paint/gimppaintoptions.c
index 1707170..e44f4bd 100644
--- a/app/paint/gimppaintoptions.c
+++ b/app/paint/gimppaintoptions.c
@@ -996,7 +996,7 @@ gimp_paint_options_set_default_brush_size (GimpPaintOptions *paint_options,
       gint height;
       gint width;
 
-      gimp_brush_transform_size (brush, 1.0, 0.0, 0.0, &height, &width);
+      gimp_brush_transform_size (brush, 1.0, 0.0, 0.0, FALSE, &height, &width);
 
       g_object_set (paint_options,
                     "brush-size", (gdouble) MAX (height, width),
diff --git a/app/tools/gimpbrushtool.c b/app/tools/gimpbrushtool.c
index 7f93a98..f814cdd 100644
--- a/app/tools/gimpbrushtool.c
+++ b/app/tools/gimpbrushtool.c
@@ -284,6 +284,7 @@ gimp_brush_tool_create_outline (GimpBrushTool *brush_tool,
                                               brush_core->scale,
                                               brush_core->aspect_ratio,
                                               brush_core->angle,
+                                              brush_core->reflect,
                                               brush_core->hardness,
                                               &width,
                                               &height);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]