From c924e3aa6ca6bb4d6285981407fbddc4055a13cd Mon Sep 17 00:00:00 2001 From: ALTaleX <2368730049@qq.com> Date: Thu, 13 Jun 2024 07:01:23 +0800 Subject: [PATCH] bug fixes and optimizations --- OpenGlass/AeroBackdrop.hpp | 5 - OpenGlass/BackdropFactory.cpp | 2 +- OpenGlass/BackdropManager.cpp | 152 ++++++++++++-------- OpenGlass/BackdropManager.hpp | 11 +- OpenGlass/GlassFramework.cpp | 68 ++++----- OpenGlass/GlassOptimizer.cpp | 238 +++++++++++++++----------------- OpenGlass/GlassReflection.hpp | 1 + OpenGlass/dcompProjection.hpp | 48 +++++-- OpenGlass/dwmcoreProjection.hpp | 48 ++++++- OpenGlass/uDwmProjection.hpp | 9 +- README.md | 6 +- 11 files changed, 349 insertions(+), 239 deletions(-) diff --git a/OpenGlass/AeroBackdrop.hpp b/OpenGlass/AeroBackdrop.hpp index 1a3c3de..aa276da 100644 --- a/OpenGlass/AeroBackdrop.hpp +++ b/OpenGlass/AeroBackdrop.hpp @@ -23,11 +23,6 @@ namespace OpenGlass::AeroBackdrop float blurAmount ) { - if (static_cast(color.A) * colorBalance == 255.f) - { - return compositor.CreateColorBrush(color); - } - wuc::CompositionBrush blurredBackdropBrush { [](auto compositor, auto blurAmount) -> wuc::CompositionBrush diff --git a/OpenGlass/BackdropFactory.cpp b/OpenGlass/BackdropFactory.cpp index bde4bf6..96da476 100644 --- a/OpenGlass/BackdropFactory.cpp +++ b/OpenGlass/BackdropFactory.cpp @@ -75,7 +75,7 @@ wuc::CompositionBrush BackdropFactory::GetOrCreateBackdropBrush( if ( policy->AccentState == 4 && - (policy->dwGradientColor << 24) == 0 + policy->dwGradientColor == 0 ) { brush = compositor.CreateColorBrush({}); diff --git a/OpenGlass/BackdropManager.cpp b/OpenGlass/BackdropManager.cpp index 7e77483..2b3cc10 100644 --- a/OpenGlass/BackdropManager.cpp +++ b/OpenGlass/BackdropManager.cpp @@ -106,39 +106,6 @@ namespace OpenGlass::BackdropManager { return Configuration::g_overrideBorder || m_data->IsFrameExtendedIntoClientAreaLRB(); } - bool ShouldUpdateBackdropRegion() const - { - // window probably minimized or not visible on the screen, - // no need to update - RECT borderRect{}; - THROW_HR_IF_NULL(E_INVALIDARG, m_window->GetActualWindowRect(&borderRect, false, true, false)); - auto virtualScreenX{ GetSystemMetrics(SM_XVIRTUALSCREEN) }; - auto virtualScreenY{ GetSystemMetrics(SM_YVIRTUALSCREEN) }; - auto virtualScreenCX{ GetSystemMetrics(SM_CXVIRTUALSCREEN) }; - auto virtualScreenCY{ GetSystemMetrics(SM_CYVIRTUALSCREEN) }; - if ( - borderRect.right <= virtualScreenX || - borderRect.bottom <= virtualScreenY || - borderRect.left >= virtualScreenX + virtualScreenCX || - borderRect.top >= virtualScreenY + virtualScreenCY || - !m_data->IsWindowVisibleAndUncloaked() - ) - { - return false; - } -#ifdef _DEBUG - OutputDebugStringW( - std::format( - L"borderRect: [{},{},{},{}]\n", - borderRect.left, - borderRect.top, - borderRect.right, - borderRect.bottom - ).c_str() - ); -#endif - return true; - } wil::unique_hrgn CompositeNewBackdropRegion() const { wil::unique_hrgn compositedRgn{ CreateRectRgn(0, 0, 0, 0) }; @@ -174,23 +141,15 @@ namespace OpenGlass::BackdropManager CombineRgn(compositedRgn.get(), compositedRgn.get(), accentRgn.get(), RGN_AND); } - // TO-DO: round corner specialization for SIB task thumbnail window - } - - CombineRgn(compositedRgn.get(), compositedRgn.get(), windowRgn.get(), RGN_AND); - if ( - m_gdiWindowRgn && - ( - m_kind != CompositedBackdropKind::Accent || - ( - m_kind == CompositedBackdropKind::Accent && - m_data->GetAccentPolicy()->IsGdiRegionRespected() - ) - ) + if ( + m_gdiWindowRgn && + m_data->GetAccentPolicy()->IsGdiRegionRespected() ) - { - CombineRgn(compositedRgn.get(), compositedRgn.get(), m_gdiWindowRgn.get(), RGN_AND); + { + CombineRgn(compositedRgn.get(), compositedRgn.get(), m_gdiWindowRgn.get(), RGN_AND); + } } + CombineRgn(compositedRgn.get(), compositedRgn.get(), windowRgn.get(), RGN_AND); return compositedRgn; } @@ -209,6 +168,23 @@ namespace OpenGlass::BackdropManager { return m_udwmVisual.get(); } + bool CanBeTrimmed() override + { + if (m_kind != CompositedBackdropKind::Accent || !m_visible) + { + return true; + } + if (m_accentRect.has_value()) + { + return false; + } + if (m_gdiWindowRgn && m_data->GetAccentPolicy()->IsGdiRegionRespected()) + { + return false; + } + + return true; + } }; // temporary workaround for aero peek/live preview @@ -298,6 +274,10 @@ namespace OpenGlass::BackdropManager void SetGdiWindowRegion(HRGN region) override {} void ValidateVisual() override {} void UpdateNCBackground() override {} + bool CanBeTrimmed() override + { + return false; + } }; class CClonedCompositedBackdropVisual : public winrt::implements, uDwm::CClonedBackdropVisual { @@ -321,6 +301,10 @@ namespace OpenGlass::BackdropManager void SetGdiWindowRegion(HRGN region) override {} void ValidateVisual() override {} void UpdateNCBackground() override {} + bool CanBeTrimmed() override + { + return false; + } }; } @@ -623,6 +607,18 @@ BackdropManager::CCompositedBackdropVisual::CCompositedBackdropVisual(uDwm::CTop OnDeviceLost(); OnBackdropKindUpdated(GlassFramework::GetActualBackdropKind(window)); + if (m_kind == CompositedBackdropKind::Accent) + { + wil::unique_hrgn clipRgn{ CreateRectRgn(0, 0, 0, 0) }; + if (GetWindowRgn(m_data->GetHwnd(), clipRgn.get()) != ERROR) + { + SetGdiWindowRegion(clipRgn.get()); + } + else + { + SetGdiWindowRegion(nullptr); + } + } } BackdropManager::CCompositedBackdropVisual::~CCompositedBackdropVisual() @@ -665,10 +661,23 @@ void BackdropManager::CCompositedBackdropVisual::SetAccentRect(LPCRECT lprc) if (lprc) { m_accentRect = *lprc; + m_gdiWindowRgn.reset(); } - else + else if (m_accentRect.has_value()) { m_accentRect = std::nullopt; + if (m_kind == CompositedBackdropKind::Accent) + { + wil::unique_hrgn clipRgn{ CreateRectRgn(0, 0, 0, 0) }; + if (GetWindowRgn(m_data->GetHwnd(), clipRgn.get()) != ERROR) + { + m_gdiWindowRgn.reset(clipRgn.release()); + } + else + { + m_gdiWindowRgn.reset(); + } + } } m_backdropDataChanged = true; } @@ -681,17 +690,19 @@ void BackdropManager::CCompositedBackdropVisual::SetGdiWindowRegion(HRGN region) m_gdiWindowRgn.reset(CreateRectRgn(0, 0, 0, 0)); } CopyRgn(m_gdiWindowRgn.get(), region); + m_accentRect = std::nullopt; } - else + else if (m_gdiWindowRgn) { m_gdiWindowRgn.reset(); + m_accentRect = std::nullopt; } m_backdropDataChanged = true; } void BackdropManager::CCompositedBackdropVisual::ValidateVisual() { - if (ShouldUpdateBackdropRegion()) + if (!m_window->IsTrullyMinimized()) { if (m_visible) { @@ -714,7 +725,7 @@ void BackdropManager::CCompositedBackdropVisual::ValidateVisual() } void BackdropManager::CCompositedBackdropVisual::UpdateNCBackground() { - if (!ShouldUpdateBackdropRegion()) + if (m_window->IsTrullyMinimized()) { return; } @@ -730,12 +741,12 @@ void BackdropManager::CCompositedBackdropVisual::UpdateNCBackground() } -size_t BackdropManager::GetBackdropCount() +size_t BackdropManager::GetCount() { return g_backdropMap.size(); } -winrt::com_ptr BackdropManager::GetOrCreateBackdropVisual(uDwm::CTopLevelWindow* window, bool createIfNecessary, bool silent) +winrt::com_ptr BackdropManager::GetOrCreate(uDwm::CTopLevelWindow* window, bool createIfNecessary, bool silent) { auto it{ g_backdropMap.find(window) }; @@ -770,10 +781,27 @@ winrt::com_ptr BackdropManager::GetO return it == g_backdropMap.end() ? nullptr : it->second; } -void BackdropManager::TryCloneBackdropVisualForWindow(uDwm::CTopLevelWindow* src, uDwm::CTopLevelWindow* dst, ICompositedBackdropVisual** visual) +winrt::com_ptr BackdropManager::GetOrCreateForAccentBlurRect(uDwm::CTopLevelWindow* window, LPCRECT accentBlurRect, bool createIfNecessary, bool silent) +{ + auto it{ g_backdropMap.find(window) }; + + auto result{ BackdropManager::GetOrCreate(window, createIfNecessary, true) }; + if (result && it == g_backdropMap.end()) + { + result->SetAccentRect(accentBlurRect); + if (!silent) + { + RedrawTopLevelWindow(window); + } + } + + return result; +} + +void BackdropManager::TryClone(uDwm::CTopLevelWindow* src, uDwm::CTopLevelWindow* dst, ICompositedBackdropVisual** visual) { auto legacyVisual{ src->GetLegacyVisual() }; - if (auto backdrop{ GetOrCreateBackdropVisual(src) }; backdrop && legacyVisual) + if (auto backdrop{ GetOrCreate(src) }; backdrop && legacyVisual) { auto it{ g_backdropMap.find(dst) }; if (it == g_backdropMap.end()) @@ -793,7 +821,7 @@ void BackdropManager::TryCloneBackdropVisualForWindow(uDwm::CTopLevelWindow* src } } -void BackdropManager::RemoveBackdrop(uDwm::CTopLevelWindow* window, bool silent) +void BackdropManager::Remove(uDwm::CTopLevelWindow* window, bool silent) { auto it{ g_backdropMap.find(window) }; @@ -808,6 +836,16 @@ void BackdropManager::RemoveBackdrop(uDwm::CTopLevelWindow* window, bool silent) } } +void BackdropManager::Trim(uDwm::CTopLevelWindow* window) +{ + auto it{ g_backdropMap.find(window) }; + + if (it != g_backdropMap.end() && it->second->CanBeTrimmed()) + { + g_backdropMap.erase(it); + } +} + void BackdropManager::Shutdown() { std::vector windowCollection{}; diff --git a/OpenGlass/BackdropManager.hpp b/OpenGlass/BackdropManager.hpp index 61dc201..7a6e0c3 100644 --- a/OpenGlass/BackdropManager.hpp +++ b/OpenGlass/BackdropManager.hpp @@ -34,6 +34,7 @@ namespace OpenGlass::BackdropManager virtual void ValidateVisual() = 0; virtual void UpdateNCBackground() = 0; + virtual bool CanBeTrimmed() = 0; }; namespace Configuration @@ -43,9 +44,11 @@ namespace OpenGlass::BackdropManager inline wf::TimeSpan g_crossfadeTime{ std::chrono::milliseconds{ 87 } }; } - size_t GetBackdropCount(); - winrt::com_ptr GetOrCreateBackdropVisual(uDwm::CTopLevelWindow* window, bool createIfNecessary = false, bool silent = false); - void TryCloneBackdropVisualForWindow(uDwm::CTopLevelWindow* src, uDwm::CTopLevelWindow* dst, ICompositedBackdropVisual** visual = nullptr); - void RemoveBackdrop(uDwm::CTopLevelWindow* window, bool silent = false); + size_t GetCount(); + winrt::com_ptr GetOrCreate(uDwm::CTopLevelWindow* window, bool createIfNecessary = false, bool silent = false); + winrt::com_ptr GetOrCreateForAccentBlurRect(uDwm::CTopLevelWindow* window, LPCRECT accentBlurRect, bool createIfNecessary = false, bool silent = false); + void TryClone(uDwm::CTopLevelWindow* src, uDwm::CTopLevelWindow* dst, ICompositedBackdropVisual** visual = nullptr); + void Remove(uDwm::CTopLevelWindow* window, bool silent = false); + void Trim(uDwm::CTopLevelWindow* window); void Shutdown(); } \ No newline at end of file diff --git a/OpenGlass/GlassFramework.cpp b/OpenGlass/GlassFramework.cpp index 14d521e..55985df 100644 --- a/OpenGlass/GlassFramework.cpp +++ b/OpenGlass/GlassFramework.cpp @@ -140,14 +140,15 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateNCAreaBackgrou return g_CTopLevelWindow_UpdateNCAreaBackground_Org(This); } auto data{ This->GetData() }; - if (!data) + if (!data || !data->IsWindowVisibleAndUncloaked() || This->IsTrullyMinimized()) { + BackdropManager::Trim(This); return g_CTopLevelWindow_UpdateNCAreaBackground_Org(This); } HRESULT hr{ S_OK }; - winrt::com_ptr backdrop{ BackdropManager::GetOrCreateBackdropVisual(This) }; + winrt::com_ptr backdrop{ BackdropManager::GetOrCreate(This) }; if (This->HasNonClientBackground()) { @@ -169,7 +170,7 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateNCAreaBackgrou if (SUCCEEDED(hr)) { - backdrop = BackdropManager::GetOrCreateBackdropVisual(This, true); + backdrop = BackdropManager::GetOrCreate(This, true); // the titlebar region has been updated // let's update our backdrop region if (GeometryRecorder::GetGeometryCount() && backdrop) @@ -215,7 +216,7 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateNCAreaBackgrou } else { - backdrop = BackdropManager::GetOrCreateBackdropVisual(This, GetActualBackdropKind(This) == BackdropManager::CompositedBackdropKind::Accent); + backdrop = BackdropManager::GetOrCreate(This, GetActualBackdropKind(This) == BackdropManager::CompositedBackdropKind::Accent); hr = g_CTopLevelWindow_UpdateNCAreaBackground_Org(This); // let's update our backdrop region @@ -245,8 +246,9 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateClientBlur(uDw return g_CTopLevelWindow_UpdateClientBlur_Org(This); } auto data{ This->GetData() }; - if (!data) + if (!data || !data->IsWindowVisibleAndUncloaked() || This->IsTrullyMinimized()) { + BackdropManager::Trim(This); return g_CTopLevelWindow_UpdateClientBlur_Org(This); } @@ -263,7 +265,7 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateClientBlur(uDw HRGN clientBlurRegion{ GeometryRecorder::GetRegionFromGeometry(g_geometryBuffer[0].get()) }; RECT clientBlurBox{}; // let's update our backdrop region - auto backdrop{ BackdropManager::GetOrCreateBackdropVisual(This, GetRgnBox(clientBlurRegion, &clientBlurBox) != NULLREGION && !IsRectEmpty(&clientBlurBox), true) }; + auto backdrop{ BackdropManager::GetOrCreate(This, GetRgnBox(clientBlurRegion, &clientBlurBox) != NULLREGION && !IsRectEmpty(&clientBlurBox), true) }; if (backdrop) { backdrop->SetClientBlurRegion(clientBlurRegion); @@ -287,8 +289,9 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_ValidateVisual(uDwm: return g_CTopLevelWindow_ValidateVisual_Org(This); } auto data{ This->GetData() }; - if (!data) + if (!data || !data->IsWindowVisibleAndUncloaked() || This->IsTrullyMinimized()) { + BackdropManager::Trim(This); return g_CTopLevelWindow_ValidateVisual_Org(This); } @@ -302,7 +305,7 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_ValidateVisual(uDwm: if (SUCCEEDED(hr)) { - auto backdrop{ BackdropManager::GetOrCreateBackdropVisual(This) }; + auto backdrop{ BackdropManager::GetOrCreate(This) }; if (backdrop) { // update existing backdrop @@ -321,8 +324,9 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateAccent(uDwm::C return g_CTopLevelWindow_UpdateAccent_Org(This, visibleAndUncloaked); } auto data{ This->GetData() }; - if (!data) + if (!data || !data->IsWindowVisibleAndUncloaked() || This->IsTrullyMinimized()) { + BackdropManager::Trim(This); return g_CTopLevelWindow_UpdateAccent_Org(This, visibleAndUncloaked); } @@ -337,7 +341,7 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateAccent(uDwm::C hr = g_CTopLevelWindow_UpdateAccent_Org(This, visibleAndUncloaked); accentPolicy->AccentState = oldAccentState; - winrt::com_ptr backdrop{ BackdropManager::GetOrCreateBackdropVisual(This, kind == BackdropManager::CompositedBackdropKind::Accent) }; + winrt::com_ptr backdrop{ BackdropManager::GetOrCreate(This, kind == BackdropManager::CompositedBackdropKind::Accent) }; if (backdrop) { backdrop->ValidateVisual(); @@ -386,8 +390,9 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateSystemBackdrop return g_CTopLevelWindow_UpdateSystemBackdropVisual_Org(This); } auto data{ This->GetData() }; - if (!data) + if (!data || !data->IsWindowVisibleAndUncloaked() || This->IsTrullyMinimized()) { + BackdropManager::Trim(This); return g_CTopLevelWindow_UpdateSystemBackdropVisual_Org(This); } @@ -404,7 +409,7 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_UpdateSystemBackdrop // release resources void STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_Destructor(uDwm::CTopLevelWindow* This) { - BackdropManager::RemoveBackdrop(This, true); + BackdropManager::Remove(This, true); g_CTopLevelWindow_Destructor_Org(This); } @@ -415,7 +420,7 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_InitializeVisualTree if (SUCCEEDED(hr)) { - BackdropManager::TryCloneBackdropVisualForWindow(This, window); + BackdropManager::TryClone(This, window); } return hr; } @@ -428,8 +433,9 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_OnClipUpdated(uDwm:: return g_CTopLevelWindow_OnClipUpdated_Org(This); } auto data{ This->GetData() }; - if (!data) + if (!data || !data->IsWindowVisibleAndUncloaked() || This->IsTrullyMinimized()) { + BackdropManager::Trim(This); return g_CTopLevelWindow_OnClipUpdated_Org(This); } @@ -438,7 +444,7 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCTopLevelWindow_OnClipUpdated(uDwm:: if (SUCCEEDED(hr)) { auto kind{ static_cast(GetActualBackdropKind(This)) }; - winrt::com_ptr backdrop{ BackdropManager::GetOrCreateBackdropVisual(This, kind == BackdropManager::CompositedBackdropKind::Accent) }; + winrt::com_ptr backdrop{ BackdropManager::GetOrCreate(This, kind == BackdropManager::CompositedBackdropKind::Accent) }; if (backdrop) { wil::unique_hrgn clipRgn{ CreateRectRgn(0, 0, 0, 0) }; @@ -473,22 +479,21 @@ HRESULT STDMETHODCALLTYPE GlassFramework::MyCWindowList_UpdateAccentBlurRect(uDw if (SUCCEEDED(hr) && SUCCEEDED(This->GetSyncedWindowDataByHwnd(milCmd->GetHwnd(), &data)) && data && (window = data->GetWindow())) { auto kind{ static_cast(GetActualBackdropKind(window)) }; - winrt::com_ptr backdrop{ BackdropManager::GetOrCreateBackdropVisual(window, kind == BackdropManager::CompositedBackdropKind::Accent) }; + auto lprc{ milCmd->GetRect() }; + if ( + lprc && + ( + lprc->right <= lprc->left || + lprc->bottom <= lprc->top + ) + ) + { + lprc = nullptr; + } + winrt::com_ptr backdrop{ BackdropManager::GetOrCreateForAccentBlurRect(window, lprc, kind == BackdropManager::CompositedBackdropKind::Accent && lprc) }; if (backdrop) { - if (data->GetAccentPolicy()->IsClipEnabled()) - { - auto lprc{ milCmd->GetRect() }; - if ( - lprc->right <= lprc->left || - lprc->bottom <= lprc->top - ) - { - lprc = nullptr; - } - backdrop->SetAccentRect(lprc); - } - + backdrop->SetAccentRect(lprc); backdrop->ValidateVisual(); } } @@ -597,12 +602,13 @@ void GlassFramework::UpdateConfiguration(ConfigurationFramework::UpdateType type for (auto i{ windowList->Blink }; i != windowList; i = i->Blink) { auto data{ reinterpret_cast(i) }; + if (!data->IsWindowVisibleAndUncloaked()) { continue; } auto hwnd{ data->GetHwnd() }; if (!hwnd || !IsWindow(hwnd)) { continue; } auto window{ data->GetWindow() }; - if (!window) { continue; } + if (!window || window->IsTrullyMinimized()) { continue; } - auto backdrop{ BackdropManager::GetOrCreateBackdropVisual(window, window->HasNonClientBackground() || GetActualBackdropKind(window) == BackdropManager::CompositedBackdropKind::Accent) }; + auto backdrop{ BackdropManager::GetOrCreate(window, window->HasNonClientBackground() || GetActualBackdropKind(window) == BackdropManager::CompositedBackdropKind::Accent) }; if (backdrop) { backdrop->ValidateVisual(); diff --git a/OpenGlass/GlassOptimizer.cpp b/OpenGlass/GlassOptimizer.cpp index 1cb5af3..5094d99 100644 --- a/OpenGlass/GlassOptimizer.cpp +++ b/OpenGlass/GlassOptimizer.cpp @@ -25,17 +25,6 @@ namespace OpenGlass::GlassOptimizer dwmcore::CVisualTree* visualTree, bool* unknown ); -#ifdef _DEBUG - HRESULT STDMETHODCALLTYPE MyCCustomBlur_BuildEffect( - dwmcore::CCustomBlur* This, - ID2D1Image* image, - D2D1_RECT_F& sourceRect, - const D2D1_SIZE_F& blurAmount, - D2D1_GAUSSIANBLUR_OPTIMIZATION optimization, - const D2D1_VECTOR_2F& outputScale, - D2D1_VECTOR_2F* scaleAmount - ); -#endif float STDMETHODCALLTYPE MyCCustomBlur_DetermineOutputScale( float size, float blurAmount, @@ -48,32 +37,61 @@ namespace OpenGlass::GlassOptimizer const D2D1_VECTOR_2F& blurAmount, D2D1_VECTOR_2F* scaleAmount ); - HRESULT WINAPI MyCDrawingContext_GetBackdropImageFromRenderTarget( + HRESULT STDMETHODCALLTYPE MyCDrawingContext_GetBackdropImageFromRenderTarget( dwmcore::CDrawingContext* This, - D2D1_RECT_F& lprc, + const D2D1_RECT_F& lprc, bool notUsingFullTargetAsBackdropInput, dwmcore::EffectInput** effectInput ); + HRESULT STDMETHODCALLTYPE MyCDrawingContext_PreSubgraph( + dwmcore::CDrawingContext* This, + dwmcore::CVisualTree* visualTree, + bool* conditionalBreak + ); + HRESULT STDMETHODCALLTYPE MyCCustomBlur_Draw( + dwmcore::CCustomBlur* This, + dwmcore::CDrawingContext* drawingContext, + const D2D1_RECT_F& destinationRect, + const D2D1_POINT_2F& point, + D2D1_INTERPOLATION_MODE interpolationMode, + D2D1_COMPOSITE_MODE compositeMode + ); decltype(&MyCVisual_GetWindowBackgroundTreatmentInternal) g_CVisual_GetWindowBackgroundTreatmentInternal_Org{ nullptr }; decltype(&MyCArrayBasedCoverageSet_AddAntiOccluderRect) g_CArrayBasedCoverageSet_AddAntiOccluderRect_Org{ nullptr }; decltype(&MyCArrayBasedCoverageSet_IsCovered) g_CArrayBasedCoverageSet_IsCovered_Org{ nullptr }; decltype(&MyCOcclusionContext_PostSubgraph) g_COcclusionContext_PostSubgraph_Org{ nullptr }; -#ifdef _DEBUG - decltype(&MyCCustomBlur_BuildEffect) g_CCustomBlur_BuildEffect_Org{ nullptr }; -#endif decltype(&MyCCustomBlur_DetermineOutputScale) g_CCustomBlur_DetermineOutputScale_Org{ nullptr }; decltype(&MyCBlurRenderingGraph_DeterminePreScale) g_CBlurRenderingGraph_DeterminePreScale_Org{ nullptr }; decltype(&MyCDrawingContext_GetBackdropImageFromRenderTarget) g_CDrawingContext_GetBackdropImageFromRenderTarget_Org{ nullptr }; + decltype(&MyCDrawingContext_PreSubgraph) g_CDrawingContext_PreSubgraph_Org{ nullptr }; + decltype(&MyCCustomBlur_Draw) g_CCustomBlur_Draw_Org{ nullptr }; - BOOL g_enableOcclusionCulling{ TRUE }; - BOOL g_enableEffectInputOptimization{ TRUE }; float g_additionalPreScaleAmount{ 0.5f }; ULONGLONG g_frameId{ 0ull }; bool g_hasWindowBackgroundTreatment{ false }; dwmcore::CVisual* g_visual{ nullptr }; dwmcore::MyDynArrayImpl g_validAntiOccluderList{}; + + HWND g_hwnd{ nullptr }; + enum D2D1_DIRECTIONALBLURKERNEL_PROP + { + D2D1_DIRECTIONALBLURKERNEL_PROP_STANDARD_DEVIATION, + D2D1_DIRECTIONALBLURKERNEL_PROP_DIRECTION, + D2D1_DIRECTIONALBLURKERNEL_PROP_KERNEL_RANGE_FACTOR, + D2D1_DIRECTIONALBLURKERNEL_PROP_OPTIMIZATION_TRANSFORM + }; + enum D2D1_DIRECTIONALBLURKERNEL_DIRECTION + { + D2D1_DIRECTIONALBLURKERNEL_DIRECTION_X, + D2D1_DIRECTIONALBLURKERNEL_DIRECTION_Y + }; + enum D2D1_DIRECTIONALBLURKERNEL_OPTIMIZATION_TRANSFORM + { + D2D1_DIRECTIONALBLURKERNEL_OPTIMIZATION_TRANSFORM_IDENDITY, + D2D1_DIRECTIONALBLURKERNEL_OPTIMIZATION_TRANSFORM_SCALE + }; } dwmcore::CWindowBackgroundTreatment* STDMETHODCALLTYPE GlassOptimizer::MyCVisual_GetWindowBackgroundTreatmentInternal(dwmcore::CVisual* This) @@ -83,6 +101,7 @@ dwmcore::CWindowBackgroundTreatment* STDMETHODCALLTYPE GlassOptimizer::MyCVisual { g_hasWindowBackgroundTreatment = true; } + return result; } HRESULT STDMETHODCALLTYPE GlassOptimizer::MyCArrayBasedCoverageSet_AddAntiOccluderRect( @@ -92,39 +111,36 @@ HRESULT STDMETHODCALLTYPE GlassOptimizer::MyCArrayBasedCoverageSet_AddAntiOcclud const MilMatrix3x2D* matrix ) { - if (g_enableOcclusionCulling) [[likely]] + auto currentFrameId{ dwmcore::GetCurrentFrameId() }; + if (g_frameId != currentFrameId) { - auto currentFrameId{ dwmcore::GetCurrentFrameId() }; - if (g_frameId != currentFrameId) - { #ifdef _DEBUG - OutputDebugStringW( - L"new frame detected, executing GC...\n" - ); + OutputDebugStringW( + L"new frame detected, executing GC...\n" + ); #endif - g_frameId = currentFrameId; - g_validAntiOccluderList.Clear(); - } + g_frameId = currentFrameId; + g_validAntiOccluderList.Clear(); + } - if ( - g_visual->GetOwningProcessId() != GetCurrentProcessId() /* actually this is useless, GetOwningProcessId only returns the process id of dwm, idk why */ || - g_hasWindowBackgroundTreatment - ) - { - dwmcore::CZOrderedRect zorderedRect{ lprc, depth, lprc }; - zorderedRect.UpdateDeviceRect(matrix); - g_validAntiOccluderList.Add(zorderedRect); + if ( + g_visual->GetOwningProcessId() != GetCurrentProcessId() /* actually this is useless, GetOwningProcessId only returns the process id of dwm, idk why */ || + g_hasWindowBackgroundTreatment + ) + { + dwmcore::CZOrderedRect zorderedRect{ lprc, depth, lprc }; + zorderedRect.UpdateDeviceRect(matrix); + g_validAntiOccluderList.Add(zorderedRect); #ifdef _DEBUG - OutputDebugStringW( - std::format( - L"{} - depth: {}, owning process id: {}\n", - __FUNCTIONW__, - depth, - g_visual->GetOwningProcessId() - ).c_str() - ); + OutputDebugStringW( + std::format( + L"{} - depth: {}, owning process id: {}\n", + __FUNCTIONW__, + depth, + g_visual->GetOwningProcessId() + ).c_str() + ); #endif - } } return g_CArrayBasedCoverageSet_AddAntiOccluderRect_Org(This, lprc, depth, matrix); @@ -136,19 +152,14 @@ bool STDMETHODCALLTYPE GlassOptimizer::MyCArrayBasedCoverageSet_IsCovered( bool deprecated ) { - if (g_enableOcclusionCulling) [[likely]] - { - auto array{ This->GetAntiOccluderArray() }; - auto arrayBackup{ *array }; - *array = g_validAntiOccluderList; + auto array{ This->GetAntiOccluderArray() }; + auto arrayBackup{ *array }; + *array = g_validAntiOccluderList; - bool result{ g_CArrayBasedCoverageSet_IsCovered_Org(This, lprc, depth, deprecated) }; + bool result{ g_CArrayBasedCoverageSet_IsCovered_Org(This, lprc, depth, deprecated) }; - *array = arrayBackup; - return result; - } - - return g_CArrayBasedCoverageSet_IsCovered_Org(This, lprc, depth, deprecated); + *array = arrayBackup; + return result; } HRESULT STDMETHODCALLTYPE GlassOptimizer::MyCOcclusionContext_PostSubgraph( dwmcore::COcclusionContext* This, @@ -165,45 +176,6 @@ HRESULT STDMETHODCALLTYPE GlassOptimizer::MyCOcclusionContext_PostSubgraph( return hr; } -#ifdef _DEBUG -HRESULT STDMETHODCALLTYPE GlassOptimizer::MyCCustomBlur_BuildEffect( - dwmcore::CCustomBlur* This, - ID2D1Image* image, - D2D1_RECT_F& sourceRect, - const D2D1_SIZE_F& blurAmount, - D2D1_GAUSSIANBLUR_OPTIMIZATION optimization, - const D2D1_VECTOR_2F& outputScale, - D2D1_VECTOR_2F* scaleAmount -) -{ - HRESULT hr{ g_CCustomBlur_BuildEffect_Org(This, image, sourceRect, blurAmount, optimization, outputScale, scaleAmount) }; - - D2D1_RECT_F cropRect{}; - This->GetCropEffect()->GetValue(D2D1_CROP_PROP_RECT, &cropRect); - OutputDebugStringW( - std::format( - L"cropRect: [{},{},{},{}], sourceRect: [{},{},{},{}], blurAmount: [{},{}], outputScale:[{},{}], scaleAmount:[{},{}]\n", - cropRect.left, - cropRect.top, - cropRect.right, - cropRect.bottom, - sourceRect.left, - sourceRect.top, - sourceRect.right, - sourceRect.bottom, - blurAmount.width, - blurAmount.height, - outputScale.x, - outputScale.y, - scaleAmount->x, - scaleAmount->y - ).c_str() - ); - - return hr; -} -#endif - float STDMETHODCALLTYPE GlassOptimizer::MyCCustomBlur_DetermineOutputScale( float size, float blurAmount, @@ -231,9 +203,9 @@ void STDMETHODCALLTYPE GlassOptimizer::MyCBlurRenderingGraph_DeterminePreScale( scaleAmount->y *= g_additionalPreScaleAmount; } } -HRESULT WINAPI GlassOptimizer::MyCDrawingContext_GetBackdropImageFromRenderTarget( +HRESULT STDMETHODCALLTYPE GlassOptimizer::MyCDrawingContext_GetBackdropImageFromRenderTarget( dwmcore::CDrawingContext* This, - D2D1_RECT_F& lprc, + const D2D1_RECT_F& lprc, bool notUsingFullTargetAsBackdropInput, dwmcore::EffectInput** effectInput ) @@ -250,38 +222,55 @@ HRESULT WINAPI GlassOptimizer::MyCDrawingContext_GetBackdropImageFromRenderTarge ).c_str() ); #endif - return g_CDrawingContext_GetBackdropImageFromRenderTarget_Org(This, lprc, static_cast(g_enableEffectInputOptimization), effectInput); + return g_CDrawingContext_GetBackdropImageFromRenderTarget_Org(This, lprc, true, effectInput); +} + +HRESULT STDMETHODCALLTYPE GlassOptimizer::MyCDrawingContext_PreSubgraph( + dwmcore::CDrawingContext* This, + dwmcore::CVisualTree* visualTree, + bool* conditionalBreak +) +{ + HWND hwnd{ reinterpret_cast(This->GetD2DContextOwner())->GetCurrentVisual()->GetHwnd()}; + if (hwnd) { g_hwnd = hwnd; } + HRESULT hr{ g_CDrawingContext_PreSubgraph_Org(This, visualTree, conditionalBreak) }; + + return hr; +} + +HRESULT STDMETHODCALLTYPE GlassOptimizer::MyCCustomBlur_Draw( + dwmcore::CCustomBlur* This, + dwmcore::CDrawingContext* drawingContext, + const D2D1_RECT_F& destinationRect, + const D2D1_POINT_2F& point, + D2D1_INTERPOLATION_MODE interpolationMode, + D2D1_COMPOSITE_MODE compositeMode +) +{ + drawingContext->GetD2DContext()->GetDeviceContext()->DrawImage( + This->GetDirectionalBlurYEffect(), + nullptr, + &destinationRect, + D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR, + D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY + ); + g_hwnd = nullptr; + + return S_OK; } void GlassOptimizer::UpdateConfiguration(ConfigurationFramework::UpdateType type) { if (type & ConfigurationFramework::UpdateType::Framework) { - g_enableOcclusionCulling = TRUE; - LOG_IF_FAILED( - wil::reg::get_value_dword_nothrow( - ConfigurationFramework::GetDwmKey(), - L"EnableOcclusionCulling", - reinterpret_cast(&g_enableOcclusionCulling) - ) - ); - g_enableEffectInputOptimization = TRUE; - LOG_IF_FAILED( - wil::reg::get_value_dword_nothrow( - ConfigurationFramework::GetDwmKey(), - L"EnableEffectInputOptimization", - reinterpret_cast(&g_enableEffectInputOptimization) - ) - ); - DWORD value{ 0 }; if (os::buildNumber < os::build_w11_21h2) { - value = 50; + value = 90; } else { - value = 75; + value = 95; } LOG_IF_FAILED( wil::reg::get_value_dword_nothrow( @@ -300,12 +289,11 @@ HRESULT GlassOptimizer::Startup() dwmcore::GetAddressFromSymbolMap("CArrayBasedCoverageSet::AddAntiOccluderRect", g_CArrayBasedCoverageSet_AddAntiOccluderRect_Org); dwmcore::GetAddressFromSymbolMap("CArrayBasedCoverageSet::IsCovered", g_CArrayBasedCoverageSet_IsCovered_Org); dwmcore::GetAddressFromSymbolMap("COcclusionContext::PostSubgraph", g_COcclusionContext_PostSubgraph_Org); -#ifdef _DEBUG - dwmcore::GetAddressFromSymbolMap("CCustomBlur::BuildEffect", g_CCustomBlur_BuildEffect_Org); -#endif dwmcore::GetAddressFromSymbolMap("CCustomBlur::DetermineOutputScale", g_CCustomBlur_DetermineOutputScale_Org); dwmcore::GetAddressFromSymbolMap("CBlurRenderingGraph::DeterminePreScale", g_CBlurRenderingGraph_DeterminePreScale_Org); dwmcore::GetAddressFromSymbolMap("CDrawingContext::GetBackdropImageFromRenderTarget", g_CDrawingContext_GetBackdropImageFromRenderTarget_Org); + dwmcore::GetAddressFromSymbolMap("CDrawingContext::PreSubgraph", g_CDrawingContext_PreSubgraph_Org); + dwmcore::GetAddressFromSymbolMap("CCustomBlur::Draw", g_CCustomBlur_Draw_Org); return HookHelper::Detours::Write([]() { @@ -315,11 +303,10 @@ HRESULT GlassOptimizer::Startup() HookHelper::Detours::Attach(&g_CArrayBasedCoverageSet_AddAntiOccluderRect_Org, MyCArrayBasedCoverageSet_AddAntiOccluderRect); HookHelper::Detours::Attach(&g_CArrayBasedCoverageSet_IsCovered_Org, MyCArrayBasedCoverageSet_IsCovered); HookHelper::Detours::Attach(&g_COcclusionContext_PostSubgraph_Org, MyCOcclusionContext_PostSubgraph); -#ifdef _DEBUG - HookHelper::Detours::Attach(&g_CCustomBlur_BuildEffect_Org, MyCCustomBlur_BuildEffect); -#endif HookHelper::Detours::Attach(&g_CCustomBlur_DetermineOutputScale_Org, MyCCustomBlur_DetermineOutputScale); HookHelper::Detours::Attach(&g_CDrawingContext_GetBackdropImageFromRenderTarget_Org, MyCDrawingContext_GetBackdropImageFromRenderTarget); + HookHelper::Detours::Attach(&g_CDrawingContext_PreSubgraph_Org, MyCDrawingContext_PreSubgraph); + HookHelper::Detours::Attach(&g_CCustomBlur_Draw_Org, MyCCustomBlur_Draw); } else { @@ -337,11 +324,10 @@ void GlassOptimizer::Shutdown() HookHelper::Detours::Detach(&g_CArrayBasedCoverageSet_AddAntiOccluderRect_Org, MyCArrayBasedCoverageSet_AddAntiOccluderRect); HookHelper::Detours::Detach(&g_CArrayBasedCoverageSet_IsCovered_Org, MyCArrayBasedCoverageSet_IsCovered); HookHelper::Detours::Detach(&g_COcclusionContext_PostSubgraph_Org, MyCOcclusionContext_PostSubgraph); -#ifdef _DEBUG - HookHelper::Detours::Detach(&g_CCustomBlur_BuildEffect_Org, MyCCustomBlur_BuildEffect); -#endif HookHelper::Detours::Detach(&g_CCustomBlur_DetermineOutputScale_Org, MyCCustomBlur_DetermineOutputScale); HookHelper::Detours::Detach(&g_CDrawingContext_GetBackdropImageFromRenderTarget_Org, MyCDrawingContext_GetBackdropImageFromRenderTarget); + HookHelper::Detours::Detach(&g_CDrawingContext_PreSubgraph_Org, MyCDrawingContext_PreSubgraph); + HookHelper::Detours::Detach(&g_CCustomBlur_Draw_Org, MyCCustomBlur_Draw); } else { diff --git a/OpenGlass/GlassReflection.hpp b/OpenGlass/GlassReflection.hpp index c8bd0ba..3b35c17 100644 --- a/OpenGlass/GlassReflection.hpp +++ b/OpenGlass/GlassReflection.hpp @@ -51,6 +51,7 @@ namespace OpenGlass m_brush.HorizontalAlignmentRatio(0.f); m_brush.VerticalAlignmentRatio(0.f); m_brush.Surface(s_reflectionSurface); + m_brush.BitmapInterpolationMode(wuc::CompositionBitmapInterpolationMode::Linear); m_visual = compositor.CreateSpriteVisual(); m_visual.Brush(m_brush); m_visual.RelativeSizeAdjustment({ 1.f, 1.f }); diff --git a/OpenGlass/dcompProjection.hpp b/OpenGlass/dcompProjection.hpp index 4d6ab11..62fdb54 100644 --- a/OpenGlass/dcompProjection.hpp +++ b/OpenGlass/dcompProjection.hpp @@ -65,14 +65,44 @@ namespace OpenGlass::dcomp } }; - // Windows 11 only, customize the content of hostbackdropbrush - DECLARE_INTERFACE_IID_(IVisualPartner, IUnknown, "01dc794b-4ff5-4491-9942-b9e7b8893be4") + + static HRESULT SetWindowBackgroundTreatment(IUnknown* unknown, const wuc::CompositionBrush& brush) { - virtual HRESULT STDMETHODCALLTYPE GetPointerEventRouter(struct ::ABI::Windows::UI::Composition::ICompositionInteractionPartner**) PURE; - virtual HRESULT STDMETHODCALLTYPE RemovePointerEventRouter() PURE; - virtual HRESULT STDMETHODCALLTYPE SetTransformParent(::ABI::Windows::UI::Composition::IVisual* visual) PURE; - virtual HRESULT STDMETHODCALLTYPE SetWindowBackgroundTreatment(::ABI::Windows::UI::Composition::ICompositionBrush* brush) PURE; - virtual HRESULT STDMETHODCALLTYPE SetInteraction(struct ::ABI::Windows::UI::Composition::ICompositionInteractionPartner*) PURE; - virtual HRESULT STDMETHODCALLTYPE SetSharedManipulationTransform(struct ::ABI::Windows::UI::Composition::ICompositionManipulationTransformPartner*) PURE; - }; + if (os::buildNumber < os::build_w11_21h2) + { + // Windows 10 only, customize the content of hostbackdropbrush + // only affect the entire tree of the applied visual + DECLARE_INTERFACE_IID_(IVisualPartner, IUnknown, "bbed8da5-977f-42cb-9b28-f0ceebced3a7") + { + virtual HRESULT STDMETHODCALLTYPE GetPointerEventRouter(struct ::ABI::Windows::UI::Composition::ICompositionInteractionPartner**) PURE; + virtual HRESULT STDMETHODCALLTYPE RemovePointerEventRouter() PURE; + virtual HRESULT STDMETHODCALLTYPE SetTransformParent(::ABI::Windows::UI::Composition::IVisual * visual) PURE; + virtual HRESULT STDMETHODCALLTYPE SetWindowBackgroundTreatment(::ABI::Windows::UI::Composition::ICompositionBrush * brush) PURE; + virtual HRESULT STDMETHODCALLTYPE SetInteraction(struct ::ABI::Windows::UI::Composition::ICompositionInteractionPartner*) PURE; + virtual HRESULT STDMETHODCALLTYPE SetSharedManipulationTransform(struct ::ABI::Windows::UI::Composition::ICompositionManipulationTransformPartner*) PURE; + }; + winrt::com_ptr visualPartner{ nullptr }; + RETURN_IF_FAILED(unknown->QueryInterface(visualPartner.put())); + RETURN_IF_FAILED(visualPartner->SetWindowBackgroundTreatment(brush.as<::ABI::Windows::UI::Composition::ICompositionBrush>().get())); + } + else + { + // Windows 11 only, customize the content of hostbackdropbrush + // affect the whole window + DECLARE_INTERFACE_IID_(IVisualPartner, IUnknown, "01dc794b-4ff5-4491-9942-b9e7b8893be4") + { + virtual HRESULT STDMETHODCALLTYPE GetPointerEventRouter(struct ::ABI::Windows::UI::Composition::ICompositionInteractionPartner**) PURE; + virtual HRESULT STDMETHODCALLTYPE RemovePointerEventRouter() PURE; + virtual HRESULT STDMETHODCALLTYPE SetTransformParent(::ABI::Windows::UI::Composition::IVisual * visual) PURE; + virtual HRESULT STDMETHODCALLTYPE SetWindowBackgroundTreatment(::ABI::Windows::UI::Composition::ICompositionBrush * brush) PURE; + virtual HRESULT STDMETHODCALLTYPE SetInteraction(struct ::ABI::Windows::UI::Composition::ICompositionInteractionPartner*) PURE; + virtual HRESULT STDMETHODCALLTYPE SetSharedManipulationTransform(struct ::ABI::Windows::UI::Composition::ICompositionManipulationTransformPartner*) PURE; + }; + winrt::com_ptr visualPartner{ nullptr }; + RETURN_IF_FAILED(unknown->QueryInterface(visualPartner.put())); + RETURN_IF_FAILED(visualPartner->SetWindowBackgroundTreatment(brush.as<::ABI::Windows::UI::Composition::ICompositionBrush>().get())); + } + + return S_OK; + } } \ No newline at end of file diff --git a/OpenGlass/dwmcoreProjection.hpp b/OpenGlass/dwmcoreProjection.hpp index 38ea751..e3605b5 100644 --- a/OpenGlass/dwmcoreProjection.hpp +++ b/OpenGlass/dwmcoreProjection.hpp @@ -305,11 +305,35 @@ namespace OpenGlass::dwmcore }; struct EffectInput : CResource {}; struct IDeviceTarget: CResource {}; + struct ID2DContextOwner : CResource {}; + struct CD2DContext : CResource + { + ID2D1DeviceContext* GetDeviceContext() const + { + return reinterpret_cast(this)[30]; + } + HRESULT STDMETHODCALLTYPE FillEffect( + const ID2DContextOwner* contextOwner, + ID2D1Effect* effect, + const D2D_RECT_F* lprc, + const D2D_POINT_2F* point, + D2D1_INTERPOLATION_MODE interpolationMode, + D2D1_COMPOSITE_MODE compositeMode + ) + { + DEFINE_INVOKER(CD2DContext::FillEffect); + return INVOKE_MEMBERFUNCTION(contextOwner, effect, lprc, point, interpolationMode, compositeMode); + } + }; struct CDrawingContext : CResource { - CDrawingContext* GetRealDrawingContext() const + CD2DContext* GetD2DContext() const + { + return reinterpret_cast(reinterpret_cast(this)[5] + 16); + } + ID2DContextOwner* GetD2DContextOwner() const { - return reinterpret_cast(reinterpret_cast(this) + 24); + return reinterpret_cast(reinterpret_cast(this) + 24); } bool STDMETHODCALLTYPE IsOccluded(const D2D1_RECT_F& lprc, int flag) const { @@ -365,6 +389,25 @@ namespace OpenGlass::dwmcore { return reinterpret_cast(this)[7]; } + void STDMETHODCALLTYPE Reset() + { + DEFINE_INVOKER(CCustomBlur::Reset); + return INVOKE_MEMBERFUNCTION(); + } + static HRESULT STDMETHODCALLTYPE Create(ID2D1DeviceContext* deviceContext, CCustomBlur** customBlur) + { + DEFINE_INVOKER(CCustomBlur::Create); + return INVOKE_FUNCTION(deviceContext, customBlur); + } + static float STDMETHODCALLTYPE DetermineOutputScale( + float size, + float blurAmount, + D2D1_GAUSSIANBLUR_OPTIMIZATION optimization + ) + { + DEFINE_INVOKER(CCustomBlur::DetermineOutputScale); + return INVOKE_FUNCTION(size, blurAmount, optimization); + } }; struct CDrawListCache : CResource {}; struct CDrawListBrush : CResource {}; @@ -407,6 +450,7 @@ namespace OpenGlass::dwmcore fullyUnDecoratedFunctionName == "CResource::GetOwningProcessId" || fullyUnDecoratedFunctionName == "COcclusionContext::PostSubgraph" || fullyUnDecoratedFunctionName == "CBlurRenderingGraph::DeterminePreScale" || + fullyUnDecoratedFunctionName == "CD2DContext::FillEffect" || ( fullyUnDecoratedFunctionName.starts_with("CDrawingContext::") && fullyUnDecoratedFunctionName != "CDrawingContext::IsOccluded" diff --git a/OpenGlass/uDwmProjection.hpp b/OpenGlass/uDwmProjection.hpp index f98d0e0..c222eb8 100644 --- a/OpenGlass/uDwmProjection.hpp +++ b/OpenGlass/uDwmProjection.hpp @@ -421,7 +421,7 @@ namespace OpenGlass::uDwm { return AccentState >= 1 && AccentState <= 4; } - bool IsClipEnabled() const + bool IsAccentBlurRectEnabled() const { return (AccentFlags & (1 << 9)) != 0; } @@ -914,6 +914,13 @@ namespace OpenGlass::uDwm return true; } + bool IsTrullyMinimized() + { + RECT borderRect{}; + THROW_HR_IF_NULL(E_INVALIDARG, GetActualWindowRect(&borderRect, false, true, false)); + + return borderRect.left <= -32000 || borderRect.top <= -32000; + } enum class BackgroundType { diff --git a/README.md b/README.md index a5b32ab..12fe253 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,9 @@ The following table demonstrates the similarities and differences between these | | DWORD | **Not supported** | GlassOverrideBorder | Specifies that the effect should extend to the border. The default value is 0. | **Disabling this option can significantly improve performance** | | | DWORD | **Not supported** | GlassCrossFadeTime | The cross fade time for backdrop switching. The default value is 87. | | | | DWORD | **Not supported** | GlassOverrideAccent | Overriding accent with the effect of OpenGlass. The default value is 0. | | -| | DWORD | **Not supported** | EnableOcclusionCulling | Enable occlusion cullling optimization for Windows 10. The default value is 1. | | -| | DWORD | **Not supported** | GlassAdditionalPreScaleAmount | Additional prescaling factor for backdrop input image, the smaller the value the more significant the performance improvement, the lower the quality of the glass. The default value is 50% for Windows 10 but 75% for Windows 11. | | -| | DWORD | **Not supported** | EnableEffectInputOptimization | In Windows 10, dwmcore creates a copy of the entire desktop for effect input by default. When this option is on, dwmcore only creates a copy of the desktop in the size of the blurred region. The default value is 1. | | +| | DWORD | **Not supported** | GlassAdditionalPreScaleAmount | Additional prescaling factor for backdrop input image, the smaller the value the more significant the performance improvement, the lower the quality of the glass. The default value is 90% for Windows 10 but 95% for Windows 11. | | +| | DWORD | **Not supported** | EnableOcclusionCulling | Enable occlusion cullling optimization for Windows 10. The default value is 1. | **Outdated** | +| | DWORD | **Not supported** | EnableEffectInputOptimization | In Windows 10, dwmcore creates a copy of the entire desktop for effect input by default. When this option is on, dwmcore only creates a copy of the desktop in the size of the blurred region. The default value is 1. | **Outdated** | > [!TIP] > Check out the code to discover more details!