UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 995 B
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{MemCachePool as t}from"../../../../core/MemCachePool.js";import s from"../../../../core/PooledArray.js";class i{constructor(i,e){this._last=new s,this._incarnation=0,this._cache=new t(i,e)}destroy(){this._last?.forAll((t=>t.dispose())),this._last=null,this._cache.destroy()}set interactive(t){t&&!this._last?this._last=new s:t||(this._last?.forAll((t=>t.dispose())),this._last=null)}clean(){this._last?.filterInPlace((t=>!(t.incarnation<this._incarnation)||(this._cache.put(t.key,t),!1)))}frame(){++this._incarnation}pop(t){if(this._last){const s=this._last.find((s=>s.key===t));if(s)return this._last.removeUnordered(s),s}return this._cache.pop(t)}put(t){t.incarnation=this._incarnation,this._last?this._last.push(t):this._cache.put(t.key,t)}get usedMemory(){return this._last?.reduce(((t,s)=>t+s.cachedMemory),0)??0}}export{i as FBOPool};