Skip to content

Commit f0f6575

Browse files
committed
Доработка по переключению в полный экран и обратно - теперь включение/выключение HDR в системе и опции "Allow turn on/off (fullscreen)" работает и без эксклюзивного режима.
1 parent 23b9873 commit f0f6575

File tree

5 files changed

+49
-32
lines changed

5 files changed

+49
-32
lines changed

Source/DX11VideoProcessor.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,9 +1499,9 @@ bool CDX11VideoProcessor::HandleHDRToggle()
14991499

15001500
const bool bNeedToggleOn = !displayConfig.HDREnabled() &&
15011501
(m_iHdrToggleDisplay == HDRTD_On || m_iHdrToggleDisplay == HDRTD_OnOff
1502-
|| m_bExclusiveScreen && (m_iHdrToggleDisplay == HDRTD_On_Fullscreen || m_iHdrToggleDisplay == HDRTD_OnOff_Fullscreen));
1502+
|| m_bExclusiveScreen || m_bFullScreen && (m_iHdrToggleDisplay == HDRTD_On_Fullscreen || m_iHdrToggleDisplay == HDRTD_OnOff_Fullscreen));
15031503
const bool bNeedToggleOff = displayConfig.HDREnabled() &&
1504-
!bHDREnabled && !m_bExclusiveScreen && m_iHdrToggleDisplay == HDRTD_OnOff_Fullscreen;
1504+
!bHDREnabled && (!m_bExclusiveScreen || !m_bFullScreen) && m_iHdrToggleDisplay == HDRTD_OnOff_Fullscreen;
15051505
DLog(L"HandleHDRToggle() : {}, {}", bNeedToggleOn, bNeedToggleOff);
15061506
if (bNeedToggleOn) {
15071507
bRet = ToggleHDR(displayConfig, true);
@@ -4210,3 +4210,13 @@ void CDX11VideoProcessor::UpdateSubPic()
42104210
}
42114211
}
42124212
}
4213+
4214+
void CDX11VideoProcessor::SwitchFullScreen(bool set)
4215+
{
4216+
m_bFullScreen = set;
4217+
4218+
if (HandleHDRToggle()) {
4219+
InitMediaType(&m_pFilter->m_inputMT);
4220+
InitSwapChain(false);
4221+
}
4222+
}

Source/DX11VideoProcessor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class CDX11VideoProcessor
152152
CD3D11Polyline m_SyncLine;
153153

154154
bool m_bExclusiveScreen = false;
155+
bool m_bFullScreen = false;
155156

156157
int m_iVPSuperRes = SUPERRES_Disable;
157158
bool m_bVPUseSuperRes = false; // but it is not exactly
@@ -279,6 +280,8 @@ class CDX11VideoProcessor
279280

280281
ISubPicAllocator* GetSubPicAllocator() override;
281282

283+
void SwitchFullScreen(bool set) override;
284+
282285
private:
283286
void UpdateTexures();
284287
void UpdatePostScaleTexures();

Source/VideoProcessor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ class CVideoProcessor
228228

229229
virtual ISubPicAllocator* GetSubPicAllocator() { return nullptr; }
230230

231+
virtual void SwitchFullScreen(bool set) {};
232+
231233
protected:
232234
inline bool SourceIsPQorHLG() {
233235
return m_srcExFmt.VideoTransferFunction == MFVideoTransFunc_2084 || m_srcExFmt.VideoTransferFunction == MFVideoTransFunc_HLG;

Source/VideoRenderer.cpp

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -961,21 +961,6 @@ STDMETHODIMP CMpcVideoRenderer::GetPreferredAspectRatio(long *plAspectX, long *p
961961
return m_VideoProcessor->GetAspectRatio(plAspectX, plAspectY);
962962
}
963963

964-
void CMpcVideoRenderer::SwitchFullScreen()
965-
{
966-
DLog(L"CMpcVideoRenderer::SwitchFullScreen() : Switch to fullscreen");
967-
m_bExclusiveScreen = true;
968-
969-
if (m_hWnd) {
970-
Init(m_VideoProcessor->Type() == VP_DX9 ? false : true);
971-
Redraw();
972-
973-
if (m_hWndParentMain) {
974-
PostMessageW(m_hWndParentMain, WM_SWITCH_FULLSCREEN, 1, 0);
975-
}
976-
}
977-
}
978-
979964
static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
980965
{
981966
CMpcVideoRenderer* pThis = reinterpret_cast <CMpcVideoRenderer*>(GetWindowLongPtrW(hwnd, 0));
@@ -1122,25 +1107,43 @@ STDMETHODIMP CMpcVideoRenderer::SetWindowPosition(long Left, long Top, long Widt
11221107

11231108
CAutoLock cRendererLock(&m_RendererLock);
11241109

1125-
if (!m_bIsD3DFullscreen && (m_Sets.bExclusiveFS || m_bExclusiveScreen)) {
1126-
const HMONITOR hMon = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
1110+
if (!m_bIsD3DFullscreen) {
1111+
auto hMon = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
11271112
MONITORINFO mi = { mi.cbSize = sizeof(mi) };
11281113
::GetMonitorInfoW(hMon, &mi);
11291114
const CRect rcMonitor(mi.rcMonitor);
1115+
auto fullScreen = (m_windowRect.Width() == rcMonitor.Width() && m_windowRect.Height() == rcMonitor.Height());
1116+
if (m_Sets.bExclusiveFS || m_bExclusiveScreen) {
1117+
auto SwitchExclusiveScreen = [this] (bool set) {
1118+
DLog(L"CMpcVideoRenderer::SetWindowPosition() : Switch {} exclusive screen", set ? L"to" : L"from");
1119+
m_bExclusiveScreen = set;
1120+
1121+
if (m_hWnd) {
1122+
Init(m_VideoProcessor->Type() == VP_DX9 ? false : true);
1123+
Redraw();
1124+
1125+
if (m_hWndParentMain) {
1126+
PostMessageW(m_hWndParentMain, WM_SWITCH_FULLSCREEN, static_cast<WPARAM>(set), 0);
1127+
}
1128+
}
1129+
};
11301130

1131-
if (!m_bExclusiveScreen && m_windowRect.Width() == rcMonitor.Width() && m_windowRect.Height() == rcMonitor.Height()) {
1132-
SwitchFullScreen();
1133-
} else if (m_bExclusiveScreen && (m_windowRect.Width() != rcMonitor.Width() || m_windowRect.Height() != rcMonitor.Height())) {
1134-
DLog(L"CMpcVideoRenderer::SetWindowPosition() : Switch from fullscreen");
1135-
m_bExclusiveScreen = false;
1131+
if (!m_bExclusiveScreen && fullScreen) {
1132+
SwitchExclusiveScreen(true);
1133+
} else if (m_bExclusiveScreen && !fullScreen) {
1134+
SwitchExclusiveScreen(false);
1135+
}
1136+
} else {
1137+
if (!m_bFullScreen && fullScreen) {
1138+
DLog(L"Switch to FullScreen");
11361139

1137-
if (m_hWnd) {
1138-
Init(m_VideoProcessor->Type() == VP_DX9 ? false : true);
1139-
Redraw();
1140+
m_bFullScreen = true;
1141+
m_VideoProcessor->SwitchFullScreen(true);
1142+
} else if (m_bFullScreen && !fullScreen) {
1143+
DLog(L"Switch from FullScreen");
11401144

1141-
if (m_hWndParentMain) {
1142-
PostMessageW(m_hWndParentMain, WM_SWITCH_FULLSCREEN, 0, 0);
1143-
}
1145+
m_bFullScreen = false;
1146+
m_VideoProcessor->SwitchFullScreen(false);
11441147
}
11451148
}
11461149
}

Source/VideoRenderer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,9 @@ class __declspec(uuid("71F080AA-8661-4093-B15E-4F6903E77D0A"))
321321

322322
LRESULT OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
323323

324-
void SwitchFullScreen();
325-
326324
bool m_bExclusiveScreen = false;
327325
bool m_bIsD3DFullscreen = false;
326+
bool m_bFullScreen = false;
328327

329328
private:
330329
HRESULT Redraw();

0 commit comments

Comments
 (0)