diff options
Diffstat (limited to 'vcl/source/outdev')
-rw-r--r-- | vcl/source/outdev/bitmap.cxx | 10 | ||||
-rw-r--r-- | vcl/source/outdev/font.cxx | 5 | ||||
-rw-r--r-- | vcl/source/outdev/map.cxx | 6 | ||||
-rw-r--r-- | vcl/source/outdev/outdev.cxx | 31 | ||||
-rw-r--r-- | vcl/source/outdev/outdevstate.cxx | 1 | ||||
-rw-r--r-- | vcl/source/outdev/text.cxx | 58 | ||||
-rw-r--r-- | vcl/source/outdev/transparent.cxx | 16 | ||||
-rw-r--r-- | vcl/source/outdev/wallpaper.cxx | 10 |
8 files changed, 85 insertions, 52 deletions
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 9f13a24f1442..03938508643f 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -410,11 +410,11 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const // If the visible part has been clipped, we have to create a // Bitmap with the correct size in which we copy the clipped // Bitmap to the correct position. - VirtualDevice aVDev( *this ); + ScopedVclPtrInstance< VirtualDevice > aVDev( *this ); - if ( aVDev.SetOutputSizePixel( aRect.GetSize() ) ) + if ( aVDev->SetOutputSizePixel( aRect.GetSize() ) ) { - if ( ((OutputDevice*)&aVDev)->mpGraphics || ((OutputDevice*)&aVDev)->AcquireGraphics() ) + if ( ((OutputDevice*)aVDev.get())->mpGraphics || ((OutputDevice*)aVDev.get())->AcquireGraphics() ) { if ( (nWidth > 0) && (nHeight > 0) ) { @@ -422,14 +422,14 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const (aRect.Left() < mnOutOffX) ? (mnOutOffX - aRect.Left()) : 0L, (aRect.Top() < mnOutOffY) ? (mnOutOffY - aRect.Top()) : 0L, nWidth, nHeight); - (((OutputDevice*)&aVDev)->mpGraphics)->CopyBits( aPosAry, mpGraphics, this, this ); + (((OutputDevice*)aVDev.get())->mpGraphics)->CopyBits( aPosAry, mpGraphics, this, this ); } else { OSL_ENSURE(false, "CopyBits with negative width or height (!)"); } - aBmp = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() ); + aBmp = aVDev->GetBitmap( Point(), aVDev->GetOutputSizePixel() ); } else bClipped = false; diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 1bf2df824ff6..27810d43ade9 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -91,7 +91,12 @@ vcl::FontInfo OutputDevice::GetDevFont( int nDevFontIndex ) const int OutputDevice::GetDevFontCount() const { if( !mpGetDevFontList ) + { + if (!mpFontCollection) + return 0; + mpGetDevFontList = mpFontCollection->GetDevFontList(); + } return mpGetDevFontList->Count(); } diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index b359e504d0a9..e7eed8872143 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -232,9 +232,8 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, vcl::Window::ImplInitAppFontData( pSVData->maWinData.mpFirstFrame ); else { - WorkWindow* pWin = new WorkWindow( NULL, 0 ); + ScopedVclPtrInstance<WorkWindow> pWin( nullptr, 0 ); vcl::Window::ImplInitAppFontData( pWin ); - delete pWin; } } rMapRes.mnMapScNumX = pSVData->maGDIData.mnAppFontX; @@ -343,6 +342,9 @@ inline void ImplCalcMapResolution( const MapMode& rMapMode, // #i75163# void OutputDevice::ImplInvalidateViewTransform() { + if(!mpOutDevData) + return; + if(mpOutDevData->mpViewTransform) { delete mpOutDevData->mpViewTransform; diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index 372eb23bc8f4..855a2d46a27f 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -82,12 +82,12 @@ namespace { // Begin initializer and accessor public functions OutputDevice::OutputDevice() : + mnRefCnt(1), // cf. VclPtrInstance and README.lifecycle maRegion(true), maFillColor( COL_WHITE ), maTextLineColor( COL_TRANSPARENT ), mxSettings( new AllSettings(Application::GetSettings()) ) { - mpGraphics = NULL; mpUnoGraphicsList = NULL; mpPrevGraphics = NULL; @@ -179,11 +179,32 @@ OutputDevice::OutputDevice() : // #i75163# mpOutDevData->mpViewTransform = NULL; mpOutDevData->mpInverseViewTransform = NULL; + + mbDisposed = false; } OutputDevice::~OutputDevice() { + disposeOnce(); +} + +void OutputDevice::disposeOnce() +{ + if ( mbDisposed ) + return; + mbDisposed = true; + + // catch badness where our OutputDevice sub-class was not + // wrapped safely in a VclPtr cosily. + // FIXME: as/when we make our destructors all protected, + // we should introduce this assert: + // assert( mnRefCnt > 0 ); + dispose(); +} + +void OutputDevice::dispose() +{ if ( GetUnoGraphicsList() ) { UnoWrapperBase* pWrapper = Application::GetUnoWrapper( false ); @@ -193,12 +214,13 @@ OutputDevice::~OutputDevice() mpUnoGraphicsList = NULL; } - delete mpOutDevData->mpRotateDev; + mpOutDevData->mpRotateDev.disposeAndClear(); // #i75163# ImplInvalidateViewTransform(); delete mpOutDevData; + mpOutDevData = NULL; // for some reason, we haven't removed state from the stack properly if ( !mpOutDevStateStack->empty() ) @@ -210,6 +232,7 @@ OutputDevice::~OutputDevice() } } delete mpOutDevStateStack; + mpOutDevStateStack = NULL; // release the active font instance if( mpFontEntry ) @@ -218,8 +241,10 @@ OutputDevice::~OutputDevice() // remove cached results of GetDevFontList/GetDevSizeList // TODO: use smart pointers for them delete mpGetDevFontList; + mpGetDevFontList = NULL; delete mpGetDevSizeList; + mpGetDevSizeList = NULL; // release ImplFontCache specific to this OutputDevice // TODO: refcount ImplFontCache @@ -242,7 +267,7 @@ OutputDevice::~OutputDevice() mpFontCollection = NULL; } - delete mpAlphaVDev; + mpAlphaVDev.disposeAndClear(); } SalGraphics* OutputDevice::GetGraphics() diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx index a71c7d66cb92..bc6bd4a8b6c9 100644 --- a/vcl/source/outdev/outdevstate.cxx +++ b/vcl/source/outdev/outdevstate.cxx @@ -641,6 +641,7 @@ void OutputDevice::InitFillColor() void OutputDevice::ImplReleaseFonts() { mpGraphics->ReleaseFonts(); + mbNewFont = true; mbInitFont = true; diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index eb7104d06215..1cc48a32223b 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -236,7 +236,7 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout ) // cache virtual device for rotation if (!mpOutDevData->mpRotateDev) - mpOutDevData->mpRotateDev = new VirtualDevice( *this, 1 ); + mpOutDevData->mpRotateDev = VclPtr<VirtualDevice>::Create( *this, 1 ); VirtualDevice* pVDev = mpOutDevData->mpRotateDev; // size it accordingly @@ -2494,18 +2494,18 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect, // fall back to bitmap method to get the bounding rectangle, // so we need a monochrome virtual device with matching font - VirtualDevice aVDev( 1 ); + ScopedVclPtrInstance< VirtualDevice > aVDev( 1 ); vcl::Font aFont( GetFont() ); aFont.SetShadow( false ); aFont.SetOutline( false ); aFont.SetRelief( RELIEF_NONE ); aFont.SetOrientation( 0 ); aFont.SetSize( Size( mpFontEntry->maFontSelData.mnWidth, mpFontEntry->maFontSelData.mnHeight ) ); - aVDev.SetFont( aFont ); - aVDev.SetTextAlign( ALIGN_TOP ); + aVDev->SetFont( aFont ); + aVDev->SetTextAlign( ALIGN_TOP ); // layout the text on the virtual device - pSalLayout = aVDev.ImplLayout( rStr, nIndex, nLen, aPoint, nLayoutWidth, pDXAry ); + pSalLayout = aVDev->ImplLayout( rStr, nIndex, nLen, aPoint, nLayoutWidth, pDXAry ); if( !pSalLayout ) return false; @@ -2515,7 +2515,7 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect, long nHeight = mpFontEntry->mnLineHeight + mnEmphasisAscent + mnEmphasisDescent; Point aOffset( nWidth/2, 8 ); Size aOutSize( nWidth + 2*aOffset.X(), nHeight + 2*aOffset.Y() ); - if( !nWidth || !aVDev.SetOutputSizePixel( aOutSize ) ) + if( !nWidth || !aVDev->SetOutputSizePixel( aOutSize ) ) { pSalLayout->Release(); return false; @@ -2523,14 +2523,14 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect, // draw text in black pSalLayout->DrawBase() = aOffset; - aVDev.SetTextColor( Color( COL_BLACK ) ); - aVDev.SetTextFillColor(); - aVDev.ImplInitTextColor(); - aVDev.ImplDrawText( *pSalLayout ); + aVDev->SetTextColor( Color( COL_BLACK ) ); + aVDev->SetTextFillColor(); + aVDev->ImplInitTextColor(); + aVDev->ImplDrawText( *pSalLayout ); pSalLayout->Release(); // find extents using the bitmap - Bitmap aBmp = aVDev.GetBitmap( Point(), aOutSize ); + Bitmap aBmp = aVDev->GetBitmap( Point(), aOutSize ); BitmapReadAccess* pAcc = aBmp.AcquireReadAccess(); if( !pAcc ) return false; @@ -2718,7 +2718,7 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, + mnEmphasisDescent; pSalLayout->Release(); - VirtualDevice aVDev(1); + ScopedVclPtrInstance< VirtualDevice > aVDev( 1 ); vcl::Font aFont(GetFont()); aFont.SetShadow(false); @@ -2728,19 +2728,19 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, if( bOptimize ) { aFont.SetSize( Size( 0, GLYPH_FONT_HEIGHT ) ); - aVDev.SetMapMode( MAP_PIXEL ); + aVDev->SetMapMode( MAP_PIXEL ); } - aVDev.SetFont( aFont ); - aVDev.SetTextAlign( ALIGN_TOP ); - aVDev.SetTextColor( Color(COL_BLACK) ); - aVDev.SetTextFillColor(); + aVDev->SetFont( aFont ); + aVDev->SetTextAlign( ALIGN_TOP ); + aVDev->SetTextColor( Color(COL_BLACK) ); + aVDev->SetTextFillColor(); - pSalLayout = aVDev.ImplLayout( rStr, nIndex, nLen, Point(0,0), nLayoutWidth, pDXArray ); + pSalLayout = aVDev->ImplLayout( rStr, nIndex, nLen, Point(0,0), nLayoutWidth, pDXArray ); if (pSalLayout == 0) return false; long nWidth = pSalLayout->GetTextWidth(); - long nHeight = ((OutputDevice*)&aVDev)->mpFontEntry->mnLineHeight + ((OutputDevice*)&aVDev)->mnEmphasisAscent - + ((OutputDevice*)&aVDev)->mnEmphasisDescent; + long nHeight = aVDev->mpFontEntry->mnLineHeight + aVDev->mnEmphasisAscent + + aVDev->mnEmphasisDescent; pSalLayout->Release(); if( !nWidth || !nHeight ) @@ -2755,7 +2755,7 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, { sal_Int32 nStart = ((nBase < nIndex) ? nBase : nIndex); sal_Int32 nLength = ((nBase > nIndex) ? nBase : nIndex) - nStart; - pSalLayout = aVDev.ImplLayout( rStr, nStart, nLength, Point(0,0), nLayoutWidth, pDXArray ); + pSalLayout = aVDev->ImplLayout( rStr, nStart, nLength, Point(0,0), nLayoutWidth, pDXArray ); if( pSalLayout ) { nXOffset = pSalLayout->GetTextWidth(); @@ -2776,25 +2776,25 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, bool bSuccess = false; // draw character into virtual device - pSalLayout = aVDev.ImplLayout( rStr, nCharPos, 1, Point(0,0), nLayoutWidth, pDXArray ); + pSalLayout = aVDev->ImplLayout( rStr, nCharPos, 1, Point(0,0), nLayoutWidth, pDXArray ); if (pSalLayout == 0) return false; long nCharWidth = pSalLayout->GetTextWidth(); Point aOffset(nCharWidth / 2, 8); Size aSize(nCharWidth + 2 * aOffset.X(), nHeight + 2 * aOffset.Y()); - bSuccess = (bool)aVDev.SetOutputSizePixel(aSize); + bSuccess = (bool)aVDev->SetOutputSizePixel(aSize); if( bSuccess ) { // draw glyph into virtual device - aVDev.Erase(); + aVDev->Erase(); pSalLayout->DrawBase() += aOffset; - pSalLayout->DrawBase() += Point( ((OutputDevice*)&aVDev)->mnTextOffX, ((OutputDevice*)&aVDev)->mnTextOffY ); - pSalLayout->DrawText( *((OutputDevice*)&aVDev)->mpGraphics ); + pSalLayout->DrawBase() += Point( aVDev->mnTextOffX, aVDev->mnTextOffY ); + pSalLayout->DrawText( *aVDev->mpGraphics ); pSalLayout->Release(); // convert character image into outline - Bitmap aBmp( aVDev.GetBitmap(Point(0, 0), aSize)); + Bitmap aBmp( aVDev->GetBitmap(Point(0, 0), aSize)); tools::PolyPolygon aPolyPoly; bool bVectorized = aBmp.Vectorize(aPolyPoly, BMP_VECTORIZE_OUTER | BMP_VECTORIZE_REDUCE_EDGES); @@ -2810,8 +2810,8 @@ bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, { Point& rPt = rPoly[k]; rPt -= aOffset; - int nPixelX = rPt.X() - ((OutputDevice&)aVDev).mnTextOffX + nXOffset; - int nPixelY = rPt.Y() - ((OutputDevice&)aVDev).mnTextOffY; + int nPixelX = rPt.X() - ((OutputDevice*)aVDev.get())->mnTextOffX + nXOffset; + int nPixelY = rPt.Y() - ((OutputDevice*)aVDev.get())->mnTextOffY; rPt.X() = ImplDevicePixelToLogicWidth( nPixelX ); rPt.Y() = ImplDevicePixelToLogicHeight( nPixelY ); } diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index 60f68c28e5dc..425a56ab7514 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -116,7 +116,7 @@ sal_uInt16 OutputDevice::GetAlphaBitCount() const bool OutputDevice::HasAlpha() { - return mpAlphaVDev != NULL; + return mpAlphaVDev != nullptr; } void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask, @@ -431,25 +431,25 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, if( !bDrawn ) { - VirtualDevice aVDev( *this, 1 ); + ScopedVclPtrInstance< VirtualDevice > aVDev( *this, 1 ); const Size aDstSz( aDstRect.GetSize() ); const sal_uInt8 cTrans = (sal_uInt8) MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 ); if( aDstRect.Left() || aDstRect.Top() ) aPolyPoly.Move( -aDstRect.Left(), -aDstRect.Top() ); - if( aVDev.SetOutputSizePixel( aDstSz ) ) + if( aVDev->SetOutputSizePixel( aDstSz ) ) { const bool bOldMap = mbMap; EnableMapMode( false ); - aVDev.SetLineColor( COL_BLACK ); - aVDev.SetFillColor( COL_BLACK ); - aVDev.DrawPolyPolygon( aPolyPoly ); + aVDev->SetLineColor( COL_BLACK ); + aVDev->SetFillColor( COL_BLACK ); + aVDev->DrawPolyPolygon( aPolyPoly ); Bitmap aPaint( GetBitmap( aDstRect.TopLeft(), aDstSz ) ); - Bitmap aPolyMask( aVDev.GetBitmap( Point(), aDstSz ) ); + Bitmap aPolyMask( aVDev->GetBitmap( Point(), aDstSz ) ); // #107766# check for non-empty bitmaps before accessing them if( !!aPaint && !!aPolyMask ) @@ -683,7 +683,7 @@ void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, if( !aDstRect.IsEmpty() ) { - std::unique_ptr<VirtualDevice> xVDev(new VirtualDevice); + ScopedVclPtrInstance< VirtualDevice > xVDev; ((OutputDevice*)xVDev.get())->mnDPIX = mnDPIX; ((OutputDevice*)xVDev.get())->mnDPIY = mnDPIY; diff --git a/vcl/source/outdev/wallpaper.cxx b/vcl/source/outdev/wallpaper.cxx index 8e4d86bc321f..ba7928b4f812 100644 --- a/vcl/source/outdev/wallpaper.cxx +++ b/vcl/source/outdev/wallpaper.cxx @@ -129,11 +129,11 @@ void OutputDevice::DrawBitmapWallpaper( long nX, long nY, { if( !pCached && !rWallpaper.GetColor().GetTransparency() ) { - VirtualDevice aVDev( *this ); - aVDev.SetBackground( rWallpaper.GetColor() ); - aVDev.SetOutputSizePixel( Size( nBmpWidth, nBmpHeight ) ); - aVDev.DrawBitmapEx( Point(), aBmpEx ); - aBmpEx = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() ); + ScopedVclPtrInstance< VirtualDevice > aVDev( *this ); + aVDev->SetBackground( rWallpaper.GetColor() ); + aVDev->SetOutputSizePixel( Size( nBmpWidth, nBmpHeight ) ); + aVDev->DrawBitmapEx( Point(), aBmpEx ); + aBmpEx = aVDev->GetBitmap( Point(), aVDev->GetOutputSizePixel() ); } bDrawColorBackground = true; |