/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{simplePipelineState as e}from"../../utils.js";import{Technique as t}from"../Technique.js";import{VTLShaderCircle as s}from"../shaders/vector-tiles/VTLShaderCircle.js";class l extends t{constructor(){super(...arguments),this.type=36,this._mesh=null,this.shaders={circle:new s}}shutdown(){this._mesh&&(this._mesh.destroy(),this._mesh=null)}render(t,s){const{context:l,displayLevel:i,painter:r,requiredLevel:n,spriteMosaic:a,state:o,styleLayer:c,styleLayerUID:u}=t,{tiles:h}=s;if(!h.some(e=>e.layerData.get(u)?.circleIndexCount??!1))return;const d=c,{circleMaterial:f}=d,m=1.2,p=d.getPaintValue("circle-translate",i),y={transform:{dvsMat:null,displayMat:1===d.getPaintValue("circle-translate-anchor",i)?o.displayMat3:o.displayViewMat3},styleLayerConfig:{circleTranslation:p,depth:d.z,antialiasingWidth:m},radius:null,radiusMix:null,blur:null,blurMix:null,opacity:null,opacityMix:null,strokeOpacity:null,strokeOpacityMix:null,strokeWidth:null,strokeWidthMix:null,color:null,colorMix:null,strokeColor:null,strokeColorMix:null};let M=-1;for(const x of h){if(!x.layerData.has(u))continue;if(y.transform.dvsMat=x.transforms.displayViewScreenMat3,x.key.level!==M){M=x.key.level;const e=f.getUniforms();for(const t of e){const e=t.getValue(d,i,M,a);t.name in y&&(y[t.name]={value:e})}}const t=x.layerData.get(u);if(!t.circleIndexCount)continue;if(this._mesh=t.getMesh(l),!this._mesh)continue;const s=n!==x.key.level?514:516,o=n!==x.key.level?x.stencilRef:255;r.setPipelineState({...e,stencil:{write:!1,test:{compare:s,op:{fail:7680,zFail:7680,zPass:7681},mask:255}}}),r.setStencilRef(l,o);const c={shader:this.shaders.circle,uniforms:y,defines:null,optionalAttributes:f.getUsedAttributes(),useComputeBuffer:!1,precisionFactors:f.getPrecisionFactors()};r.submitDrawMeshUntyped(l,c,this._mesh,{stencilRef:x.stencilRef}),x.triangleCount+=t.circleIndexCount/3}}}export{l as VTLTechniqueCircle};
