[gimp/gimp-2-10] app: in gimppaintcore-loops, add finalize[_step]() algorithm functions



commit 197ec919cdeca6a6611ac0367565e0b53f952d74
Author: Ell <ell_se yahoo com>
Date:   Mon Feb 11 13:56:01 2019 -0500

    app: in gimppaintcore-loops, add finalize[_step]() algorithm functions
    
    In gimppaintcore-loops, add finalize() and finalize_step()
    algorithm functions, which get called at the end of processing the
    entire area, and at the end of processing each chunk, respectively.
    Algorithms can use these functions to clean up allocated resources.
    
    (cherry picked from commit 4d2ce154008a248d77af1dc5c0680480c764d249)

 app/paint/gimppaintcore-loops.cc | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
---
diff --git a/app/paint/gimppaintcore-loops.cc b/app/paint/gimppaintcore-loops.cc
index 74745a5eb7..604943daee 100644
--- a/app/paint/gimppaintcore-loops.cc
+++ b/app/paint/gimppaintcore-loops.cc
@@ -327,6 +327,41 @@ struct AlgorithmBase
                gint                            y) const
   {
   }
+
+  /* The 'finalize_step()' function is called once per chunk after its
+   * processing is done, and should finalize any chunk-specific resources of
+   * the state object.
+   *
+   * 'params' is the same parameter struct passed to the constructor.  'state'
+   * is the state object.
+   *
+   * An algorithm that overrides this function should call the
+   * 'finalize_step()' function of its base class after performing its own
+   * finalization, using the same arguments.
+   */
+  template <class Derived>
+  void
+  finalize_step (const GimpPaintCoreLoopsParams *params,
+                 State<Derived>                 *state) const
+  {
+  }
+
+  /* The 'finalize()' function is called once per state object after processing
+   * is done, and should finalize the state object.
+   *
+   * 'params' is the same parameter struct passed to the constructor.  'state'
+   * is the state object.
+   *
+   * An algorithm that overrides this function should call the 'finalize()'
+   * function of its base class after performing its own finalization, using
+   * the same arguments.
+   */
+  template <class Derived>
+  void
+  finalize (const GimpPaintCoreLoopsParams *params,
+            State<Derived>                 *state) const
+  {
+  }
 };
 
 
@@ -1182,7 +1217,11 @@ gimp_paint_core_loops_process (const GimpPaintCoreLoopsParams *params,
                                              iter, &roi, area, rect,
                                              rect->y + y);
                     }
+
+                  algorithm.finalize_step (params, &state);
                 }
+
+              algorithm.finalize (params, &state);
             }
           else
             {
@@ -1195,6 +1234,9 @@ gimp_paint_core_loops_process (const GimpPaintCoreLoopsParams *params,
                                          NULL, &roi, area, area,
                                          area->y + y);
                 }
+
+              algorithm.finalize_step (params, &state);
+              algorithm.finalize      (params, &state);
             }
         });
     },


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