From 9f29f057d43411a9bb34c8c711fe3c801a074070 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 2 May 2021 18:05:25 +0200 Subject: [PATCH] Added clamping for ResolutionScale property --- src/ComputeSharp.WinUI/ComputeShaderPanel.Properties.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ComputeSharp.WinUI/ComputeShaderPanel.Properties.cs b/src/ComputeSharp.WinUI/ComputeShaderPanel.Properties.cs index 4f924035..08b2d42b 100644 --- a/src/ComputeSharp.WinUI/ComputeShaderPanel.Properties.cs +++ b/src/ComputeSharp.WinUI/ComputeShaderPanel.Properties.cs @@ -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. /// - /// The accepted range is [0.1 and 1] (default is 1). + /// The accepted range is [0.1 and 1] (default is 1, exceeding values will be clamped). public double ResolutionScale { get => (double)GetValue(ResolutionScaleProperty); - set => SetValue(ResolutionScaleProperty, value); + set => SetValue(ResolutionScaleProperty, Math.Clamp(value, 0.0, 1.0)); } /// @@ -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(); }