diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2025-02-18 08:07:29 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2025-02-18 12:08:33 +0100 |
commit | b5510122fd68e3d16117684f51062dfb03961b85 (patch) | |
tree | 0056c37275bf70f3c0d47d4f9a63597721f16b5f | |
parent | 0434700e36440082c9f23bb591924d9f57f449aa (diff) |
remove mpThreadGraphics from GDI backend
we have required for a long time now that all vcl/UI updates
run with the SolarMutex locked, so they are all effectively
single-threaded.
Change-Id: I4a0ce64a5fa9cb563d04f581cf3aa6e6e51ba1c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181811
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
-rw-r--r-- | vcl/inc/win/saldata.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/win/salframe.h | 1 | ||||
-rw-r--r-- | vcl/win/app/salinst.cxx | 8 | ||||
-rw-r--r-- | vcl/win/window/salframe.cxx | 98 |
4 files changed, 9 insertions, 101 deletions
diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx index 4ab4e2c0401a..6a00566cca31 100644 --- a/vcl/inc/win/saldata.hxx +++ b/vcl/inc/win/saldata.hxx @@ -115,7 +115,6 @@ public: sal_uInt16 mnStockPenCount; // count of static pens sal_uInt16 mnStockBrushCount; // count of static brushes WPARAM mnSalObjWantKeyEvt; // KeyEvent that should be processed by SalObj-Hook - BYTE mnCacheDCInUse; // count of CacheDC in use bool mbObjClassInit; // is SALOBJECTCLASS initialised DWORD mnAppThreadId; // Id from Application-Thread SalIcon* mpFirstIcon; // icon cache, points to first icon, NULL if none @@ -204,8 +203,6 @@ OUString ImplSalGetUniString(const char* pStr, sal_Int32 nLen = -1); #define SAL_MSG_CREATEOBJECT (WM_USER+116) // wParam == 0; lParam == pObject; #define SAL_MSG_DESTROYOBJECT (WM_USER+117) -// wParam == hWnd; lParam == 0; lResult == hDC -#define SAL_MSG_GETCACHEDDC (WM_USER+120) // wParam == hWnd; lParam == 0 #define SAL_MSG_RELEASEDC (WM_USER+121) // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h index ada7f2f022fe..fdf1b98a9873 100644 --- a/vcl/inc/win/salframe.h +++ b/vcl/inc/win/salframe.h @@ -41,7 +41,6 @@ public: HCURSOR mhCursor; // cursor handle HIMC mhDefIMEContext; // default IME-Context WinSalGraphics* mpLocalGraphics; // current main thread frame graphics - WinSalGraphics* mpThreadGraphics; // current frame graphics for other threads (DCX_CACHE) WinSalFrame* mpNextFrame; // pointer to next frame HMENU mSelectedhMenu; // the menu where highlighting is currently going on HMENU mLastActivatedhMenu; // the menu that was most recently opened diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx index 0a8f33c06f0c..ccbbefa89ad6 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -271,7 +271,6 @@ SalData::SalData() mnStockPenCount = 0; // count of static pens mnStockBrushCount = 0; // count of static brushes mnSalObjWantKeyEvt = 0; // KeyEvent for the SalObj hook - mnCacheDCInUse = 0; // count of CacheDC in use mbObjClassInit = false; // is SALOBJECTCLASS initialised mnAppThreadId = 0; // Id from Application-Thread mpFirstIcon = nullptr; // icon cache, points to first icon, NULL if none @@ -668,13 +667,6 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, b delete reinterpret_cast<SalObject*>(lParam); } break; - case (SAL_MSG_GETCACHEDDC): - { - NoYieldLockGuard g; - nRet = reinterpret_cast<LRESULT>( - GetDCEx(reinterpret_cast<HWND>(wParam), nullptr, 0x00000002L)); - } - break; case (SAL_MSG_RELEASEDC): { NoYieldLockGuard g; diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 2cf8a4020736..7fd12ef926d7 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -862,7 +862,6 @@ WinSalFrame::WinSalFrame() mhCursor = LoadCursor( nullptr, IDC_ARROW ); mhDefIMEContext = nullptr; mpLocalGraphics = nullptr; - mpThreadGraphics = nullptr; m_eState = vcl::WindowState::Normal; mnShowState = SW_SHOWNORMAL; mnMinWidth = 0; @@ -948,8 +947,6 @@ bool WinSalFrame::ReleaseFrameGraphicsDC( WinSalGraphics* pGraphics ) pGraphics->setHDC(nullptr); SendMessageW( pSalData->mpInstance->mhComWnd, SAL_MSG_RELEASEDC, reinterpret_cast<WPARAM>(mhWnd), reinterpret_cast<LPARAM>(hDC) ); - if ( pGraphics == mpThreadGraphics ) - pSalData->mnCacheDCInUse--; return true; } @@ -967,14 +964,6 @@ WinSalFrame::~WinSalFrame() *ppFrame = mpNextFrame; mpNextFrame = nullptr; - // destroy the thread SalGraphics - if ( mpThreadGraphics ) - { - ReleaseFrameGraphicsDC( mpThreadGraphics ); - delete mpThreadGraphics; - mpThreadGraphics = nullptr; - } - // destroy the local SalGraphics if ( mpLocalGraphics ) { @@ -1010,7 +999,6 @@ WinSalFrame::~WinSalFrame() bool WinSalFrame::InitFrameGraphicsDC( WinSalGraphics *pGraphics, HDC hDC, HWND hWnd ) { - SalData* pSalData = GetSalData(); assert( pGraphics ); pGraphics->setHWND( hWnd ); @@ -1023,8 +1011,6 @@ bool WinSalFrame::InitFrameGraphicsDC( WinSalGraphics *pGraphics, HDC hDC, HWND if ( !hDC ) return false; - if ( pGraphics == mpThreadGraphics ) - pSalData->mnCacheDCInUse++; return true; } @@ -1037,41 +1023,20 @@ SalGraphics* WinSalFrame::AcquireGraphics() WinSalGraphics *pGraphics = nullptr; HDC hDC = nullptr; - // Other threads get an own DC, because Windows modify in the - // other case our DC (changing clip region), when they send a - // WM_ERASEBACKGROUND message - if ( !pSalData->mpInstance->IsMainThread() ) - { - // We use only three CacheDC's for all threads, because W9x is limited - // to max. 5 Cache DC's per thread - if ( pSalData->mnCacheDCInUse >= 3 ) - return nullptr; - - if ( !mpThreadGraphics ) - mpThreadGraphics = new WinSalGraphics(WinSalGraphics::WINDOW, true, mhWnd, this); - pGraphics = mpThreadGraphics; - assert( !pGraphics->getHDC() ); - hDC = reinterpret_cast<HDC>(static_cast<sal_IntPtr>(SendMessageW( pSalData->mpInstance->mhComWnd, - SAL_MSG_GETCACHEDDC, reinterpret_cast<WPARAM>(mhWnd), 0 ))); - } - else - { - if ( !mpLocalGraphics ) - mpLocalGraphics = new WinSalGraphics(WinSalGraphics::WINDOW, true, mhWnd, this); - pGraphics = mpLocalGraphics; - hDC = pGraphics->getHDC(); - if ( !hDC ) - hDC = GetDC( mhWnd ); - } + assert(pSalData->mpInstance->IsMainThread()); + if ( !mpLocalGraphics ) + mpLocalGraphics = new WinSalGraphics(WinSalGraphics::WINDOW, true, mhWnd, this); + pGraphics = mpLocalGraphics; + hDC = pGraphics->getHDC(); + if ( !hDC ) + hDC = GetDC( mhWnd ); mbGraphics = InitFrameGraphicsDC( pGraphics, hDC, mhWnd ); return mbGraphics ? pGraphics : nullptr; } -void WinSalFrame::ReleaseGraphics( SalGraphics* pGraphics ) +void WinSalFrame::ReleaseGraphics( SalGraphics* /*pGraphics*/ ) { - if ( mpThreadGraphics == pGraphics ) - ReleaseFrameGraphicsDC( mpThreadGraphics ); mbGraphics = false; } @@ -1497,29 +1462,7 @@ void WinSalFrame::ImplSetParentFrame( HWND hNewParentWnd, bool bAsChild ) } // to recreate the DCs, if they were destroyed - bool bHadLocalGraphics = false, bHadThreadGraphics = false; - - HFONT hFont = nullptr; - HPEN hPen = nullptr; - HBRUSH hBrush = nullptr; - - int oldCount = pSalData->mnCacheDCInUse; - - // release the thread DC - if ( mpThreadGraphics ) - { - // save current gdi objects before hdc is gone - HDC hDC = mpThreadGraphics->getHDC(); - if ( hDC ) - { - hFont = static_cast<HFONT>(GetCurrentObject( hDC, OBJ_FONT )); - hPen = static_cast<HPEN>(GetCurrentObject( hDC, OBJ_PEN )); - hBrush = static_cast<HBRUSH>(GetCurrentObject( hDC, OBJ_BRUSH )); - } - - bHadThreadGraphics = ReleaseFrameGraphicsDC( mpThreadGraphics ); - assert( (bHadThreadGraphics && hDC) || (!bHadThreadGraphics && !hDC) ); - } + bool bHadLocalGraphics = false; // release the local DC if ( mpLocalGraphics ) @@ -1535,27 +1478,6 @@ void WinSalFrame::ImplSetParentFrame( HWND hNewParentWnd, bool bAsChild ) // succeeded ? SAL_WARN_IF( !IsWindow( hWnd ), "vcl", "WinSalFrame::SetParent not successful"); - // re-create thread DC - if( bHadThreadGraphics ) - { - HDC hDC = reinterpret_cast<HDC>(static_cast<sal_IntPtr>( - SendMessageW( pSalData->mpInstance->mhComWnd, - SAL_MSG_GETCACHEDDC, reinterpret_cast<WPARAM>(hWnd), 0 ))); - InitFrameGraphicsDC( mpThreadGraphics, hDC, hWnd ); - if ( hDC ) - { - // re-select saved gdi objects - if( hFont ) - SelectObject( hDC, hFont ); - if( hPen ) - SelectObject( hDC, hPen ); - if( hBrush ) - SelectObject( hDC, hBrush ); - - SAL_WARN_IF( oldCount != pSalData->mnCacheDCInUse, "vcl", "WinSalFrame::SetParent() hDC count corrupted"); - } - } - // re-create local DC if( bHadLocalGraphics ) InitFrameGraphicsDC( mpLocalGraphics, GetDC( hWnd ), hWnd ); @@ -2189,8 +2111,6 @@ void WinSalFrame::Flush() { if(mpLocalGraphics) mpLocalGraphics->Flush(); - if(mpThreadGraphics) - mpThreadGraphics->Flush(); GdiFlush(); } |