vcl/source/bitmap/bitmappaint.cxx |   54 +++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 29 deletions(-)

New commits:
commit 0bfe57f50b79362ab1167388ba95c8f0bf988c4f
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Jul 3 11:25:02 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Jul 3 13:48:03 2023 +0200

    fix assert when using skia and DBG_UTIL
    
    after
        commit 72f2de04a23680fcb75cf5bc89b3422f9e89cdef
        Author: Noel Grandin <noel.gran...@collabora.co.uk>
        Date:   Fri Jun 30 15:02:16 2023 +0200
        optimised Skia Invert() operation
    
    Change-Id: I173b5a4693d4aefff82c45059874ee21b1e93996
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153872
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/source/bitmap/bitmappaint.cxx 
b/vcl/source/bitmap/bitmappaint.cxx
index 7701af429ef6..55ad22bea1b8 100644
--- a/vcl/source/bitmap/bitmappaint.cxx
+++ b/vcl/source/bitmap/bitmappaint.cxx
@@ -60,46 +60,42 @@ bool Bitmap::Erase(const Color& rFillColor)
 
 bool Bitmap::Invert()
 {
-    BitmapScopedWriteAccess pAcc(*this);
-    bool bRet = false;
+    ScopedReadAccess pReadAcc(*this);
 
-    if (pAcc)
+    if (pReadAcc->HasPalette())
     {
-        if (pAcc->HasPalette())
+        BitmapScopedWriteAccess pWriteAcc(*this);
+        BitmapPalette aBmpPal(pWriteAcc->GetPalette());
+        const sal_uInt16 nCount = aBmpPal.GetEntryCount();
+
+        for (sal_uInt16 i = 0; i < nCount; i++)
         {
-            BitmapPalette aBmpPal(pAcc->GetPalette());
-            const sal_uInt16 nCount = aBmpPal.GetEntryCount();
+            aBmpPal[i].Invert();
+        }
 
-            for (sal_uInt16 i = 0; i < nCount; i++)
-            {
-                aBmpPal[i].Invert();
-            }
+        pWriteAcc->SetPalette(aBmpPal);
+    }
+    else if (!mxSalBmp->Invert()) // try optimised call first
+    {
+        BitmapScopedWriteAccess pWriteAcc(*this);
+        const tools::Long nWidth = pWriteAcc->Width();
+        const tools::Long nHeight = pWriteAcc->Height();
 
-            pAcc->SetPalette(aBmpPal);
-        }
-        else if (!mxSalBmp->Invert()) // try optimised call first
+        for (tools::Long nY = 0; nY < nHeight; nY++)
         {
-            const tools::Long nWidth = pAcc->Width();
-            const tools::Long nHeight = pAcc->Height();
-
-            for (tools::Long nY = 0; nY < nHeight; nY++)
+            Scanline pScanline = pWriteAcc->GetScanline(nY);
+            for (tools::Long nX = 0; nX < nWidth; nX++)
             {
-                Scanline pScanline = pAcc->GetScanline(nY);
-                for (tools::Long nX = 0; nX < nWidth; nX++)
-                {
-                    BitmapColor aBmpColor = pAcc->GetPixelFromData(pScanline, 
nX);
-                    aBmpColor.Invert();
-                    pAcc->SetPixelOnData(pScanline, nX, aBmpColor);
-                }
+                BitmapColor aBmpColor = pWriteAcc->GetPixelFromData(pScanline, 
nX);
+                aBmpColor.Invert();
+                pWriteAcc->SetPixelOnData(pScanline, nX, aBmpColor);
             }
         }
-
-        mxSalBmp->InvalidateChecksum();
-        pAcc.reset();
-        bRet = true;
     }
 
-    return bRet;
+    mxSalBmp->InvalidateChecksum();
+
+    return true;
 }
 
 namespace

Reply via email to