UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.18 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{BufferObject as e}from"./BufferObject.js";import{TextureWrapMode as r,PixelType as t,SizedPixelFormat as o,TextureSamplingMode as n,Usage as i,DataType as s,PrimitiveType as a}from"./enums.js";import{FramebufferObject as p}from"./FramebufferObject.js";import{makePipelineState as c,writeDestinationPremultipliedAlpha as m}from"./renderState.js";import{TextureDescriptor as l}from"./TextureDescriptor.js";import{VertexArrayObject as f}from"./VertexArrayObject.js";import{VertexElementDescriptor as u}from"./VertexElementDescriptor.js";import{WebGLDriverTestModule as g}from"./WebGLDriverTestModule.js";class b extends g{constructor(e){if(super(),this._rctx=e,!e.gl)return;if(!(e.capabilities.colorBufferFloat?.textureFloat&&e.capabilities.colorBufferFloat?.floatBlend))return;const r="\n precision highp float;\n attribute vec2 a_pos;\n\n void main() {\n gl_Position = vec4(a_pos * 2.0 - 1.0, 0.0, 1.0);\n }\n ",t="\n precision highp float;\n\n void main() {\n gl_FragColor = vec4(0.5, 0.5, 0.5, 0.5);\n }\n ";this._program=e.programCache.acquire(r,t,new Map([["a_pos",0]]))}_test(g){const b=this._rctx,d=new l(1);d.wrapMode=r.CLAMP_TO_EDGE,d.dataType=t.FLOAT,d.internalFormat=o.RGBA32F,d.samplingMode=n.NEAREST;const _=new p(b,d),w=e.createVertex(b,i.STATIC_DRAW,new Uint16Array([0,0,1,0,0,1,1,1])),A=new f(b,new Map([["a_pos",0]]),new Map([["geometry",[new u("a_pos",2,s.UNSIGNED_SHORT,0,4)]]]),new Map([["geometry",w]]));b.gl.getError(),b.useProgram(g);const T=b.getBoundFramebufferObject(),{x:j,y:x,width:E,height:h}=b.getViewport();b.bindFramebuffer(_),b.setViewport(0,0,1,1),b.bindVAO(A),b.drawArrays(a.TRIANGLE_STRIP,0,4);const F=c({blending:m});b.setPipelineState(F),b.drawArrays(a.TRIANGLE_STRIP,0,4);const O=b.gl.getError();return b.setViewport(j,x,E,h),b.bindFramebuffer(T),A.dispose(),_.dispose(),O!==b.gl.INVALID_OPERATION||(console.warn("Device claims support for WebGL extension EXT_float_blend but does not support it. Using fall back."),!1)}}export{b as FloatBufferBlend};