Switch away from OS version detection for DirectWrite things (#2065)
* If IDWriteTextFormat1 does not exist, return directly * We use DXGI_SCALING_NONE create SwapChain first, if failed switch to DXGI_SCALING_STRETCH Co-Authored-By: Michael Niksa <miniksa@microsoft.com> Co-Authored-By: Dustin L. Howett (MSFT) <duhowett@microsoft.com>
This commit is contained in:
parent
5da2ab1a86
commit
9d36b08b82
|
@ -25,10 +25,10 @@
|
||||||
"Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
|
"Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
|
||||||
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
|
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
|
||||||
"Microsoft.VisualStudio.Component.VC.Tools.ARM64",
|
"Microsoft.VisualStudio.Component.VC.Tools.ARM64",
|
||||||
"Microsoft.VisualStudio.Component.VC.v141.x86.x64",
|
"Microsoft.VisualStudio.Component.VC.v142.x86.x64",
|
||||||
"Microsoft.VisualStudio.Component.VC.v141.ARM64",
|
"Microsoft.VisualStudio.Component.VC.v142.ARM64",
|
||||||
"Microsoft.VisualStudio.ComponentGroup.UWP.VC",
|
"Microsoft.VisualStudio.ComponentGroup.UWP.VC",
|
||||||
"Microsoft.VisualStudio.ComponentGroup.UWP.VC.v141",
|
"Microsoft.VisualStudio.ComponentGroup.UWP.VC.v142",
|
||||||
"Microsoft.VisualStudio.Component.UWP.VC.ARM64"
|
"Microsoft.VisualStudio.Component.UWP.VC.ARM64"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,13 +133,8 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory1* const factory,
|
||||||
RETURN_IF_FAILED(_analyzer->AnalyzeBidi(this, 0, textLength, this));
|
RETURN_IF_FAILED(_analyzer->AnalyzeBidi(this, 0, textLength, this));
|
||||||
RETURN_IF_FAILED(_analyzer->AnalyzeScript(this, 0, textLength, this));
|
RETURN_IF_FAILED(_analyzer->AnalyzeScript(this, 0, textLength, this));
|
||||||
RETURN_IF_FAILED(_analyzer->AnalyzeNumberSubstitution(this, 0, textLength, this));
|
RETURN_IF_FAILED(_analyzer->AnalyzeNumberSubstitution(this, 0, textLength, this));
|
||||||
|
|
||||||
// Perform our custom font fallback analyzer that mimics the pattern of the real analyzers.
|
// Perform our custom font fallback analyzer that mimics the pattern of the real analyzers.
|
||||||
// Fallback routines are not available below Windows 8.1, so just skip them and let a replacement character happen.
|
RETURN_IF_FAILED(_AnalyzeFontFallback(this, 0, textLength));
|
||||||
if (IsWindows8Point1OrGreater())
|
|
||||||
{
|
|
||||||
RETURN_IF_FAILED(_AnalyzeFontFallback(this, 0, textLength));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure that a font face is attached to every run
|
// Ensure that a font face is attached to every run
|
||||||
for (auto& run : _runs)
|
for (auto& run : _runs)
|
||||||
|
@ -790,7 +785,11 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory1* const factory,
|
||||||
{
|
{
|
||||||
// Get the font fallback first
|
// Get the font fallback first
|
||||||
::Microsoft::WRL::ComPtr<IDWriteTextFormat1> format1;
|
::Microsoft::WRL::ComPtr<IDWriteTextFormat1> format1;
|
||||||
RETURN_IF_FAILED(_format.As(&format1));
|
if (FAILED(_format.As(&format1)))
|
||||||
|
{
|
||||||
|
// If IDWriteTextFormat1 does not exist, return directly as this OS version doesn't have font fallback.
|
||||||
|
return S_FALSE;
|
||||||
|
}
|
||||||
RETURN_HR_IF_NULL(E_NOINTERFACE, format1);
|
RETURN_HR_IF_NULL(E_NOINTERFACE, format1);
|
||||||
|
|
||||||
::Microsoft::WRL::ComPtr<IDWriteFontFallback> fallback;
|
::Microsoft::WRL::ComPtr<IDWriteFontFallback> fallback;
|
||||||
|
|
|
@ -192,16 +192,7 @@ DxEngine::~DxEngine()
|
||||||
SwapChainDesc.BufferCount = 2;
|
SwapChainDesc.BufferCount = 2;
|
||||||
SwapChainDesc.SampleDesc.Count = 1;
|
SwapChainDesc.SampleDesc.Count = 1;
|
||||||
SwapChainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
|
SwapChainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
|
||||||
|
SwapChainDesc.Scaling = DXGI_SCALING_NONE;
|
||||||
// DXGI_SCALING_NONE is only valid on Windows 8+
|
|
||||||
if (IsWindows8OrGreater())
|
|
||||||
{
|
|
||||||
SwapChainDesc.Scaling = DXGI_SCALING_NONE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SwapChainDesc.Scaling = DXGI_SCALING_STRETCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (_chainMode)
|
switch (_chainMode)
|
||||||
{
|
{
|
||||||
|
@ -216,13 +207,23 @@ DxEngine::~DxEngine()
|
||||||
|
|
||||||
// We can't do alpha for HWNDs. Set to ignore. It will fail otherwise.
|
// We can't do alpha for HWNDs. Set to ignore. It will fail otherwise.
|
||||||
SwapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
|
SwapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
|
||||||
|
const auto createSwapChainResult = _dxgiFactory2->CreateSwapChainForHwnd(_d3dDevice.Get(),
|
||||||
|
_hwndTarget,
|
||||||
|
&SwapChainDesc,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
&_dxgiSwapChain);
|
||||||
|
if (FAILED(createSwapChainResult))
|
||||||
|
{
|
||||||
|
SwapChainDesc.Scaling = DXGI_SCALING_STRETCH;
|
||||||
|
RETURN_IF_FAILED(_dxgiFactory2->CreateSwapChainForHwnd(_d3dDevice.Get(),
|
||||||
|
_hwndTarget,
|
||||||
|
&SwapChainDesc,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
&_dxgiSwapChain));
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_IF_FAILED(_dxgiFactory2->CreateSwapChainForHwnd(_d3dDevice.Get(),
|
|
||||||
_hwndTarget,
|
|
||||||
&SwapChainDesc,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
&_dxgiSwapChain));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SwapChainMode::ForComposition:
|
case SwapChainMode::ForComposition:
|
||||||
|
|
Loading…
Reference in a new issue