From e69615ccb016de1c64864bbc9cf1bbef9f50c1da Mon Sep 17 00:00:00 2001 From: Chris Sherlock Date: Mon, 10 Mar 2014 23:42:13 +1100 Subject: fdo#74702 Moved ImplInitGraphics into correct classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently we check to see what type of class is being used. This really violates the Single Responsibility Principle, and tightly couples the code to OutputDevice. The responsibility for initializing graphics should be done by Printer, VirtualDevice and Window. Please note: to get this working, I've had to make Printer a friend class of VirtualDevice. I'm not entirely happy about this, I'll need to revisit this later when I look at Printer in more detail. For now, this is a hack to allow me to seperate out this function. Change-Id: I9d5946c22fa70670a4f85bf338b4209499d0aa54 Reviewed-on: https://gerrit.libreoffice.org/8528 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- vcl/source/gdi/virdev.cxx | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'vcl/source/gdi/virdev.cxx') diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index eda91c0060dc..bb9d37fd5ab1 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -34,7 +34,51 @@ using namespace ::com::sun::star::uno; +bool VirtualDevice::ImplInitGraphics() const +{ + DBG_TESTSOLARMUTEX(); + + mbInitLineColor = true; + mbInitFillColor = true; + mbInitFont = true; + mbInitTextColor = true; + mbInitClipRegion = true; + + ImplSVData* pSVData = ImplGetSVData(); + + const VirtualDevice* pVirDev = (const VirtualDevice*)this; + + if ( pVirDev->mpVirDev ) + { + mpGraphics = pVirDev->mpVirDev->AcquireGraphics(); + // if needed retry after releasing least recently used virtual device graphics + while ( !mpGraphics ) + { + if ( !pSVData->maGDIData.mpLastVirGraphics ) + break; + pSVData->maGDIData.mpLastVirGraphics->ImplReleaseGraphics(); + mpGraphics = pVirDev->mpVirDev->AcquireGraphics(); + } + // update global LRU list of virtual device graphics + if ( mpGraphics ) + { + mpNextGraphics = pSVData->maGDIData.mpFirstVirGraphics; + pSVData->maGDIData.mpFirstVirGraphics = const_cast(this); + if ( mpNextGraphics ) + mpNextGraphics->mpPrevGraphics = const_cast(this); + if ( !pSVData->maGDIData.mpLastVirGraphics ) + pSVData->maGDIData.mpLastVirGraphics = const_cast(this); + } + } + if ( mpGraphics ) + { + mpGraphics->SetXORMode( (ROP_INVERT == meRasterOp) || (ROP_XOR == meRasterOp), ROP_INVERT == meRasterOp ); + mpGraphics->setAntiAliasB2DDraw(mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW); + } + + return mpGraphics ? true : false; +} void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData ) -- cgit v1.2.3