Added clamping for ResolutionScale property

このコミットが含まれているのは:
Sergio Pedri committed 2021-11-20 00:27:58 +01:00
1 親 eb3bd8638b
コミット 9f29f057d4
1ファイル変更
+3 -5
+3 -5
ファイルの表示
@@ -1,4 +1,4 @@
using Microsoft.Toolkit.Diagnostics;
using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
@@ -29,11 +29,11 @@ namespace ComputeSharp.WinUI
/// Gets or sets the resolution scale to be used to render frames.
/// This can help achieve higher framerates with more complex shaders.
/// </summary>
/// <remarks>The accepted range is [0.1 and 1] (default is 1).</remarks>
/// <remarks>The accepted range is [0.1 and 1] (default is 1, exceeding values will be clamped).</remarks>
public double ResolutionScale
{
get => (double)GetValue(ResolutionScaleProperty);
set => SetValue(ResolutionScaleProperty, value);
set => SetValue(ResolutionScaleProperty, Math.Clamp(value, 0.0, 1.0));
}
/// <summary>
@@ -51,8 +51,6 @@ namespace ComputeSharp.WinUI
var @this = (ComputeShaderPanel)d;
var resolutionScale = (double)e.NewValue;
Guard.IsBetweenOrEqualTo(resolutionScale, 0.1, 1.0, nameof(resolutionScale));
@this.resolutionScale = resolutionScale;
@this.OnResize();
}