@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.08 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as e}from"../../../core/maybe.js";import{RenderCategory as h}from"../webgl.js";import{isManagedDepthTexture as o}from"./ManagedDepthTexture.js";import{ManagedFBOResource as r,AttachmentType as s}from"./ManagedFBOResource.js";import{ColorAttachment0 as i,DepthStencilAttachment as a}from"../../webgl/enums.js";class c extends r{constructor(t,e,o,r,i,a){super(t,a),this.fbo=o,this.type=s.FBO,this._colors=new Map,this._name=h.COMPOSITE,this.acquireColor=null,this.acquireDepth=null,this._name=e,this.acquireColor=r,this.acquireDepth=i}dispose(){this.fbo?.dispose()}get cachedMemory(){return this.fbo?.usedMemory||0}get numberOfColorAttachments(){return this._colors.size}get name(){return this._name}setName(t){this._name=t}getTexture(t=i){return t===a?this.fbo?.depthStencilTexture:this.fbo?.getColorTexture(t)}get depthTexture(){return this.getTexture(a)}getAttachment(t=i){return t===a?this._depth:this._colors.get(t)}hasAttachment(e){return t(this._colors,(t=>t.name===e))}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=e(this._depth)}obtainDepthTexture(){const t=this._depth;return o(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);const e=this._colors.get(t);this._colors.delete(t),e?.release()}detachAllColors(){this._colors.forEach(((t,e)=>this.detachColor(e)))}detachAll(){this.detachAllColors(),this.detachDepth()}detachAllColorsBut0(){this._colors.forEach(((t,e)=>{e!==i&&this.detachColor(e)}))}detachAllButColor0(){this.detachAllColorsBut0(),this.detachDepth()}}export{c as default};