Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / vcl / BitmapFilter.hxx
blobc19d83b2d507bb7b98ab6fbb2bbbb3c737391428
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #ifndef INCLUDED_VCL_BITMAPFILTER_HXX
12 #define INCLUDED_VCL_BITMAPFILTER_HXX
14 #include <vcl/bitmapex.hxx>
15 #include <functional>
17 class Animation;
19 namespace vcl::bitmap
21 // Generates strip ranges and run the input function with the start and
22 // end as parameters. The additional parameter bLast denotes if the
23 // iteration is the last one.
25 // Example:
26 // first = 0, last = 100, STRIP_SIZE = 32
27 // this will generate:
28 // [0, 31, false], [32, 63, false], [64, 95, false], [96, 100, true]
29 template <int STRIP_SIZE>
30 void generateStripRanges(
31 tools::Long nFirst, tools::Long nLast,
32 std::function<void(tools::Long const nStart, tools::Long const nEnd, bool const bLast)>
33 aFunction)
35 tools::Long nStart = nFirst;
36 for (; nStart < nLast - STRIP_SIZE; nStart += STRIP_SIZE)
38 tools::Long nEnd = nStart + STRIP_SIZE - 1;
39 aFunction(nStart, nEnd, false);
41 aFunction(nStart, nLast, true);
44 } // end vcl::bitmap
46 class VCL_DLLPUBLIC BitmapFilter
48 public:
49 BitmapFilter();
50 virtual ~BitmapFilter();
52 virtual BitmapEx execute(BitmapEx const& rBitmapEx) const = 0;
54 static bool Filter(BitmapEx& rBmpEx, BitmapFilter const& rFilter);
55 static bool Filter(Animation& rBmpEx, BitmapFilter const& rFilter);
58 #endif
60 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */