using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Runtime.CompilerServices;
using ComputeSharp.D2D1.Interop;
#if WINDOWS_UWP
using ComputeSharp.D2D1.Uwp.Buffers;
using ComputeSharp.D2D1.Uwp.Collections;
#else
using ComputeSharp.D2D1.WinUI.Buffers;
using ComputeSharp.D2D1.WinUI.Collections;
#endif
using Windows.Graphics.Effects;
#if WINDOWS_UWP
namespace ComputeSharp.D2D1.Uwp;
#else
namespace ComputeSharp.D2D1.WinUI;
#endif
///
partial class PixelShaderEffect
{
///
/// Represents the collection of sources in a instance.
///
public sealed class SourceCollection : IList, IReadOnlyList, IList, IFixedCountList
{
///
/// The collection of valid resource texture indices for the current effect.
///
private static readonly ImmutableArray Indices = GetIndices();
///
/// The fixed buffer of instances.
///
private GraphicsEffectSourceBuffer fixedBuffer;
///
/// Creates a new instance with the specified parameters.
///
/// The owning instance.
internal SourceCollection(PixelShaderEffect owner)
{
Owner = owner;
}
///
public int Count
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => D2D1PixelShader.GetInputCount();
}
///
public IGraphicsEffectSource? this[int index]
{
get
{
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, D2D1PixelShader.GetInputCount(), nameof(index));
return Owner.GetSource(index);
}
set
{
default(ArgumentOutOfRangeException).ThrowIfNotInRange(index, 0, D2D1PixelShader.GetInputCount(), nameof(index));
Owner.SetSource(value, index);
}
}
///
object? IList.this[int index]
{
get => this[index];
set => this[index] = (IGraphicsEffectSource?)value;
}
///
/// The owning instance.
///
internal PixelShaderEffect Owner { get; }
///
/// Gets a reference to the value containing the available -s.
///
internal ref GraphicsEffectSourceBuffer Storage => ref this.fixedBuffer;
///
ImmutableArray IFixedCountList.Indices => Indices;
///
bool ICollection.IsReadOnly => false;
///
bool IList.IsReadOnly => false;
///
bool IList.IsFixedSize => true;
///
bool ICollection.IsSynchronized => true;
///
object ICollection.SyncRoot => default(NotSupportedException).Throw