nss: upgrade to release 3.73
[LibreOffice.git] / vcl / source / bitmap / bitmapfilter.cxx
blob67744e71aa05f6891c507d82dfb25fa83c66df8c
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 #include <vcl/BitmapFilter.hxx>
12 #include <vcl/animate/Animation.hxx>
14 #include <sal/log.hxx>
16 BitmapFilter::BitmapFilter() {}
18 BitmapFilter::~BitmapFilter() {}
20 bool BitmapFilter::Filter(BitmapEx& rBmpEx, BitmapFilter const& rFilter)
22 if (rBmpEx.IsEmpty())
24 return true;
27 BitmapEx aTmpBmpEx(rFilter.execute(rBmpEx));
29 if (aTmpBmpEx.IsEmpty())
31 SAL_WARN("vcl.gdi", "Bitmap filter failed");
32 return false;
35 rBmpEx = aTmpBmpEx;
36 return true;
39 bool BitmapFilter::Filter(Animation& rAnimation, BitmapFilter const& rFilter)
41 SAL_WARN_IF(rAnimation.IsInAnimation(), "vcl", "Animation modified while it is animated");
43 bool bRet = false;
45 if (!rAnimation.IsInAnimation() && !rAnimation.Count())
47 bRet = true;
49 std::vector<std::unique_ptr<AnimationBitmap>>& aList = rAnimation.GetAnimationFrames();
50 for (size_t i = 0, n = aList.size(); (i < n) && bRet; ++i)
52 bRet = BitmapFilter::Filter(aList[i]->maBitmapEx, rFilter);
55 BitmapEx aBmpEx(rAnimation.GetBitmapEx());
56 BitmapFilter::Filter(aBmpEx, rFilter);
57 rAnimation.SetBitmapEx(aBmpEx);
60 return bRet;
63 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */