From 2e1a12905d76378882669364ca4f2c19bd48ac4b Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 16 Apr 2025 22:01:29 +0200 Subject: [PATCH] Cleanup: Remove WIN32_COMPOSITING This PR removes unused Win32 code that we've had for about 13 years, hidden behind a define that we've never enabled. The intent of this optional code was to allow showing Blender windows as transparent, something that looked pretty cool back then. The main method used was an API call of DwmEnableBlurBehindWindow, but this function has not done anything since Windows 8 because styles and tastes have changed. Pull Request: https://projects.blender.org/blender/blender/pulls/137620 --- intern/ghost/intern/GHOST_ContextWGL.cc | 36 ++---------------------- intern/ghost/intern/GHOST_ContextWGL.hh | 2 -- intern/ghost/intern/GHOST_SystemWin32.cc | 7 +---- intern/ghost/intern/GHOST_WindowWin32.cc | 23 +-------------- intern/ghost/intern/GHOST_WindowWin32.hh | 3 -- 5 files changed, 5 insertions(+), 66 deletions(-) diff --git a/intern/ghost/intern/GHOST_ContextWGL.cc b/intern/ghost/intern/GHOST_ContextWGL.cc index ee9aca5a73d..2b832100769 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.cc +++ b/intern/ghost/intern/GHOST_ContextWGL.cc @@ -159,10 +159,6 @@ static int weight_pixel_format(PIXELFORMATDESCRIPTOR &pfd, PIXELFORMATDESCRIPTOR if (preferredPFD.cAlphaBits > 0 && pfd.cAlphaBits > 0) { weight++; } -#ifdef WIN32_COMPOSITING - if ((preferredPFD.dwFlags & PFD_SUPPORT_COMPOSITION) && (pfd.dwFlags & PFD_SUPPORT_COMPOSITION)) - weight++; -#endif return weight; } @@ -339,15 +335,9 @@ struct DummyContextWGL { 1, /* version */ (DWORD)(PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER | /* support double-buffering */ - (stereoVisual ? PFD_STEREO : 0) | /* support stereo */ - ( -#ifdef WIN32_COMPOSITING - /* Support composition for transparent background. */ - needAlpha ? PFD_SUPPORT_COMPOSITION : -#endif - 0)), - PFD_TYPE_RGBA, /* color type */ - (BYTE)(needAlpha ? 32 : 24), /* preferred color depth */ + (stereoVisual ? PFD_STEREO : 0)), /* support stereo */ + PFD_TYPE_RGBA, /* color type */ + (BYTE)(needAlpha ? 32 : 24), /* preferred color depth */ 0, 0, 0, @@ -461,26 +451,6 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_1(bool stereoVisual, bool needAlp if (nNumFormats > 0) { iPixelFormat = iPixelFormats[0]; - -#ifdef WIN32_COMPOSITING - if (needAlpha) { - // scan through all pixel format to make sure one supports compositing - PIXELFORMATDESCRIPTOR pfd; - int i; - - for (i = 0; i < nNumFormats; i++) { - if (DescribePixelFormat(m_hDC, iPixelFormats[i], sizeof(PIXELFORMATDESCRIPTOR), &pfd)) { - if (pfd.dwFlags & PFD_SUPPORT_COMPOSITION) { - iPixelFormat = iPixelFormats[i]; - break; - } - } - } - if (i == nNumFormats) { - fprintf(stderr, "Warning! Unable to find a pixel format with compositing capability.\n"); - } - } -#endif } // check pixel format diff --git a/intern/ghost/intern/GHOST_ContextWGL.hh b/intern/ghost/intern/GHOST_ContextWGL.hh index b6771a7e5f5..05e53982c1f 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.hh +++ b/intern/ghost/intern/GHOST_ContextWGL.hh @@ -8,8 +8,6 @@ #pragma once -// #define WIN32_COMPOSITING - #include "GHOST_Context.hh" #include diff --git a/intern/ghost/intern/GHOST_SystemWin32.cc b/intern/ghost/intern/GHOST_SystemWin32.cc index 8e55da166c5..570cd0b1296 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cc +++ b/intern/ghost/intern/GHOST_SystemWin32.cc @@ -285,7 +285,6 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(const char *title, state, gpuSettings.context_type, ((gpuSettings.flags & GHOST_gpuStereoVisual) != 0), - false, (GHOST_WindowWin32 *)parentWindow, ((gpuSettings.flags & GHOST_gpuDebugContext) != 0), is_dialog, @@ -618,11 +617,7 @@ GHOST_TSuccess GHOST_SystemWin32::init() ::LoadIcon(nullptr, IDI_APPLICATION); } wc.hCursor = ::LoadCursor(0, IDC_ARROW); - wc.hbrBackground = -#ifdef INW32_COMPISITING - (HBRUSH)CreateSolidBrush -#endif - (HBRUSH) GetStockObject(DKGRAY_BRUSH); + wc.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); wc.lpszMenuName = 0; wc.lpszClassName = L"GHOST_WindowClass"; diff --git a/intern/ghost/intern/GHOST_WindowWin32.cc b/intern/ghost/intern/GHOST_WindowWin32.cc index 54926323aba..ebc5182aa0c 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cc +++ b/intern/ghost/intern/GHOST_WindowWin32.cc @@ -60,7 +60,6 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, GHOST_TWindowState state, GHOST_TDrawingContextType type, bool wantStereoVisual, - bool alphaBackground, GHOST_WindowWin32 *parentwindow, bool is_debug, bool dialog, @@ -78,7 +77,6 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, m_hasGrabMouse(false), m_nPressedButtons(0), m_customCursor(0), - m_wantAlphaBackground(alphaBackground), m_Bar(nullptr), m_wintab(nullptr), m_lastPointerTabletData(GHOST_TABLET_DATA_NONE), @@ -210,25 +208,6 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, ::ShowWindow(m_hWnd, nCmdShow); -#ifdef WIN32_COMPOSITING - if (alphaBackground && parentwindowhwnd == 0) { - - HRESULT hr = S_OK; - - /* Create and populate the Blur Behind structure. */ - DWM_BLURBEHIND bb = {0}; - - /* Enable Blur Behind and apply to the entire client area. */ - bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION; - bb.fEnable = true; - bb.hRgnBlur = CreateRectRgn(0, 0, -1, -1); - - /* Apply Blur Behind. */ - hr = DwmEnableBlurBehindWindow(m_hWnd, &bb); - DeleteObject(bb.hRgnBlur); - } -#endif - /* Initialize WINTAB. */ if (system->getTabletAPI() != GHOST_kTabletWinPointer) { loadWintab(GHOST_kWindowStateMinimized != state); @@ -656,7 +635,7 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty for (int minor = 6; minor >= 3; --minor) { GHOST_Context *context = new GHOST_ContextWGL( m_wantStereoVisual, - m_wantAlphaBackground, + false, m_hWnd, m_hDC, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, diff --git a/intern/ghost/intern/GHOST_WindowWin32.hh b/intern/ghost/intern/GHOST_WindowWin32.hh index eb2b83dbb94..d47c71465b2 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.hh +++ b/intern/ghost/intern/GHOST_WindowWin32.hh @@ -77,7 +77,6 @@ class GHOST_WindowWin32 : public GHOST_Window { GHOST_TWindowState state, GHOST_TDrawingContextType type, bool wantStereoVisual, - bool alphaBackground, GHOST_WindowWin32 *parentWindow, bool is_debug, bool dialog, @@ -394,8 +393,6 @@ class GHOST_WindowWin32 : public GHOST_Window { int m_nPressedButtons; /** HCURSOR structure of the custom cursor. */ HCURSOR m_customCursor; - /** Request GL context with alpha channel. */ - bool m_wantAlphaBackground; /** ITaskbarList3 structure for progress bar. */ ITaskbarList3 *m_Bar;