Enable proper D2D1 bokeh blur unit tests

このコミットが含まれているのは:
Sergio Pedri committed 2022-08-20 00:44:45 +02:00
1 親 bef0c333f7
コミット ff9fa35989
2ファイル変更
+24 -6

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

+3
ファイルの表示
@@ -50,6 +50,9 @@
<None Update="Assets\ZonePlate.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\ComputeSharp.Tests\Assets\CityWith1920x1280Resizing.png" Link="Assets\City.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
+21 -6
ファイルの表示
@@ -3,8 +3,11 @@ using System.Reflection;
using ComputeSharp.BokehBlur.Processors;
using ComputeSharp.D2D1.Tests.Effects;
using ComputeSharp.D2D1.Tests.Helpers;
using ComputeSharp.Tests.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
namespace ComputeSharp.D2D1.Tests;
@@ -53,15 +56,27 @@ public class EndToEndTests
}
[TestMethod]
public void BokehBlur()
[DataRow(8, 1, "Landscape")]
[DataRow(32, 3, "Landscape")]
[DataRow(80, 1, "City")]
[DataRow(80, 2, "City")]
public void BokehBlur(int radius, int numberOfComponents, string filename)
{
BokehBlurEffect bokehBlurEffect = new(32, 3);
string assetsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Assets");
string temporaryPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "temp");
string sourcePath = Path.Combine(assetsPath, Path.ChangeExtension(filename, "png"));
string destinationPathForCpu = Path.Combine(temporaryPath, Path.ChangeExtension($"{filename}_{radius}_{numberOfComponents}_cpu", "png"));
string destinationPathForGpu = Path.Combine(temporaryPath, Path.ChangeExtension($"{filename}_{radius}_{numberOfComponents}_gpu", "png"));
bokehBlurEffect.ApplyEffect(
Path.Combine(assetsPath, "Landscape.png"),
Path.Combine(temporaryPath, "Landscape_BokehBlur.png"));
_ = Directory.CreateDirectory(temporaryPath);
using Image<Rgba32> original = Image.Load<Rgba32>(sourcePath);
using Image<Rgba32> cpu = original.Clone(c => c.BokehBlur(radius, numberOfComponents, 3));
cpu.SaveAsPng(destinationPathForCpu);
new BokehBlurEffect(radius, numberOfComponents).ApplyEffect(sourcePath, destinationPathForGpu);
TolerantImageComparer.AssertEqual(destinationPathForCpu, destinationPathForGpu, 0.00002f);
}
}