/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../core/mathUtils","../../../geometry/support/aaBoundingRect","./interfaces","../webgl-engine/lib/basicInterfaces","../webgl-engine/lib/LocalOriginFactory"],(function(e,t,r,i,a,s,n){"use strict";var o;e.OverlaySource=void 0,(o=e.OverlaySource||(e.OverlaySource={}))[o.None=0]="None",o[o.ColorAndWater=1]="ColorAndWater",o[o.Highlight=2]="Highlight",o[o.Occluded=3]="Occluded";let l=function(){function r(e,t){this.index=e,this.renderTargets=t,this._extent=i.create(),this.resolution=0,this.renderLocalOrigin=n.fromValues(0,0,0,"O"),this.pixelRatio=1,this.mapUnitsPerPixel=1,this.canvasGeometries=new g,this.validTargets=null,this.hasDrapedFeatureSource=!1,this.hasDrapedRasterSource=!1,this.hasTargetWithoutRasterImage=!1,this.index=e,this.validTargets=new Array(t.renderTargets.length).fill(!1)}var o=r.prototype;return o.getValidTexture=function(e){return this.validTargets[e]?this.renderTargets.getTarget(e).getTexture():null},o.getColorTexture=function(t){const r=t===e.OverlaySource.ColorAndWater?this.renderTargets.getTarget(a.RenderTargetType.Color):t===e.OverlaySource.Highlight?this.renderTargets.getTarget(a.RenderTargetType.Highlight):this.renderTargets.getTarget(a.RenderTargetType.Occluded);return r?r.getTexture():null},o.getColorTextureNoRasterImage=function(){return this._needsColorWithoutRasterImage?this.getValidTexture(a.RenderTargetType.ColorNoRasterImage):this.hasDrapedFeatureSource?this.getValidTexture(a.RenderTargetType.Color):null},o.getNormalTexture=function(t){const r=t===e.OverlaySource.ColorAndWater?this.renderTargets.getTarget(a.RenderTargetType.Water):null;return r?r.getTexture():null},o.draw=function(e,t){const r=this.computeRenderTargetValidityBitfield();for(const i of this.renderTargets.renderTargets)i.type!==a.RenderTargetType.ColorNoRasterImage||this._needsColorWithoutRasterImage?this.validTargets[i.type]=e.drawTarget(this,i,t):this.validTargets[i.type]=!1;return r^this.computeRenderTargetValidityBitfield()?s.ValidationState.CHANGED:s.ValidationState.UNCHANGED},o.computeRenderTargetValidityBitfield=function(){const e=this.validTargets;return+e[a.RenderTargetType.Color]|+e[a.RenderTargetType.ColorNoRasterImage]<<1|+e[a.RenderTargetType.Highlight]<<2|+e[a.RenderTargetType.Water]<<3|+e[a.RenderTargetType.Occluded]<<4},o.setupGeometryViewsCyclical=function(e){this.setupGeometryViewsDirect();const t=.001*e.range;if(this._extent[0]-t<=e.min){const t=this.canvasGeometries.extents[this.canvasGeometries.numViews++];i.offset(this._extent,e.range,0,t)}if(this._extent[2]+t>=e.max){const t=this.canvasGeometries.extents[this.canvasGeometries.numViews++];i.offset(this._extent,-e.range,0,t)}},o.setupGeometryViewsDirect=function(){this.canvasGeometries.numViews=1,i.copy(this.canvasGeometries.extents[0],this._extent)},o.hasSomeSizedView=function(){for(let e=0;e<this.canvasGeometries.numViews;e++){const t=this.canvasGeometries.extents[e];if(t[0]!==t[2]&&t[1]!==t[3])return!0}return!1},o.applyViewport=function(e){e.setViewport(this.index===a.OverlayIndex.INNER?0:this.resolution,0,this.resolution,this.resolution)},t._createClass(r,[{key:"extent",get:function(){return this._extent}},{key:"_needsColorWithoutRasterImage",get:function(){return this.hasDrapedRasterSource&&this.hasDrapedFeatureSource&&this.hasTargetWithoutRasterImage}}]),r}();function u(e,t,i){return Math.min(r.nextHighestPowerOfTwo(Math.max(e,t)+256),i)}let g=function(){this.extents=[i.create(),i.create(),i.create()],this.numViews=0};e.Overlay=l,e.computeOverlayResolution=u,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
