vcl/inc/win/salgdi.h | 43 +++++++++++++++---------- vcl/source/opengl/OpenGLContext.cxx | 2 - vcl/win/source/gdi/salgdi.cxx | 47 ++++++++++++++++++---------- vcl/win/source/gdi/salprn.cxx | 14 ++++---- vcl/win/source/gdi/salvd.cxx | 10 +++--- vcl/win/source/window/salframe.cxx | 60 ++++++++++++++++++------------------ 6 files changed, 100 insertions(+), 76 deletions(-)
New commits: commit 33e9890625c630148a8eb9fa08563812b5302bde Author: Markus Mohrhard <[email protected]> Date: Sun Nov 2 03:31:00 2014 +0100 at least some sanity for WinSalGraphics we no longer invite everyone to change our member variables. This was obviously written by a C programmer and needs further refactoring. Change-Id: I896576a5abc24e8d03787d30e6ba6c11b0bf84c6 diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 363ab0f..9392cc5 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -144,6 +144,8 @@ public: class WinSalGraphics : public SalGraphics { + friend class WinSalGraphicsImpl; + friend class ScopedFont; private: boost::scoped_ptr<SalGraphicsImpl> mpImpl; @@ -154,21 +156,6 @@ private: bool mbScreen : 1; // is Screen compatible HWND mhWnd; // Window-Handle, when Window-Graphics -public: - HDC getHDC() const { return mhLocalDC; } - void setHDC(HDC aNew) { mhLocalDC = aNew; } - - enum Type - { - PRINTER, - VIRTUAL_DEVICE, - WINDOW, - SCREEN - }; - -public: - - HWND gethWnd(); HFONT mhFonts[ MAX_FALLBACK ]; // Font + Fallbacks const ImplWinFontData* mpWinFontData[ MAX_FALLBACK ]; // pointer to the most recent font face ImplWinFontEntry* mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the most recent font instance @@ -191,6 +178,30 @@ public: sal_uIntPtr mnFontKernPairCount;// Number of Kerning Pairs of the current Font int mnPenWidth; // Linienbreite +public: + HDC getHDC() const { return mhLocalDC; } + void setHDC(HDC aNew) { mhLocalDC = aNew; } + + HPALETTE getDefPal() const; + void setDefPal(HPALETTE hDefPal); + + HRGN getRegion() const; + + void InitGraphics(); + void DeInitGraphics(); + + enum Type + { + PRINTER, + VIRTUAL_DEVICE, + WINDOW, + SCREEN + }; + +public: + + HWND gethWnd(); + HFONT ImplDoSetFont( FontSelectPattern* i_pFont, float& o_rFontScale, HFONT& o_rOldFont ); public: @@ -391,8 +402,6 @@ public: }; // Init/Deinit Graphics -void ImplSalInitGraphics( WinSalGraphics* ); -void ImplSalDeInitGraphics( WinSalGraphics* ); void ImplUpdateSysColorEntries(); int ImplIsSysColorEntry( SalColor nSalColor ); void ImplGetLogFontFromFontSelect( HDC, const FontSelectPattern*, diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx index af16d90..4022d2d 100644 --- a/vcl/win/source/gdi/salgdi.cxx +++ b/vcl/win/source/gdi/salgdi.cxx @@ -464,34 +464,34 @@ void ImplUpdateSysColorEntries() ImplInsertSysColorEntry( COLOR_INACTIVECAPTIONTEXT ); } -void ImplSalInitGraphics( WinSalGraphics* pData ) +void WinSalGraphics::InitGraphics() { // calculate the minimal line width for the printer - if ( pData->isPrinter() ) + if ( isPrinter() ) { - int nDPIX = GetDeviceCaps( pData->getHDC(), LOGPIXELSX ); + int nDPIX = GetDeviceCaps( getHDC(), LOGPIXELSX ); if ( nDPIX <= 300 ) - pData->mnPenWidth = 0; + mnPenWidth = 0; else - pData->mnPenWidth = nDPIX/300; + mnPenWidth = nDPIX/300; } - ::SetTextAlign( pData->getHDC(), TA_BASELINE | TA_LEFT | TA_NOUPDATECP ); - ::SetBkMode( pData->getHDC(), WIN32_TRANSPARENT ); - ::SetROP2( pData->getHDC(), R2_COPYPEN ); + ::SetTextAlign( getHDC(), TA_BASELINE | TA_LEFT | TA_NOUPDATECP ); + ::SetBkMode( getHDC(), WIN32_TRANSPARENT ); + ::SetROP2( getHDC(), R2_COPYPEN ); } -void ImplSalDeInitGraphics( WinSalGraphics* pData ) +void WinSalGraphics::DeInitGraphics() { // clear clip region - SelectClipRgn( pData->getHDC(), 0 ); + SelectClipRgn( getHDC(), 0 ); // select default objects - if ( pData->mhDefPen ) - SelectPen( pData->getHDC(), pData->mhDefPen ); - if ( pData->mhDefBrush ) - SelectBrush( pData->getHDC(), pData->mhDefBrush ); - if ( pData->mhDefFont ) - SelectFont( pData->getHDC(), pData->mhDefFont ); + if ( mhDefPen ) + SelectPen( getHDC(), mhDefPen ); + if ( mhDefBrush ) + SelectBrush( getHDC(), mhDefBrush ); + if ( mhDefFont ) + SelectFont( getHDC(), mhDefFont ); } HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp ) @@ -644,6 +644,21 @@ void WinSalGraphics::setHWND(HWND hWnd) mhWnd = hWnd; } +HPALETTE WinSalGraphics::getDefPal() const +{ + return mhDefPal; +} + +void WinSalGraphics::setDefPal(HPALETTE hDefPal) +{ + mhDefPal = hDefPal; +} + +HRGN WinSalGraphics::getRegion() const +{ + return mhRegion; +} + void WinSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) { rDPIX = GetDeviceCaps( getHDC(), LOGPIXELSX ); diff --git a/vcl/win/source/gdi/salprn.cxx b/vcl/win/source/gdi/salprn.cxx index b992554..ad22b4e 100644 --- a/vcl/win/source/gdi/salprn.cxx +++ b/vcl/win/source/gdi/salprn.cxx @@ -1048,7 +1048,7 @@ static WinSalGraphics* ImplCreateSalPrnGraphics( HDC hDC ) WinSalGraphics* pGraphics = new WinSalGraphics(WinSalGraphics::PRINTER, false, 0); pGraphics->SetLayout( 0 ); pGraphics->setHDC(hDC); - ImplSalInitGraphics( pGraphics ); + pGraphics->InitGraphics(); return pGraphics; } @@ -1060,7 +1060,7 @@ static bool ImplUpdateSalPrnIC( WinSalInfoPrinter* pPrinter, ImplJobSetup* pSetu if ( pPrinter->mpGraphics ) { - ImplSalDeInitGraphics( pPrinter->mpGraphics ); + pPrinter->mpGraphics->DeInitGraphics(); DeleteDC( pPrinter->mpGraphics->getHDC() ); delete pPrinter->mpGraphics; } @@ -1124,7 +1124,7 @@ WinSalInfoPrinter::~WinSalInfoPrinter() { if ( mpGraphics ) { - ImplSalDeInitGraphics( mpGraphics ); + mpGraphics->DeInitGraphics(); DeleteDC( mpGraphics->getHDC() ); delete mpGraphics; } @@ -1407,7 +1407,7 @@ WinSalPrinter::~WinSalPrinter() { if ( mpGraphics ) { - ImplSalDeInitGraphics( mpGraphics ); + mpGraphics->DeInitGraphics(); delete mpGraphics; } @@ -1582,7 +1582,7 @@ bool WinSalPrinter::EndJob() { if ( mpGraphics ) { - ImplSalDeInitGraphics( mpGraphics ); + mpGraphics->DeInitGraphics(); delete mpGraphics; mpGraphics = NULL; } @@ -1645,7 +1645,7 @@ void ImplSalPrinterAbortJobAsync( HDC hPrnDC ) { if ( pPrinter->mpGraphics ) { - ImplSalDeInitGraphics( pPrinter->mpGraphics ); + pPrinter->mpGraphics->DeInitGraphics(); delete pPrinter->mpGraphics; pPrinter->mpGraphics = NULL; } @@ -1705,7 +1705,7 @@ bool WinSalPrinter::EndPage() HDC hDC = mhDC; if ( hDC && mpGraphics ) { - ImplSalDeInitGraphics( mpGraphics ); + mpGraphics->DeInitGraphics(); delete mpGraphics; mpGraphics = NULL; } diff --git a/vcl/win/source/gdi/salvd.cxx b/vcl/win/source/gdi/salvd.cxx index 820f12f..2269deb 100644 --- a/vcl/win/source/gdi/salvd.cxx +++ b/vcl/win/source/gdi/salvd.cxx @@ -109,10 +109,10 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics, pVirGraphics->setHDC(hDC); if ( pSalData->mhDitherPal && pVirGraphics->isScreen() ) { - pVirGraphics->mhDefPal = SelectPalette( hDC, pSalData->mhDitherPal, TRUE ); + pVirGraphics->setDefPal(SelectPalette( hDC, pSalData->mhDitherPal, TRUE )); RealizePalette( hDC ); } - ImplSalInitGraphics( pVirGraphics ); + pVirGraphics->InitGraphics(); pVDev->setHDC(hDC); pVDev->mhBmp = hBmp; @@ -163,9 +163,9 @@ WinSalVirtualDevice::~WinSalVirtualDevice() *ppVirDev = mpNext; // destroy saved DC - if( mpGraphics->mhDefPal ) - SelectPalette( mpGraphics->getHDC(), mpGraphics->mhDefPal, TRUE ); - ImplSalDeInitGraphics( mpGraphics ); + if( mpGraphics->getDefPal() ) + SelectPalette( mpGraphics->getHDC(), mpGraphics->getDefPal(), TRUE ); + mpGraphics->InitGraphics(); if( mhDefBmp ) SelectBitmap( mpGraphics->getHDC(), mhDefBmp ); if( !mbForeignDC ) diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx index dde2845..9dd008b 100644 --- a/vcl/win/source/window/salframe.cxx +++ b/vcl/win/source/window/salframe.cxx @@ -932,9 +932,9 @@ WinSalFrame::~WinSalFrame() // destroy saved DC if ( mpGraphics ) { - if ( mpGraphics->mhDefPal ) - SelectPalette( mpGraphics->getHDC(), mpGraphics->mhDefPal, TRUE ); - ImplSalDeInitGraphics( mpGraphics ); + if ( mpGraphics->getDefPal() ) + SelectPalette( mpGraphics->getHDC(), mpGraphics->getDefPal(), TRUE ); + mpGraphics->DeInitGraphics(); ReleaseDC( mhWnd, mpGraphics->getHDC() ); delete mpGraphics; mpGraphics = NULL; @@ -995,10 +995,10 @@ SalGraphics* WinSalFrame::AcquireGraphics() mpGraphics2->setHDC(hDC); if ( pSalData->mhDitherPal ) { - mpGraphics2->mhDefPal = SelectPalette( hDC, pSalData->mhDitherPal, TRUE ); + mpGraphics2->setDefPal(SelectPalette( hDC, pSalData->mhDitherPal, TRUE )); RealizePalette( hDC ); } - ImplSalInitGraphics( mpGraphics2 ); + mpGraphics2->InitGraphics(); mbGraphics = TRUE; pSalData->mnCacheDCInUse++; @@ -1018,10 +1018,10 @@ SalGraphics* WinSalFrame::AcquireGraphics() mpGraphics->setHDC(hDC); if ( pSalData->mhDitherPal ) { - mpGraphics->mhDefPal = SelectPalette( hDC, pSalData->mhDitherPal, TRUE ); + mpGraphics->setDefPal(SelectPalette( hDC, pSalData->mhDitherPal, TRUE )); RealizePalette( hDC ); } - ImplSalInitGraphics( mpGraphics ); + mpGraphics->InitGraphics(); mbGraphics = TRUE; } } @@ -1039,9 +1039,9 @@ void WinSalFrame::ReleaseGraphics( SalGraphics* pGraphics ) if ( mpGraphics2->getHDC() ) { SalData* pSalData = GetSalData(); - if ( mpGraphics2->mhDefPal ) - SelectPalette( mpGraphics2->getHDC(), mpGraphics2->mhDefPal, TRUE ); - ImplSalDeInitGraphics( mpGraphics2 ); + if ( mpGraphics2->getDefPal() ) + SelectPalette( mpGraphics2->getHDC(), mpGraphics2->getDefPal(), TRUE ); + mpGraphics2->InitGraphics(); SendMessageW( pSalData->mpFirstInstance->mhComWnd, SAL_MSG_RELEASEDC, (WPARAM)mhWnd, @@ -1489,9 +1489,9 @@ static void ImplSetParentFrame( WinSalFrame* pThis, HWND hNewParentWnd, bool bAs // destroy saved DC if ( pThis->mpGraphics ) { - if ( pThis->mpGraphics->mhDefPal ) - SelectPalette( pThis->mpGraphics->getHDC(), pThis->mpGraphics->mhDefPal, TRUE ); - ImplSalDeInitGraphics( pThis->mpGraphics ); + if ( pThis->mpGraphics->getDefPal() ) + SelectPalette( pThis->mpGraphics->getHDC(), pThis->mpGraphics->getDefPal(), TRUE ); + pThis->mpGraphics->InitGraphics(); ReleaseDC( pThis->mhWnd, pThis->mpGraphics->getHDC() ); } @@ -1523,10 +1523,10 @@ static void ImplSetParentFrame( WinSalFrame* pThis, HWND hNewParentWnd, bool bAs pThis->mpGraphics2->setHDC(hDC); if ( pSalData->mhDitherPal ) { - pThis->mpGraphics2->mhDefPal = SelectPalette( hDC, pSalData->mhDitherPal, TRUE ); + pThis->mpGraphics2->setDefPal(SelectPalette( hDC, pSalData->mhDitherPal, TRUE )); RealizePalette( hDC ); } - ImplSalInitGraphics( pThis->mpGraphics2 ); + pThis->mpGraphics2->InitGraphics(); // re-select saved gdi objects if( hFont ) @@ -1552,10 +1552,10 @@ static void ImplSetParentFrame( WinSalFrame* pThis, HWND hNewParentWnd, bool bAs pThis->mpGraphics->setHDC( GetDC( hWnd ) ); if ( GetSalData()->mhDitherPal ) { - pThis->mpGraphics->mhDefPal = SelectPalette( pThis->mpGraphics->getHDC(), GetSalData()->mhDitherPal, TRUE ); + pThis->mpGraphics->setDefPal(SelectPalette( pThis->mpGraphics->getHDC(), GetSalData()->mhDitherPal, TRUE )); RealizePalette( pThis->mpGraphics->getHDC() ); } - ImplSalInitGraphics( pThis->mpGraphics ); + pThis->mpGraphics->InitGraphics(); pThis->mbGraphics = TRUE; } } @@ -3753,7 +3753,7 @@ static bool ImplHandlePaintMsg( HWND hWnd ) { // clip-region must be reset, as we do not get a proper // bounding-rectangle otherwise - if ( pFrame->mpGraphics && pFrame->mpGraphics->mhRegion ) + if ( pFrame->mpGraphics && pFrame->mpGraphics->getRegion() ) SelectClipRgn( pFrame->mpGraphics->getHDC(), 0 ); // according to Window-Documentation one shall check first if @@ -3769,10 +3769,10 @@ static bool ImplHandlePaintMsg( HWND hWnd ) // Paint // reset ClipRegion - if ( pFrame->mpGraphics && pFrame->mpGraphics->mhRegion ) + if ( pFrame->mpGraphics && pFrame->mpGraphics->getRegion() ) { SelectClipRgn( pFrame->mpGraphics->getHDC(), - pFrame->mpGraphics->mhRegion ); + pFrame->mpGraphics->getRegion() ); } if ( bMutex ) @@ -3791,10 +3791,10 @@ static bool ImplHandlePaintMsg( HWND hWnd ) else { // reset ClipRegion - if ( pFrame->mpGraphics && pFrame->mpGraphics->mhRegion ) + if ( pFrame->mpGraphics && pFrame->mpGraphics->getRegion() ) { SelectClipRgn( pFrame->mpGraphics->getHDC(), - pFrame->mpGraphics->mhRegion ); + pFrame->mpGraphics->getRegion() ); } } } @@ -4147,7 +4147,7 @@ static void ImplHandleForcePalette( HWND hWnd ) if ( pFrame && pFrame->mpGraphics ) { WinSalGraphics* pGraphics = pFrame->mpGraphics; - if ( pGraphics && pGraphics->mhDefPal ) + if ( pGraphics && pGraphics->getDefPal() ) { SelectPalette( pGraphics->getHDC(), hPal, FALSE ); if ( RealizePalette( pGraphics->getHDC() ) ) @@ -4210,10 +4210,10 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg, while ( pTempVD ) { pGraphics = pTempVD->mpGraphics; - if ( pGraphics->mhDefPal ) + if ( pGraphics->getDefPal() ) { SelectPalette( pGraphics->getHDC(), - pGraphics->mhDefPal, + pGraphics->getDefPal(), TRUE ); } pTempVD = pTempVD->mpNext; @@ -4222,10 +4222,10 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg, while ( pTempFrame ) { pGraphics = pTempFrame->mpGraphics; - if ( pGraphics && pGraphics->mhDefPal ) + if ( pGraphics && pGraphics->getDefPal() ) { SelectPalette( pGraphics->getHDC(), - pGraphics->mhDefPal, + pGraphics->getDefPal(), TRUE ); } pTempFrame = pTempFrame->mpNextFrame; @@ -4260,7 +4260,7 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg, while ( pTempVD ) { pGraphics = pTempVD->mpGraphics; - if ( pGraphics->mhDefPal ) + if ( pGraphics->getDefPal() ) { SelectPalette( pGraphics->getHDC(), hPal, TRUE ); RealizePalette( pGraphics->getHDC() ); @@ -4273,7 +4273,7 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg, if ( pTempFrame != pFrame ) { pGraphics = pTempFrame->mpGraphics; - if ( pGraphics && pGraphics->mhDefPal ) + if ( pGraphics && pGraphics->getDefPal() ) { SelectPalette( pGraphics->getHDC(), hPal, TRUE ); if ( RealizePalette( pGraphics->getHDC() ) ) @@ -4290,7 +4290,7 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg, while ( pTempFrame ) { pGraphics = pTempFrame->mpGraphics; - if ( pGraphics && pGraphics->mhDefPal ) + if ( pGraphics && pGraphics->getDefPal() ) { InvalidateRect( pTempFrame->mhWnd, NULL, FALSE ); UpdateWindow( pTempFrame->mhWnd ); commit a27186d64d75c18006c2aa127da0d974d135d823 Author: Markus Mohrhard <[email protected]> Date: Sun Nov 2 02:49:22 2014 +0100 use false instead of 0 Change-Id: I7210493b98e8ed778eeba6518dc131e63863ff67 diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 0242bf5..b4c2cee 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -160,7 +160,7 @@ bool WGLisExtensionSupported(const char *extension) supported = (char*)glGetString(GL_EXTENSIONS); // If That Failed Too, Must Be No Extensions Supported if (supported == NULL) - return 0; + return false; // Begin Examination At Start Of String, Increment By 1 On False Match for (const char* p = supported; ; p++) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
