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.
This commit is contained in:
Ell 2019-02-11 13:56:01 -05:00
parent 0d1f724112
commit 4d2ce15400
1 changed files with 42 additions and 0 deletions

View File

@ -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);
}
});
},