/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../../../chunks/_rollupPluginBabelHelpers","../../../../../core/maybe","../../../../../chunks/vec4f32","../Utils","./WGLBrush","../shaders/BackgroundPrograms","../../../../webgl/enums","../../../../webgl/ProgramTemplate"],(function(e,t,r,o,i,n,s,a){"use strict";const c=()=>o.createProgramDescriptor("clip",{geometry:[{location:0,name:"a_pos",count:2,type:s.DataType.SHORT}]});let l=function(o){function i(){var e;return(e=o.apply(this,arguments)||this)._color=r.fromValues(0,1,0,1),e}e._inheritsLoose(i,o);var l=i.prototype;return l.dispose=function(){this._program&&this._program.dispose()},l.prepareState=function({context:e}){e.setStencilTestEnabled(!0),e.setBlendingEnabled(!1),e.setFaceCullingEnabled(!1),e.setColorMask(!1,!1,!1,!1),e.setStencilOp(s.StencilOperation.KEEP,s.StencilOperation.KEEP,s.StencilOperation.REPLACE),e.setStencilWriteMask(255),e.setStencilFunction(s.CompareFunction.ALWAYS,0,255)},l.draw=function(e,r){const{context:o,state:i,requestRender:l}=e,p=c(),u=r.getVAO(o,i,p.attributes,p.bufferLayouts);t.isNone(u.indexBuffer)||(this._program||(this._program=a.createProgram(o,n.background)),!t.isSome(l)||this._program.isCompiled?(o.useProgram(this._program),this._program.setUniform2fv("u_coord_range",[1,1]),this._program.setUniform4fv("u_color",this._color),this._program.setUniformMatrix3fv("u_dvsMat3",i.displayMat3),o.bindVAO(u),o.drawElements(s.PrimitiveType.TRIANGLES,u.indexBuffer.size,s.DataType.UNSIGNED_INT,0),o.bindVAO()):l())},i}(i);return l}));
