using System;
using System.IO;
using ComputeSharp.SwapChain.Shaders;
#if WINDOWS_UWP
using ComputeSharp.Uwp;
#else
using ComputeSharp.WinUI;
#endif
using Windows.ApplicationModel;
#nullable enable
namespace ComputeSharp.SwapChain.Core.Shaders.Runners;
///
/// A specialized for .
///
public sealed class ContouredLayersRunner : IShaderRunner
{
///
/// A texture for \Textures\RustyMetal.png.
///
private ReadOnlyTexture2D? texture;
///
public bool TryExecute(IReadWriteNormalizedTexture2D texture, TimeSpan timespan, object? parameter)
{
if (this.texture is null ||
this.texture.GraphicsDevice != texture.GraphicsDevice)
{
string filename = Path.Combine(Package.Current.InstalledLocation.Path, "Assets", "Textures", "RustyMetal.png");
this.texture?.Dispose();
this.texture = texture.GraphicsDevice.LoadReadOnlyTexture2D(filename);
}
texture.GraphicsDevice.ForEach(texture, new ContouredLayers((float)timespan.TotalSeconds, this.texture));
return true;
}
}