/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as t}from"tslib";import{someMap as e}from"../../../core/MapUtils.js";import{releaseMaybe as o}from"../../../core/maybe.js";import{subclass as s}from"../../../core/accessorSupport/decorators.js";import{RenderNodeOutput as r}from"../webgl.js";import{isManagedDepthTexture as h}from"./ManagedDepthTexture.js";import i from"./ManagedFBOResource.js";import{ColorAttachment0 as a,DepthStencilAttachment as c}from"../../webgl/enums.js";let l=class extends i{constructor(t,e,o,s,h,i){super(t,i),this.fbo=o,this.type=0,this._colors=new Map,this._name=r.COMPOSITE,this.acquireColor=null,this.acquireDepth=null,this._name=e,this.acquireColor=s,this.acquireDepth=h}dispose(){this.fbo?.dispose()}get usedMemory(){return this.fbo?.usedMemory||0}get name(){return this._name}setName(t){this._name=t}getTexture(t=a){return t===c?this.fbo?.depthStencilTexture:this.fbo?.getColorTexture(t)}get depthTexture(){return this.getTexture(c)}getAttachment(t=a){return t===c?this._depth:this._colors.get(t)}obtainAttachment(t){const e=this.getAttachment(t);return e?.retain(),this.detachColor(t),e}hasAttachment(t){return e(this._colors,e=>e.name===t)}attachDepth(t){return t?.retain(),this.detachDepth(),t&&this.fbo?.attachDepthStencil(t.attachment),this._depth=t,this}detachDepth(){this.fbo?.detachDepthStencilTexture(),this.fbo?.detachDepthStencilBuffer(),this._depth=o(this._depth)}obtainDepthTexture(){const t=this._depth;return h(t)?(this.fbo?.detachDepthStencilTexture(),this._depth=null,t):null}attachColor(t,e){return t.retain(),this.detachColor(e),this.fbo?.attachColorTexture(t.attachment,e),this._colors.set(e,t),this}detachColor(t){this.fbo?.detachColorTexture(t),this._colors.get(t)?.release(),this._colors.delete(t)}detachAllColors(){const t=Array.from(this._colors.keys());this._detachColors(t)}detachAll(){this.detachAllColors(),this.detachDepth()}detachAllColorsBut0(){const t=Array.from(this._colors.keys());t.shift(),this._detachColors(t)}_detachColors(t){this.fbo.detachColorTextures(...t),t.forEach(t=>{this._colors.get(t)?.release(),this._colors.delete(t)})}detachAllButColor0(){this.detachAllColorsBut0(),this.detachDepth()}};l=t([s("esri.views.3d.webgl.ManagedFBO")],l);const n=l;export{n as default};
