LazyTextureCache<TKey>

References
public abstract class LazyTextureCache<TKey>
Abstract base class for multi-resolution lazy texture evaluations and caching. This cache is designed to generate a family of related textures that can be indexed by key, such as slices through colour spaces, or animation frames.
TKeyLookup key to use to identify specific textures. For colour spaces this is usually some sort of transformation or slice parameter, for animations it is usually the timestamp or frame index.

Constructors

LazyTextureCache

#
protected LazyTextureCache(Size quickSize, Size prettySize, int padding, IEqualityComparer<TKey> comparer)
Create a new instance of the lazy texture cache.
quickSize (Size)Resolution of low quality images.
prettySize (Size)Resolution of high quality images.
padding (int)Padding edges around computed slices.
comparer (IEqualityComparer<TKey>)Comparer.

LazyTextureCache

#
protected LazyTextureCache(Size quickSize, Size prettySize, int padding)
Create a new instance of the lazy texture cache.
quickSize (Size)Resolution for quick (low quality) images.
prettySize (Size)Resolution for pretty (high quality) images.
padding (int)Padding edges around computed images.

Fields

DefaultCacheLimit

#
public const int DefaultCacheLimit = 512
The global default cache limit.

Properties

AutoCancelRendering

#
public bool AutoCancelRendering { get; set; }
Gets or sets whether high quality texture rendering will be cancelled automatically if a new texture is requested.

CacheLimit

#
public int CacheLimit { get; set; }
Gets or sets the cache size limit. If the number of cached textures exceeds this limit the cache will be emptied entirely. Note that changes to the cache limit won't be taken into consideration until the next texture is scheduled for caching.

Count

#
public int Count { get; }
Gets the total number of cached textures. This includes textures of all quality levels.

Filter

#
public NamedPalette Filter { get; set; }
Gets or sets the rounding table to use when making textures.

Padding

#
public int Padding { get; }
Gets the padding (in pixels) for all textures.

PrettySize

#
public Size PrettySize { get; }
Gets the resolution for high quality, fine textures.

QuickSize

#
public Size QuickSize { get; }
Gets the resolution for low quality, coarse textures.

Indexers

this[]

#
public IMultiResolutionTexture this[TKey key, TextureCacheAccess access = TextureCacheAccess.QuickNowPrettyLater] { get; }
Gets the texture associated with the given key. If the requested texture hasn't been created yet, it will be rendered in low resolution in the caller thread and a high resolution rendering will commence in a background thread.
key (TKey)Key to retrieve.
access (TextureCacheAccess = TextureCacheAccess.QuickNowPrettyLater)Cache access.
Cached texture.

Methods

Clear

#
public void Clear()
Clear all cached textures.

CreateTexture

#
protected abstract Bitmap CreateTexture(Size size, int padding, TKey key, CancellationToken token)
Implement this method to generate custom textures.
size (Size)Size of texture.
padding (int)Padding around texture.
key (TKey)Texture key.
token (CancellationToken)Cancellation token for process.
Texture. Dimensions must be size.Width+2*padding by size.Height+2*padding.

ProcessKey

#
protected virtual TKey ProcessKey(TKey key)
Override this method if you wish to perform some operation to key values such as rounding or limiting. The base implementation returns the input key. A common operation would be rounding or clipping.
key (TKey)Key to process.
Processed key.