/*
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 o=function(){function e(){this._fbo=null,this._size=[0,0],this._programDesc={"frei-chen":{vsPath:"post-processing/pp",fsPath:"post-processing/edge-detect/frei-chen",attributes:new Map([["a_position",0]])},sobel:{vsPath:"post-processing/pp",fsPath:"post-processing/edge-detect/sobel",attributes:new Map([["a_position",0]])},blit:{vsPath:"post-processing/pp",fsPath:"post-processing/blit",attributes:new Map([["a_position",0]])}}}var o=e.prototype;return o.dispose=function(){this._fbo&&(this._fbo.dispose(),this._fbo=null),this._quad&&(this._quad.dispose(),this._quad=null)},o.draw=function(e,i,o){this._createOrResizeResources(e);const{context:r,state:n,painter:a,pixelRatio:c}=e,{materialManager:u}=a,l=this._programDesc,{size:d}=n,h=[Math.round(c*d[0]),Math.round(c*d[1])],p=r.gl;this._quad||(this._quad=new t(r,[-1,-1,1,-1,-1,1,1,1]));const b="frei-chen",_=this._fbo,f=this._quad;f.bind();const g=u.getProgram(l[b]);r.useProgram(g),r.bindFramebuffer(_),r.setClearColor(0,0,0,0),r.clear(p.COLOR_BUFFER_BIT),r.bindTexture(i.colorTexture,4),g.setUniform1i("u_colorTexture",4),g.setUniform2fv("u_texSize",h),f.draw(),r.bindFramebuffer(i),r.setStencilWriteMask(0),r.setStencilTestEnabled(!1),r.setDepthWriteEnabled(!1),r.setDepthTestEnabled(!1),r.setBlendingEnabled(!0);const m=u.getProgram(l.blit);r.useProgram(m),r.bindTexture(_.colorTexture,6),m.setUniform1i("u_texture",6),r.setBlendFunction(s.BlendFactor.ONE,s.BlendFactor.ZERO),f.draw(),r.setBlendFunction(s.BlendFactor.ONE,s.BlendFactor.ONE_MINUS_SRC_ALPHA),f.unbind()},o._createOrResizeResources=function(e){const{context:t,state:o,pixelRatio:r}=e,{size:n}=o,a=Math.round(r*n[0]),c=Math.round(r*n[1]);this._fbo&&this._size[0]===a&&this._size[1]===c||(this._size[0]=a,this._size[1]=c,this._fbo?this._fbo.resize(a,c):this._fbo=new i.FramebufferObject(t,{colorTarget:s.TargetType.TEXTURE,depthStencilTarget:s.DepthStencilTargetType.NONE,width:a,height:c}))},e}();e.EdgeDetect=o,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
