WebGLFilterBackend
Defined in: src/filters/WebGLFilterBackend.ts:11
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new WebGLFilterBackend(
__namedParameters
):WebGLFilterBackend
Defined in: src/filters/WebGLFilterBackend.ts:56
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”tileSize?
Section titled “tileSize?”number
= config.textureSize
Returns
Section titled “Returns”WebGLFilterBackend
Properties
Section titled “Properties”aPosition
Section titled “aPosition”aPosition:
Float32Array
Defined in: src/filters/WebGLFilterBackend.ts:17
Define …
canvas
Section titled “canvas”canvas:
HTMLCanvasElement
Defined in: src/filters/WebGLFilterBackend.ts:25
gl:
WebGLRenderingContext
Defined in: src/filters/WebGLFilterBackend.ts:30
The Webgl context that will execute the operations for filtering
gpuInfo
Section titled “gpuInfo”gpuInfo:
any
Defined in: src/filters/WebGLFilterBackend.ts:45
Contains GPU info for debug
imageBuffer?
Section titled “imageBuffer?”
optional
imageBuffer:ArrayBuffer
Defined in: src/filters/WebGLFilterBackend.ts:23
If GLPut data is the fastest operation, or if forced, this buffer will be used to transfer the data back in the 2d logic
programCache
Section titled “programCache”programCache:
any
Defined in: src/filters/WebGLFilterBackend.ts:35
Keyed map for shader cache
resources
Section titled “resources”resources:
TPipelineResources
={}
Defined in: src/filters/WebGLFilterBackend.ts:54
Experimental. This object is a sort of repository of help layers used to avoid of recreating them during frequent filtering. If you are previewing a filter with a slider you probably do not want to create help layers every filter step. in this object there will be appended some canvases, created once, resized sometimes cleared never. Clearing is left to the developer.
textureCache
Section titled “textureCache”textureCache:
TTextureCache
Defined in: src/filters/WebGLFilterBackend.ts:40
Keyed map for texture cache
tileSize
Section titled “tileSize”tileSize:
number
Defined in: src/filters/WebGLFilterBackend.ts:12
Methods
Section titled “Methods”applyFilters()
Section titled “applyFilters()”applyFilters(
filters
,source
,width
,height
,targetCanvas
,cacheKey?
):undefined
|TWebGLPipelineState
Defined in: src/filters/WebGLFilterBackend.ts:106
Attempts to apply the requested filters to the source provided, drawing the filtered output to the provided target canvas.
Parameters
Section titled “Parameters”filters
Section titled “filters”BaseFilter
<string
, Record
<string
, any
>, Record
<string
, any
>>[]
The filters to apply.
source
Section titled “source”TexImageSource
The source to be filtered.
number
The width of the source input.
height
Section titled “height”number
The height of the source input.
targetCanvas
Section titled “targetCanvas”HTMLCanvasElement
The destination for filtered output to be drawn.
cacheKey?
Section titled “cacheKey?”string
A key used to cache resources related to the source. If omitted, caching will be skipped.
Returns
Section titled “Returns”undefined
| TWebGLPipelineState
captureGPUInfo()
Section titled “captureGPUInfo()”captureGPUInfo():
any
Defined in: src/filters/WebGLFilterBackend.ts:378
Attempt to extract GPU information strings from a WebGL context.
Useful information when debugging or blacklisting specific GPUs.
Returns
Section titled “Returns”any
A GPU info object with renderer and vendor strings.
clearWebGLCaches()
Section titled “clearWebGLCaches()”clearWebGLCaches():
void
Defined in: src/filters/WebGLFilterBackend.ts:193
Wipe out WebGL-related caches.
Returns
Section titled “Returns”void
copyGLTo2D()
Section titled “copyGLTo2D()”copyGLTo2D(
gl
,pipelineState
):void
Defined in: src/filters/WebGLFilterBackend.ts:318
Copy an input WebGL canvas on to an output 2D canvas.
The WebGL canvas is assumed to be upside down, with the top-left pixel of the desired output image appearing in the bottom-left corner of the WebGL canvas.
Parameters
Section titled “Parameters”WebGLRenderingContext
pipelineState
Section titled “pipelineState”The 2D target canvas to copy on to.
Returns
Section titled “Returns”void
copyGLTo2DPutImageData()
Section titled “copyGLTo2DPutImageData()”copyGLTo2DPutImageData(
this
,gl
,pipelineState
):void
Defined in: src/filters/WebGLFilterBackend.ts:350
Copy an input WebGL canvas on to an output 2D canvas using 2d canvas’ putImageData API. Measurably faster than using ctx.drawImage in Firefox (version 54 on OSX Sierra).
Parameters
Section titled “Parameters”Required
<WebGLFilterBackend
>
WebGLRenderingContext
pipelineState
Section titled “pipelineState”The 2D target canvas to copy on to.
Returns
Section titled “Returns”void
createTexture()
Section titled “createTexture()”createTexture(
gl
,width
,height
,textureImageSource?
,filter?
):null
|WebGLTexture
Defined in: src/filters/WebGLFilterBackend.ts:211
Create a WebGL texture object.
Accepts specific dimensions to initialize the texture to or a source image.
Parameters
Section titled “Parameters”WebGLRenderingContext
The GL context to use for creating the texture.
number
The width to initialize the texture at.
height
Section titled “height”number
The height to initialize the texture.
textureImageSource?
Section titled “textureImageSource?”TexImageSource
A source for the texture data.
filter?
Section titled “filter?”gl.NEAREST default or gl.LINEAR filters for the texture. This filter is very useful for LUTs filters. If you need interpolation use gl.LINEAR
9728
| 9729
Returns
Section titled “Returns”null
| WebGLTexture
createWebGLCanvas()
Section titled “createWebGLCanvas()”createWebGLCanvas(
width
,height
):void
Defined in: src/filters/WebGLFilterBackend.ts:74
Create a canvas element and associated WebGL context and attaches them as class properties to the GLFilterBackend class.
Parameters
Section titled “Parameters”number
height
Section titled “height”number
Returns
Section titled “Returns”void
dispose()
Section titled “dispose()”dispose():
void
Defined in: src/filters/WebGLFilterBackend.ts:178
Detach event listeners, remove references, and clean up caches.
Returns
Section titled “Returns”void
evictCachesForKey()
Section titled “evictCachesForKey()”evictCachesForKey(
cacheKey
):void
Defined in: src/filters/WebGLFilterBackend.ts:302
Clear out cached resources related to a source image that has been filtered previously.
Parameters
Section titled “Parameters”cacheKey
Section titled “cacheKey”string
The cache key provided when the source image was filtered.
Returns
Section titled “Returns”void
getCachedTexture()
Section titled “getCachedTexture()”getCachedTexture(
uniqueId
,textureImageSource
,filter?
):null
|WebGLTexture
Defined in: src/filters/WebGLFilterBackend.ts:271
Can be optionally used to get a texture from the cache array
If an existing texture is not found, a new texture is created and cached.
Parameters
Section titled “Parameters”uniqueId
Section titled “uniqueId”string
A cache key to use to find an existing texture.
textureImageSource
Section titled “textureImageSource”TexImageSource
A source to use to create the texture cache entry if one does not already exist.
filter?
Section titled “filter?”9728
| 9729
Returns
Section titled “Returns”null
| WebGLTexture
setupGLContext()
Section titled “setupGLContext()”setupGLContext(
width
,height
):void
Defined in: src/filters/WebGLFilterBackend.ts:65
Setup a WebGL context suitable for filtering, and bind any needed event handlers.
Parameters
Section titled “Parameters”number
height
Section titled “height”number
Returns
Section titled “Returns”void