Fix DPI compensation path when no device context is available
このコミットが含まれているのは:
1 親
d28366f765
コミット
ad400fbd3b
5ファイル変更
+56
-3
検索条件に一致するファイルはありません
@@ -35,4 +35,25 @@ internal static unsafe class ICanvasDeviceExtensions
|
||||
|
||||
return hresult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ID2D1DeviceContext"/> from an input <see cref="ICanvasDevice"/>.
|
||||
/// </summary>
|
||||
/// <param name="canvasDevice">The input <see cref="ICanvasDevice"/> object.</param>
|
||||
/// <param name="d2D1DeviceContext">The resulting <see cref="ID2D1DeviceContext"/> object.</param>
|
||||
/// <returns>The <see cref="HRESULT"/> for the operation.</returns>
|
||||
public static HRESULT CreateD2DDeviceContext(this ref ICanvasDevice canvasDevice, ID2D1DeviceContext** d2D1DeviceContext)
|
||||
{
|
||||
using ComPtr<ID2D1Device1> d2D1Device1 = default;
|
||||
|
||||
// Get the underlying ID2D1Device1 object
|
||||
canvasDevice.GetD2DDevice(d2D1Device1.GetAddressOf()).Assert();
|
||||
|
||||
// Create the new device context
|
||||
HRESULT hresult = d2D1Device1.Get()->CreateDeviceContext(
|
||||
options: D2D1_DEVICE_CONTEXT_OPTIONS.D2D1_DEVICE_CONTEXT_OPTIONS_NONE,
|
||||
deviceContext: d2D1DeviceContext);
|
||||
|
||||
return hresult;
|
||||
}
|
||||
}
|
||||
@@ -280,14 +280,22 @@ unsafe partial class PixelShaderEffect<T>
|
||||
// Create an ID2D1Effect for the DPI compensation, if there isn't one already
|
||||
if (!sourceReference.HasDpiCompensationEffect)
|
||||
{
|
||||
// We need to create a DPI compensation effect, so a device context must be available
|
||||
using ComPtr<ID2D1DeviceContext> d2D1DeviceContextEffective = default;
|
||||
|
||||
// We need to create a DPI compensation effect, so a device context must be available.
|
||||
// If there is no input device context, just create a new one from the realization device.
|
||||
if (d2D1DeviceContext is null)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(E.E_POINTER);
|
||||
this.canvasDevice.Get()->CreateD2DDeviceContext(d2D1DeviceContextEffective.GetAddressOf()).Assert();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, just use the input device context
|
||||
*&d2D1DeviceContextEffective = new ComPtr<ID2D1DeviceContext>(d2D1DeviceContext);
|
||||
}
|
||||
|
||||
// Create the DPI compensation effect
|
||||
d2D1DeviceContext->CreateEffect(
|
||||
d2D1DeviceContextEffective.Get()->CreateEffect(
|
||||
effectId: (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in CLSID.CLSID_D2D1DpiCompensation)),
|
||||
effect: d2D1EffectDpiCompensation.GetAddressOf()).Assert();
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする