/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../../../chunks/_rollupPluginBabelHelpers","../../../../../core/maybe","../definitions","../VertexStream","./WGLBrush","../../../../webgl/enums"],(function(e,t,i,n,r,a){"use strict";const s={nearest:{defines:[],samplingMode:a.TextureSamplingMode.NEAREST,mips:!1},bilinear:{defines:[],samplingMode:a.TextureSamplingMode.LINEAR,mips:!1},bicubic:{defines:["bicubic"],samplingMode:a.TextureSamplingMode.LINEAR,mips:!1},trilinear:{defines:[],samplingMode:a.TextureSamplingMode.LINEAR_MIPMAP_LINEAR,mips:!0}},o=(e,t,i)=>{if("dynamic"===i.samplingMode){const{state:i}=e,n=t.resolution/t.pixelRatio/i.resolution,r=Math.round(e.pixelRatio)!==e.pixelRatio,a=n>1.05||n<.95;return i.rotation||a||r||t.isSourceScaled||t.rotation?s.bilinear:s.nearest}return s[i.samplingMode]};let d=function(r){function s(){var e;return(e=r.apply(this,arguments)||this)._desc={vsPath:"raster/bitmap",fsPath:"raster/bitmap",attributes:new Map([["a_pos",0]])},e}e._inheritsLoose(s,r);var d=s.prototype;return d.dispose=function(){this._quad&&this._quad.dispose()},d.prepareState=function({context:e},t){e.setBlendingEnabled(!0),"additive"===t.blendFunction?e.setBlendFunctionSeparate(a.BlendFactor.ONE,a.BlendFactor.ONE,a.BlendFactor.ONE,a.BlendFactor.ONE):e.setBlendFunctionSeparate(a.BlendFactor.ONE,a.BlendFactor.ONE_MINUS_SRC_ALPHA,a.BlendFactor.ONE,a.BlendFactor.ONE_MINUS_SRC_ALPHA),e.setColorMask(!0,!0,!0,!0),e.setStencilWriteMask(0),e.setStencilTestEnabled(!0),e.setStencilFunction(a.CompareFunction.EQUAL,t.stencilRef,255)},d.draw=function(e,r){const{context:a,renderingOptions:s,painter:d,requestRender:l}=e;if(!r.source)return;const c=o(e,r,s),u=d.materialManager.getProgram(this._desc,c.defines);if(t.isSome(l)&&!u.isCompiled)return void l();e.timeline.begin(this.name),this._quad||(this._quad=new n(a,[0,0,1,0,0,1,1,1]));const{coordScale:p,computedOpacity:m,transforms:f}=r;r.setSamplingProfile(c),r.bind(e.context,i.TEXTURE_BINDING_BITMAP),a.useProgram(u),u.setUniformMatrix3fv("u_dvsMat3",f.dvs),u.setUniform1i("u_texture",i.TEXTURE_BINDING_BITMAP),u.setUniform2fv("u_coordScale",p),u.setUniform1f("u_opacity",m),this._quad.draw(),e.timeline.end(this.name)},s}(r);return d}));
