/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{fromValues as e}from"../../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import r from"./WGLBrush.js";import{background as t}from"../shaders/BackgroundPrograms.js";import{PrimitiveType as i}from"../../../../webgl/enums.js";import{createProgram as s}from"../../../../webgl/ProgramTemplate.js";import{VertexArrayObject as o}from"../../../../webgl/VertexArrayObject.js";import{Pos2b as a}from"../../../../webgl/VertexAttributeLayouts.js";import{VertexBuffer as l}from"../../../../webgl/VertexBuffer.js";class n extends r{constructor(){super(...arguments),this._color=e(1,0,0,1),this._initialized=!1}dispose(){this._solidProgram&&(this._solidProgram.dispose(),this._solidProgram=null),this._solidVertexArrayObject&&(this._solidVertexArrayObject.dispose(),this._solidVertexArrayObject=null)}prepareState({context:e}){e.setDepthWriteEnabled(!1),e.setDepthTestEnabled(!1),e.setStencilTestEnabled(!0),e.setBlendingEnabled(!1),e.setColorMask(!1,!1,!1,!1),e.setStencilOp(7680,7680,7681),e.setStencilWriteMask(255)}draw(e,r){const{context:t,requestRender:s,allowDelayedRender:o}=e;this._initialized||this._initialize(t),!o||null==s||this._solidProgram.compiled?(t.setStencilFunctionSeparate(1032,516,r.stencilRef,255),t.bindVAO(this._solidVertexArrayObject),t.useProgram(this._solidProgram),this._solidProgram.setUniformMatrix3fv("u_dvsMat3",r.transforms.displayViewScreenMat3),this._solidProgram.setUniform2fv("u_coord_range",[r.rangeX,r.rangeY]),this._solidProgram.setUniform1f("u_depth",0),this._solidProgram.setUniform4fv("u_color",this._color),t.drawArrays(i.TRIANGLE_STRIP,0,4),t.bindVAO(null)):s()}_initialize(e){if(this._initialized)return!0;const r=new Int8Array([0,0,1,0,0,1,1,1]),i=new l(e,a,r),n=new o(e,i);return this._solidProgram=s(e,t,n.locations),this._solidVertexArrayObject=n,this._initialized=!0,!0}}export{n as default};
