@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
89 lines • 2.52 kB
TypeScript
/**
* Adding and removing elements to atlas can be costly. It can trigger repack, it may require splatting or cleaning.
* This abstraction allows us to bypass that most of the time by caching unused patches and just reusing them in the future
* if they are requested again.
*
* The caching strategy here is a little unusual. The texture atlas has a certain size, and the cache will use as much of
* the atlas space as it can. Meaning that if there is not much unused space - the cache will be very small
* And if only a small part of the atlas is area is used by "live" patches, the cache can be quite large
*/
export class CachingTextureAtlas extends AbstractTextureAtlas {
/**
*
* @param {AbstractTextureAtlas} atlas
*/
constructor({ atlas }: AbstractTextureAtlas);
/**
*
* @type {PatchRecord[]}
* @private
*/
private __cached_patches;
/**
*
* @type {TextureAtlas}
* @private
*/
private __atals;
/**
* Finds an entry in the cache to evict
* @returns {number}
* @private
*/
private __find_eviction_target;
/**
* Finds an entry in the cache that could be replaced with an incoming element
* @private
* @returns {number}
* @param {number} width
* @param {number} height
*/
private __find_replacement_target;
/**
* Will evict specified element from cache
* @private
* @param {number} index
*/
private __evict;
/**
* Evict all cached elements, purging the cache
* @private
*/
private __evict_all;
/**
* Free up space in cache to accommodate certain area
* @private
* @param {number} width
* @param {number} height
* @returns {boolean} true if enough space was freed up to fit specified area, false otherwise
*/
private __evict_for;
/**
*
* @returns {AbstractTextureAtlas}
*/
get atlas(): AbstractTextureAtlas;
/**
*
* @return {Sampler2D}
*/
get sampler(): Sampler2D;
reset(): void;
/**
*
* @param {Sampler2D} sampler
* @returns {number}
* @private
*/
private __find_cache_record_index;
/**
*
* @param {AtlasPatch} patch
* @returns {number}
* @private
*/
private __find_cache_record_index_by_patch;
add(sampler: any, padding?: number): any;
}
import { AbstractTextureAtlas } from "./AbstractTextureAtlas.js";
//# sourceMappingURL=CachingTextureAtlas.d.ts.map