include/vcl/outdev.hxx         |    7 +++++++
 vcl/source/outdev/bitmapex.cxx |   20 ++++++++++++++++++++
 vcl/source/outdev/textline.cxx |   22 +++++++---------------
 3 files changed, 34 insertions(+), 15 deletions(-)

New commits:
commit e4c797af09f6362c915cbe63a23bc785b522692c
Author:     Noel Grandin <[email protected]>
AuthorDate: Sun Jul 27 13:17:29 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Mon Jul 28 14:57:21 2025 +0200

    BitmapEx->Bitmap in WavyLineCache
    
    now that Bitmap can handle transparency
    
    Change-Id: Ie72ee76c1c3e2613254f2ac744aa63909f58cb1f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188442
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index af90516add7e..1b4ad3210631 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1333,6 +1333,13 @@ public:
                                     const Point& rSrcPtPixel,
                                     const Size& rSrcSizePixel,
                                     const BitmapEx& rBitmapEx);
+    // draw bitmap (potentially with alpha)
+    void                        DrawBitmapEx(
+                                    const Point& rDestPt,
+                                    const Size& rDestSize,
+                                    const Point& rSrcPtPixel,
+                                    const Size& rSrcSizePixel,
+                                    const Bitmap& rBitmap);
 
     SAL_DLLPRIVATE void         DrawBitmapEx(
                                     const Point& rDestPt,
diff --git a/vcl/source/outdev/bitmapex.cxx b/vcl/source/outdev/bitmapex.cxx
index 2957cc4ea5e8..1fc131575595 100644
--- a/vcl/source/outdev/bitmapex.cxx
+++ b/vcl/source/outdev/bitmapex.cxx
@@ -123,6 +123,26 @@ void OutputDevice::DrawBitmapEx( const Point& rDestPt, 
const Size& rDestSize,
                  MetaActionType::BMPEXSCALEPART);
 }
 
+void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
+                                 const Point& rSrcPtPixel, const Size& 
rSrcSizePixel,
+                                 const Bitmap& rBitmap)
+{
+    assert(!is_double_buffered_window());
+
+    if( ImplIsRecordLayout() )
+        return;
+
+    if ( !rBitmap.HasAlpha() )
+    {
+        DrawBitmap(rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel,
+                   rBitmap);
+        return;
+    }
+
+    DrawBitmapEx(rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, rBitmap,
+                 MetaActionType::BMPEXSCALEPART);
+}
+
 void OutputDevice::DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
                                  const Point& rSrcPtPixel, const Size& 
rSrcSizePixel,
                                  const BitmapEx& rBitmapEx, const 
MetaActionType nAction )
diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx
index 957f950dda8e..460c3f0118dc 100644
--- a/vcl/source/outdev/textline.cxx
+++ b/vcl/source/outdev/textline.cxx
@@ -52,7 +52,7 @@ namespace {
         {
         }
 
-        bool find( Color aLineColor, size_t nLineWidth, size_t nWaveHeight, 
size_t nWordWidth, BitmapEx& rOutput )
+        bool find( Color aLineColor, size_t nLineWidth, size_t nWaveHeight, 
size_t nWordWidth, Bitmap& rOutput )
         {
             Key aKey = { nWaveHeight, sal_uInt32(aLineColor) };
             auto item = m_aItems.find( aKey );
@@ -67,7 +67,7 @@ namespace {
             return true;
         }
 
-        void insert( const BitmapEx& aBitmap, const Color& aLineColor, const 
size_t nLineWidth, const size_t nWaveHeight, const size_t nWordWidth, BitmapEx& 
rOutput )
+        void insert( const Bitmap& aBitmap, const Color& aLineColor, const 
size_t nLineWidth, const size_t nWaveHeight, const size_t nWordWidth, Bitmap& 
rOutput )
         {
             Key aKey = { nWaveHeight, sal_uInt32(aLineColor) };
             m_aItems.insert( std::pair< Key, WavyLineCacheItem>( aKey, { 
nLineWidth, nWordWidth, aBitmap } ) );
@@ -93,7 +93,7 @@ namespace {
         {
             size_t m_aLineWidth;
             size_t m_aWordWidth;
-            BitmapEx m_Bitmap;
+            Bitmap m_Bitmap;
         };
 
         struct Key
@@ -1063,7 +1063,7 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, 
const Point& rEndPos, to
         if ( !snLineCache.get() )
             return;
         WavyLineCache& rLineCache = *snLineCache.get();
-        BitmapEx aWavylinebmp;
+        Bitmap aWavylinebmp;
         if ( !rLineCache.find( GetLineColor(), nLineWidth, nWaveHeight, nEndX 
- nStartX, aWavylinebmp ) )
         {
             size_t nWordLength = nEndX - nStartX;
@@ -1076,19 +1076,11 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, 
const Point& rEndPos, to
             pVirtDev->Erase();
             pVirtDev->SetAntialiasing( AntialiasingFlags::Enable );
             pVirtDev->ImplDrawWaveLineBezier( 0, 0, nWordLength, 0, 
nWaveHeight, fOrientation, nLineWidth );
-            BitmapEx aBitmapEx(pVirtDev->GetBitmap(Point(0, 0), 
pVirtDev->GetOutputSize()));
+            Bitmap aBitmap(pVirtDev->GetBitmap(Point(0, 0), 
pVirtDev->GetOutputSize()));
 
-            // Ideally we don't need this block, but in the split rgb surface 
+ separate alpha surface
-            // with Antialiasing enabled and the svp/cairo backend we get both 
surfaces antialiased
-            // so their combination of aliases merge to overly wash-out the 
color. Hack it by taking just
-            // the alpha surface and use it to blend the original solid line 
color
-            Bitmap aSolidColor(aBitmapEx.GetBitmap());
-            aSolidColor.Erase(GetLineColor());
-            aBitmapEx = BitmapEx(aSolidColor, aBitmapEx.GetAlphaMask());
-
-            rLineCache.insert( aBitmapEx, GetLineColor(), nLineWidth, 
nWaveHeight, nWordLength, aWavylinebmp );
+            rLineCache.insert( aBitmap, GetLineColor(), nLineWidth, 
nWaveHeight, nWordLength, aWavylinebmp );
         }
-        if ( aWavylinebmp.ImplGetBitmapSalBitmap() != nullptr )
+        if ( aWavylinebmp.ImplGetSalBitmap() != nullptr )
         {
             Size _size( nEndX - nStartX, aWavylinebmp.GetSizePixel().Height() 
);
             DrawBitmapEx(Point( rStartPos.X(), rStartPos.Y() ), PixelToLogic( 
_size ), Point(), _size, aWavylinebmp);

Reply via email to