/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{destroyMaybe as e}from"../../../../../../../core/maybe.js";import{fromValues as t}from"../../../../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{FeatureTile as s}from"../../../FeatureTile.js";import{Mesh as i}from"../../../meshing/Mesh.js";import{Technique as r}from"../Technique.js";import{TileDebugInfoShader as o,TileDebugInfoOutlineShader as n}from"../shaders/TileDebugInfoShader.js";import{TileDebugInfoTexture as h}from"./TileDebugInfoTexture.js";import{PrimitiveType as a,DataType as u}from"../../../../../../webgl/enums.js";import{VertexElementDescriptor as d}from"../../../../../../webgl/VertexElementDescriptor.js";class l extends r{constructor(){super(...arguments),this.type=34,this.drawPhase=64,this.shaders={outline:new n,tileInfo:new o},this._outlineMesh=null,this._color=t(1,0,0,1),this._texture=new h}render(e,t){if(!(this.drawPhase&e.drawPhase))return;const{context:i,painter:r}=e;if(!t.isReady&&t instanceof s&&t.hasData)return;const o=this._getOutlineMesh(i);r.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"composite"},depth:!1,stencil:!1});const n={shader:this.shaders.outline,uniforms:{config:{dvsMat3:t.transforms.displayViewScreenMat3,coordRange:[t.rangeX,t.rangeY],depth:0,color:this._color}},textures:void 0,defines:void 0,optionalAttributes:void 0,useComputeBuffer:!1};r.submitDrawMeshUntyped(i,n,o);const h=this._texture.getTexture(i,t);r.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"composite"},depth:!1,stencil:!1});const a={shader:this.shaders.tileInfo,uniforms:{config:{dvsMat3:t.transforms.displayViewScreenMat3,depth:0,coordRatio:[t.rangeX/t.width,t.rangeY/t.height],delta:[0,0],dimensions:[h.descriptor.width,h.descriptor.height]}},textures:{texture:{texture:h,unit:0}},defines:void 0,optionalAttributes:void 0,useComputeBuffer:!1};r.submitDrawMesh(i,a,r.quadMesh)}shutdown(){this._outlineMesh=e(this._outlineMesh),this._texture.shutdown()}_getOutlineMesh(e){return this._outlineMesh||(this._outlineMesh=new i(e,{vertex:{geometry:{data:new Int8Array([0,0,1,0,1,1,0,1]),layout:[new d("position",2,u.BYTE,0,2)]}},groups:[{primitive:a.LINE_LOOP}],parts:[{group:0,start:0,count:4}]})),this._outlineMesh}}export{l as TileDebugInfoTechnique};
