4 changed files with 104 additions and 36 deletions
@ -0,0 +1,45 @@ |
|||
using System; |
|||
using Windows.Graphics.Effects; |
|||
using Windows.Graphics.Effects.Interop; |
|||
|
|||
|
|||
namespace Avalonia.Win32 |
|||
{ |
|||
abstract class EffectBase : IGraphicsEffect, IGraphicsEffectSource, global::Windows.Graphics.Effects.Interop.IGraphicsEffectD2D1Interop |
|||
{ |
|||
private IGraphicsEffectSource[] _sources; |
|||
|
|||
public EffectBase(params IGraphicsEffectSource[] sources) |
|||
{ |
|||
_sources = sources; |
|||
} |
|||
|
|||
private IGraphicsEffectSource _source; |
|||
|
|||
public virtual string Name { get; set; } |
|||
|
|||
public abstract Guid EffectId { get; } |
|||
|
|||
public abstract uint PropertyCount { get; } |
|||
|
|||
public uint SourceCount => (uint)_sources.Length; |
|||
|
|||
public IGraphicsEffectSource GetSource(uint index) |
|||
{ |
|||
if(index < _sources.Length) |
|||
{ |
|||
return _sources[index]; |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
public uint GetNamedPropertyMapping(string name, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public abstract object GetProperty(uint index); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,35 @@ |
|||
using System; |
|||
using Windows.Graphics.Effects; |
|||
|
|||
|
|||
namespace Avalonia.Win32 |
|||
{ |
|||
class SaturationEffect : EffectBase |
|||
{ |
|||
public SaturationEffect(IGraphicsEffect source) : base(source) |
|||
{ |
|||
} |
|||
|
|||
enum D2D1_SATURATION_PROP |
|||
{ |
|||
D2D1_SATURATION_PROP_SATURATION, |
|||
D2D1_SATURATION_PROP_FORCE_DWORD |
|||
}; |
|||
|
|||
public override Guid EffectId => D2DEffects.CLSID_D2D1Saturation; |
|||
|
|||
public override uint PropertyCount => 1; |
|||
|
|||
public override object GetProperty(uint index) |
|||
{ |
|||
switch ((D2D1_SATURATION_PROP)index) |
|||
{ |
|||
case D2D1_SATURATION_PROP.D2D1_SATURATION_PROP_SATURATION: |
|||
return 2.0f; |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue