[Libreoffice-commits] core.git: include/vcl vcl/source
Chris Sherlock
chris.sherlock79 at gmail.com
Fri Mar 21 12:10:54 PDT 2014
include/vcl/outdev.hxx | 6 +
include/vcl/print.hxx | 2
include/vcl/virdev.hxx | 1
include/vcl/window.hxx | 1
vcl/source/gdi/outdev.cxx | 140 +++++++------------------------------------
vcl/source/gdi/print.cxx | 84 +++++++++++++++++++++++++
vcl/source/gdi/virdev.cxx | 32 +++++++++
vcl/source/window/window.cxx | 31 +++++++++
8 files changed, 180 insertions(+), 117 deletions(-)
New commits:
commit 143c059ff7f69a363b3cf736a9f0197a9f25cf9c
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date: Wed Mar 12 23:36:17 2014 +1100
fdo#74702 Moved ImplReleaseGraphics into correct classes
Made OutputDevice::ImplReleaseGraphics a pure virtual function, then
implemented function in Printer, Window and VirtualDevice. The reason
was that OutputDevice was checking to see if it was a Printer, Window
or VirtualDevice that was calling on it in an if statement, very
uncool :-) Now I let the classes themselves do the work.
There is some common functionality, which is to release the fonts. I
have put this into a protected OutputDevice function, ImplReleaseFonts.
Change-Id: Id41db2119d4022ea2fc7855158ca9f610af3c85c
Reviewed-on: https://gerrit.libreoffice.org/8548
Reviewed-by: Norbert Thiebaud <nthiebaud at gmail.com>
Tested-by: Norbert Thiebaud <nthiebaud at gmail.com>
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index c539556..67b7a1f 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -352,6 +352,10 @@ private:
mutable bool mbRefPoint : 1;
mutable bool mbEnableRTL : 1;
+
+protected:
+ virtual void ImplReleaseFonts();
+
public:
/** @name Initialization and accessor functions
*/
@@ -393,7 +397,7 @@ public:
@param bRelease Determines whether to release the fonts of the
physically released graphics device.
*/
- SAL_DLLPRIVATE void ImplReleaseGraphics( bool bRelease = true );
+ virtual void ImplReleaseGraphics( bool bRelease = true ) = 0;
/** Initialize the graphics device's data structures.
*/
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index 2e8098d..0f5897d 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -248,6 +248,8 @@ private:
Link maErrorHdl;
bool ImplInitGraphics() const;
+ void ImplReleaseGraphics( bool bRelease = true );
+ void ImplReleaseFonts();
SAL_DLLPRIVATE void ImplInitData();
SAL_DLLPRIVATE void ImplInit( SalPrinterQueueInfo* pInfo );
SAL_DLLPRIVATE void ImplInitDisplay( const Window* pWindow );
diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index b78495d..72cc3fe 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -62,6 +62,7 @@ private:
{ return ((meRefDevMode & REFDEV_FORCE_ZERO_EXTLEAD) != 0); }
public:
bool ImplInitGraphics() const;
+ void ImplReleaseGraphics( bool bRelease = true );
public:
/** Create a virtual device of size 1x1
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 62aa5c8..8d76850 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -375,6 +375,7 @@ private:
public:
SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData );
bool ImplInitGraphics() const;
+ void ImplReleaseGraphics( bool bRelease = true );
SAL_DLLPRIVATE WinBits ImplInitRes( const ResId& rResId );
SAL_DLLPRIVATE WindowResHeader ImplLoadResHeader( const ResId& rResId );
SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx
index 762f2bd..8518345 100644
--- a/vcl/source/gdi/outdev.cxx
+++ b/vcl/source/gdi/outdev.cxx
@@ -551,134 +551,42 @@ SalGraphics const *OutputDevice::ImplGetGraphics() const
return mpGraphics;
}
-void OutputDevice::ImplReleaseGraphics( bool bRelease )
+void OutputDevice::ImplInitOutDevData()
{
- DBG_TESTSOLARMUTEX();
-
- if ( !mpGraphics )
- return;
-
- // release the fonts of the physically released graphics device
- if( bRelease )
+ if ( !mpOutDevData )
{
-#ifndef UNX
- // HACK to fix an urgent P1 printing issue fast
- // WinSalPrinter does not respect GetGraphics/ReleaseGraphics conventions
- // so Printer::mpGraphics often points to a dead WinSalGraphics
- // TODO: fix WinSalPrinter's GetGraphics/ReleaseGraphics handling
- if( meOutDevType != OUTDEV_PRINTER )
-#endif
- mpGraphics->ReleaseFonts();
-
- mbNewFont = true;
- mbInitFont = true;
-
- if ( mpFontEntry )
- {
- mpFontCache->Release( mpFontEntry );
- mpFontEntry = NULL;
- }
-
- if ( mpGetDevFontList )
- {
- delete mpGetDevFontList;
- mpGetDevFontList = NULL;
- }
+ mpOutDevData = new ImplOutDevData;
+ mpOutDevData->mpRotateDev = NULL;
+ mpOutDevData->mpRecordLayout = NULL;
- if ( mpGetDevSizeList )
- {
- delete mpGetDevSizeList;
- mpGetDevSizeList = NULL;
- }
+ // #i75163#
+ mpOutDevData->mpViewTransform = NULL;
+ mpOutDevData->mpInverseViewTransform = NULL;
}
+}
- ImplSVData* pSVData = ImplGetSVData();
- if ( meOutDevType == OUTDEV_WINDOW )
- {
- Window* pWindow = (Window*)this;
+void OutputDevice::ImplReleaseFonts()
+{
+ mpGraphics->ReleaseFonts();
+ mbNewFont = true;
+ mbInitFont = true;
- if ( bRelease )
- pWindow->mpWindowImpl->mpFrame->ReleaseGraphics( mpGraphics );
- // remove from global LRU list of window graphics
- if ( mpPrevGraphics )
- mpPrevGraphics->mpNextGraphics = mpNextGraphics;
- else
- pSVData->maGDIData.mpFirstWinGraphics = mpNextGraphics;
- if ( mpNextGraphics )
- mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
- else
- pSVData->maGDIData.mpLastWinGraphics = mpPrevGraphics;
- }
- else if ( meOutDevType == OUTDEV_VIRDEV )
+ if ( mpFontEntry )
{
- VirtualDevice* pVirDev = (VirtualDevice*)this;
-
- if ( bRelease )
- pVirDev->mpVirDev->ReleaseGraphics( mpGraphics );
- // remove from global LRU list of virtual device graphics
- if ( mpPrevGraphics )
- mpPrevGraphics->mpNextGraphics = mpNextGraphics;
- else
- pSVData->maGDIData.mpFirstVirGraphics = mpNextGraphics;
- if ( mpNextGraphics )
- mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
- else
- pSVData->maGDIData.mpLastVirGraphics = mpPrevGraphics;
+ mpFontCache->Release( mpFontEntry );
+ mpFontEntry = NULL;
}
- else if ( meOutDevType == OUTDEV_PRINTER )
- {
- Printer* pPrinter = (Printer*)this;
- if ( !pPrinter->mpJobGraphics )
- {
- if ( pPrinter->mpDisplayDev )
- {
- VirtualDevice* pVirDev = pPrinter->mpDisplayDev;
- if ( bRelease )
- pVirDev->mpVirDev->ReleaseGraphics( mpGraphics );
- // remove from global LRU list of virtual device graphics
- if ( mpPrevGraphics )
- mpPrevGraphics->mpNextGraphics = mpNextGraphics;
- else
- pSVData->maGDIData.mpFirstVirGraphics = mpNextGraphics;
- if ( mpNextGraphics )
- mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
- else
- pSVData->maGDIData.mpLastVirGraphics = mpPrevGraphics;
- }
- else
- {
- if ( bRelease )
- pPrinter->mpInfoPrinter->ReleaseGraphics( mpGraphics );
- // remove from global LRU list of printer graphics
- if ( mpPrevGraphics )
- mpPrevGraphics->mpNextGraphics = mpNextGraphics;
- else
- pSVData->maGDIData.mpFirstPrnGraphics = mpNextGraphics;
- if ( mpNextGraphics )
- mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
- else
- pSVData->maGDIData.mpLastPrnGraphics = mpPrevGraphics;
- }
- }
+ if ( mpGetDevFontList )
+ {
+ delete mpGetDevFontList;
+ mpGetDevFontList = NULL;
}
- mpGraphics = NULL;
- mpPrevGraphics = NULL;
- mpNextGraphics = NULL;
-}
-
-void OutputDevice::ImplInitOutDevData()
-{
- if ( !mpOutDevData )
+ if ( mpGetDevSizeList )
{
- mpOutDevData = new ImplOutDevData;
- mpOutDevData->mpRotateDev = NULL;
- mpOutDevData->mpRecordLayout = NULL;
-
- // #i75163#
- mpOutDevData->mpViewTransform = NULL;
- mpOutDevData->mpInverseViewTransform = NULL;
+ delete mpGetDevSizeList;
+ mpGetDevSizeList = NULL;
}
}
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index dca6ef3..3f1acd1 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -527,6 +527,90 @@ bool Printer::ImplInitGraphics() const
return mpGraphics ? true : false;
}
+void Printer::ImplReleaseFonts()
+{
+#ifndef UNX
+ // HACK to fix an urgent P1 printing issue fast
+ // WinSalPrinter does not respect GetGraphics/ReleaseGraphics conventions
+ // so Printer::mpGraphics often points to a dead WinSalGraphics
+ // TODO: fix WinSalPrinter's GetGraphics/ReleaseGraphics handling
+ mpGraphics->ReleaseFonts();
+#endif
+ mbNewFont = true;
+ mbInitFont = true;
+
+ if ( mpFontEntry )
+ {
+ mpFontCache->Release( mpFontEntry );
+ mpFontEntry = NULL;
+ }
+
+ if ( mpGetDevFontList )
+ {
+ delete mpGetDevFontList;
+ mpGetDevFontList = NULL;
+ }
+
+ if ( mpGetDevSizeList )
+ {
+ delete mpGetDevSizeList;
+ mpGetDevSizeList = NULL;
+ }
+}
+
+void Printer::ImplReleaseGraphics( bool bRelease )
+{
+ DBG_TESTSOLARMUTEX();
+
+ if ( !mpGraphics )
+ return;
+
+ // release the fonts of the physically released graphics device
+ if( bRelease )
+ ImplReleaseFonts();
+
+ ImplSVData* pSVData = ImplGetSVData();
+
+ Printer* pPrinter = (Printer*)this;
+
+ if ( !pPrinter->mpJobGraphics )
+ {
+ if ( pPrinter->mpDisplayDev )
+ {
+ VirtualDevice* pVirDev = pPrinter->mpDisplayDev;
+ if ( bRelease )
+ pVirDev->mpVirDev->ReleaseGraphics( mpGraphics );
+ // remove from global LRU list of virtual device graphics
+ if ( mpPrevGraphics )
+ mpPrevGraphics->mpNextGraphics = mpNextGraphics;
+ else
+ pSVData->maGDIData.mpFirstVirGraphics = mpNextGraphics;
+ if ( mpNextGraphics )
+ mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
+ else
+ pSVData->maGDIData.mpLastVirGraphics = mpPrevGraphics;
+ }
+ else
+ {
+ if ( bRelease )
+ pPrinter->mpInfoPrinter->ReleaseGraphics( mpGraphics );
+ // remove from global LRU list of printer graphics
+ if ( mpPrevGraphics )
+ mpPrevGraphics->mpNextGraphics = mpNextGraphics;
+ else
+ pSVData->maGDIData.mpFirstPrnGraphics = mpNextGraphics;
+ if ( mpNextGraphics )
+ mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
+ else
+ pSVData->maGDIData.mpLastPrnGraphics = mpPrevGraphics;
+ }
+ }
+
+ mpGraphics = NULL;
+ mpPrevGraphics = NULL;
+ mpNextGraphics = NULL;
+}
+
void Printer::ImplInit( SalPrinterQueueInfo* pInfo )
{
ImplSVData* pSVData = ImplGetSVData();
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index cf8ab48..68789c8 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -82,6 +82,38 @@ bool VirtualDevice::ImplInitGraphics() const
return mpGraphics ? true : false;
}
+void VirtualDevice::ImplReleaseGraphics( bool bRelease )
+{
+ DBG_TESTSOLARMUTEX();
+
+ if ( !mpGraphics )
+ return;
+
+ // release the fonts of the physically released graphics device
+ if ( bRelease )
+ ImplReleaseFonts();
+
+ ImplSVData* pSVData = ImplGetSVData();
+
+ VirtualDevice* pVirDev = (VirtualDevice*)this;
+
+ if ( bRelease )
+ pVirDev->mpVirDev->ReleaseGraphics( mpGraphics );
+ // remove from global LRU list of virtual device graphics
+ if ( mpPrevGraphics )
+ mpPrevGraphics->mpNextGraphics = mpNextGraphics;
+ else
+ pSVData->maGDIData.mpFirstVirGraphics = mpNextGraphics;
+ if ( mpNextGraphics )
+ mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
+ else
+ pSVData->maGDIData.mpLastVirGraphics = mpPrevGraphics;
+
+ mpGraphics = NULL;
+ mpPrevGraphics = NULL;
+ mpNextGraphics = NULL;
+}
+
void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev,
long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData )
{
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index f56c2e1..dbb2c5f 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -420,6 +420,37 @@ bool Window::ImplInitGraphics() const
return mpGraphics ? true : false;
}
+void Window::ImplReleaseGraphics( bool bRelease )
+{
+ DBG_TESTSOLARMUTEX();
+
+ if ( !mpGraphics )
+ return;
+
+ // release the fonts of the physically released graphics device
+ if( bRelease )
+ ImplReleaseFonts();
+
+ ImplSVData* pSVData = ImplGetSVData();
+
+ Window* pWindow = (Window*)this;
+
+ if ( bRelease )
+ pWindow->mpWindowImpl->mpFrame->ReleaseGraphics( mpGraphics );
+ // remove from global LRU list of window graphics
+ if ( mpPrevGraphics )
+ mpPrevGraphics->mpNextGraphics = mpNextGraphics;
+ else
+ pSVData->maGDIData.mpFirstWinGraphics = mpNextGraphics;
+ if ( mpNextGraphics )
+ mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
+ else
+ pSVData->maGDIData.mpLastWinGraphics = mpPrevGraphics;
+
+ mpGraphics = NULL;
+ mpPrevGraphics = NULL;
+ mpNextGraphics = NULL;
+}
bool Window::HasMirroredGraphics() const
{
More information about the Libreoffice-commits
mailing list