/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.25/esri/copyright.txt for details. */ import{Z as e}from"../../chunks/vec2f64.js";import{ContextType as t}from"./context-util.js";import{PixelType as n,TextureType as a,PixelFormat as r,SizedPixelFormat as i,TextureSamplingMode as o,TextureWrapMode as s,UniformType as u}from"./enums.js";import{Texture as f}from"./Texture.js";function m(e,u,m="nearest",c=!1){const l=!(c&&"u8"===u.pixelType),_=l?n.FLOAT:n.UNSIGNED_BYTE,p=null==u.pixels||0===u.pixels.length?null:l?u.getAsRGBAFloat():u.getAsRGBA(),g=e.capabilities.textureFloat?.textureFloatLinear,T={width:u.width,height:u.height,target:a.TEXTURE_2D,pixelFormat:r.RGBA,internalFormat:e.type===t.WEBGL2&&l?i.RGBA32F:r.RGBA,samplingMode:!g||"bilinear"!==m&&"cubic"!==m?o.NEAREST:o.LINEAR,dataType:_,wrapMode:s.CLAMP_TO_EDGE,flipped:!1};return new f(e,T,p)}function c(e,u){const{spacing:m,offsets:c,coefficients:l,size:[_,p]}=u,g=m[0]>1,T={width:g?4*_:_,height:p,target:a.TEXTURE_2D,pixelFormat:r.RGBA,internalFormat:e.type===t.WEBGL2?i.RGBA32F:r.RGBA,dataType:n.FLOAT,samplingMode:o.NEAREST,wrapMode:s.CLAMP_TO_EDGE,flipped:!1},E=new Float32Array(g?_*p*16:2*c.length);if(g)for(let t=0,n=0;t{const r=t.get(a)||t.get(a+"[0]");r&&d(e,a,n[a],r)}))}function O(e,t,n,a){n.length===a.length&&(a.some((e=>null==e))||n.some((e=>null==e))||n.forEach(((n,r)=>{t.setUniform1i(n,r),e.bindTexture(a[r],r)})))}function d(e,t,n,a){if(null===a||null==n)return!1;const{info:r}=a;switch(r.type){case u.FLOAT:r.size>1?e.setUniform1fv(t,n):e.setUniform1f(t,n);break;case u.FLOAT_VEC2:e.setUniform2fv(t,n);break;case u.FLOAT_VEC3:e.setUniform3fv(t,n);break;case u.FLOAT_VEC4:e.setUniform4fv(t,n);break;case u.FLOAT_MAT3:e.setUniformMatrix3fv(t,n);break;case u.FLOAT_MAT4:e.setUniformMatrix4fv(t,n);break;case u.INT:r.size>1?e.setUniform1iv(t,n):e.setUniform1i(t,n);break;case u.BOOL:e.setUniform1i(t,n?1:0);break;case u.INT_VEC2:case u.BOOL_VEC2:e.setUniform2iv(t,n);break;case u.INT_VEC3:case u.BOOL_VEC3:e.setUniform3iv(t,n);break;case u.INT_VEC4:case u.BOOL_VEC4:e.setUniform4iv(t,n);break;default:return!1}return!0}export{l as createColormapTexture,m as createRasterTexture,c as createTransformTexture,g as getBasicGridUniforms,p as getColormapUniforms,_ as getCommonUniforms,E as getShadedReliefUniforms,T as getStretchUniforms,A as getUniformLocationInfos,O as setTextures,h as setUniforms};