/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{ZEROS as e}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{SizedPixelFormat as t,PixelType as n}from"./enums.js";import a from"./Texture.js";import{TextureDescriptor as r}from"./TextureDescriptor.js";function u(e,u,i="nearest",o=!1){const s=!(o&&"u8"===u.pixelType),m=s?n.FLOAT:n.UNSIGNED_BYTE,l=null==u.pixels||0===u.pixels.length?null:s?u.getAsRGBAFloat():u.getAsRGBA(),c=e.capabilities.textureFloatLinear,f=new r(u.width,u.height);return f.internalFormat=s?t.RGBA32F:6408,f.samplingMode=!c||"bilinear"!==i&&"cubic"!==i?9728:9729,f.dataType=m,f.wrapMode=33071,new a(e,f,l)}function i(e,u){const{spacing:i,offsets:o,coefficients:s,size:[m,l]}=u,c=i[0]>1,f=new r(c?4*m:m,l);f.internalFormat=t.RGBA32F,f.dataType=n.FLOAT,f.samplingMode=9728,f.wrapMode=33071;const p=new Float32Array(c?m*l*16:2*o.length);if(c&&null!=s)for(let t=0,n=0;t<s.length;t++)p[n++]=s[t],t%3==2&&(p[n++]=1);else for(let t=0;t<l;t++)for(let e=0;e<m;e++){const n=4*(t*m+e),a=2*(e*l+t);p[n]=o[a],p[n+1]=o[a+1],p[n+3]=-1===o[a]?0:1}return new a(e,f,p)}function o(e,t){const n=new r(t.length/4,1);return n.internalFormat=6408,n.samplingMode=9728,n.wrapMode=33071,new a(e,n,t)}function s(e,t,u){const i=new r(u[0],u[1]);return i.internalFormat=6406,i.pixelFormat=6406,i.dataType=n.UNSIGNED_BYTE,i.samplingMode=9728,i.wrapMode=33071,new a(e,i,t)}function m(t,n,a,r=1,u=!0){return{u_flipY:u,u_applyTransform:!!t,u_opacity:r,u_transformSpacing:t?t.spacing:e,u_transformGridSize:t?t.size:e,u_targetImageSize:n,u_srcImageSize:a}}function l(e,t){return{u_colormapOffset:t||0,u_colormapMaxIndex:e?e.length/4-1:0}}function c(e){return{u_bandCount:e.bandCount,u_minOutput:e.minOutput,u_maxOutput:e.maxOutput,u_minCutOff:e.minCutOff,u_maxCutOff:e.maxCutOff,u_factor:e.factor,u_useGamma:e.useGamma,u_gamma:e.gamma,u_gammaCorrection:e.gammaCorrection}}function f(e){return{u_hillshadeType:e.hillshadeType,u_sinZcosAs:e.sinZcosAs,u_sinZsinAs:e.sinZsinAs,u_cosZs:e.cosZs,u_weights:e.weights,u_factor:e.factor,u_minValue:e.minValue,u_maxValue:e.maxValue}}export{o as createColormapTexture,s as createPixelMaskTexture,u as createRasterTexture,i as createTransformTexture,l as getColormapUniforms,m as getCommonUniforms,f as getShadedReliefUniforms,c as getStretchUniforms};
