Files
Xune/UIX.RenderApi.Skia/Microsoft/Iris/Render/Graphics/EffectProperty.cs
T

143 lines
4.7 KiB
C#
Raw Normal View History

2021-07-11 22:59:29 -05:00
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Render.Graphics.EffectProperty
// Assembly: UIX.RenderApi, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: D47658B8-A8EA-43D6-8837-ECE823BFFFC1
// Assembly location: C:\Program Files\Zune\UIX.RenderApi.dll
using Microsoft.Iris.Render.Common;
using Microsoft.Iris.Render.Internal;
namespace Microsoft.Iris.Render.Graphics
{
2021-07-11 23:04:40 -05:00
internal class EffectProperty : RenderObject
2021-07-11 22:59:29 -05:00
{
2021-07-11 23:04:40 -05:00
private const byte k_dynamicFlag = 128;
private byte m_nID;
private object m_oValue;
private byte m_propertyType;
internal EffectProperty(
string stName,
EffectPropertyType eptType,
bool fIsDynamic,
object oValue,
byte nID)
{
this.m_propertyType = (byte)eptType;
this.IsDynamic = fIsDynamic;
this.m_nID = nID;
this.Value = oValue;
}
private EffectProperty(EffectProperty copy)
{
this.m_propertyType = copy.m_propertyType;
this.IsDynamic = copy.IsDynamic;
this.m_nID = copy.m_nID;
this.Value = copy.Value;
}
protected override void Dispose(bool fInDispose)
{
try
{
if (!fInDispose || this.m_oValue == null)
return;
this.ModifyUsage(false);
2021-07-11 23:07:04 -05:00
this.m_oValue = null;
2021-07-11 23:04:40 -05:00
}
finally
{
base.Dispose(fInDispose);
}
}
internal object Value
{
get => this.m_oValue;
set
{
this.ModifyUsage(false);
this.m_oValue = value;
this.ModifyUsage(true);
}
}
internal bool IsDynamic
{
2021-07-11 23:07:04 -05:00
get => (m_propertyType & 128) == 128;
2021-07-11 23:04:40 -05:00
set
{
if (value)
2021-07-11 23:07:04 -05:00
this.m_propertyType |= 128;
2021-07-11 23:04:40 -05:00
else
2021-07-11 23:07:04 -05:00
this.m_propertyType &= 127;
2021-07-11 23:04:40 -05:00
}
}
internal bool IsSharedResource => this.Type == EffectPropertyType.Image || this.Type == EffectPropertyType.ImageArray || this.Type == EffectPropertyType.Video;
2021-07-11 23:07:04 -05:00
internal EffectPropertyType Type => (EffectPropertyType)(m_propertyType & 4294967167U);
2021-07-11 23:04:40 -05:00
internal byte ID
{
get => this.m_nID;
set => this.m_nID = value;
}
internal bool HasIdenticalValue(object oValue)
{
switch (this.Type)
{
case EffectPropertyType.Integer:
return (int)this.Value == (int)oValue;
case EffectPropertyType.Float:
return !Math2.WithinEpsilon((float)this.Value, (float)oValue);
case EffectPropertyType.Vector2:
return (Vector2)this.Value == (Vector2)oValue;
case EffectPropertyType.Vector3:
return (Vector3)this.Value == (Vector3)oValue;
case EffectPropertyType.Vector4:
return (Vector4)this.Value == (Vector4)oValue;
case EffectPropertyType.Image:
return (Image)this.Value == (Image)oValue;
case EffectPropertyType.Color:
return (ColorF)this.Value == (ColorF)oValue;
case EffectPropertyType.ImageArray:
SharedResource[] resources1 = ((SharedResourceArray)oValue).Resources;
SharedResource[] resources2 = ((SharedResourceArray)this.Value).Resources;
if (resources1.Length != resources1.Length)
return false;
for (int index = 0; index < resources2.Length; ++index)
{
if (resources2[index] != resources1[index])
return false;
}
return true;
case EffectPropertyType.Video:
return (VideoStream)this.Value == (VideoStream)oValue;
default:
return false;
}
}
internal EffectProperty Clone() => new EffectProperty(this);
private void ModifyUsage(bool fLock)
{
if (this.m_oValue == null || !(this.m_oValue is SharedResource oValue))
return;
if (fLock)
{
2021-07-11 23:07:04 -05:00
oValue.RegisterUsage(this);
oValue.AddActiveUser(this);
2021-07-11 23:04:40 -05:00
}
else
{
2021-07-11 23:07:04 -05:00
oValue.RemoveActiveUser(this);
oValue.UnregisterUsage(this);
2021-07-11 23:04:40 -05:00
}
}
2021-07-11 22:59:29 -05:00
}
}