@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.4 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{Pos2us as e}from"../2d/engine/webgl/DefaultVertexAttributeLayouts.js";import{BufferObject as r}from"./BufferObject.js";import{TextureWrapMode as t,TextureSamplingMode as o,Usage as n,FramebufferBit as s,PrimitiveType as i,PixelFormat as a,PixelType as p}from"./enums.js";import{FramebufferObject as m}from"./FramebufferObject.js";import{Texture as u}from"./Texture.js";import{TextureDescriptor as c}from"./TextureDescriptor.js";import{VertexArrayObject as d}from"./VertexArrayObject.js";import{WebGLDriverTestModule as g}from"./WebGLDriverTestModule.js";class f extends g{constructor(e){super(),this._rctx=e;const r="\n precision highp float;\n\n attribute vec2 a_pos;\n varying vec2 v_uv;\n\n void main() {\n v_uv = a_pos;\n gl_Position = vec4(a_pos * 2.0 - 1.0, 0.0, 1.0);\n }\n ",t="\n precision highp float;\n\n varying vec2 v_uv;\n\n uniform sampler2D u_texture;\n\n void main() {\n gl_FragColor = texture2D(u_texture, v_uv);\n }\n ";this._program=e.programCache.acquire(r,t,new Map([["a_pos",0]]))}dispose(){super.dispose()}_test(g){const f=this._rctx;if(!f.gl)return g.dispose(),!0;const l=new c(1);l.wrapMode=t.CLAMP_TO_EDGE,l.samplingMode=o.NEAREST;const _=new m(f,l),v=r.createVertex(f,n.STATIC_DRAW,new Uint16Array([0,0,1,0,0,1,1,1])),x=new d(f,new Map([["a_pos",0]]),e,new Map([["geometry",v]])),h=new c;h.samplingMode=o.LINEAR,h.wrapMode=t.CLAMP_TO_EDGE;const b=new u(f,h,w);f.useProgram(g),f.bindTexture(b,0),g.setUniform1i("u_texture",0);const A=f.getBoundFramebufferObject(),{x:E,y:T,width:j,height:C}=f.getViewport();f.bindFramebuffer(_),f.setViewport(0,0,1,1),f.setClearColor(0,0,0,0),f.setBlendingEnabled(!1),f.clear(s.COLOR),f.bindVAO(x),f.drawArrays(i.TRIANGLE_STRIP,0,4);const y=new Uint8Array(4);return _.readPixels(0,0,1,1,a.RGBA,p.UNSIGNED_BYTE,y),x.dispose(),_.dispose(),b.dispose(),f.setViewport(E,T,j,C),f.bindFramebuffer(A),255!==y[0]}}const w=new Image;w.src="data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='5' height='5' version='1.1' viewBox='0 0 5 5' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='5' height='5' fill='%23f00' fill-opacity='.5'/%3E%3C/svg%3E%0A",w.width=5,w.height=5,w.decode();export{f as SVGPremultipliedAlpha};