[gimp/soc-2011-seamless-clone2] app: port smudge blending to RGBA float



commit 5c5df032e63de9bdb9f146b71e40ab0854b499c1
Author: Michael Natterer <mitch gimp org>
Date:   Sat Dec 8 22:16:05 2012 +0100

    app: port smudge blending to RGBA float

 app/gegl/gimp-gegl-loops.c |   32 ++++++++++++++++----------------
 app/gegl/gimp-gegl-loops.h |    2 +-
 app/paint/gimpsmudge.c     |    4 ++--
 3 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-loops.c b/app/gegl/gimp-gegl-loops.c
index 7d72da6..2085313 100644
--- a/app/gegl/gimp-gegl-loops.c
+++ b/app/gegl/gimp-gegl-loops.c
@@ -340,38 +340,38 @@ gimp_gegl_smudge_blend (GeglBuffer          *top_buffer,
                         const GeglRectangle *bottom_rect,
                         GeglBuffer          *dest_buffer,
                         const GeglRectangle *dest_rect,
-                        guchar               blend)
+                        gdouble              blend)
 {
   GeglBufferIterator *iter;
 
   iter = gegl_buffer_iterator_new (top_buffer, top_rect, 0,
-                                   babl_format ("R'G'B'A u8"),
+                                   babl_format ("RGBA float"),
                                    GEGL_BUFFER_READ, GEGL_ABYSS_NONE);
 
   gegl_buffer_iterator_add (iter, bottom_buffer, bottom_rect, 0,
-                            babl_format ("R'G'B'A u8"),
+                            babl_format ("RGBA float"),
                             GEGL_BUFFER_READ, GEGL_ABYSS_NONE);
 
   gegl_buffer_iterator_add (iter, dest_buffer, dest_rect, 0,
-                            babl_format ("R'G'B'A u8"),
+                            babl_format ("RGBA float"),
                             GEGL_BUFFER_WRITE, GEGL_ABYSS_NONE);
 
   while (gegl_buffer_iterator_next (iter))
     {
-      const guchar *top    = iter->data[0];
-      const guchar *bottom = iter->data[1];
-      guchar       *dest   = iter->data[2];
-      const guint   blend1 = 255 - blend;
-      const guint   blend2 = blend + 1;
+      const gfloat *top    = iter->data[0];
+      const gfloat *bottom = iter->data[1];
+      gfloat       *dest   = iter->data[2];
+      const gfloat  blend1 = 1.0 - blend;
+      const gfloat  blend2 = blend;
 
       while (iter->length--)
         {
-          const gint  a1 = blend1 * bottom[3];
-          const gint  a2 = blend2 * top[3];
-          const gint  a  = a1 + a2;
-          guint       b;
+          const gfloat a1 = blend1 * bottom[3];
+          const gfloat a2 = blend2 * top[3];
+          const gfloat a  = a1 + a2;
+          gint         b;
 
-          if (!a)
+          if (a == 0)
             {
               for (b = 0; b < 4; b++)
                 dest[b] = 0;
@@ -380,9 +380,9 @@ gimp_gegl_smudge_blend (GeglBuffer          *top_buffer,
             {
               for (b = 0; b < 3; b++)
                 dest[b] =
-                  bottom[b] + (bottom[b] * a1 + top[b] * a2 - a * bottom[b]) / a;
+                  bottom[b] + (bottom[b] * a1 + top[b] * a2 - a * bottom[b]);
 
-              dest[3] = a >> 8;
+              dest[3] = a;
             }
 
           top    += 4;
diff --git a/app/gegl/gimp-gegl-loops.h b/app/gegl/gimp-gegl-loops.h
index d1fb935..f166967 100644
--- a/app/gegl/gimp-gegl-loops.h
+++ b/app/gegl/gimp-gegl-loops.h
@@ -49,7 +49,7 @@ void   gimp_gegl_smudge_blend       (GeglBuffer          *top_buffer,
                                      const GeglRectangle *bottom_rect,
                                      GeglBuffer          *dest_buffer,
                                      const GeglRectangle *dest_rect,
-                                     guchar               blend);
+                                     gdouble              blend);
 
 void   gimp_gegl_apply_mask         (GeglBuffer          *mask_buffer,
                                      const GeglRectangle *mask_rect,
diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c
index eeb3d73..a93d546 100644
--- a/app/paint/gimpsmudge.c
+++ b/app/paint/gimpsmudge.c
@@ -179,7 +179,7 @@ gimp_smudge_start (GimpPaintCore    *paint_core,
   smudge->accum_buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
                                                           accum_size,
                                                           accum_size),
-                                          gimp_drawable_get_format (drawable));
+                                          babl_format ("RGBA float"));
 
   /*  adjust the x and y coordinates to the upper left corner of the
    *  accumulator
@@ -304,7 +304,7 @@ gimp_smudge_motion (GimpPaintCore    *paint_core,
                                           paint_buffer_y - y,
                                           paint_buffer_width,
                                           paint_buffer_height),
-                          ROUND (rate * 255.0));
+                          rate);
 
   gegl_buffer_copy (smudge->accum_buffer,
                     GEGL_RECTANGLE (paint_buffer_x - x,


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