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