// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("exports ../../../core/has ../../../core/maybe ../../../core/libs/gl-matrix-2/math/vec2 ../../../core/libs/gl-matrix-2/factories/vec2f64 ../../../layers/support/layerUtils ./BlendLayersTechnique ./interfaces ./LayerClass ./NeighborIndex ./TerrainData ./terrainUtils ./TextureFader ./TextureReference ./TileCompositor ./TileRenderInfo ./TileTexture ./TileUpdate ../webgl-engine/core/shaderLibrary/output/BlendOptions ../webgl-engine/core/shaderLibrary/terrain/BlendLayersOutput ../webgl-engine/lib/glUtil3D ../../webgl/enums ../../webgl/Texture ../../webgl/TextureDescriptor".split(" "), function(K,ja,Q,R,S,z,aa,L,A,w,ba,q,T,M,ca,da,U,F,V,r,ea,D,N,fa){function O(a,b,c){g.layerIndex=b;g.vtlNeighborInfos.clear();const d=a.layerInfo[A.LayerClass.MAP][b];R.set(g.offset,0,0);g.tile=a;g.scale=1;g.sourceLod=a.lij;g.sourceLayerInfo=d;g.isVTLBackground=c;if(d.data)return c&&a.forEachLoadedNeighbor((n,t)=>{if(n.level===a.level){var u=n.layerInfo[A.LayerClass.MAP][b];if(q.isVectorTilePerLayerInfo(u)&&d.data!==u.data){var l=g.vtlNeighborInfos.pushNew();l.offset=v[t];l.sourceLod=n.lij;l.sourceLayerInfo= u}}}),g;const e=d.upsampleInfo;return e?(c=e.tile.layerInfo[A.LayerClass.MAP][b],g.tile=e.tile,R.copy(g.offset,e.offset),g.scale=e.scale,g.sourceLod=e.tile.lij,g.sourceLayerInfo=c,g):c?g:null}function ha(a){a=a.sourceLayerInfo.data;return a.source?"nearest"===a.interpolation:!1}function W(a){let b="normal"!==a.blendMode;z.isGroupLayer(a.parent)&&(b=W(a.parent)||b);return b}function X(a,b){z.isGroupLayer(a.parent)&&X(a.parent,b);const c=a.uid;if(null!=c&&""!==c){const d=G.get(c);d?d.start=b:G.set(c, new Y(b,b,a.blendMode,a.opacity,r.BlendLayersOutput.Composite,1))}}class Y{constructor(a,b,c,d,e,n){this.start=a;this.end=b;this.blendMode=c;this.opacity=d;this.output=e;this.baseOpacity=n}}class ia{constructor(a,b,c,d){this._rctx=a;this.tileSize=b;this._techniques=c;this._cache=d;this._passParameters=new aa.BlendLayersPassParameters;this._backgroundColor=this._backgroundTexture=null;this._backgroundDirty=!1;this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy;this._compositor=new ca.TileCompositor(this._rctx, this._techniques);this._ensureBackgroundTexture(this.tileSize)}dispose(){this._compositor=Q.disposeMaybe(this._compositor);this._backgroundTexture=Q.releaseMaybe(this._backgroundTexture)}get backgroundIsGrid(){return null==this._backgroundColor}get backgroundColor(){return this._backgroundColor}updateHeading(a){this._compositor?.updateHeading(a)}updateTileTexture(a,b){if(a.renderData){var c=a.surface,d=c.baseOpacity,e=0,n=0,t=this.tileSize,u=!1,l=!1,B=c.view.state.contentPixelRatio,p=!1;G.clear(); E.length=0;for(var x=a.layerInfo[A.LayerClass.MAP],k=0,C=null;k {J.start===f&&(J.output=d?r.BlendLayersOutput.Composite:t&&I?this.backgroundIsGrid?r.BlendLayersOutput.GridComposite:r.BlendLayersOutput.ColorComposite:r.BlendLayersOutput.Composite,J.baseOpacity=I?B:1,E.push(J),this._compositor.openGroup(e),P=!0)});var m=0===C;m=P?r.BlendLayersOutput.GroupBackgroundComposite:t&&m?this.backgroundIsGrid?r.BlendLayersOutput.GridComposite:r.BlendLayersOutput.ColorComposite:r.BlendLayersOutput.Composite;c=V.blendModeFromString[q.isBlendableLayerView(c)?c.layer.blendMode: "normal"];this._passParameters.baseOpacity=I&&!P&&1>B?B:1;this._passParameters.opacity=H;q.isVectorTileRenderInfo(h)?k=this._compositor.drawVectorData(this._passParameters,m,e,c,h,n,this.tileSize,k):q.isImageryTileRenderInfo(h)?(this._compositor.drawRasterData(this._passParameters,m,e,c,h),ha(h)&&(x=D.TextureSamplingMode.NEAREST)):this._dataToTexture(h)&&(this._passParameters.texture=h.sourceLayerInfo.data.texture,this._passParameters.offset=h.offset,this._passParameters.scale=h.scale,this._compositor.drawImageData(this._passParameters, m,e,c));for(;0B;l=a.ensureTexture(e,y,()=>this._buildTexture(e,y,x));this._compositor.copyFBOToTexture(l);this._compositor.unbind();a.setTextureReference(new M.TextureReference(l, b,Z,p?1:B,0,1))}_dataToTexture(a){if(q.isImageSourceRenderInfo(a)){const b=a.sourceLayerInfo;b.data=this._buildTexture(b.data,!0);a.tile.setMemoryDirty()}return q.isTextureTileRenderInfo(a)}setBackground(a){this._backgroundColor!==a&&(this._backgroundColor=a,this._backgroundDirty=!0)}_buildTexture(a,b,c=D.TextureSamplingMode.LINEAR_MIPMAP_LINEAR){if(null==a)return null;const d=new fa.TextureDescriptor;d.wrapMode=D.TextureWrapMode.CLAMP_TO_EDGE;d.samplingMode=c;d.maxAnisotropy=this._maxAnisotropy; d.preMultiplyAlpha=!0;d.flipped=!0;d.hasMipmap=!0;b||(d.pixelFormat=D.PixelFormat.RGB);b=this._rctx;let e;if("number"===typeof a)d.width=d.height=a,e=this._buildTileTexture(d,a);else if(ba.isImageWithType(a))d.isOpaque=a.isOpaque,d.isOpaque&&(d.pixelFormat=D.PixelFormat.RGB),e=this._buildTileTexture(d,a.element.width,a.element);else try{d.width=a.width,d.height=a.height,e=this._buildTileTexture(d,a.width,a)}catch(n){e=new U(ea.createEmptyTexture(b)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}a= b.bindTexture(e.texture,N.Texture.TEXTURE_UNIT_FOR_UPDATES);e.generateMipmap();b.bindTexture(a,N.Texture.TEXTURE_UNIT_FOR_UPDATES);return e}_buildTileTexture(a,b,c){b=this._cache.pop(`${b} ${a.pixelFormat}`);if(!b)return new U(new N.Texture(this._rctx,a,c),this._cache);b.retain();b.texture.setData(c);return b}get test(){}}const G=new Map,E=[],g=new da.TileRenderInfo,Z={offset:[0,0],scale:1},v=[];v[w.NeighborIndex.NORTH]=[0,-1];v[w.NeighborIndex.NORTH_EAST]=[-1,-1];v[w.NeighborIndex.EAST]=[-1,0];v[w.NeighborIndex.SOUTH_EAST]= [-1,1];v[w.NeighborIndex.SOUTH]=[0,1];v[w.NeighborIndex.SOUTH_WEST]=[1,1];v[w.NeighborIndex.WEST]=[1,0];v[w.NeighborIndex.NORTH_WEST]=[1,-1];K.GroupInfo=Y;K.TileRenderer=ia;Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})});