[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source

Caolán McNamara caolanm at redhat.com
Tue Feb 16 16:03:33 UTC 2016


 include/vcl/bitmap.hxx       |   17 ++----
 include/vcl/bitmapex.hxx     |    4 -
 vcl/inc/impbmp.hxx           |    5 -
 vcl/source/gdi/bitmap.cxx    |  120 +++++++++++++------------------------------
 vcl/source/gdi/bitmap3.cxx   |   32 +++--------
 vcl/source/gdi/bmpacc.cxx    |   37 ++++++-------
 vcl/source/gdi/impbmp.cxx    |   10 +--
 vcl/source/outdev/bitmap.cxx |   12 ++--
 vcl/source/outdev/mask.cxx   |    8 +-
 9 files changed, 90 insertions(+), 155 deletions(-)

New commits:
commit 3cdb86054c09617cea85dfc24ecbaf9cba376d7b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Feb 16 10:39:28 2016 +0000

    use std shared_ptr for sharing ImpBitmaps
    
    Change-Id: I1a0360096964f6402bd3631f2b3f34bf9595ebc6
    Reviewed-on: https://gerrit.libreoffice.org/22394
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index 58fde12..e45c8f0 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -716,10 +716,9 @@ public:
 
 public:
 
-    SAL_DLLPRIVATE void     ImplReleaseRef();
     SAL_DLLPRIVATE void     ImplMakeUnique();
-    ImpBitmap*              ImplGetImpBitmap() const { return mpImpBmp;}
-    SAL_DLLPRIVATE void     ImplSetImpBitmap( ImpBitmap* pImpBmp );
+    std::shared_ptr<ImpBitmap> ImplGetImpBitmap() const { return mxImpBmp;}
+    SAL_DLLPRIVATE void     ImplSetImpBitmap( std::shared_ptr<ImpBitmap> xImpBmp );
     SAL_DLLPRIVATE void     ImplAssignWithSize( const Bitmap& rBitmap );
 
     SAL_DLLPRIVATE void     ImplAdaptBitCount(Bitmap& rNew) const;
@@ -787,7 +786,7 @@ public:
 
 private:
 
-    ImpBitmap*              mpImpBmp;
+    std::shared_ptr<ImpBitmap> mxImpBmp;
     MapMode                 maPrefMapMode;
     Size                    maPrefSize;
 
@@ -795,27 +794,27 @@ private:
 
 inline bool Bitmap::operator!() const
 {
-    return( mpImpBmp == nullptr );
+    return( mxImpBmp == nullptr );
 }
 
 inline bool Bitmap::operator==( const Bitmap& rBitmap ) const
 {
-    return( rBitmap.mpImpBmp == mpImpBmp );
+    return( rBitmap.mxImpBmp == mxImpBmp );
 }
 
 inline bool Bitmap::operator!=( const Bitmap& rBitmap ) const
 {
-    return( rBitmap.mpImpBmp != mpImpBmp );
+    return( rBitmap.mxImpBmp != mxImpBmp );
 }
 
 inline bool Bitmap::IsSameInstance( const Bitmap& rBitmap ) const
 {
-    return( rBitmap.mpImpBmp == mpImpBmp );
+    return( rBitmap.mxImpBmp == mxImpBmp );
 }
 
 inline bool Bitmap::IsEmpty() const
 {
-    return( mpImpBmp == nullptr );
+    return( mxImpBmp == nullptr );
 }
 
 inline const MapMode& Bitmap::GetPrefMapMode() const
diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx
index 1e8511c..a4dea75 100644
--- a/include/vcl/bitmapex.hxx
+++ b/include/vcl/bitmapex.hxx
@@ -445,8 +445,8 @@ public:
                             const Size &rSize );
 public:
 
-    SAL_DLLPRIVATE  ImpBitmap*  ImplGetBitmapImpBitmap() const { return aBitmap.ImplGetImpBitmap(); }
-    SAL_DLLPRIVATE  ImpBitmap*  ImplGetMaskImpBitmap() const { return aMask.ImplGetImpBitmap(); }
+    SAL_DLLPRIVATE  std::shared_ptr<ImpBitmap>  ImplGetBitmapImpBitmap() const { return aBitmap.ImplGetImpBitmap(); }
+    SAL_DLLPRIVATE  std::shared_ptr<ImpBitmap>  ImplGetMaskImpBitmap() const { return aMask.ImplGetImpBitmap(); }
 
 
 private:
diff --git a/vcl/inc/impbmp.hxx b/vcl/inc/impbmp.hxx
index 5787b3f..4d365a7 100644
--- a/vcl/inc/impbmp.hxx
+++ b/vcl/inc/impbmp.hxx
@@ -37,7 +37,6 @@ class Bitmap;
 class ImpBitmap
 {
 private:
-    sal_uLong           mnRefCount;
     SalBitmap*          mpSalBitmap;
 
 public:
@@ -63,10 +62,6 @@ public:
     BitmapBuffer*       ImplAcquireBuffer( BitmapAccessMode nMode );
     void                ImplReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode );
 
-    sal_uLong           ImplGetRefCount() const { return mnRefCount; }
-    void                ImplIncRefCount() { mnRefCount++; }
-    void                ImplDecRefCount() { mnRefCount--; }
-
     BitmapChecksum      ImplGetChecksum() const;
     void                ImplInvalidateChecksum();
 
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index f182eb2..89369ca 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -34,13 +34,11 @@
 #include <salbmp.hxx>
 #include <memory>
 
-Bitmap::Bitmap() :
-    mpImpBmp( nullptr )
+Bitmap::Bitmap()
 {
 }
 
-Bitmap::Bitmap( const ResId& rResId ) :
-    mpImpBmp( nullptr )
+Bitmap::Bitmap( const ResId& rResId )
 {
     const BitmapEx aBmpEx( rResId );
 
@@ -48,26 +46,23 @@ Bitmap::Bitmap( const ResId& rResId ) :
         *this = aBmpEx.GetBitmap();
 }
 
-Bitmap::Bitmap( const Bitmap& rBitmap ) :
-    maPrefMapMode   ( rBitmap.maPrefMapMode ),
-    maPrefSize      ( rBitmap.maPrefSize )
+Bitmap::Bitmap(const Bitmap& rBitmap)
+    : mxImpBmp(rBitmap.mxImpBmp)
+    , maPrefMapMode(rBitmap.maPrefMapMode)
+    , maPrefSize(rBitmap.maPrefSize)
 {
-    mpImpBmp = rBitmap.mpImpBmp;
-
-    if ( mpImpBmp )
-        mpImpBmp->ImplIncRefCount();
 }
 
-Bitmap::Bitmap( SalBitmap* pSalBitmap )
+Bitmap::Bitmap(SalBitmap* pSalBitmap)
+    : mxImpBmp(new ImpBitmap(pSalBitmap))
+    , maPrefMapMode(MapMode(MAP_PIXEL))
+    , maPrefSize(mxImpBmp->ImplGetSize())
 {
-    mpImpBmp = new ImpBitmap(pSalBitmap);
-    maPrefMapMode = MapMode( MAP_PIXEL );
-    maPrefSize = mpImpBmp->ImplGetSize();
 }
 
 Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalette* pPal )
 {
-    if( rSizePixel.Width() && rSizePixel.Height() )
+    if (rSizePixel.Width() && rSizePixel.Height())
     {
         BitmapPalette   aPal;
         BitmapPalette*  pRealPal = nullptr;
@@ -121,16 +116,13 @@ Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalett
                 pRealPal = const_cast<BitmapPalette*>(pPal);
         }
 
-        mpImpBmp = new ImpBitmap;
-        mpImpBmp->ImplCreate( rSizePixel, nBitCount, pRealPal ? *pRealPal : aPal );
+        mxImpBmp.reset(new ImpBitmap);
+        mxImpBmp->ImplCreate( rSizePixel, nBitCount, pRealPal ? *pRealPal : aPal );
     }
-    else
-        mpImpBmp = nullptr;
 }
 
 Bitmap::~Bitmap()
 {
-    ImplReleaseRef();
 }
 
 const BitmapPalette& Bitmap::GetGreyPalette( int nEntries )
@@ -233,12 +225,7 @@ Bitmap& Bitmap::operator=( const Bitmap& rBitmap )
 
     maPrefSize = rBitmap.maPrefSize;
     maPrefMapMode = rBitmap.maPrefMapMode;
-
-    if ( rBitmap.mpImpBmp )
-        rBitmap.mpImpBmp->ImplIncRefCount();
-
-    ImplReleaseRef();
-    mpImpBmp = rBitmap.mpImpBmp;
+    mxImpBmp = rBitmap.mxImpBmp;
 
     return *this;
 }
@@ -246,26 +233,24 @@ Bitmap& Bitmap::operator=( const Bitmap& rBitmap )
 bool Bitmap::IsEqual( const Bitmap& rBmp ) const
 {
     return(IsSameInstance(rBmp) || // Includes both are nullptr
-        (rBmp.mpImpBmp && mpImpBmp && mpImpBmp->ImplIsEqual(*rBmp.mpImpBmp)));
+        (rBmp.mxImpBmp && mxImpBmp && mxImpBmp->ImplIsEqual(*rBmp.mxImpBmp)));
 }
 
 void Bitmap::SetEmpty()
 {
     maPrefMapMode = MapMode();
     maPrefSize = Size();
-
-    ImplReleaseRef();
-    mpImpBmp = nullptr;
+    mxImpBmp.reset();
 }
 
 Size Bitmap::GetSizePixel() const
 {
-    return( mpImpBmp ? mpImpBmp->ImplGetSize() : Size() );
+    return( mxImpBmp ? mxImpBmp->ImplGetSize() : Size() );
 }
 
 sal_uInt16 Bitmap::GetBitCount() const
 {
-    return( mpImpBmp ? mpImpBmp->ImplGetBitCount() : 0 );
+    return( mxImpBmp ? mxImpBmp->ImplGetBitCount() : 0 );
 }
 
 bool Bitmap::HasGreyPalette() const
@@ -288,38 +273,21 @@ BitmapChecksum Bitmap::GetChecksum() const
 {
     BitmapChecksum nRet = 0;
 
-    if( mpImpBmp )
+    if( mxImpBmp )
     {
-        nRet = mpImpBmp->ImplGetChecksum();
+        nRet = mxImpBmp->ImplGetChecksum();
     }
 
     return nRet;
 }
 
-void Bitmap::ImplReleaseRef()
-{
-    if( mpImpBmp )
-    {
-        if( mpImpBmp->ImplGetRefCount() > 1UL )
-            mpImpBmp->ImplDecRefCount();
-        else
-        {
-            delete mpImpBmp;
-            mpImpBmp = nullptr;
-        }
-    }
-}
-
 void Bitmap::ImplMakeUnique()
 {
-    if( mpImpBmp && mpImpBmp->ImplGetRefCount() > 1UL )
+    if (mxImpBmp && !mxImpBmp.unique())
     {
-        ImpBitmap* pOldImpBmp = mpImpBmp;
-
-        pOldImpBmp->ImplDecRefCount();
-
-        mpImpBmp = new ImpBitmap;
-        mpImpBmp->ImplCreate( *pOldImpBmp );
+        std::shared_ptr<ImpBitmap> xOldImpBmp = mxImpBmp;
+        mxImpBmp.reset(new ImpBitmap);
+        mxImpBmp->ImplCreate(*xOldImpBmp);
     }
 }
 
@@ -345,13 +313,9 @@ void Bitmap::ImplAssignWithSize( const Bitmap& rBitmap )
 }
 
 
-void Bitmap::ImplSetImpBitmap( ImpBitmap* pImpBmp )
+void Bitmap::ImplSetImpBitmap(std::shared_ptr<ImpBitmap> xImpBmp)
 {
-    if( pImpBmp != mpImpBmp )
-    {
-        ImplReleaseRef();
-        mpImpBmp = pImpBmp;
-    }
+    mxImpBmp = xImpBmp;
 }
 
 BitmapInfoAccess* Bitmap::AcquireInfoAccess()
@@ -504,7 +468,7 @@ bool Bitmap::Invert()
                     pAcc->SetPixel( nY, nX, pAcc->GetPixel( nY, nX ).Invert() );
         }
 
-        mpImpBmp->ImplInvalidateChecksum();
+        mxImpBmp->ImplInvalidateChecksum();
         ReleaseAccess( pAcc );
         bRet = true;
     }
@@ -1551,22 +1515,17 @@ bool Bitmap::Replace( const AlphaMask& rAlpha, const Color& rMergeColor )
 
 bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol )
 {
-    if( mpImpBmp )
+    if( mxImpBmp )
     {
         // implementation specific replace
-        ImpBitmap* pImpBmp = new ImpBitmap;
-
-        if( pImpBmp->ImplCreate( *mpImpBmp ) && pImpBmp->ImplReplace( rSearchColor, rReplaceColor, nTol ) )
+        std::shared_ptr<ImpBitmap> xImpBmp(new ImpBitmap);
+        if (xImpBmp->ImplCreate(*mxImpBmp) && xImpBmp->ImplReplace(rSearchColor, rReplaceColor, nTol))
         {
-            ImplSetImpBitmap( pImpBmp );
+            ImplSetImpBitmap(xImpBmp);
             maPrefMapMode = MapMode( MAP_PIXEL );
-            maPrefSize = pImpBmp->ImplGetSize();
+            maPrefSize = xImpBmp->ImplGetSize();
             return true;
         }
-        else
-        {
-            delete pImpBmp;
-        }
     }
 
     // Bitmaps with 1 bit color depth can cause problems
@@ -1733,14 +1692,11 @@ Bitmap Bitmap::CreateDisplayBitmap( OutputDevice* pDisplay )
 
     SalGraphics* pDispGraphics = pDisplay->GetGraphics();
 
-    if( mpImpBmp && pDispGraphics )
+    if( mxImpBmp && pDispGraphics )
     {
-        ImpBitmap* pImpDispBmp = new ImpBitmap;
-
-        if( pImpDispBmp->ImplCreate( *mpImpBmp, pDispGraphics ) )
-            aDispBmp.ImplSetImpBitmap( pImpDispBmp );
-        else
-            delete pImpDispBmp;
+        std::shared_ptr<ImpBitmap> xImpDispBmp(new ImpBitmap);
+        if (xImpDispBmp->ImplCreate(*mxImpBmp, pDispGraphics))
+            aDispBmp.ImplSetImpBitmap(xImpDispBmp);
     }
 
     return aDispBmp;
@@ -1924,9 +1880,9 @@ bool Bitmap::MakeMono( sal_uInt8 cThreshold )
 bool Bitmap::GetSystemData( BitmapSystemData& rData ) const
 {
     bool bRet = false;
-    if( mpImpBmp )
+    if (mxImpBmp)
     {
-        SalBitmap* pSalBitmap = mpImpBmp->ImplGetSalBitmap();
+        SalBitmap* pSalBitmap = mxImpBmp->ImplGetSalBitmap();
         if( pSalBitmap )
             bRet = pSalBitmap->GetSystemData( rData );
     }
diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx
index 53dd598..257eaa4 100644
--- a/vcl/source/gdi/bitmap3.cxx
+++ b/vcl/source/gdi/bitmap3.cxx
@@ -245,20 +245,15 @@ void ImplCreateDitherMatrix( sal_uInt8 (*pDitherMatrix)[16][16] )
 bool Bitmap::Convert( BmpConversion eConversion )
 {
     // try to convert in backend
-    if (mpImpBmp)
+    if (mxImpBmp)
     {
-        ImpBitmap* pImpBmp = new ImpBitmap;
-
-        if (pImpBmp->ImplCreate(*mpImpBmp) && pImpBmp->ImplConvert(eConversion))
+        std::shared_ptr<ImpBitmap> xImpBmp(new ImpBitmap);
+        if (xImpBmp->ImplCreate(*mxImpBmp) && xImpBmp->ImplConvert(eConversion))
         {
-            ImplSetImpBitmap(pImpBmp);
-            SAL_INFO( "vcl.opengl", "Ref count: " << mpImpBmp->ImplGetRefCount() );
+            ImplSetImpBitmap(xImpBmp);
+            SAL_INFO( "vcl.opengl", "Ref count: " << mxImpBmp.use_count() );
             return true;
         }
-        else
-        {
-            delete pImpBmp;
-        }
     }
 
     const sal_uInt16 nBitCount = GetBitCount ();
@@ -898,23 +893,18 @@ bool Bitmap::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag n
 
     const sal_uInt16 nStartCount(GetBitCount());
 
-    if( mpImpBmp )
+    if (mxImpBmp)
     {
         // implementation specific scaling
-        ImpBitmap* pImpBmp = new ImpBitmap;
-
-        if( pImpBmp->ImplCreate( *mpImpBmp ) && pImpBmp->ImplScale( rScaleX, rScaleY, nScaleFlag ) )
+        std::shared_ptr<ImpBitmap> xImpBmp(new ImpBitmap);
+        if (xImpBmp->ImplCreate(*mxImpBmp) && xImpBmp->ImplScale(rScaleX, rScaleY, nScaleFlag))
         {
-            ImplSetImpBitmap( pImpBmp );
-            SAL_INFO( "vcl.opengl", "Ref count: " << mpImpBmp->ImplGetRefCount() );
+            ImplSetImpBitmap(xImpBmp);
+            SAL_INFO( "vcl.opengl", "Ref count: " << mxImpBmp.use_count() );
             maPrefMapMode = MapMode( MAP_PIXEL );
-            maPrefSize = pImpBmp->ImplGetSize();
+            maPrefSize = xImpBmp->ImplGetSize();
             return true;
         }
-        else
-        {
-            delete pImpBmp;
-        }
     }
 
     //fdo#33455
diff --git a/vcl/source/gdi/bmpacc.cxx b/vcl/source/gdi/bmpacc.cxx
index b1d5982..149a5336 100644
--- a/vcl/source/gdi/bmpacc.cxx
+++ b/vcl/source/gdi/bmpacc.cxx
@@ -48,38 +48,35 @@ BitmapInfoAccess::~BitmapInfoAccess()
 
 void BitmapInfoAccess::ImplCreate( Bitmap& rBitmap )
 {
-    ImpBitmap* pImpBmp = rBitmap.ImplGetImpBitmap();
+    std::shared_ptr<ImpBitmap> xImpBmp = rBitmap.ImplGetImpBitmap();
 
-    DBG_ASSERT( pImpBmp, "Forbidden Access to empty bitmap!" );
+    DBG_ASSERT( xImpBmp, "Forbidden Access to empty bitmap!" );
 
-    if( pImpBmp )
+    if( xImpBmp )
     {
         if( mnAccessMode == BITMAP_WRITE_ACCESS && !maBitmap.ImplGetImpBitmap() )
         {
             rBitmap.ImplMakeUnique();
-            pImpBmp = rBitmap.ImplGetImpBitmap();
+            xImpBmp = rBitmap.ImplGetImpBitmap();
         }
         else
         {
             DBG_ASSERT( mnAccessMode != BITMAP_WRITE_ACCESS ||
-                        pImpBmp->ImplGetRefCount() == 2,
+                        xImpBmp.use_count() == 2,
                         "Unpredictable results: bitmap is referenced more than once!" );
         }
 
-        mpBuffer = pImpBmp->ImplAcquireBuffer( mnAccessMode );
+        mpBuffer = xImpBmp->ImplAcquireBuffer( mnAccessMode );
 
         if( !mpBuffer )
         {
-            ImpBitmap* pNewImpBmp = new ImpBitmap;
-
-            if( pNewImpBmp->ImplCreate( *pImpBmp, rBitmap.GetBitCount()  ) )
+            std::shared_ptr<ImpBitmap> xNewImpBmp(new ImpBitmap);
+            if (xNewImpBmp->ImplCreate(*xImpBmp, rBitmap.GetBitCount()))
             {
-                pImpBmp = pNewImpBmp;
-                rBitmap.ImplSetImpBitmap( pImpBmp );
-                mpBuffer = pImpBmp->ImplAcquireBuffer( mnAccessMode );
+                xImpBmp = xNewImpBmp;
+                rBitmap.ImplSetImpBitmap( xImpBmp );
+                mpBuffer = xImpBmp->ImplAcquireBuffer( mnAccessMode );
             }
-            else
-                delete pNewImpBmp;
         }
 
         maBitmap = rBitmap;
@@ -88,11 +85,11 @@ void BitmapInfoAccess::ImplCreate( Bitmap& rBitmap )
 
 void BitmapInfoAccess::ImplDestroy()
 {
-    ImpBitmap* pImpBmp = maBitmap.ImplGetImpBitmap();
+    std::shared_ptr<ImpBitmap> xImpBmp = maBitmap.ImplGetImpBitmap();
 
-    if( mpBuffer && pImpBmp )
+    if (mpBuffer && xImpBmp)
     {
-        pImpBmp->ImplReleaseBuffer( mpBuffer, mnAccessMode );
+        xImpBmp->ImplReleaseBuffer( mpBuffer, mnAccessMode );
         mpBuffer = nullptr;
     }
 }
@@ -130,8 +127,8 @@ void BitmapReadAccess::ImplInitScanBuffer( Bitmap& rBitmap )
     if (!mpBuffer)
         return;
 
-    ImpBitmap* pImpBmp = rBitmap.ImplGetImpBitmap();
-    if (!pImpBmp)
+    std::shared_ptr<ImpBitmap> xImpBmp = rBitmap.ImplGetImpBitmap();
+    if (!xImpBmp)
         return;
 
     maColorMask = mpBuffer->maColorMask;
@@ -164,7 +161,7 @@ void BitmapReadAccess::ImplInitScanBuffer( Bitmap& rBitmap )
         delete[] mpScanBuf;
         mpScanBuf = nullptr;
 
-        pImpBmp->ImplReleaseBuffer( mpBuffer, mnAccessMode );
+        xImpBmp->ImplReleaseBuffer( mpBuffer, mnAccessMode );
         mpBuffer = nullptr;
     }
 }
diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx
index 416fa29..b25450d 100644
--- a/vcl/source/gdi/impbmp.cxx
+++ b/vcl/source/gdi/impbmp.cxx
@@ -24,15 +24,13 @@
 #include <salbmp.hxx>
 #include <impbmp.hxx>
 
-ImpBitmap::ImpBitmap() :
-            mnRefCount  ( 1 ),
-            mpSalBitmap ( ImplGetSVData()->mpDefInst->CreateSalBitmap() )
+ImpBitmap::ImpBitmap()
+    : mpSalBitmap(ImplGetSVData()->mpDefInst->CreateSalBitmap())
 {
 }
 
-ImpBitmap::ImpBitmap(SalBitmap* pBitmap) :
-            mnRefCount  ( 1 ),
-            mpSalBitmap ( pBitmap )
+ImpBitmap::ImpBitmap(SalBitmap* pBitmap)
+    : mpSalBitmap(pBitmap)
 {
 }
 
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 52aec29..0b44c0f 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -462,8 +462,8 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const
 
                 if( pSalBmp )
                 {
-                    ImpBitmap* pImpBmp = new ImpBitmap(pSalBmp);
-                    aBmp.ImplSetImpBitmap( pImpBmp );
+                    std::shared_ptr<ImpBitmap> xImpBmp(new ImpBitmap(pSalBmp));
+                    aBmp.ImplSetImpBitmap(xImpBmp);
                 }
             }
         }
@@ -516,11 +516,11 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
                 rBitmapEx.Mirror(nMirrFlags);
 
             const SalBitmap* pSalSrcBmp = rBitmapEx.ImplGetBitmapImpBitmap()->ImplGetSalBitmap();
-            const ImpBitmap* pMaskBmp = rBitmapEx.ImplGetMaskImpBitmap();
+            std::shared_ptr<ImpBitmap> xMaskBmp = rBitmapEx.ImplGetMaskImpBitmap();
 
-            if (pMaskBmp)
+            if (xMaskBmp)
             {
-                SalBitmap* pSalAlphaBmp = pMaskBmp->ImplGetSalBitmap();
+                SalBitmap* pSalAlphaBmp = xMaskBmp->ImplGetSalBitmap();
                 bool bTryDirectPaint(pSalSrcBmp && pSalAlphaBmp);
 
                 if (bTryDirectPaint && mpGraphics->DrawAlphaBitmap(aPosAry, *pSalSrcBmp, *pSalAlphaBmp, this))
@@ -587,7 +587,7 @@ void OutputDevice::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize
                     }
 
                     mpGraphics->DrawBitmap(aPosAry, *pSalSrcBmp,
-                                           *pMaskBmp->ImplGetSalBitmap(),
+                                           *xMaskBmp->ImplGetSalBitmap(),
                                            this);
                 }
 
diff --git a/vcl/source/outdev/mask.cxx b/vcl/source/outdev/mask.cxx
index 739cbf1..5c8409c 100644
--- a/vcl/source/outdev/mask.cxx
+++ b/vcl/source/outdev/mask.cxx
@@ -106,8 +106,8 @@ void OutputDevice::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor,
 {
     assert(!is_double_buffered_window());
 
-    const ImpBitmap* pImpBmp = rMask.ImplGetImpBitmap();
-    if ( pImpBmp )
+    std::shared_ptr<ImpBitmap> xImpBmp = rMask.ImplGetImpBitmap();
+    if (xImpBmp)
     {
         SalTwoRect aPosAry(rSrcPtPixel.X(), rSrcPtPixel.Y(), rSrcSizePixel.Width(), rSrcSizePixel.Height(),
                            ImplLogicXToDevicePixel(rDestPt.X()), ImplLogicYToDevicePixel(rDestPt.Y()),
@@ -115,7 +115,7 @@ void OutputDevice::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor,
                            ImplLogicHeightToDevicePixel(rDestSize.Height()));
 
         // we don't want to mirror via coordinates
-        const BmpMirrorFlags nMirrFlags = AdjustTwoRect( aPosAry, pImpBmp->ImplGetSize() );
+        const BmpMirrorFlags nMirrFlags = AdjustTwoRect( aPosAry, xImpBmp->ImplGetSize() );
 
         // check if output is necessary
         if( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight )
@@ -129,7 +129,7 @@ void OutputDevice::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor,
                                       ImplColorToSal( rMaskColor ) , this);
             }
             else
-                mpGraphics->DrawMask( aPosAry, *pImpBmp->ImplGetSalBitmap(),
+                mpGraphics->DrawMask( aPosAry, *xImpBmp->ImplGetSalBitmap(),
                                       ImplColorToSal( rMaskColor ), this );
 
         }


More information about the Libreoffice-commits mailing list