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
#Create a new instance of the lazy texture cache.
protected LazyTextureCache()
Size
quickSize,
Resolution of low quality images.
Size
prettySize,
Resolution of high quality images.
padding,
Padding edges around computed slices.
comparer
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[]
#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.
Returns: Cached texture.
Methods
CreateTexture
#Implement this method to generate custom textures.
protected abstract Bitmap CreateTexture()
Size
size,
Size of texture.
padding,
Padding around texture.
TKey
key,
Texture key.
token
Cancellation token for process.
Returns: Texture. Dimensions must be size.Width+2*padding by size.Height+2*padding.
ProcessKey
#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.
protected virtual TKey ProcessKey()
TKey
key
Key to process.
Returns: Processed key.