/*
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","../DefaultVertexAttributeLayouts","./WGLBrush","../shaders/BackgroundPrograms","../../../../webgl/BufferObject","../../../../webgl/enums","../../../../webgl/ProgramTemplate","../../../../webgl/VertexArrayObject"],(function(e,t,r,i,s,o,n,a,l,c){"use strict";let d=function(s){function d(){var e;return(e=s.apply(this,arguments)||this)._color=r.fromValues(1,0,0,1),e._initialized=!1,e}e._inheritsLoose(d,s);var u=d.prototype;return u.dispose=function(){this._solidProgram&&(this._solidProgram.dispose(),this._solidProgram=null),this._solidVertexArrayObject&&(this._solidVertexArrayObject.dispose(),this._solidVertexArrayObject=null)},u.prepareState=function({context:e},t){e.setDepthWriteEnabled(!1),e.setDepthTestEnabled(!1),e.setStencilTestEnabled(!0),e.setBlendingEnabled(!1),e.setColorMask(!1,!1,!1,!1),e.setStencilOp(a.StencilOperation.KEEP,a.StencilOperation.KEEP,a.StencilOperation.REPLACE),e.setStencilWriteMask(255),e.setStencilFunctionSeparate(a.Face.FRONT_AND_BACK,a.CompareFunction.GREATER,t.stencilRef,255)},u.draw=function(e,r){const{context:i,requestRender:s}=e;this._initialized||this._initialize(i),!t.isSome(s)||this._solidProgram.isCompiled?(i.bindVAO(this._solidVertexArrayObject),i.useProgram(this._solidProgram),this._solidProgram.setUniformMatrix3fv("u_dvsMat3",r.transforms.dvs),this._solidProgram.setUniform2fv("u_coord_range",[r.rangeX,r.rangeY]),this._solidProgram.setUniform1f("u_depth",0),this._solidProgram.setUniform4fv("u_color",this._color),i.drawArrays(a.PrimitiveType.TRIANGLE_STRIP,0,4),i.bindVAO()):s()},u._initialize=function(e){if(this._initialized)return!0;const t=l.createProgram(e,o.background);if(!t)return!1;const r=new Int8Array([0,0,1,0,0,1,1,1]),s=n.BufferObject.createVertex(e,a.Usage.STATIC_DRAW,r),d=new c.VertexArrayObject(e,o.background.attributes,i.Pos2b,{geometry:s});return this._solidProgram=t,this._solidVertexArrayObject=d,this._initialized=!0,!0},d}(s);return d}));
