LazyTextureCache<TKey>
ReferencesAbstract 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.
Type parameters:
| TKey | Lookup 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.
Parameters:
| 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. |
Fields
Properties
AutoCancelRendering
#Gets or sets whether high quality texture rendering will be cancelled automatically if a new texture is requested.
CacheLimit
#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.
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.
Parameters:
| key (TKey) | Key to retrieve. |
| access (TextureCacheAccess = TextureCacheAccess.QuickNowPrettyLater) | Cache access. |
Returns: Cached texture.
Methods
CreateTexture
#Implement this method to generate custom textures.
Parameters:
| size (Size) | Size of texture. |
| padding (int) | Padding around texture. |
| key (TKey) | Texture key. |
| token (CancellationToken) | Cancellation token for process. |
Returns: 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.
Parameters:
| key (TKey) | Key to process. |
Returns: Processed key.