/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{BaseRasterProcessorTechnique as e}from"./BaseRasterProcessorTechnique.js";import{ReprojectShader as t}from"../../shaders/raster/processor/ReprojectShader.js";class r extends e{constructor(){super(...arguments),this.name="RasterReprojectProcessor",this.type=19,this.shaders={reproject:new t}}_process(e,t){const r=e.rasterFunction.parameters,o=this._getInterpolationDefines(t.interpolation,!!r.requireNNEdge),{config:i,projectionConfig:n,projectionDefines:s}=this._getReprojectConfig(t),a={shader:this.shaders.reproject,uniforms:{config:i,projectionConfig:n},defines:{...s,...o,applyPixelMask:!1,applyPixelHighlights:!1},optionalAttributes:null,useComputeBuffer:!1},{interpolation:c}=t;t.interpolation="nearest";const{painter:p,context:u}=e;p.submitDrawMesh(u,a,p.quadMesh),t.interpolation=c,t.projected=!0}_getReprojectConfig(e){const{source:t}=e,{names:r,textures:o}=e.getTextures({forProcessing:!0}),i={texture:{texture:o[r.indexOf("u_image")],unit:0},dvsMat3:new Float32Array([2,0,0,0,2,0,-1,-1,0]),coordScale:[1,1],srcImageSize:[t.width,t.height],opacity:1},n=o[r.indexOf("u_transformGrid")],{transformGrid:s}=e,a=!(!n||!s);return{config:i,projectionConfig:a?{transformTexture:{texture:n,unit:1},targetImageSize:[e.width,e.height],transformSpacing:s.spacing,transformGridSize:s.size}:void 0,projectionDefines:{applyProjection:a,lookupProjection:a&&1===s.spacing[0]}}}_getInterpolationDefines(e,t){const r="bilinear"===e&&t;return{bilinear:r,bicubic:"cubic"===e,nearestOnEdge:r}}}export{r as ReprojectTechnique};
