diff options
author | Anton Fedchin <anightik@gmail.com> | 2017-10-25 15:38:00 +0300 |
---|---|---|
committer | Anton Fedchin <anightik@gmail.com> | 2017-11-02 09:56:39 +0300 |
commit | 72626fb05d702778241f748ede99b0e92d0c6591 (patch) | |
tree | 3571d638b0d5336df7f308a5e25928efd1a9777a | |
parent | d335ff60f8785d35af52edf3c55ffb5aed155cb6 (diff) |
win32: fix rendering on displays with scaling > 100%
-rw-r--r-- | xbmc/rendering/dx/DeviceResources.cpp | 24 | ||||
-rw-r--r-- | xbmc/rendering/dx/DeviceResources.h | 18 | ||||
-rw-r--r-- | xbmc/rendering/dx/DirectXHelper.h | 6 | ||||
-rw-r--r-- | xbmc/rendering/dx/RenderSystemDX.cpp | 2 |
4 files changed, 28 insertions, 22 deletions
diff --git a/xbmc/rendering/dx/DeviceResources.cpp b/xbmc/rendering/dx/DeviceResources.cpp index e8c0aecf3d..74066f552f 100644 --- a/xbmc/rendering/dx/DeviceResources.cpp +++ b/xbmc/rendering/dx/DeviceResources.cpp @@ -40,24 +40,6 @@ using namespace concurrency; #define CHECK_ERR() if (FAILED(hr)) { LOG_HR(hr); breakOnDebug; return; } #define RETURN_ERR(ret) if (FAILED(hr)) { LOG_HR(hr); breakOnDebug; return (##ret); } -namespace DisplayMetrics -{ - // High resolution displays can require a lot of GPU and battery power to render. - // High resolution phones, for example, may suffer from poor battery life if - // games attempt to render at 60 frames per second at full fidelity. - // The decision to render at full fidelity across all platforms and form factors - // should be deliberate. - static const bool SupportHighResolutions = false; - - // The default thresholds that define a "high resolution" display. If the thresholds - // are exceeded and SupportHighResolutions is false, the dimensions will be scaled - // by 50%. - static const float Dpi100 = 96.0f; // 100% of standard desktop display. - static const float DpiThreshold = 192.0f; // 200% of standard desktop display. - static const float WidthThreshold = 1920.0f; // 1080p width. - static const float HeightThreshold = 1080.0f; // 1080p height. -}; - bool DX::DeviceResources::CBackBuffer::Acquire(ID3D11Texture2D* pTexture) { if (!pTexture) @@ -180,8 +162,8 @@ void DX::DeviceResources::SetViewPort(D3D11_VIEWPORT& viewPort) const { viewPort.TopLeftX, viewPort.TopLeftY, - ConvertDipsToPixels(viewPort.Width, m_dpi), - ConvertDipsToPixels(viewPort.Height, m_dpi), + viewPort.Width, + viewPort.Height, viewPort.MinDepth, viewPort.MinDepth }; @@ -514,7 +496,7 @@ void DX::DeviceResources::ResizeBuffers() swapChainDesc.BufferCount = 3 * (1 + bHWStereoEnabled); swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; swapChainDesc.Flags = 0; - swapChainDesc.Scaling = scaling; + swapChainDesc.Scaling = DXGI_SCALING_NONE; swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE; swapChainDesc.SampleDesc.Count = 1; swapChainDesc.SampleDesc.Quality = 0; diff --git a/xbmc/rendering/dx/DeviceResources.h b/xbmc/rendering/dx/DeviceResources.h index 1fdd1cbef1..0d6e993dfc 100644 --- a/xbmc/rendering/dx/DeviceResources.h +++ b/xbmc/rendering/dx/DeviceResources.h @@ -38,6 +38,24 @@ struct RESOLUTION_INFO; namespace DX { + namespace DisplayMetrics + { + // High resolution displays can require a lot of GPU and battery power to render. + // High resolution phones, for example, may suffer from poor battery life if + // games attempt to render at 60 frames per second at full fidelity. + // The decision to render at full fidelity across all platforms and form factors + // should be deliberate. + static const bool SupportHighResolutions = false; + + // The default thresholds that define a "high resolution" display. If the thresholds + // are exceeded and SupportHighResolutions is false, the dimensions will be scaled + // by 50%. + static const float Dpi100 = 96.0f; // 100% of standard desktop display. + static const float DpiThreshold = 192.0f; // 200% of standard desktop display. + static const float WidthThreshold = 1920.0f; // 1080p width. + static const float HeightThreshold = 1080.0f; // 1080p height. + }; + interface IDeviceNotify { virtual void OnDXDeviceLost() = 0; diff --git a/xbmc/rendering/dx/DirectXHelper.h b/xbmc/rendering/dx/DirectXHelper.h index 474cb8e05d..279cbaea16 100644 --- a/xbmc/rendering/dx/DirectXHelper.h +++ b/xbmc/rendering/dx/DirectXHelper.h @@ -48,6 +48,12 @@ namespace DX return floorf(dips * dpi / dipsPerInch + 0.5f); // Round to nearest integer. } + inline float ConvertPixelsToDips(float pixels, float dpi) + { + static const float dipsPerInch = 96.0f; + return floorf(pixels / (dpi / dipsPerInch) + 0.5f); // Round to nearest integer. + } + inline float RationalToFloat(DXGI_RATIONAL rational) { return RATIONAL_TO_FLOAT(rational); diff --git a/xbmc/rendering/dx/RenderSystemDX.cpp b/xbmc/rendering/dx/RenderSystemDX.cpp index 6893f3a0e2..38c7c77b28 100644 --- a/xbmc/rendering/dx/RenderSystemDX.cpp +++ b/xbmc/rendering/dx/RenderSystemDX.cpp @@ -109,7 +109,7 @@ void CRenderSystemDX::OnResize() if (!m_bRenderCreated) return; - auto outputSize = m_deviceResources->GetLogicalSize(); + auto outputSize = m_deviceResources->GetOutputSize(); // set camera to center of screen CPoint camPoint = { outputSize.Width * 0.5f, outputSize.Height * 0.5f }; |