[PATCH] wip

Thomas Arnhold (via Code Review) gerrit at gerrit.libreoffice.org
Sat Mar 23 12:30:48 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2944

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/44/2944/1

wip

Change-Id: I23427e1e3bfb583ef10123577ebec76af617f917
---
M vcl/inc/vcl/bitmap.hxx
M vcl/source/gdi/bitmap.cxx
M vcl/source/gdi/bmpacc.cxx
3 files changed, 3 insertions(+), 38 deletions(-)



diff --git a/vcl/inc/vcl/bitmap.hxx b/vcl/inc/vcl/bitmap.hxx
index 7753083..d25a0ce 100644
--- a/vcl/inc/vcl/bitmap.hxx
+++ b/vcl/inc/vcl/bitmap.hxx
@@ -20,6 +20,7 @@
 #ifndef _SV_BITMAP_HXX
 #define _SV_BITMAP_HXX
 
+#include <o3tl/cow_wrapper.hxx>
 #include <tools/link.hxx>
 #include <tools/solar.h>
 #include <vcl/dllapi.h>
@@ -302,7 +303,7 @@
 {
 private:
 
-    ImpBitmap*          mpImpBmp;
+    o3tl::cow_wrapper< ImpBitmap > mpImpBmp;
     MapMode             maPrefMapMode;
     Size                maPrefSize;
 
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index 64d8f4e..6cf0cac 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -52,9 +52,6 @@
     maPrefSize      ( rBitmap.maPrefSize )
 {
     mpImpBmp = rBitmap.mpImpBmp;
-
-    if ( mpImpBmp )
-        mpImpBmp->ImplIncRefCount();
 }
 
 Bitmap::Bitmap( SalBitmap* pSalBitmap )
@@ -121,7 +118,7 @@
                 pRealPal = (BitmapPalette*) pPal;
         }
 
-        mpImpBmp = new ImpBitmap;
+        mpImpBmp = ImpBitmap;
         mpImpBmp->ImplCreate( rSizePixel, nBitCount, pRealPal ? *pRealPal : aPal );
     }
     else
@@ -231,10 +228,6 @@
     maPrefSize = rBitmap.maPrefSize;
     maPrefMapMode = rBitmap.maPrefMapMode;
 
-    if ( rBitmap.mpImpBmp )
-        rBitmap.mpImpBmp->ImplIncRefCount();
-
-    ImplReleaseRef();
     mpImpBmp = rBitmap.mpImpBmp;
 
     return *this;
@@ -253,7 +246,6 @@
     maPrefMapMode = MapMode();
     maPrefSize = Size();
 
-    ImplReleaseRef();
     mpImpBmp = NULL;
 }
 
@@ -342,33 +334,6 @@
     }
 
     return nRet;
-}
-
-void Bitmap::ImplReleaseRef()
-{
-    if( mpImpBmp )
-    {
-        if( mpImpBmp->ImplGetRefCount() > 1UL )
-            mpImpBmp->ImplDecRefCount();
-        else
-        {
-            delete mpImpBmp;
-            mpImpBmp = NULL;
-        }
-    }
-}
-
-void Bitmap::ImplMakeUnique()
-{
-    if( mpImpBmp && mpImpBmp->ImplGetRefCount() > 1UL )
-    {
-        ImpBitmap* pOldImpBmp = mpImpBmp;
-
-        pOldImpBmp->ImplDecRefCount();
-
-        mpImpBmp = new ImpBitmap;
-        mpImpBmp->ImplCreate( *pOldImpBmp );
-    }
 }
 
 void Bitmap::ImplAssignWithSize( const Bitmap& rBitmap )
diff --git a/vcl/source/gdi/bmpacc.cxx b/vcl/source/gdi/bmpacc.cxx
index b9d970c..48fd1e0 100644
--- a/vcl/source/gdi/bmpacc.cxx
+++ b/vcl/source/gdi/bmpacc.cxx
@@ -71,7 +71,6 @@
     {
         if( mbModify && !maBitmap.ImplGetImpBitmap() )
         {
-            rBitmap.ImplMakeUnique();
             pImpBmp = rBitmap.ImplGetImpBitmap();
         }
         else

-- 
To view, visit https://gerrit.libreoffice.org/2944
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23427e1e3bfb583ef10123577ebec76af617f917
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Thomas Arnhold <thomas at arnhold.org>



More information about the LibreOffice mailing list