| 1 |
/* |
| 2 |
* Copyright (C) 2005-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "HDRStatus.h" |
| 12 |
#include "rendering/dx/RenderSystemDX.h" |
| 13 |
#include "windowing/windows/WinSystemWin32.h" |
| 14 |
|
| 15 |
struct D3D10DDIARG_CREATERESOURCE; |
| 16 |
|
| 17 |
class CWinSystemWin32DX : public CWinSystemWin32, public CRenderSystemDX |
| 18 |
{ |
| 19 |
friend interface DX::IDeviceNotify; |
| 20 |
public: |
| 21 |
CWinSystemWin32DX(); |
| 22 |
~CWinSystemWin32DX(); |
| 23 |
|
| 24 |
static void Register(); |
| 25 |
static std::unique_ptr<CWinSystemBase> CreateWinSystem(); |
| 26 |
|
| 27 |
// Implementation of CWinSystemBase via CWinSystemWin32 |
| 28 |
CRenderSystemBase *GetRenderSystem() override { return this; } |
| 29 |
bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override; |
| 30 |
bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) override; |
| 31 |
bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) override; |
| 32 |
void PresentRenderImpl(bool rendered) override; |
| 33 |
bool DPIChanged(WORD dpi, RECT windowRect) const override; |
| 34 |
void SetWindow(HWND hWnd) const; |
| 35 |
bool DestroyRenderSystem() override; |
| 36 |
void* GetHWContext() override { return m_deviceResources->GetD3DContext(); } |
| 37 |
|
| 38 |
void UninitHooks(); |
| 39 |
void InitHooks(IDXGIOutput* pOutput); |
| 40 |
|
| 41 |
void OnMove(int x, int y) override; |
| 42 |
void OnResize(int width, int height); |
| 43 |
|
| 44 |
/*! |
| 45 |
\brief Register as a dependent of the DirectX Render System |
| 46 |
Resources should call this on construction if they're dependent on the Render System |
| 47 |
for survival. Any resources that registers will get callbacks on loss and reset of |
| 48 |
device. In addition, callbacks for destruction and creation of the device are also called, |
| 49 |
where any resources dependent on the DirectX device should be destroyed and recreated. |
| 50 |
\sa Unregister, ID3DResource |
| 51 |
*/ |
| 52 |
void Register(ID3DResource *resource) const |
| 53 |
{ |
| 54 |
m_deviceResources->Register(resource); |
| 55 |
}; |
| 56 |
/*! |
| 57 |
\brief Unregister as a dependent of the DirectX Render System |
| 58 |
Resources should call this on destruction if they're a dependent on the Render System |
| 59 |
\sa Register, ID3DResource |
| 60 |
*/ |
| 61 |
void Unregister(ID3DResource *resource) const |
| 62 |
{ |
| 63 |
m_deviceResources->Unregister(resource); |
| 64 |
}; |
| 65 |
|
| 66 |
void Register(IDispResource* resource) override { CWinSystemWin32::Register(resource); } |
| 67 |
void Unregister(IDispResource* resource) override { CWinSystemWin32::Unregister(resource); } |
| 68 |
|
| 69 |
void FixRefreshRateIfNecessary(const D3D10DDIARG_CREATERESOURCE* pResource) const; |
| 70 |
|
| 71 |
// HDR OS/display override |
| 72 |
bool IsHDRDisplay() override; |
| 73 |
HDR_STATUS ToggleHDR() override; |
| 74 |
HDR_STATUS GetOSHDRStatus() override; |
| 75 |
|
| 76 |
// HDR support |
| 77 |
bool IsHDROutput() const; |
| 78 |
bool IsTransferPQ() const; |
| 79 |
void SetHdrMetaData(DXGI_HDR_METADATA_HDR10& hdr10) const; |
| 80 |
void SetHdrColorSpace(const DXGI_COLOR_SPACE_TYPE colorSpace) const; |
| 81 |
|
| 82 |
// Get debug info from swapchain |
| 83 |
DEBUG_INFO_RENDER GetDebugInfo() override; |
| 84 |
|
| 85 |
bool SupportsVideoSuperResolution() override; |
| 86 |
|
| 87 |
protected: |
| 88 |
void SetDeviceFullScreen(bool fullScreen, RESOLUTION_INFO& res) override; |
| 89 |
void ReleaseBackBuffer() override; |
| 90 |
void CreateBackBuffer() override; |
| 91 |
void ResizeDeviceBuffers() override; |
| 92 |
bool IsStereoEnabled() override; |
| 93 |
void OnScreenChange(HMONITOR monitor) override; |
| 94 |
bool ChangeResolution(const RESOLUTION_INFO& res, bool forceChange = false) override; |
| 95 |
|
| 96 |
HMODULE m_hDriverModule; |
| 97 |
}; |
| 98 |
|