Use primary constructors in remaining projects

このコミットが含まれているのは:
Sergio Pedri committed 2023-11-20 23:06:22 +01:00
1 親 46a6b25756
コミット 6897ecfcb2
14ファイル変更
+55 -174

検索条件に一致するファイルはありません

+5 -14
ファイルの表示
@@ -11,28 +11,19 @@ namespace SixLabors.ImageSharp;
/// <remarks>
/// This is a more efficient version of the <see cref="Complex64"/> type.
/// </remarks>
internal readonly struct Complex64
/// <param name="real">The real part in the complex number.</param>
/// <param name="imaginary">The imaginary part in the complex number.</param>
internal readonly struct Complex64(float real, float imaginary)
{
/// <summary>
/// The real part of the complex number.
/// </summary>
public readonly float Real;
public readonly float Real = real;
/// <summary>
/// The imaginary part of the complex number.
/// </summary>
public readonly float Imaginary;
/// <summary>
/// Initializes a new instance of the <see cref="Complex64"/> struct.
/// </summary>
/// <param name="real">The real part in the complex number.</param>
/// <param name="imaginary">The imaginary part in the complex number.</param>
public Complex64(float real, float imaginary)
{
this.Real = real;
this.Imaginary = imaginary;
}
public readonly float Imaginary = imaginary;
/// <summary>
/// Performs the multiplication operation between a <see cref="Complex64"/> instance and a <see cref="float"/> scalar.
+2
ファイルの表示
@@ -5,6 +5,8 @@ using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32;
#pragma warning disable IDE0290
namespace ComputeSharp.BokehBlur.Processors;
/// <summary>
+2
ファイルの表示
@@ -5,6 +5,8 @@ using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32;
#pragma warning disable IDE0290
namespace ComputeSharp.BokehBlur.Processors;
/// <summary>
+3 -16
ファイルの表示
@@ -56,7 +56,8 @@ internal abstract class PixelShaderEffect : CanvasEffect
/// An effect for an animated pixel shader.
/// </summary>
/// <typeparam name="T">The type of pixel shader to render.</typeparam>
public sealed class For<T> : PixelShaderEffect
/// <param name="factory">The input <typeparamref name="T"/> factory.</param>
public sealed class For<T>(For<T>.Factory factory) : PixelShaderEffect
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
{
/// <summary>
@@ -64,20 +65,6 @@ internal abstract class PixelShaderEffect : CanvasEffect
/// </summary>
private static readonly EffectNode<PixelShaderEffect<T>> Effect = new();
/// <summary>
/// The <typeparamref name="T"/> factory to use.
/// </summary>
private readonly Factory factory;
/// <summary>
/// Creates a new <see cref="For{T}"/> instance with the specified parameters.
/// </summary>
/// <param name="factory">The input <typeparamref name="T"/> factory.</param>
public For(Factory factory)
{
this.factory = factory;
}
/// <inheritdoc/>
protected override void BuildEffectGraph(EffectGraph effectGraph)
{
@@ -87,7 +74,7 @@ internal abstract class PixelShaderEffect : CanvasEffect
/// <inheritdoc/>
protected override void ConfigureEffectGraph(EffectGraph effectGraph)
{
effectGraph.GetNode(Effect).ConstantBuffer = this.factory(ElapsedTime, ScreenWidth, ScreenHeight);
effectGraph.GetNode(Effect).ConstantBuffer = factory(ElapsedTime, ScreenWidth, ScreenHeight);
}
/// <summary>
+3 -16
ファイルの表示
@@ -56,7 +56,8 @@ public abstract class PixelShaderEffect : CanvasEffect
/// An effect for an animated pixel shader.
/// </summary>
/// <typeparam name="T">The type of pixel shader to render.</typeparam>
public sealed class For<T> : PixelShaderEffect
/// <param name="factory">The input <typeparamref name="T"/> factory.</param>
public sealed class For<T>(For<T>.Factory factory) : PixelShaderEffect
where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor<T>
{
/// <summary>
@@ -64,20 +65,6 @@ public abstract class PixelShaderEffect : CanvasEffect
/// </summary>
private static readonly EffectNode<PixelShaderEffect<T>> Effect = new();
/// <summary>
/// The <typeparamref name="T"/> factory to use.
/// </summary>
private readonly Factory factory;
/// <summary>
/// Creates a new <see cref="For{T}"/> instance with the specified parameters.
/// </summary>
/// <param name="factory">The input <typeparamref name="T"/> factory.</param>
public For(Factory factory)
{
this.factory = factory;
}
/// <inheritdoc/>
protected override void BuildEffectGraph(EffectGraph effectGraph)
{
@@ -87,7 +74,7 @@ public abstract class PixelShaderEffect : CanvasEffect
/// <inheritdoc/>
protected override void ConfigureEffectGraph(EffectGraph effectGraph)
{
effectGraph.GetNode(Effect).ConstantBuffer = this.factory(ElapsedTime, ScreenWidth, ScreenHeight);
effectGraph.GetNode(Effect).ConstantBuffer = factory(ElapsedTime, ScreenWidth, ScreenHeight);
}
/// <summary>
+10 -17
ファイルの表示
@@ -7,35 +7,28 @@ namespace ComputeSharp.SwapChain.Core.ViewModels;
/// <summary>
/// A viewmodel for a compute shader.
/// </summary>
public sealed partial class ShaderRunnerViewModel : ObservableObject
/// <param name="shaderType">The name of the shader type to execute.</param>
/// <param name="shaderRunner">The <see cref="IShaderRunner"/> instance to execute.</param>
/// <param name="pixelShaderEffect">The <see cref="Shaders.PixelShaderEffect"/> instance to execute.</param>
public sealed partial class ShaderRunnerViewModel(
string shaderType,
IShaderRunner shaderRunner,
PixelShaderEffect pixelShaderEffect) : ObservableObject
{
/// <summary>
/// Creates a new <see cref="ShaderRunnerViewModel"/> instance.
/// </summary>
/// <param name="shaderType">The name of the shader type to execute.</param>
/// <param name="shaderRunner">The <see cref="IShaderRunner"/> instance to execute.</param>
/// <param name="pixelShaderEffect">The <see cref="Shaders.PixelShaderEffect"/> instance to execute.</param>
public ShaderRunnerViewModel(string shaderType, IShaderRunner shaderRunner, PixelShaderEffect pixelShaderEffect)
{
ShaderType = shaderType;
ShaderRunner = shaderRunner;
PixelShaderEffect = pixelShaderEffect;
}
/// <summary>
/// Gets the name of the shader type to execute.
/// </summary>
public string ShaderType { get; }
public string ShaderType => shaderType;
/// <summary>
/// Gets the <see cref="IShaderRunner"/> instance to execute.
/// </summary>
public IShaderRunner ShaderRunner { get; }
public IShaderRunner ShaderRunner => shaderRunner;
/// <summary>
/// Gets the <see cref="PixelShaderEffect"/> instance to execute.
/// </summary>
public PixelShaderEffect PixelShaderEffect { get; }
public PixelShaderEffect PixelShaderEffect => pixelShaderEffect;
/// <summary>
/// Gets or sets whether the current shader is selected.
+3 -16
ファイルの表示
@@ -8,13 +8,9 @@ namespace ComputeSharp.SwapChain.Backend;
/// <summary>
/// A class representing a simple Win32 application.
/// </summary>
internal sealed unsafe class Win32Application
/// <param name="shaderCallback">The function pointer used to run a shader on a target texture.</param>
internal sealed unsafe class Win32Application(delegate*<IReadWriteNormalizedTexture2D<float4>, TimeSpan, void> shaderCallback)
{
/// <summary>
/// The function pointer used to run a shader on a target texture.
/// </summary>
private readonly delegate*<IReadWriteNormalizedTexture2D<float4>, TimeSpan, void> shaderCallback;
/// <summary>
/// The <see cref="ID3D12Device"/> pointer for the device currently in use.
/// </summary>
@@ -75,15 +71,6 @@ internal sealed unsafe class Win32Application
/// </summary>
private volatile bool isResizePending;
/// <summary>
/// Creates a new <see cref="Win32Application"/> instance with the specified parameters.
/// </summary>
/// <param name="shaderCallback">The function pointer used to run a shader on a target texture.</param>
public Win32Application(delegate*<IReadWriteNormalizedTexture2D<float4>, TimeSpan, void> shaderCallback)
{
this.shaderCallback = shaderCallback;
}
/// <summary>
/// Initializes the current application.
/// </summary>
@@ -241,7 +228,7 @@ internal sealed unsafe class Win32Application
}
// Generate the new frame by invoking the callback
this.shaderCallback(this.texture!, time);
shaderCallback(this.texture!, time);
using ComPtr<ID3D12Resource> d3D12Resource = default;