diff options
author | Neil <nyamatongwe@gmail.com> | 2025-02-10 13:08:51 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2025-02-10 13:08:51 +1100 |
commit | f2e9767e7aa2f3e012f46bf1c5f8b41872051bf0 (patch) | |
tree | 761e794feeba4a1ab80ef4b9d2710b79206e0d70 | |
parent | 883a12357e66c08d9519671b278fd19cb5009570 (diff) | |
download | scintilla-mirror-f2e9767e7aa2f3e012f46bf1c5f8b41872051bf0.tar.gz |
Use ID2D1HwndRenderTarget::Resize when handling WM_SIZE to avoid larger state
invalidation which may be more costly to restore.
-rw-r--r-- | win32/ScintillaWin.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 2d0441fdd..b0eaf979d 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -1581,8 +1581,21 @@ PRectangle ScintillaWin::GetClientRectangle() const { void ScintillaWin::SizeWindow() { #if defined(USE_D2D) + HRESULT hrResize = E_FAIL; + + if (((technology == Technology::DirectWrite) || (technology == Technology::DirectWriteRetain)) && targets.pHwndRT) { + // May be able to just resize the HWND render target + const int scaleFactor = GetFirstIntegralMultipleDeviceScaleFactor(); + const D2D1_SIZE_U pixelSize = ::GetSizeUFromRect(GetClientRect(MainHWND()), scaleFactor); + hrResize = targets.pHwndRT->Resize(pixelSize); + if (FAILED(hrResize)) { + Platform::DebugPrintf("Failed to Resize ID2D1HwndRenderTarget 0x%lx\n", hrResize); + } + } if (paintState == PaintState::notPainting) { - DropRenderTarget(); + if (FAILED(hrResize)) { + DropRenderTarget(); + } } else { targets.valid = false; } |