summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-01-26 12:54:19 +0100
committerMichael Stahl <mstahl@redhat.com>2016-01-26 17:51:28 +0100
commiteb63ac518167601896afe0c336e2562efa0f43f2 (patch)
treef012ab389780da395edbe8c10b7023f3d870d03c
parentvcl: convert boost::shared_array to std::shared_ptr (diff)
downloadcore-eb63ac518167601896afe0c336e2562efa0f43f2.tar.gz
core-eb63ac518167601896afe0c336e2562efa0f43f2.zip
vcl: actually that shared_array was a scam
The only things passed as buffers there were null pointers and shared_arrays that had the deletion explicitly disabled with a struct NoDelete, so it's sufficient to just pass a pointer. Change-Id: I68d618782aa654242048516d2e910b8136b16e2d
-rw-r--r--desktop/source/lib/init.cxx18
-rw-r--r--include/vcl/virdev.hxx7
-rw-r--r--vcl/headless/svpvd.cxx6
-rw-r--r--vcl/inc/headless/svpvd.hxx2
-rw-r--r--vcl/inc/salvd.hxx2
-rw-r--r--vcl/source/gdi/virdev.cxx11
6 files changed, 15 insertions, 31 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 53d84f7d3c60..88b5d1fc70b4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -101,17 +101,6 @@ typedef struct
const char *filterName;
} ExtensionMap;
-// We need a shared_ptr for passing into the BitmapDevice (via
-// VirtualDevice.SetOutputSizePixelScaleOffsetAndBuffer which goes via the
-// SvpVirtualDevice, ending up in the cairo surface. However as we're
-// given the array externally we can't delete it, and hence need to override
-// shared_ptr's default of deleting its pointer.
-template<typename T>
-struct NoDelete
-{
- void operator()(T* /* p */) {}
-};
-
static const ExtensionMap aWriterExtensionMap[] =
{
{ "doc", "MS Word 97" },
@@ -924,11 +913,9 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
pDevice->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
#endif
- std::shared_ptr<sal_uInt8> aBuffer( pBuffer, NoDelete<sal_uInt8>() );
-
pDevice->SetOutputSizePixelScaleOffsetAndBuffer(
Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
- aBuffer);
+ pBuffer);
pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
@@ -1569,12 +1556,11 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
unsigned char* pBuffer = static_cast<unsigned char*>(malloc(4 * nFontWidth * nFontHeight));
memset(pBuffer, 0, nFontWidth * nFontHeight * 4);
- std::shared_ptr<sal_uInt8> aBuffer(pBuffer, NoDelete<sal_uInt8>());
aDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
aDevice->SetOutputSizePixelScaleOffsetAndBuffer(
Size(nFontWidth, nFontHeight), Fraction(1.0), Point(),
- aBuffer);
+ pBuffer);
aDevice->DrawText(Point(0,0), aFontName);
return pBuffer;
diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index e56a9a1a74f1..b9b5bba0e474 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -24,7 +24,6 @@
#include <vcl/salgtype.hxx>
#include <vcl/outdev.hxx>
-#include <memory>
class SalVirtualDevice;
struct SystemGraphicsData;
@@ -47,9 +46,9 @@ private:
SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, DeviceFormat eFormat, const SystemGraphicsData *pData = nullptr );
SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
- const std::shared_ptr<sal_uInt8> &pBuffer );
+ sal_uInt8* pBuffer );
SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
- const std::shared_ptr<sal_uInt8> &pBuffer );
+ sal_uInt8* pBuffer );
VirtualDevice (const VirtualDevice &) = delete;
VirtualDevice & operator= (const VirtualDevice &) = delete;
@@ -127,7 +126,7 @@ public:
bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize,
const Fraction& rScale,
const Point& rNewOffset,
- const std::shared_ptr<sal_uInt8> &pBuffer );
+ sal_uInt8* pBuffer);
bool SetOutputSize( const Size& rNewSize, bool bErase = true )
{ return SetOutputSizePixel( LogicToPixel( rNewSize ), bErase ); }
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index 1711f396cac5..7840aecc3807 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -51,11 +51,11 @@ void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
{
- return SetSizeUsingBuffer(nNewDX, nNewDY, std::shared_ptr<sal_uInt8>());
+ return SetSizeUsingBuffer(nNewDX, nNewDY, nullptr);
}
bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
- const std::shared_ptr<sal_uInt8> &pBuffer )
+ sal_uInt8 *const pBuffer)
{
B2IVector aDevSize( nNewDX, nNewDY );
if( aDevSize.getX() == 0 )
@@ -75,7 +75,7 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
else
{
m_pSurface = pBuffer ?
- cairo_image_surface_create_for_data(pBuffer.get(), CAIRO_FORMAT_ARGB32,
+ cairo_image_surface_create_for_data(pBuffer, CAIRO_FORMAT_ARGB32,
aDevSize.getX(),
aDevSize.getY(),
cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, aDevSize.getX()))
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
index 9807c78c65e0..9256768a0fed 100644
--- a/vcl/inc/headless/svpvd.hxx
+++ b/vcl/inc/headless/svpvd.hxx
@@ -47,7 +47,7 @@ public:
virtual bool SetSize( long nNewDX, long nNewDY ) override;
virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY,
- const std::shared_ptr<sal_uInt8> &pBuffer
+ sal_uInt8 * pBuffer
) override;
// SalGeometryProvider
diff --git a/vcl/inc/salvd.hxx b/vcl/inc/salvd.hxx
index d3874c110399..95b4068db023 100644
--- a/vcl/inc/salvd.hxx
+++ b/vcl/inc/salvd.hxx
@@ -48,7 +48,7 @@ public:
// Set new size using a buffer at the given address
virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY,
- const std::shared_ptr<sal_uInt8> & /* pBuffer */ )
+ sal_uInt8 * /* pBuffer */)
{
// Only the headless virtual device has an implementation that uses
// pBuffer (and bTopDown).
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index bd7adffd43a3..016bf034f839 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -280,7 +280,7 @@ void VirtualDevice::dispose()
}
bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
- const std::shared_ptr<sal_uInt8> &pBuffer )
+ sal_uInt8 *const pBuffer)
{
SAL_INFO( "vcl.gdi",
"VirtualDevice::InnerImplSetOutputSizePixel( " << rNewSize.Width() << ", "
@@ -386,7 +386,7 @@ void VirtualDevice::ImplFillOpaqueRectangle( const Rectangle& rRect )
}
bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
- const std::shared_ptr<sal_uInt8> &pBuffer )
+ sal_uInt8 *const pBuffer)
{
if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer) )
{
@@ -401,8 +401,7 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
if( !mpAlphaVDev )
{
mpAlphaVDev = VclPtr<VirtualDevice>::Create(*this, meAlphaFormat);
- mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase,
- std::shared_ptr<sal_uInt8>());
+ mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase, nullptr);
}
// TODO: copy full outdev state to new one, here. Also needed in outdev2.cxx:DrawOutDev
@@ -435,12 +434,12 @@ void VirtualDevice::EnableRTL( bool bEnable )
bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase )
{
- return ImplSetOutputSizePixel(rNewSize, bErase, std::shared_ptr<sal_uInt8>());
+ return ImplSetOutputSizePixel(rNewSize, bErase, nullptr);
}
bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer(
const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset,
- const std::shared_ptr<sal_uInt8> &pBuffer )
+ sal_uInt8 *const pBuffer)
{
if (pBuffer) {
MapMode mm = GetMapMode();