diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-07-01 15:57:15 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-07-05 23:17:16 +0200 |
commit | 8166f340511f49c91deba161f27d9ded11a14e14 (patch) | |
tree | c5d074d5c41cf63ee8d70c6f5cb83547b1b4a9eb /include | |
parent | b945946135cb302c1805fdf6502e02dbdf52b813 (diff) |
add generateStripRanges and use that in StackBlur and ScaleSuper
generateStripRanges divides a range into equally long stripes that
is useful for defining scanlines for a thread. This is used in
the BitmapFilterStackBlur and BitmapScaleSuperFilter as they are
running using a thread pool.
Change-Id: Ifb9f70dea3b0233e6aa30ccf20187a2ff58fd5a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97725
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/vcl/BitmapFilter.hxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/vcl/BitmapFilter.hxx b/include/vcl/BitmapFilter.hxx index 19599d06316f..0521ded42357 100644 --- a/include/vcl/BitmapFilter.hxx +++ b/include/vcl/BitmapFilter.hxx @@ -12,8 +12,36 @@ #define INCLUDED_VCL_BITMAPFILTER_HXX #include <vcl/bitmapex.hxx> +#include <functional> + class Animation; +namespace vcl::bitmap +{ +// Generates strip ranges and run the input function with the start and +// end as parameters. The additional parameter bLast denotes if the +// iteration is teh last one. +// +// Example: +// first = 0, last = 100, STRIP_SIZE = 32 +// this will generate: +// [0, 31, false], [32, 63, false], [64, 95, false], [96, 100, true] +template <int STRIP_SIZE> +void generateStripRanges( + long nFirst, long nLast, + std::function<void(long const nStart, long const nEnd, bool const bLast)> aFunction) +{ + long nStart = nFirst; + for (; nStart < nLast - STRIP_SIZE; nStart += STRIP_SIZE) + { + long nEnd = nStart + STRIP_SIZE - 1; + aFunction(nStart, nEnd, false); + } + aFunction(nStart, nLast, true); +} + +} // end vcl::bitmap + class VCL_DLLPUBLIC BitmapFilter { public: |