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

Michael Stahl mstahl at redhat.com
Thu May 26 08:19:54 UTC 2016


 vcl/inc/pch/precompiled_vcl.hxx |    1 
 vcl/inc/quartz/salbmp.h         |    6 ++--
 vcl/quartz/salbmp.cxx           |   49 ++++++++++++++++++++--------------------
 3 files changed, 28 insertions(+), 28 deletions(-)

New commits:
commit 0edec345cdbceae4847d1780f914ce16e56c0959
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed May 25 23:10:03 2016 +0200

    vcl: replace boost::shared_array with std::shared_ptr
    
    This was already using get() everywhere.
    
    Change-Id: I6d1eee4fe9b0494a1c49ac44917d9fc7c22b43a4
    Reviewed-on: https://gerrit.libreoffice.org/25470
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx
index 833d73e..06dc155 100644
--- a/vcl/inc/pch/precompiled_vcl.hxx
+++ b/vcl/inc/pch/precompiled_vcl.hxx
@@ -57,7 +57,6 @@
 #include <boost/math/special_functions/sinc.hpp>
 #include <boost/multi_array.hpp>
 #include <boost/optional.hpp>
-#include <boost/shared_array.hpp>
 #include <osl/conditn.hxx>
 #include <osl/diagnose.h>
 #include <osl/diagnose.hxx>
diff --git a/vcl/inc/quartz/salbmp.h b/vcl/inc/quartz/salbmp.h
index 6ffd1e3..994604f 100644
--- a/vcl/inc/quartz/salbmp.h
+++ b/vcl/inc/quartz/salbmp.h
@@ -30,7 +30,7 @@
 #include "salvd.hxx"
 #include "salbmp.hxx"
 
-#include <boost/shared_array.hpp>
+#include <memory>
 
 
 struct  BitmapBuffer;
@@ -42,8 +42,8 @@ public:
     CGContextRef                    mxGraphicContext;
     mutable CGImageRef              mxCachedImage;
     BitmapPalette                   maPalette;
-    boost::shared_array<sal_uInt8>  maUserBuffer;
-    boost::shared_array<sal_uInt8>  maContextBuffer;
+    std::shared_ptr<sal_uInt8> m_pUserBuffer;
+    std::shared_ptr<sal_uInt8> m_pContextBuffer;
     sal_uInt16                      mnBits;
     int                             mnWidth;
     int                             mnHeight;
diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx
index 3464307..4ec0809 100644
--- a/vcl/quartz/salbmp.cxx
+++ b/vcl/quartz/salbmp.cxx
@@ -22,6 +22,7 @@
 #include <cstddef>
 #include <limits>
 
+#include <o3tl/make_shared.hxx>
 #include <basegfx/vector/b2ivector.hxx>
 #include <tools/color.hxx>
 #include <vcl/bitmap.hxx>
@@ -176,7 +177,7 @@ bool QuartzSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount
 {
     const QuartzSalBitmap& rSourceBitmap = static_cast<const QuartzSalBitmap&>(rSalBmp);
 
-    if( isValidBitCount( nNewBitCount ) &&  rSourceBitmap.maUserBuffer.get() )
+    if (isValidBitCount(nNewBitCount) && rSourceBitmap.m_pUserBuffer.get())
     {
         mnBits = nNewBitCount;
         mnWidth = rSourceBitmap.mnWidth;
@@ -186,9 +187,9 @@ bool QuartzSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount
         if( AllocateUserData() )
         {
             ConvertBitmapData( mnWidth, mnHeight, mnBits, mnBytesPerRow, maPalette,
-                               maUserBuffer.get(), rSourceBitmap.mnBits,
+                               m_pUserBuffer.get(), rSourceBitmap.mnBits,
                                rSourceBitmap.mnBytesPerRow, rSourceBitmap.maPalette,
-                               rSourceBitmap.maUserBuffer.get() );
+                               rSourceBitmap.m_pUserBuffer.get() );
             return true;
         }
     }
@@ -204,7 +205,7 @@ bool QuartzSalBitmap::Create( const css::uno::Reference< css::rendering::XBitmap
 void QuartzSalBitmap::Destroy()
 {
     DestroyContext();
-    maUserBuffer.reset();
+    m_pUserBuffer.reset();
 }
 
 void QuartzSalBitmap::DestroyContext()
@@ -221,7 +222,7 @@ void QuartzSalBitmap::DestroyContext()
         SAL_INFO("vcl.cg", "CGContextRelease(" << mxGraphicContext << ")" );
         CGContextRelease( mxGraphicContext );
         mxGraphicContext = nullptr;
-        maContextBuffer.reset();
+        m_pContextBuffer.reset();
     }
 }
 
@@ -231,7 +232,7 @@ bool QuartzSalBitmap::CreateContext()
 
     // prepare graphics context
     // convert image from user input if available
-    const bool bSkipConversion = !maUserBuffer;
+    const bool bSkipConversion = !m_pUserBuffer;
     if( bSkipConversion )
         AllocateUserData();
 
@@ -245,12 +246,12 @@ bool QuartzSalBitmap::CreateContext()
     if( (mnBits == 16) || (mnBits == 32) )
     {
         // no conversion needed for truecolor
-        maContextBuffer = maUserBuffer;
+        m_pContextBuffer = m_pUserBuffer;
     }
     else if( mnBits == 8 && maPalette.IsGreyPalette() )
     {
         // no conversion needed for grayscale
-        maContextBuffer = maUserBuffer;
+        m_pContextBuffer = m_pUserBuffer;
         aCGColorSpace = GetSalData()->mxGraySpace;
         aCGBmpInfo = kCGImageAlphaNone;
         bitsPerComponent = mnBits;
@@ -262,17 +263,17 @@ bool QuartzSalBitmap::CreateContext()
         nContextBytesPerRow = mnWidth << 2;
         try
         {
-            maContextBuffer.reset( new sal_uInt8[ mnHeight * nContextBytesPerRow ] );
+            m_pContextBuffer = o3tl::make_shared_array<sal_uInt8>(mnHeight * nContextBytesPerRow);
 #ifdef DBG_UTIL
             for (size_t i = 0; i < mnHeight * nContextBytesPerRow; i++)
-                maContextBuffer.get()[i] = (i & 0xFF);
+                m_pContextBuffer.get()[i] = (i & 0xFF);
 #endif
 
             if( !bSkipConversion )
             {
                 ConvertBitmapData( mnWidth, mnHeight,
-                                   32, nContextBytesPerRow, maPalette, maContextBuffer.get(),
-                                   mnBits, mnBytesPerRow, maPalette, maUserBuffer.get() );
+                                   32, nContextBytesPerRow, maPalette, m_pContextBuffer.get(),
+                                   mnBits, mnBytesPerRow, maPalette, m_pUserBuffer.get() );
             }
         }
         catch( const std::bad_alloc& )
@@ -281,16 +282,16 @@ bool QuartzSalBitmap::CreateContext()
         }
     }
 
-    if( maContextBuffer.get() )
+    if (m_pContextBuffer.get())
     {
-        mxGraphicContext = CGBitmapContextCreate( maContextBuffer.get(), mnWidth, mnHeight,
+        mxGraphicContext = CGBitmapContextCreate( m_pContextBuffer.get(), mnWidth, mnHeight,
                                                   bitsPerComponent, nContextBytesPerRow,
                                                   aCGColorSpace, aCGBmpInfo );
         SAL_INFO("vcl.cg", "CGBitmapContextCreate(" << mnWidth << "x" << mnHeight << "x" << bitsPerComponent << ") = " << mxGraphicContext );
     }
 
     if( !mxGraphicContext )
-        maContextBuffer.reset();
+        m_pContextBuffer.reset();
 
     return mxGraphicContext != nullptr;
 }
@@ -322,7 +323,7 @@ bool QuartzSalBitmap::AllocateUserData()
     {
         try
         {
-            maUserBuffer.reset( new sal_uInt8[mnBytesPerRow * mnHeight] );
+            m_pUserBuffer = o3tl::make_shared_array<sal_uInt8>(mnBytesPerRow * mnHeight);
             alloc = true;
         }
         catch (std::bad_alloc &) {}
@@ -330,7 +331,7 @@ bool QuartzSalBitmap::AllocateUserData()
     if (!alloc)
     {
         SAL_WARN( "vcl.quartz", "bad alloc " << mnBytesPerRow << "x" << mnHeight);
-        maUserBuffer.reset( static_cast<sal_uInt8*>(nullptr) );
+        m_pUserBuffer.reset( static_cast<sal_uInt8*>(nullptr) );
         mnBytesPerRow = 0;
     }
 #ifdef DBG_UTIL
@@ -338,12 +339,12 @@ bool QuartzSalBitmap::AllocateUserData()
     {
         for (size_t i = 0; i < mnBytesPerRow * mnHeight; i++)
         {
-            maUserBuffer.get()[i] = (i & 0xFF);
+            m_pUserBuffer.get()[i] = (i & 0xFF);
         }
     }
 #endif
 
-    return maUserBuffer.get() != nullptr;
+    return m_pUserBuffer.get() != nullptr;
 }
 
 namespace {
@@ -750,8 +751,8 @@ const BitmapPalette& GetDefaultPalette( int mnBits, bool bMonochrome )
 
 BitmapBuffer* QuartzSalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ )
 {
-    if( !maUserBuffer.get() )
-//  || maContextBuffer.get() && (maUserBuffer.get() != maContextBuffer.get()) )
+    if (!m_pUserBuffer.get())
+//  || m_pContextBuffer.get() && (m_pUserBuffer.get() != m_pContextBuffer.get()) )
     {
         // fprintf(stderr,"ASB::Acq(%dx%d,d=%d)\n",mnWidth,mnHeight,mnBits);
         // TODO: AllocateUserData();
@@ -763,7 +764,7 @@ BitmapBuffer* QuartzSalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ )
     pBuffer->mnHeight = mnHeight;
     pBuffer->maPalette = maPalette;
     pBuffer->mnScanlineSize = mnBytesPerRow;
-    pBuffer->mpBits = maUserBuffer.get();
+    pBuffer->mpBits = m_pUserBuffer.get();
     pBuffer->mnBitCount = mnBits;
     switch( mnBits )
     {
@@ -927,7 +928,7 @@ CGImageRef QuartzSalBitmap::CreateColorMask( int nX, int nY, int nWidth,
                                              int nHeight, SalColor nMaskColor ) const
 {
     CGImageRef xMask = nullptr;
-    if( maUserBuffer.get() && (nX + nWidth <= mnWidth) && (nY + nHeight <= mnHeight) )
+    if (m_pUserBuffer.get() && (nX + nWidth <= mnWidth) && (nY + nHeight <= mnHeight))
     {
         const sal_uInt32 nDestBytesPerRow = nWidth << 2;
         sal_uInt32* pMaskBuffer = static_cast<sal_uInt32*>( rtl_allocateMemory( nHeight * nDestBytesPerRow ) );
@@ -943,7 +944,7 @@ CGImageRef QuartzSalBitmap::CreateColorMask( int nX, int nY, int nWidth,
             reinterpret_cast<sal_uInt8*>(&nColor)[2] = SALCOLOR_GREEN( nMaskColor );
             reinterpret_cast<sal_uInt8*>(&nColor)[3] = SALCOLOR_BLUE( nMaskColor );
 
-            sal_uInt8* pSource = maUserBuffer.get();
+            sal_uInt8* pSource = m_pUserBuffer.get();
             if( nY )
                 pSource += nY * mnBytesPerRow;
 


More information about the Libreoffice-commits mailing list