vcl/source/animate/Animation.cxx |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit e4f7dd75937e9f7eaf92c7e9e244a03a3f17f48d
Author:     Christopher Sherlock <chris.sherloc...@gmail.com>
AuthorDate: Sun Feb 23 14:49:19 2025 +1100
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Thu Feb 27 02:40:33 2025 +0100

    vcl: simplify Animation::Invert()
    
    Regardless of whether all the frames are inverted, the animation bitmap
    will always be inverted. Thus, we can invert the bitmap first, and then
    start inverting all the frames. This simplifies matters because we can
    just exit the function with a false return if the invert fails on any
    animation frame.
    
    Secondly, this allows us to convert to a for range loop.
    
    Change-Id: Ifa8152e9903bfc53634b67c8933b50915e7a194f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182050
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx
index f9738f10ff08..772a7d70526b 100644
--- a/vcl/source/animate/Animation.cxx
+++ b/vcl/source/animate/Animation.cxx
@@ -495,16 +495,15 @@ bool Animation::Invert()
     if (IsInAnimation() || maFrames.empty())
         return false;
 
-    bool bRet = true;
+    maBitmapEx.Invert();
 
-    for (size_t i = 0, n = maFrames.size(); (i < n) && bRet; ++i)
+    for (auto& pFrame : maFrames)
     {
-        bRet = maFrames[i]->maBitmapEx.Invert();
+        if (!pFrame->maBitmapEx.Invert())
+            return false;
     }
 
-    maBitmapEx.Invert();
-
-    return bRet;
+    return true;
 }
 
 void Animation::Mirror(BmpMirrorFlags nMirrorFlags)

Reply via email to