/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../VertexStream","../../../../../webgl/enums","../../../../../webgl/FramebufferObject"],(function(e,t,s,i){"use strict";let r=function(){function e(){this._fbo=null,this._size=[0,0],this._programDesc={"edge-enhance":{vsPath:"post-processing/pp",fsPath:"post-processing/edge-enhance",attributes:new Map([["a_position",0]])},blit:{vsPath:"post-processing/pp",fsPath:"post-processing/blit",attributes:new Map([["a_position",0]])}}}var r=e.prototype;return r.dispose=function(){this._fbo&&(this._fbo.dispose(),this._fbo=null),this._quad&&(this._quad.dispose(),this._quad=null)},r.draw=function(e,i,r){this._createOrResizeResources(e);const{context:n,state:o,painter:a,pixelRatio:u}=e,{materialManager:c}=a,h=this._programDesc,d=o.size,l=[Math.round(u*d[0]),Math.round(u*d[1])],_=n.gl;this._quad||(this._quad=new t(n,[-1,-1,1,-1,-1,1,1,1]));const b=this._fbo,p=this._quad;p.bind();const f=c.getProgram(h["edge-enhance"]);n.useProgram(f),n.bindFramebuffer(b),n.setClearColor(0,0,0,0),n.clear(_.COLOR_BUFFER_BIT),n.bindTexture(i.colorTexture,4),f.setUniform1i("u_colorTexture",4),f.setUniform2fv("u_texSize",l),p.draw(),n.bindFramebuffer(i),n.setStencilWriteMask(0),n.setStencilTestEnabled(!1),n.setDepthWriteEnabled(!1),n.setDepthTestEnabled(!1),n.setBlendingEnabled(!0);const g=c.getProgram(h.blit);n.useProgram(g),n.bindTexture(b.colorTexture,6),g.setUniform1i("u_texture",6),n.setBlendFunction(s.BlendFactor.ONE,s.BlendFactor.ONE_MINUS_SRC_ALPHA),p.draw(),p.unbind()},r._createOrResizeResources=function(e){const{context:t,state:r,pixelRatio:n}=e,{size:o}=r,a=Math.round(n*o[0]),u=Math.round(n*o[1]);this._fbo&&this._size[0]===a&&this._size[1]===u||(this._size[0]=a,this._size[1]=u,this._fbo?this._fbo.resize(a,u):this._fbo=new i.FramebufferObject(t,{colorTarget:s.TargetType.TEXTURE,depthStencilTarget:s.DepthStencilTargetType.NONE,width:a,height:u}))},e}();e.EdgeEnhance=r,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
