Queue ClearCache

This commit is contained in:
L1Q 2017-11-17 18:15:20 +02:00
parent 8e671348ae
commit 87a0c958cf

View file

@ -35,7 +35,7 @@ public abstract class BaseEffectShape : BaseShape
public abstract string OverlayText { get; }
private bool isEffectCaching, cachePending;
private bool isEffectCaching, cachePending, cacheClearingPending;
private Image cachedEffect;
public abstract void ApplyEffect(Bitmap bmp);
@ -44,6 +44,11 @@ public override void OnUpdate()
{
base.OnUpdate();
if (cacheClearingPending)
{
ClearCache();
}
if (cachePending)
{
CacheEffect();
@ -166,10 +171,15 @@ private void CacheEffect()
private void ClearCache()
{
if (!isEffectCaching && cachedEffect != null)
if (isEffectCaching)
{
cacheClearingPending = true;
}
else if (cachedEffect != null)
{
cachedEffect.Dispose();
cachedEffect = null;
cacheClearingPending = false;
}
}