Skip to content

Commit 721a5c5

Browse files
committed
fix(ui): resolve HDR overexposure by decoupling UI surface format
- Force UI layers to use DXGI_FORMAT_B8G8R8A8_UNORM (SDR) in CompositionEngine. - Remove all legacy manual HDR brightness compensation logic (ScaleUiColor, GetHdrUiWhiteScale, SetHdrWhiteScale) from UIRenderer and sub-components. - Rely on Windows DWM automatic SDR-to-HDR boost for consistent UI appearance. - Update version to 5.2.1.0.
1 parent b30316b commit 721a5c5

13 files changed

Lines changed: 188 additions & 307 deletions

QuickView/CompositionEngine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ HRESULT CompositionEngine::CreateLayerSurface(UILayer layer, UINT width, UINT he
829829

830830
HRESULT hr = m_device->CreateSurface(
831831
width, height,
832-
m_surfaceFormat,
832+
kUiSurfaceFormat,
833833
DXGI_ALPHA_MODE_PREMULTIPLIED,
834834
&data.surface
835835
);
@@ -847,7 +847,7 @@ HRESULT CompositionEngine::CreateAllSurfaces(UINT width, UINT height) {
847847

848848
// Ensure background surface
849849
m_backgroundLayer.surface.Reset();
850-
HRESULT hr = m_device->CreateSurface(width, height, m_surfaceFormat, DXGI_ALPHA_MODE_PREMULTIPLIED, &m_backgroundLayer.surface);
850+
HRESULT hr = m_device->CreateSurface(width, height, kUiSurfaceFormat, DXGI_ALPHA_MODE_PREMULTIPLIED, &m_backgroundLayer.surface);
851851
if (SUCCEEDED(hr)) {
852852
m_backgroundLayer.width = width;
853853
m_backgroundLayer.height = height;
@@ -867,7 +867,7 @@ ID2D1DeviceContext* CompositionEngine::BeginLayerUpdate(UILayer layer, const REC
867867

868868
D2D1_BITMAP_PROPERTIES1 props = D2D1::BitmapProperties1(
869869
D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW,
870-
D2D1::PixelFormat(m_surfaceFormat, D2D1_ALPHA_MODE_PREMULTIPLIED)
870+
D2D1::PixelFormat(kUiSurfaceFormat, D2D1_ALPHA_MODE_PREMULTIPLIED)
871871
);
872872

873873
data.target.Reset();

QuickView/CompositionEngine.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ class CompositionEngine {
218218
// Advanced Color (HDR) Support
219219
bool m_allowAdvancedColor = true;
220220
bool m_isAdvancedColor = false;
221-
DXGI_FORMAT m_surfaceFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
221+
DXGI_FORMAT m_surfaceFormat = DXGI_FORMAT_B8G8R8A8_UNORM; // Image layers (FP16 in HDR mode)
222+
// UI layers always use SDR format - DWM handles SDR→HDR boost automatically
223+
static constexpr DXGI_FORMAT kUiSurfaceFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
222224
QuickView::DisplayColorInfo m_displayColorInfo;
223225

224226
// Background State Tracking (to avoid redundant redraws)

QuickView/GalleryOverlay.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,8 @@
88

99
extern AppConfig g_config;
1010

11-
namespace {
12-
static D2D1_COLOR_F ScaleUiColor(const D2D1_COLOR_F& color, float hdrWhiteScale) {
13-
const float scale = (std::max)(1.0f, hdrWhiteScale);
14-
return D2D1::ColorF(
15-
(std::max)(0.0f, color.r * scale),
16-
(std::max)(0.0f, color.g * scale),
17-
(std::max)(0.0f, color.b * scale),
18-
color.a);
19-
}
20-
}
11+
12+
2113

2214
GalleryOverlay::GalleryOverlay() {}
2315

@@ -104,9 +96,9 @@ void GalleryOverlay::Render(ID2D1DeviceContext* pDC, const D2D1_SIZE_F& size) {
10496

10597
// Init resources
10698
bool isLight = IsLightThemeActive();
107-
if (!m_brushBg) pDC->CreateSolidColorBrush(ScaleUiColor(D2D1::ColorF(0.0f, 0.0f, 0.0f, 1.0f), m_hdrWhiteScale), &m_brushBg);
108-
if (!m_brushSelection) pDC->CreateSolidColorBrush(ScaleUiColor(D2D1::ColorF(D2D1::ColorF::DodgerBlue), m_hdrWhiteScale), &m_brushSelection); // Accent
109-
if (!m_brushText) pDC->CreateSolidColorBrush(ScaleUiColor(D2D1::ColorF(D2D1::ColorF::White), m_hdrWhiteScale), &m_brushText);
99+
if (!m_brushBg) pDC->CreateSolidColorBrush(D2D1::ColorF(0.0f, 0.0f, 0.0f, 1.0f), &m_brushBg);
100+
if (!m_brushSelection) pDC->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::DodgerBlue), &m_brushSelection); // Accent
101+
if (!m_brushText) pDC->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), &m_brushText);
110102

111103
D2D1_COLOR_F bgClr = isLight ? D2D1::ColorF(0.95f, 0.95f, 0.97f, 0.4f)
112104
: D2D1::ColorF(0.0f, 0.0f, 0.0f, 0.4f);
@@ -115,9 +107,9 @@ void GalleryOverlay::Render(ID2D1DeviceContext* pDC, const D2D1_SIZE_F& size) {
115107
D2D1_COLOR_F accClr = isLight ? D2D1::ColorF(0.0f, 0.45f, 0.9f, 1.0f)
116108
: D2D1::ColorF(D2D1::ColorF::DodgerBlue);
117109

118-
m_brushBg->SetColor(ScaleUiColor(bgClr, m_hdrWhiteScale));
119-
m_brushSelection->SetColor(ScaleUiColor(accClr, m_hdrWhiteScale));
120-
m_brushText->SetColor(ScaleUiColor(txtClr, m_hdrWhiteScale));
110+
m_brushBg->SetColor(bgClr);
111+
m_brushSelection->SetColor(accClr);
112+
m_brushText->SetColor(txtClr);
121113

122114
// Background (Controllable Dimmer)
123115
if (g_config.EnableAmbientDimmer) {
@@ -236,7 +228,7 @@ void GalleryOverlay::Render(ID2D1DeviceContext* pDC, const D2D1_SIZE_F& size) {
236228
D2D1_COLOR_F phBase =
237229
isLight ? D2D1::ColorF(0.85f, 0.85f, 0.85f, 1.0f)
238230
: D2D1::ColorF(0.2f, 0.2f, 0.2f, 1.0f);
239-
D2D1_COLOR_F color = ScaleUiColor(phBase, m_hdrWhiteScale);
231+
D2D1_COLOR_F color = phBase;
240232
color.a *= m_opacity;
241233

242234
ComPtr<ID2D1SolidColorBrush> phBrush;

QuickView/GalleryOverlay.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ class GalleryOverlay {
1515

1616
// Render the gallery overlay
1717
void Render(ID2D1DeviceContext* pDC, const D2D1_SIZE_F& size);
18-
void SetHdrWhiteScale(float scale) { m_hdrWhiteScale = scale; }
19-
2018
// Interaction
2119
bool OnKeyDown(UINT key); // Returns true if handled
2220
bool OnMouseWheel(int delta);
@@ -45,8 +43,6 @@ class GalleryOverlay {
4543

4644
bool m_isVisible = false;
4745
float m_opacity = 0.0f; // 0.0 - 1.0 (Fade in)
48-
float m_hdrWhiteScale = 1.0f;
49-
5046
// Scroll state
5147
float m_scrollTop = 0.0f;
5248
float m_maxScroll = 0.0f;

QuickView/HelpOverlay.cpp

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,8 @@
55

66
extern AppConfig g_config;
77

8-
namespace {
9-
static D2D1_COLOR_F ScaleUiColor(const D2D1_COLOR_F& color, float hdrWhiteScale) {
10-
const float scale = (std::max)(1.0f, hdrWhiteScale);
11-
return D2D1::ColorF(
12-
(std::max)(0.0f, color.r * scale),
13-
(std::max)(0.0f, color.g * scale),
14-
(std::max)(0.0f, color.b * scale),
15-
color.a);
16-
}
17-
}
8+
9+
1810

1911
HelpOverlay::HelpOverlay() {
2012
}
@@ -49,14 +41,14 @@ void HelpOverlay::CreateResources(ID2D1RenderTarget* pRT) {
4941
D2D1_COLOR_F keyClr = isLight ? D2D1::ColorF(0.12f, 0.12f, 0.15f, 0.7f) : D2D1::ColorF(1.0f, 1.0f, 1.0f, 0.7f);
5042
D2D1_COLOR_F bordClr = isLight ? D2D1::ColorF(0.0f, 0.0f, 0.0f, 0.15f) : D2D1::ColorF(1.0f, 1.0f, 1.0f, 0.15f);
5143

52-
pRT->CreateSolidColorBrush(ScaleUiColor(bgClr, m_hdrWhiteScale), &m_brushBg);
53-
pRT->CreateSolidColorBrush(ScaleUiColor(txtClr, m_hdrWhiteScale), &m_brushText);
54-
pRT->CreateSolidColorBrush(ScaleUiColor(headClr, m_hdrWhiteScale), &m_brushHeader);
55-
pRT->CreateSolidColorBrush(ScaleUiColor(keyClr, m_hdrWhiteScale), &m_brushKey);
56-
pRT->CreateSolidColorBrush(ScaleUiColor(bordClr, m_hdrWhiteScale), &m_brushBorder);
57-
pRT->CreateSolidColorBrush(ScaleUiColor(D2D1::ColorF(1.0f, 1.0f, 1.0f, 0.1f), m_hdrWhiteScale), &m_brushScrollBg);
58-
pRT->CreateSolidColorBrush(ScaleUiColor(D2D1::ColorF(1.0f, 1.0f, 1.0f, 0.3f), m_hdrWhiteScale), &m_brushScrollThumb);
59-
pRT->CreateSolidColorBrush(ScaleUiColor(D2D1::ColorF(1.0f, 0.2f, 0.2f, 0.8f), m_hdrWhiteScale), &m_brushCloseBg);
44+
pRT->CreateSolidColorBrush(bgClr, &m_brushBg);
45+
pRT->CreateSolidColorBrush(txtClr, &m_brushText);
46+
pRT->CreateSolidColorBrush(headClr, &m_brushHeader);
47+
pRT->CreateSolidColorBrush(keyClr, &m_brushKey);
48+
pRT->CreateSolidColorBrush(bordClr, &m_brushBorder);
49+
pRT->CreateSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 0.1f), &m_brushScrollBg);
50+
pRT->CreateSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 0.3f), &m_brushScrollThumb);
51+
pRT->CreateSolidColorBrush(D2D1::ColorF(1.0f, 0.2f, 0.2f, 0.8f), &m_brushCloseBg);
6052
}
6153

6254
if (m_brushBg) {
@@ -69,14 +61,14 @@ void HelpOverlay::CreateResources(ID2D1RenderTarget* pRT) {
6961
D2D1_COLOR_F scrlBg = isLight ? D2D1::ColorF(0.0f, 0.0f, 0.0f, 0.05f) : D2D1::ColorF(1.0f, 1.0f, 1.0f, 0.1f);
7062
D2D1_COLOR_F scrlTh = isLight ? D2D1::ColorF(0.0f, 0.0f, 0.0f, 0.2f) : D2D1::ColorF(1.0f, 1.0f, 1.0f, 0.3f);
7163

72-
m_brushBg->SetColor(ScaleUiColor(bgClr, m_hdrWhiteScale));
73-
m_brushText->SetColor(ScaleUiColor(txtClr, m_hdrWhiteScale));
74-
m_brushHeader->SetColor(ScaleUiColor(headClr, m_hdrWhiteScale));
75-
m_brushKey->SetColor(ScaleUiColor(keyClr, m_hdrWhiteScale));
76-
m_brushBorder->SetColor(ScaleUiColor(bordClr, m_hdrWhiteScale));
77-
m_brushScrollBg->SetColor(ScaleUiColor(scrlBg, m_hdrWhiteScale));
78-
m_brushScrollThumb->SetColor(ScaleUiColor(scrlTh, m_hdrWhiteScale));
79-
m_brushCloseBg->SetColor(ScaleUiColor(D2D1::ColorF(1.0f, 0.2f, 0.2f, 0.8f), m_hdrWhiteScale));
64+
m_brushBg->SetColor(bgClr);
65+
m_brushText->SetColor(txtClr);
66+
m_brushHeader->SetColor(headClr);
67+
m_brushKey->SetColor(keyClr);
68+
m_brushBorder->SetColor(bordClr);
69+
m_brushScrollBg->SetColor(scrlBg);
70+
m_brushScrollThumb->SetColor(scrlTh);
71+
m_brushCloseBg->SetColor(D2D1::ColorF(1.0f, 0.2f, 0.2f, 0.8f));
8072
}
8173

8274
if (!m_dwriteFactory) {
@@ -247,7 +239,7 @@ void HelpOverlay::Render(ID2D1RenderTarget* pRT, float winW, float winH) {
247239
// Theme-aware Material Filler
248240
bool isLight = IsLightThemeActive();
249241
D2D1_COLOR_F fillerColor = isLight ? D2D1::ColorF(0.95f, 0.95f, 0.97f, 1.0f) : D2D1::ColorF(0.08f, 0.08f, 0.10f, 1.0f);
250-
m_brushBg->SetColor(ScaleUiColor(fillerColor, m_hdrWhiteScale));
242+
m_brushBg->SetColor(fillerColor);
251243
m_brushBg->SetOpacity(masterOpacity);
252244

253245
pRT->FillRoundedRectangle(D2D1::RoundedRect(m_finalRect, 8.0f * s, 8.0f * s), m_brushBg.Get());

QuickView/HelpOverlay.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class HelpOverlay {
1818
void Init(ID2D1RenderTarget* pRT, HWND hwnd);
1919
void Render(ID2D1RenderTarget* pRT, float winW, float winH);
2020
void SetUIScale(float scale);
21-
void SetHdrWhiteScale(float scale) { m_hdrWhiteScale = scale; }
22-
2321
void SetVisible(bool visible);
2422
bool IsVisible() const { return m_visible; }
2523
void Toggle() { SetVisible(!m_visible); }
@@ -47,8 +45,6 @@ class HelpOverlay {
4745
float m_scrollOffset = 0.0f;
4846
float m_contentHeight = 0.0f;
4947
float m_uiScale = 1.0f;
50-
float m_hdrWhiteScale = 1.0f;
51-
5248
// Interaction
5349
bool m_hoverClose = false;
5450
D2D1_RECT_F m_closeRect = {};

QuickView/QuickView.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
// Version Information - This sets the display name in Windows
1212
VS_VERSION_INFO VERSIONINFO
13-
FILEVERSION 5,2,0,0
14-
PRODUCTVERSION 5,2,0,0
13+
FILEVERSION 5,2,1,0
14+
PRODUCTVERSION 5,2,1,0
1515
FILEFLAGSMASK 0x3fL
1616
FILEFLAGS 0x0L
1717
FILEOS VOS_NT_WINDOWS32
@@ -24,11 +24,11 @@ BEGIN
2424
BEGIN
2525
VALUE "CompanyName", "QuickView"
2626
VALUE "FileDescription", "QuickView"
27-
VALUE "FileVersion", "5.2.0.0"
27+
VALUE "FileVersion", "5.2.1.0"
2828
VALUE "InternalName", "QuickView"
2929
VALUE "OriginalFilename", "QuickView.exe"
3030
VALUE "ProductName", "QuickView"
31-
VALUE "ProductVersion", "5.2.0.0"
31+
VALUE "ProductVersion", "5.2.1.0"
3232
END
3333
END
3434
BLOCK "VarFileInfo"

0 commit comments

Comments
 (0)