vcl/inc/osx/salframe.h | 2 +- vcl/inc/osx/salprn.h | 2 +- vcl/inc/skia/x11/salvd.hxx | 2 +- vcl/inc/win/salframe.h | 2 +- vcl/inc/win/salvd.h | 2 +- vcl/osx/salframe.cxx | 12 ++++++------ vcl/osx/salprn.cxx | 8 ++++---- vcl/skia/x11/salvd.cxx | 10 +++++----- vcl/win/gdi/salvd.cxx | 8 ++++---- vcl/win/window/salframe.cxx | 24 +++++++++++++----------- 10 files changed, 37 insertions(+), 35 deletions(-)
New commits: commit c5fe3bfdee9b910b998e8f2bf31ca9c2c20739d7 Author: Noel Grandin <[email protected]> AuthorDate: Sat May 17 22:19:03 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sun May 18 08:56:31 2025 +0200 rename mbGraphics -> mbGraphicsAcquired to improve its readability, I never know what the flag means Change-Id: If862ac36f6951b5cedf0299b522bdba72d843a89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185456 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/vcl/inc/osx/salframe.h b/vcl/inc/osx/salframe.h index 5244e1ebab38..f338a2b78e5f 100644 --- a/vcl/inc/osx/salframe.h +++ b/vcl/inc/osx/salframe.h @@ -57,7 +57,7 @@ public: int mnMinHeight; // min. client height in pixels int mnMaxWidth; // max. client width in pixels int mnMaxHeight; // max. client height in pixels - bool mbGraphics; // is Graphics used? + bool mbGraphicsAcquired; // is Graphics used? bool mbShown; bool mbInitShow; bool mbPositioned; diff --git a/vcl/inc/osx/salprn.h b/vcl/inc/osx/salprn.h index 24df3f172daa..933dd2bdfa14 100644 --- a/vcl/inc/osx/salprn.h +++ b/vcl/inc/osx/salprn.h @@ -36,7 +36,7 @@ class AquaSalInfoPrinter : public SalInfoPrinter /// Printer graphics AquaSalGraphics* mpGraphics; /// is Graphics used - bool mbGraphics; + bool mbGraphicsAcquired; /// job active ? bool mbJob; diff --git a/vcl/inc/skia/x11/salvd.hxx b/vcl/inc/skia/x11/salvd.hxx index 02babb2366e6..1cb14d5de47a 100644 --- a/vcl/inc/skia/x11/salvd.hxx +++ b/vcl/inc/skia/x11/salvd.hxx @@ -17,7 +17,7 @@ class X11SkiaSalVirtualDevice final : public SalVirtualDevice { SalDisplay* mpDisplay; std::unique_ptr<X11SalGraphics> mpGraphics; - bool mbGraphics; // is Graphics used + bool mbGraphicsAcquired; // is Graphics used SalX11Screen mnXScreen; int mnWidth; int mnHeight; diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h index 37f43dafdbe6..31f6b88a8cc9 100644 --- a/vcl/inc/win/salframe.h +++ b/vcl/inc/win/salframe.h @@ -56,7 +56,7 @@ public: UINT mnInputLang; // current Input Language UINT mnInputCodePage; // current Input CodePage SalFrameStyleFlags mnStyle; // style - bool mbGraphics; // is Graphics used + bool mbGraphicsAcquired; // is Graphics used bool mbCaption; // has window a caption bool mbBorder; // has window a border bool mbFixBorder; // has window a fixed border diff --git a/vcl/inc/win/salvd.h b/vcl/inc/win/salvd.h index ded57b00a173..530fe4fb4cad 100644 --- a/vcl/inc/win/salvd.h +++ b/vcl/inc/win/salvd.h @@ -38,7 +38,7 @@ private: std::unique_ptr<WinSalGraphics> mpGraphics; // current VirDev graphics WinSalVirtualDevice* mpNext; // next VirDev sal_uInt16 mnBitCount; // BitCount (0 or 1) - bool mbGraphics; // is Graphics used + bool mbGraphicsAcquired; // is Graphics used bool mbForeignDC; // uses a foreign DC instead of a bitmap tools::Long mnWidth; tools::Long mnHeight; diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx index e469882db3e2..34b6bdf783c6 100644 --- a/vcl/osx/salframe.cxx +++ b/vcl/osx/salframe.cxx @@ -71,7 +71,7 @@ AquaSalFrame::AquaSalFrame( SalFrame* pParent, SalFrameStyleFlags salFrameStyle mnMinHeight(0), mnMaxWidth(0), mnMaxHeight(0), - mbGraphics(false), + mbGraphicsAcquired(false), mbShown(false), mbInitShow(true), mbPositioned(false), @@ -309,7 +309,7 @@ void AquaSalFrame::screenParametersChanged() SalGraphics* AquaSalFrame::AcquireGraphics() { - if ( mbGraphics ) + if ( mbGraphicsAcquired ) return nullptr; if ( !mpGraphics ) @@ -318,14 +318,14 @@ SalGraphics* AquaSalFrame::AcquireGraphics() mpGraphics->SetWindowGraphics( this ); } - mbGraphics = true; + mbGraphicsAcquired = true; return mpGraphics; } void AquaSalFrame::ReleaseGraphics( SalGraphics *pGraphics ) { SAL_WARN_IF( pGraphics != mpGraphics, "vcl", "graphics released on wrong frame" ); - mbGraphics = false; + mbGraphicsAcquired = false; } bool AquaSalFrame::PostEvent(std::unique_ptr<ImplSVEvent> pData) @@ -1149,7 +1149,7 @@ void AquaSalFrame::SetPointerPos( tools::Long nX, tools::Long nY ) void AquaSalFrame::Flush() { - if( !(mbGraphics && mpGraphics && mpNSView && mbShown) ) + if( !(mbGraphicsAcquired && mpGraphics && mpNSView && mbShown) ) return; OSX_SALDATA_RUNINMAIN( Flush() ) @@ -1165,7 +1165,7 @@ void AquaSalFrame::Flush() void AquaSalFrame::Flush( const tools::Rectangle& rRect ) { - if( !(mbGraphics && mpGraphics && mpNSView && mbShown) ) + if( !(mbGraphicsAcquired && mpGraphics && mpNSView && mbShown) ) return; OSX_SALDATA_RUNINMAIN( Flush( rRect ) ) diff --git a/vcl/osx/salprn.cxx b/vcl/osx/salprn.cxx index 9baababcc146..e70c78d79378 100644 --- a/vcl/osx/salprn.cxx +++ b/vcl/osx/salprn.cxx @@ -48,7 +48,7 @@ using namespace com::sun::star::beans; AquaSalInfoPrinter::AquaSalInfoPrinter( const SalPrinterQueueInfo& i_rQueue ) : mpGraphics( nullptr ), - mbGraphics( false ), + mbGraphicsAcquired( false ), mbJob( false ), mpPrinter( nil ), mpPrintInfo( nil ), @@ -153,14 +153,14 @@ void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const SalGraphics* AquaSalInfoPrinter::AcquireGraphics() { - SalGraphics* pGraphics = mbGraphics ? nullptr : mpGraphics; - mbGraphics = true; + SalGraphics* pGraphics = mbGraphicsAcquired ? nullptr : mpGraphics; + mbGraphicsAcquired = true; return pGraphics; } void AquaSalInfoPrinter::ReleaseGraphics( SalGraphics* ) { - mbGraphics = false; + mbGraphicsAcquired = false; } bool AquaSalInfoPrinter::Setup( weld::Window*, ImplJobSetup* ) diff --git a/vcl/skia/x11/salvd.cxx b/vcl/skia/x11/salvd.cxx index c128bae50413..c517a165efa1 100644 --- a/vcl/skia/x11/salvd.cxx +++ b/vcl/skia/x11/salvd.cxx @@ -33,7 +33,7 @@ X11SkiaSalVirtualDevice::X11SkiaSalVirtualDevice(const SalGraphics& rGraphics, t tools::Long nDY, std::unique_ptr<X11SalGraphics> pNewGraphics) : mpGraphics(std::move(pNewGraphics)) - , mbGraphics(false) + , mbGraphicsAcquired(false) , mnXScreen(0) { assert(mpGraphics); @@ -50,7 +50,7 @@ X11SkiaSalVirtualDevice::X11SkiaSalVirtualDevice(const SalGraphics& rGraphics, t const SystemGraphicsData& /*rData*/, std::unique_ptr<X11SalGraphics> pNewGraphics) : mpGraphics(std::move(pNewGraphics)) - , mbGraphics(false) + , mbGraphicsAcquired(false) , mnXScreen(0) { // TODO Check where a VirtualDevice is created from SystemGraphicsData @@ -67,16 +67,16 @@ X11SkiaSalVirtualDevice::~X11SkiaSalVirtualDevice() {} SalGraphics* X11SkiaSalVirtualDevice::AcquireGraphics() { - if (mbGraphics) + if (mbGraphicsAcquired) return nullptr; if (mpGraphics) - mbGraphics = true; + mbGraphicsAcquired = true; return mpGraphics.get(); } -void X11SkiaSalVirtualDevice::ReleaseGraphics(SalGraphics*) { mbGraphics = false; } +void X11SkiaSalVirtualDevice::ReleaseGraphics(SalGraphics*) { mbGraphicsAcquired = false; } bool X11SkiaSalVirtualDevice::SetSize(tools::Long nDX, tools::Long nDY) { diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx index c31228d23118..22dca8b03337 100644 --- a/vcl/win/gdi/salvd.cxx +++ b/vcl/win/gdi/salvd.cxx @@ -132,7 +132,7 @@ WinSalVirtualDevice::WinSalVirtualDevice(HDC hDC, HBITMAP hBMP, sal_uInt16 nBitC : mhLocalDC(hDC), // HDC or 0 for Cache Device mhBmp(hBMP), // Memory Bitmap mnBitCount(nBitCount), // BitCount (0 or 1) - mbGraphics(false), // is Graphics used + mbGraphicsAcquired(false), // is Graphics used mbForeignDC(bForeignDC), // uses a foreign DC instead of a bitmap mnWidth(nWidth), mnHeight(nHeight) @@ -181,18 +181,18 @@ WinSalVirtualDevice::~WinSalVirtualDevice() SalGraphics* WinSalVirtualDevice::AcquireGraphics() { - if ( mbGraphics ) + if ( mbGraphicsAcquired ) return nullptr; if ( mpGraphics ) - mbGraphics = true; + mbGraphicsAcquired = true; return mpGraphics.get(); } void WinSalVirtualDevice::ReleaseGraphics( SalGraphics* ) { - mbGraphics = false; + mbGraphicsAcquired = false; } bool WinSalVirtualDevice::SetSize( tools::Long nDX, tools::Long nDY ) diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index e91adfb59da4..d4db5180ec33 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -869,7 +869,7 @@ WinSalFrame::WinSalFrame() mnMaxHeight = SHRT_MAX; mnInputLang = 0; mnInputCodePage = 0; - mbGraphics = false; + mbGraphicsAcquired = false; mbCaption = false; mbBorder = false; mbFixBorder = false; @@ -1015,7 +1015,7 @@ bool WinSalFrame::InitFrameGraphicsDC( WinSalGraphics *pGraphics, HDC hDC, HWND SalGraphics* WinSalFrame::AcquireGraphics() { - if ( mbGraphics || !mhWnd ) + if ( mbGraphicsAcquired || !mhWnd ) return nullptr; SalData* pSalData = GetSalData(); @@ -1031,13 +1031,13 @@ SalGraphics* WinSalFrame::AcquireGraphics() mpLocalGraphics = new WinSalGraphics(WinSalGraphics::WINDOW, true, mhWnd, this); mpLocalGraphics->setHDC( hDC ); } - mbGraphics = true; + mbGraphicsAcquired = true; return mpLocalGraphics; } void WinSalFrame::ReleaseGraphics( SalGraphics* /*pGraphics*/ ) { - mbGraphics = false; + mbGraphicsAcquired = false; } bool WinSalFrame::PostEvent(std::unique_ptr<ImplSVEvent> pData) commit dedc5ed4f9964cd097cf031aff3d686832d3c462 Author: Noel Grandin <[email protected]> AuthorDate: Sat May 17 22:11:17 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sun May 18 08:56:21 2025 +0200 simplify WinSalFrame::AcquireGraphics inline InitFrameGraphicsDC, simplify the resulting logic, and reshuffle a little to avoid a leak in the unlikely possibility that GetDC returns nullptr. Change-Id: I6ebe15ee1d395a3a91db8c1e201b88f89e26806a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185455 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 54e975e0e6a8..e91adfb59da4 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -1019,18 +1019,20 @@ SalGraphics* WinSalFrame::AcquireGraphics() return nullptr; SalData* pSalData = GetSalData(); - assert(pSalData->mpInstance->IsMainThread()); SAL_WARN_IF(!pSalData->mpInstance->IsMainThread(), "vcl", "ERROR: pSalData->mpInstance is not main thread!"); + if ( !mpLocalGraphics ) - mpLocalGraphics = new WinSalGraphics(WinSalGraphics::WINDOW, true, mhWnd, this); - WinSalGraphics* pGraphics = mpLocalGraphics; - HDC hDC = pGraphics->getHDC(); - if ( !hDC ) - hDC = GetDC( mhWnd ); + { + HDC hDC = GetDC( mhWnd ); + if (!hDC) + return nullptr; - mbGraphics = InitFrameGraphicsDC( pGraphics, hDC, mhWnd ); - return mbGraphics ? pGraphics : nullptr; + mpLocalGraphics = new WinSalGraphics(WinSalGraphics::WINDOW, true, mhWnd, this); + mpLocalGraphics->setHDC( hDC ); + } + mbGraphics = true; + return mpLocalGraphics; } void WinSalFrame::ReleaseGraphics( SalGraphics* /*pGraphics*/ )
