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



commit 4d2ce154008a248d77af1dc5c0680480c764d249
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.

 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 0a46e7c433..a6548c7cdf 100644
--- a/app/paint/gimppaintcore-loops.cc
+++ b/app/paint/gimppaintcore-loops.cc
@@ -329,6 +329,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
+  {
+  }
 };
 
 
@@ -1184,7 +1219,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
             {
@@ -1197,6 +1236,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]