/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{disposeMaybe as r}from"../../../../core/maybe.js";import{bitBlit as t}from"./shaders/BitBlitPrograms.js";import{PrimitiveType as e}from"../../../webgl/enums.js";import{createProgram as i}from"../../../webgl/ProgramTemplate.js";import{VertexArrayObject as s}from"../../../webgl/VertexArrayObject.js";import{PosTex2b as o}from"../../../webgl/VertexAttributeLayouts.js";import{VertexBuffer as a}from"../../../webgl/VertexBuffer.js";class n{constructor(){this._initialized=!1}dispose(){this._program=r(this._program),this._vertexArrayObject=r(this._vertexArrayObject)}render(r,t,i,s){r&&(this._initialized||this._initialize(r),r.setBlendFunctionSeparate(1,771,1,771),r.bindVAO(this._vertexArrayObject),r.useProgram(this._program),t.setSamplingMode(i),r.bindTexture(t,0),this._program.setUniform1i("u_tex",0),this._program.setUniform1f("u_opacity",s),r.drawArrays(e.TRIANGLE_STRIP,0,4),r.bindTexture(null,0),r.bindVAO(null))}_initialize(r){if(this._initialized)return!0;const e=new Int8Array(16);e[0]=-1,e[1]=-1,e[2]=0,e[3]=0,e[4]=1,e[5]=-1,e[6]=1,e[7]=0,e[8]=-1,e[9]=1,e[10]=0,e[11]=1,e[12]=1,e[13]=1,e[14]=1,e[15]=1;const n=new s(r,new a(r,o,e));return this._program=i(r,t,n.locations),this._vertexArrayObject=n,this._initialized=!0,!0}}export{n as BitBlitRenderer};
