Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTaleX531 committed Jul 6, 2024
1 parent 2b65519 commit 58c7eec
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 52 deletions.
4 changes: 2 additions & 2 deletions OpenGlass/GlassEffectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ namespace OpenGlass::GlassEffectManager
class CGlassEffect : public winrt::implements<CGlassEffect, IGlassEffect>
{
bool m_initialized{ false };
bool m_normalDesktopRender{ false };
Type m_type{ Type::Blur };
float m_glassOpacity{ 0.63f };
float m_blurAmount{ 9.f };
D2D1_COLOR_F m_color{};

D2D1_SIZE_F m_glassSize{};
D2D1_SIZE_F m_desktopSize{};
D2D1_POINT_2F m_glassDesktopPosition{};
Expand Down Expand Up @@ -93,7 +94,6 @@ HRESULT STDMETHODCALLTYPE GlassEffectManager::CGlassEffect::Invalidate(
)
{
m_backdropPixelFormat = backdropBitmap->GetPixelFormat();
m_normalDesktopRender = normalDesktopRender;
if (!m_initialized)
{
RETURN_IF_FAILED(Initialize());
Expand Down
6 changes: 6 additions & 0 deletions OpenGlass/GlassEffectManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

namespace OpenGlass::GlassEffectManager
{
enum class Type : UCHAR
{
Blur,
Aero
};

// [Guid("01AA613C-2376-4B95-8A74-B94CA840D4D1")]
DECLARE_INTERFACE_IID_(IGlassEffect, IUnknown, "01AA613C-2376-4B95-8A74-B94CA840D4D1")
{
Expand Down
34 changes: 27 additions & 7 deletions OpenGlass/GlassRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ namespace OpenGlass::GlassRenderer
dwmcore::IDrawingContext* g_drawingContextNoRef{ nullptr };
ID2D1Device* g_deviceNoRef{ nullptr };

GlassEffectManager::Type g_type{ GlassEffectManager::Type::Blur };
float g_blurAmount{ 9.f };
float g_glassOpacity{ 0.63f };
// exclusively used by aero backdrop
float g_colorBalance{ 0.f };
float g_afterglowBalance{ 0.43f };
}

HRESULT STDMETHODCALLTYPE GlassRenderer::MyCRenderData_TryDrawCommandAsDrawList(
Expand Down Expand Up @@ -170,7 +174,6 @@ HRESULT STDMETHODCALLTYPE GlassRenderer::MyCDrawingContext_DrawGeometry(
D2D1_COLOR_F color{ dwmcore::Convert_D2D1_COLOR_F_scRGB_To_D2D1_COLOR_F_sRGB(g_drawColor.value()) };
dwmcore::CShapePtr geometryShape{};
if (
g_drawColor.value().a == 1.f ||
FAILED(geometry->GetShapeData(nullptr, &geometryShape)) ||
!geometryShape ||
geometryShape->IsEmpty()
Expand All @@ -188,13 +191,15 @@ HRESULT STDMETHODCALLTYPE GlassRenderer::MyCDrawingContext_DrawGeometry(
This->GetDrawingContext()->CalcLocalSpaceClippedBounds(boundRect, &localSpaceClippedBounds);

if (
normalDesktopRender &&
g_drawColor.value().a == 1.f ||
(
worldSpaceClippedBounds.right <= worldSpaceClippedBounds.left ||
worldSpaceClippedBounds.bottom <= worldSpaceClippedBounds.top ||
localSpaceClippedBounds.right <= localSpaceClippedBounds.left ||
localSpaceClippedBounds.bottom <= localSpaceClippedBounds.top ||
This->GetDrawingContext()->IsOccluded(boundRect, This->GetDrawingContext()->GetD2DContextOwner()->GetCurrentZ())
normalDesktopRender &&
(
worldSpaceClippedBounds.right <= worldSpaceClippedBounds.left ||
worldSpaceClippedBounds.bottom <= worldSpaceClippedBounds.top ||
localSpaceClippedBounds.right <= localSpaceClippedBounds.left ||
localSpaceClippedBounds.bottom <= localSpaceClippedBounds.top
)
)
)
{
Expand Down Expand Up @@ -325,6 +330,21 @@ void GlassRenderer::UpdateConfiguration(ConfigurationFramework::UpdateType type)
ReflectionRenderer::g_reflectionIntensity = std::clamp(static_cast<float>(ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"ColorizationGlassReflectionIntensity")) / 100.f, 0.f, 1.f);
ReflectionRenderer::g_reflectionParallaxIntensity = std::clamp(static_cast<float>(ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"ColorizationGlassReflectionParallaxIntensity", 10)) / 100.f, 0.f, 1.f);
ReflectionRenderer::g_reflectionBitmap = nullptr;

auto colorBalance{ ConfigurationFramework::DwmTryDwordFromHKCUAndHKLM(L"ColorizationColorBalanceOverride") };
if (!colorBalance.has_value())
{
colorBalance = ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"ColorizationColorBalance", 0);
}
g_colorBalance = std::clamp(static_cast<float>(colorBalance.value()) / 100.f, 0.f, 1.f);
auto afterglowBalance{ ConfigurationFramework::DwmTryDwordFromHKCUAndHKLM(L"ColorizationAfterglowBalanceOverride") };
if (!afterglowBalance.has_value())
{
afterglowBalance = ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"ColorizationAfterglowBalance", 43);
}
g_afterglowBalance = std::clamp(static_cast<float>(afterglowBalance.value()) / 100.f, 0.f, 1.f);

g_type = static_cast<GlassEffectManager::Type>(std::clamp(ConfigurationFramework::DwmGetDwordFromHKCUAndHKLM(L"GlassType", 0), 0ul, 4ul));
}
}

Expand Down
58 changes: 15 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
# OpenGlass
A replica of the dead software glass8, also known as the upstream project of [DWMBlurGlass](https://github.com/Maplespe/DWMBlurGlass).

This software is designed for Windows 10 2004 to Windows 11 23H2, which is currently in its early stages and may have various efficiency issues and bugs. OpenGlass works with Windows 10 1809 at a minimum, but I highly recommend you to use Windows 10 22H2.

Some simple tests show that at lower blur radius OpenGlass performs slightly worse than glass8, but at higher blur radius the performance will be a bit better. For some applications where `DwmEnableBlurBehind` and `DwmExtendFrameIntoClientArea` are used in combination, OpenGlass performs almost twice as well as glass8.
This branch does not rely on `dcomp` and `Windows.UI.Composition`, so it is very limited in functionality and it is not unusual to encounter all kinds of bugs, but its performance is much better than the master branch. Currently this branch ONLY supports Windows 10 22H2.
> [!IMPORTANT]
> This software is intended for advanced users only. If you are a beginner and you do not have deeper knowledge of Windows (such as registry editing etc.) you should not install this software.
> For the average users, you should consider using [DWMBlurGlass](https://github.com/Maplespe/DWMBlurGlass).
Expand All @@ -18,51 +16,25 @@ Some simple tests show that at lower blur radius OpenGlass performs slightly wor
4. When you use it for the first time or just after updating your system, OpenGlass will try to download the symbol files and you will see its download progress bar in the taskbar, but please don't close it and be patient for about 15s. When the symbol files are ready, enjoy!
5. When you want to stop using OpenGlass or update the version of OpenGlass, running `shutdown.bat` will remove the effects of OpenGlass for you and exit the helper process. At this time, you can either replace the OpenGlass files or continue to run `uninstall.bat` and manually delete the remaining files to complete the uninstallation.

## Documentation (Migrate from glass8 to OpenGlass)
The following table demonstrates the similarities and differences between these two software.
> [!NOTE]
> 1. Most of the OpenGlass settings are stored in the `HKCU\SOFTWARE\Microsoft\Windows\DWM` and `HKLM\SOFTWARE\Microsoft\Windows\DWM`, but some registry items are stored only in HKLM and will remain constant at runtime.
> 2. All external resources referenced by OpenGlass must ensure that it can be accessed by DWM, so paths like `C:\Users\*` are invalid.
> 3. Normally, OpenGlass uses the udwm internal API to get the calculated color instead of reading the registry directly to get the color.
## Documentation
The legacy branch can use most of the features of the master branch. The following table lists the difference with master branch. The legacy branch uses the colors stored by `CTopLevelWindow`, so you can change the color settings using AWM without problems.

- `Not implemented` means that this feature has not yet been implemented but is possible in the future.
- `Not supported` means that this feature is impossible to be implemented in current structure.

| glass8 | Type | Description | OpenGlass | Description | Remarks
| master branch | Type | Description | legacy branch | Description | Remarks
| ---- | ---- | ---- | ---- | ---- | ---- |
| EnableLogging | DWORD | 0x0 = disables logging to debug.log (default) / 0x1 = enables verbose logging / logging of donation key messages and fatal errors is always enabled | | | **Not implemented** |
| MaxDeviceFeatureLevel | DWORD | Describes the set of features targeted by a Direct3D device. | | | **Not supported** |
| DisableGlassOnBattery | DWORD | 0x1 = When your AC power is unplugged and computer is running on the battery then the blur effect will be disabled to decrease power consumption (default) / 0x0 = blur effect won't be disabled on battery | | 0x01 = When your battery saver is activated then the effect will be disabled to decrease power consumption / 0x0 = blur effect won't be disabled when battery saver is activated | **The default value is 1 instead of 0** |
| DisabledHooks | DWORD | **Undocumented** | | 0x01 = Disable the hooks of CaptionTextHandler.cpp to enable compatibility with third-party mods | **This registry item is stored only in HKLM** |
| ForceD3DMode | DWORD | **Undocumented** | | | **Not supported** |
| GeometryCommand | DWORD | **Undocumented** | | | **Not supported** |
| GlassOpacity | DWORD | The amount of the opacity of the windows frames (0-100%). | | | **OK** |
| ColorizationBlurBalance/ColorizationBlurBalanceInactive | DWORD | | | | **Not supported** |
| ColorizationColorCaption | DWORD | Color used for drawing window titles. Format is 0xBBGGRR. | | | **OK** |
| BlurDeviation | DWORD | Standard deviation for Gaussian blur, default = 30 (which means σ = 3.0). Value 0 results in non-blurred transparency. | | | **OK** |
| RoundRectRadius | DWORD | The radius of glass geometry, Win8 = 0, Win7 = 12 | | | **OK** |
| ColorizationGlassReflectionIntensity | DWORD | The intensity of reflection effect (0-100%). The default value is 0%. | | | **OK** |
| | DWORD | **Not supported** | ColorizationGlassReflectionParallaxIntensity | The parallax intensity of the refection effect (0-100%). The default value is 10%. | |
| CustomThemeReflection | String | path to PNG file which will be used as overlay image to simulate reflection (Aero stripes) effect | | If the value does not exist, it will use the resource's bitmap. | **OK** |
| CustomThemeMaterial | String | **Undocumented** | | | **Only works for GlassType=Acrylic** |
| MaterialOpacity | DWORD | **Undocumented** | | | **Only works for GlassType=Acrylic** |
| CustomThemeAtlas | String | path to PNG file with theme resource (bitmap must have exactly the same layout as msstyle theme you are using!) | CustomThemeMsstyle | path to msstyle file | **CustomThemeAtlas is not supported, use CustomThemeMsstyle instead** |
| | DWORD | **Not supported** | CustomThemeMsstyleUseDefaults | Color scheme uses the result from GetThemeDefaults | |
| TextGlowMode | DWORD | Specifies how window caption glow effect will be rendered. 0x0=No glow effect. 0x1=Glow effect loaded from atlas (default). 0x2=Glow effect loaded from atlas and theme opacity is respected. 0x3=Composited glow effect using your theme settings. HIWORD of the value specifies glow size (0 = theme default). | TextGlowSize | The value specifies glow size. The default value is 15. | **TextGlowMode is deprecated, use TextGlowSize instead** |
| EnableBlurBlend | DWORD | Controls how the blurred background and frame colour are composited together (0x0 = default). | | | **Not supported** |
| ForceSystemMetrics | DWORD | **Undocumented** | | | **Not implemented** |
| GlassSafetyZoneMode | DWORD | **Undocumented** | | | **Not supported** |
| CenterCaption | DWORD | **Undocumented** | | | **OK** |
| | DWORD | **Not supported** | GlassLuminosity | The luminosity of Acrylic/Mica effect | |
| | DWORD | **Not supported** | GlassType | The type of backdrop effect (0x0-0x4). 0x0=Blur. 0x01=Aero. 0x02=Acrylic. 0x03=Mica. 0x04=Solid. | |
| | 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** | 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** | ForceAccentColorization | When this option is on, OpenGlass will always uses the colors from `AccentColor` and `AccentColorInactive`, which will ignore all the system settings related to color. | You can turn it on when there exists third-party softwares that break the auto-coloring. |
| | DWORD | **Not supported** | GlassCrossFadeEasingFunction | The easing function for cross fade animation. 0x0=Linear. 0x1=CubicBezier. The Default value is 0. | |
| | DWORD | **Not supported** | ColorizationColorBalanceOverride | Override the value of `ColorizationColorBalance`. | |
| | DWORD | **Not supported** | ColorizationAfterglowBalanceOverride | Override the value of `ColorizationAfterglowBalance`. | |
| RoundRectRadius | DWORD | The radius of glass geometry, Win8 = 0, Win7 = 12 | | Rounded corners are not anti-aliased. | **OK** |
| CustomThemeMaterial | String | **Undocumented** | | | **Not implemented** |
| MaterialOpacity | DWORD | **Undocumented** | | | **Not implemented** |
| GlassLuminosity | DWORD | The luminosity of Acrylic/Mica effect | | | **Not implemented** |
| GlassType | DWORD | The type of backdrop effect (0x0-0x4). 0x0=Blur. 0x01=Aero. 0x02=Acrylic. 0x03=Mica. 0x04=Solid. | | Only 0x0 is implemented. | **OK** |
| GlassOverrideBorder | DWORD | Specifies that the effect should extend to the border. The default value is 0. | | The glass will override the border by default. | **Not implemented** |
| GlassCrossFadeTime | DWORD | The cross fade time for backdrop switching. The default value is 87. | | | **Not supported** |
| GlassOverrideAccent | DWORD | Overriding accent with the effect of OpenGlass. The default value is 0. | | Some windows are overwritten resulting in full transparency. And the behavior of the overrides makes a difference. | **OK** |
| GlassAdditionalPreScaleAmount | DWORD | 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. | | | **Not implemented** |
| ForceAccentColorization | DWORD | When this option is on, OpenGlass will always uses the colors from `AccentColor` and `AccentColorInactive`, which will ignore all the system settings related to color. You can turn it on when there exists third-party softwares that break the auto-coloring. | | | **Not implemented** |
| GlassCrossFadeEasingFunction | DWORD | The easing function for cross fade animation. 0x0=Linear. 0x1=CubicBezier. The Default value is 0. | | | **Not supported** |

> [!TIP]
> Check out the code to discover more details!
Expand Down

0 comments on commit 58c7eec

Please sign in to comment.