/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{disposeMaybe as e}from"../../../../../../../core/maybe.js";import{Technique as t}from"../Technique.js";import{OpacityShader as r}from"../shaders/OpacityShader.js";import s from"../../../../../../webgl/Texture.js";import{TextureDescriptor as i}from"../../../../../../webgl/TextureDescriptor.js";class o extends t{constructor(){super(...arguments),this.type=24,this._layerFBOTexture=null,this._size=[0,0],this.shaders={opacity:new r}}shutdown(){super.shutdown(),this._layerFBOTexture=e(this._layerFBOTexture)}render(e,t){const{layerFBO:r}=t,{width:s,height:i}=r;this._createOrResizeResources(e,s,i);const{context:o,painter:a}=e,{amount:l}=t.effect,n=this._layerFBOTexture;o.bindFramebuffer(r),t.layerFBO.copyToTexture(0,0,s,i,0,0,n);const u={color:{write:[!0,!0,!0,!0],blendMode:"custom",blendParameters:{srcRGB:1,dstRGB:771,srcAlpha:1,dstAlpha:771}},depth:!1,stencil:!1},h={layerTexture:{texture:n,unit:0},opacity:l};n.setSamplingMode(9728),o.setClearColor(0,0,0,0),o.clear(16384),a.setPipelineState(u),a.submitDrawMesh(o,{shader:this.shaders.opacity,uniforms:{config:h},defines:null,optionalAttributes:null,useComputeBuffer:!1},a.quadMesh)}_createOrResizeResources(e,t,r){const{context:o}=e;if(!this._layerFBOTexture||this._size[0]!==t||this._size[1]!==r)if(this._size[0]=t,this._size[1]=r,this._layerFBOTexture)this._layerFBOTexture.resize(t,r);else{const e=new i(t,r);e.internalFormat=6408,e.wrapMode=33071,e.samplingMode=9728,this._layerFBOTexture=new s(o,e)}}}export{o as OpacityTechnique};
