UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 2.34 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import t from"../../core/Error.js";import e from"../../core/Logger.js";import{hasValue as r}from"../../core/object.js";import{PixelType as n,SizedPixelFormat as o,SizedDepthStencilFormat as i,SizedDepthFormat as u,CompressedTextureFormat as a,sizedPixelFormatValues as l}from"./enums.js";const c=()=>e.getLogger("esri/views/webgl/textureUtils");function s(t){const{width:e,height:r,depth:n}=t;(null!=e&&e<0||null!=r&&r<0||null!=n&&n<0)&&c().error("Negative dimension parameters are not allowed!");const{internalFormat:o}=t;if(o&&(m(o)||p(o))){const{linearFilterDepth:e,compareEnabled:r,samplingMode:n,hasMipmap:o}=t;o&&c().error("Depth textures cannot have mipmaps"),e?9729!==n&&9728!==n&&c().error("Depth textures cannot sample mipmaps"):(9728!==n&&c().error("Depth textures without filtering must use NEAREST filtering"),r&&c().error("Depth textures without filtering cannot use compare function"))}}function h(t){return l.includes(t)}function m(t){return r(u,t)}function p(t){return r(i,t)}function f(t){return null!=t&&r(a,t)}function d(t){return null!=t&&"type"in t&&"compressed"===t.type}function g(t){return null!=t&&"byteLength"in t}function w(t){return null!=t&&!d(t)&&!g(t)}function x(t){return 32879===t||35866===t}function F(t,e,r,n=1){let o=Math.max(e,r);return 32879===t&&(o=Math.max(o,n)),Math.floor(Math.log2(o))+1}function E(e){if(null!=e.internalFormat)return e.internalFormat;switch(e.dataType){case n.FLOAT:switch(e.pixelFormat){case 6408:return o.RGBA32F;case 6407:return o.RGB32F;default:throw new t("texture:unknown-format","Unable to derive format")}case n.UNSIGNED_BYTE:switch(e.pixelFormat){case 6408:return o.RGBA8;case 6407:return o.RGB8}}const{pixelFormat:r}=e;return e.internalFormat=34041===r?i.DEPTH24_STENCIL8:6402===r?u.DEPTH_COMPONENT24:r,e.internalFormat}function T(t){let e="width"in t?t.width:t.codedWidth,r="height"in t?t.height:t.codedHeight;const n=1;return t instanceof HTMLVideoElement&&(e=t.videoWidth,r=t.videoHeight),{width:e,height:r,depth:n}}export{F as calcMipmapLevels,E as deriveInternalFormat,T as getDimensions,x as is3DTarget,g as isArrayBufferView,d as isCompressedData,f as isCompressedFormat,m as isSizedDepthFormat,p as isSizedDepthStencilFormat,h as isSizedPixelFormat,w as isTexImageSource,s as validateTexture};