include/vcl/outdev.hxx         |   11 +++++
 vcl/source/outdev/bitmapex.cxx |   78 +++++++++++++++++++++++++----------------
 2 files changed, 59 insertions(+), 30 deletions(-)

New commits:
commit d0e049200d75bcd7ea1a3a98c3c9146749785b03
Author:     Christopher Sherlock <[email protected]>
AuthorDate: Sat Nov 1 17:28:04 2025 +1100
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Wed Jan 21 10:21:30 2026 +0100

    vcl: extract draw bitmap functions
    
    Change-Id: I208a10fa492c943d66c123d9ccb25e890369da41
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193409
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    Tested-by: Jenkins

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index e78d6d3cfaec..9f8f1be9ae27 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1421,6 +1421,17 @@ protected:
                                     double &fMaximumArea);
 
 private:
+
+    SAL_DLLPRIVATE void         DrawScaledAndTranslatedBitmap(
+                                    const basegfx::B2DVector& rScale,
+                                    const basegfx::B2DVector& rTranslate,
+                                    const Bitmap& rBitmap);
+
+    SAL_DLLPRIVATE void         DrawMirroredBitmap(
+                                    const basegfx::B2DVector& rScale,
+                                    const basegfx::B2DVector& rTranslate,
+                                    const Bitmap& rBitmap);
+
     SAL_DLLPRIVATE void         DrawAlphaBitmap(
                                     const Point& rDestPt,
                                     const Size& rDestSize,
diff --git a/vcl/source/outdev/bitmapex.cxx b/vcl/source/outdev/bitmapex.cxx
index 835c860ec176..835e1a933464 100644
--- a/vcl/source/outdev/bitmapex.cxx
+++ b/vcl/source/outdev/bitmapex.cxx
@@ -139,6 +139,51 @@ struct LocalTimeTest
 };
 #endif
 
+void OutputDevice::DrawScaledAndTranslatedBitmap(
+        const basegfx::B2DVector& rScale, const basegfx::B2DVector& rTranslate,
+        const Bitmap& rBitmap)
+{
+    // with no rotation, shear or mirroring it can be mapped to DrawBitmap
+    // do *not* execute the mirroring here, it's done in the fallback
+    // #i124580# the correct DestSize needs to be calculated based on MaxXY 
values
+    Point aDestPt(basegfx::fround<tools::Long>(rTranslate.getX()), 
basegfx::fround<tools::Long>(rTranslate.getY()));
+
+    const Size aDestSize(
+        basegfx::fround<tools::Long>(rScale.getX() + rTranslate.getX()) - 
aDestPt.X(),
+        basegfx::fround<tools::Long>(rScale.getY() + rTranslate.getY()) - 
aDestPt.Y());
+
+    const Point aOrigin = GetMapMode().GetOrigin();
+
+    if (!mpMetaFile && comphelper::LibreOfficeKit::isActive() && 
GetMapMode().GetMapUnit() != MapUnit::MapPixel)
+    {
+        aDestPt.Move(aOrigin.getX(), aOrigin.getY());
+        EnableMapMode(false);
+    }
+
+    DrawBitmap(aDestPt, aDestSize, rBitmap);
+    if (!mpMetaFile && comphelper::LibreOfficeKit::isActive() && 
GetMapMode().GetMapUnit() != MapUnit::MapPixel)
+    {
+        EnableMapMode();
+        aDestPt.Move(-aOrigin.getX(), -aOrigin.getY());
+    }
+    return;
+}
+
+void OutputDevice::DrawMirroredBitmap(
+        const basegfx::B2DVector& rScale, const basegfx::B2DVector& rTranslate,
+        const Bitmap& rBitmap)
+{
+    // with no rotation or shear it can be mapped to DrawBitmap
+    // do *not* execute the mirroring here, it's done in the fallback
+    // #i124580# the correct DestSize needs to be calculated based on MaxXY 
values
+    const Point aDestPt(basegfx::fround<tools::Long>(rTranslate.getX()), 
basegfx::fround<tools::Long>(rTranslate.getY()));
+    const Size aDestSize(
+        basegfx::fround<tools::Long>(rScale.getX() + rTranslate.getX()) - 
aDestPt.X(),
+        basegfx::fround<tools::Long>(rScale.getY() + rTranslate.getY()) - 
aDestPt.Y());
+
+    DrawBitmap(aDestPt, aDestSize, rBitmap);
+}
+
 void OutputDevice::DrawTransformedBitmapEx(
     const basegfx::B2DHomMatrix& rTransformation,
     const Bitmap& rBitmap,
@@ -229,28 +274,9 @@ void OutputDevice::DrawTransformedBitmapEx(
     const bool bMirroredX(aScale.getX() < 0.0);
     const bool bMirroredY(aScale.getY() < 0.0);
 
-    if(!bRotated && !bSheared && !bMirroredX && !bMirroredY)
+    if (!bRotated && !bSheared && !bMirroredX && !bMirroredY)
     {
-        // with no rotation, shear or mirroring it can be mapped to DrawBitmap
-        // do *not* execute the mirroring here, it's done in the fallback
-        // #i124580# the correct DestSize needs to be calculated based on 
MaxXY values
-        Point aDestPt(basegfx::fround<tools::Long>(aTranslate.getX()), 
basegfx::fround<tools::Long>(aTranslate.getY()));
-        const Size aDestSize(
-            basegfx::fround<tools::Long>(aScale.getX() + aTranslate.getX()) - 
aDestPt.X(),
-            basegfx::fround<tools::Long>(aScale.getY() + aTranslate.getY()) - 
aDestPt.Y());
-        const Point aOrigin = GetMapMode().GetOrigin();
-        if (!mpMetaFile && comphelper::LibreOfficeKit::isActive() && 
GetMapMode().GetMapUnit() != MapUnit::MapPixel)
-        {
-            aDestPt.Move(aOrigin.getX(), aOrigin.getY());
-            EnableMapMode(false);
-        }
-
-        DrawBitmap(aDestPt, aDestSize, bitmap);
-        if (!mpMetaFile && comphelper::LibreOfficeKit::isActive() && 
GetMapMode().GetMapUnit() != MapUnit::MapPixel)
-        {
-            EnableMapMode();
-            aDestPt.Move(-aOrigin.getX(), -aOrigin.getY());
-        }
+        DrawScaledAndTranslatedBitmap(aScale, aTranslate, bitmap);
         return;
     }
 
@@ -261,15 +287,7 @@ void OutputDevice::DrawTransformedBitmapEx(
     // take the fallback when no rotate and shear, but mirror (else we would 
have done this above)
     if(!bRotated && !bSheared)
     {
-        // with no rotation or shear it can be mapped to DrawBitmap
-        // do *not* execute the mirroring here, it's done in the fallback
-        // #i124580# the correct DestSize needs to be calculated based on 
MaxXY values
-        const Point aDestPt(basegfx::fround<tools::Long>(aTranslate.getX()), 
basegfx::fround<tools::Long>(aTranslate.getY()));
-        const Size aDestSize(
-            basegfx::fround<tools::Long>(aScale.getX() + aTranslate.getX()) - 
aDestPt.X(),
-            basegfx::fround<tools::Long>(aScale.getY() + aTranslate.getY()) - 
aDestPt.Y());
-
-        DrawBitmap(aDestPt, aDestSize, bitmap);
+        DrawMirroredBitmap(aScale, aTranslate, bitmap);
         return;
     }
 

Reply via email to