UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.29 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import"../../../../../core/has.js";import{BitBlitRenderer as e}from"../BitBlitRenderer.js";import{Effect as t}from"./Effect.js";import s from"./highlight/HighlightRenderer.js";import r from"./highlight/HighlightSurfaces.js";import{FramebufferBit as i,TextureSamplingMode as h}from"../../../../webgl/enums.js";const d=4,l=4/d;class o extends t{constructor(){super(...arguments),this.defines=["highlight"],this._hlRenderer=new s,this._width=void 0,this._height=void 0,this._boundFBO=null,this._hlSurfaces=new r,this._adjustedWidth=void 0,this._adjustedHeight=void 0,this._blitRenderer=new e}dispose(){this._hlSurfaces?.dispose(),this._hlRenderer?.dispose(),this._boundFBO=null}bind(e){const{context:t,painter:s}=e,{width:r,height:h}=t.getViewport(),d=s.getFbos().effect0;this.setup(e,r,h),t.bindFramebuffer(d),t.setColorMask(!0,!0,!0,!0),t.setClearColor(0,0,0,0),t.clear(i.COLOR)}unbind(){}setup({context:e},t,s){this._width=t,this._height=s;const r=t%d,i=s%d;t+=r<d/2?-r:d-r,s+=i<d/2?-i:d-i,this._adjustedWidth=t,this._adjustedHeight=s,this._boundFBO=e.getBoundFramebufferObject();const h=Math.round(t*l),o=Math.round(s*l);this._hlRenderer.setup(e,h,o),this._hlSurfaces.setup(e,h,o)}draw(e){const{context:t,passOptions:s}=e,r=s.activeGradient,d=t.getBoundFramebufferObject();t.setViewport(0,0,this._adjustedWidth*l,this._adjustedHeight*l),t.bindFramebuffer(this._hlSurfaces.sharedBlur1Fbo),t.setStencilTestEnabled(!1),t.setClearColor(0,0,0,0),t.clear(i.COLOR),this._blitRenderer.render(t,d.colorTexture,h.NEAREST,1),t.setStencilTestEnabled(!1),t.setBlendingEnabled(!1),t.setColorMask(!1,!1,!1,!0),t.bindFramebuffer(this._hlSurfaces.sharedBlur2Fbo),t.setClearColor(0,0,0,0),t.clear(i.COLOR),this._hlRenderer.preBlur(t,this._hlSurfaces.sharedBlur1Tex),t.bindFramebuffer(this._hlSurfaces.sharedBlur1Fbo),t.setClearColor(0,0,0,0),t.clear(i.COLOR),this._hlRenderer.finalBlur(t,this._hlSurfaces.sharedBlur2Tex),t.bindFramebuffer(this._boundFBO),t.setBlendingEnabled(!0),t.setColorMask(!0,!0,!0,!0),t.setViewport(0,0,this._width,this._height),this._hlRenderer.renderHighlight(t,this._hlSurfaces.sharedBlur1Tex,r),this._boundFBO=null}}export{o as default};