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