Skip to content

WebGLFilterBackend

Defined in: src/filters/WebGLFilterBackend.ts:11

new WebGLFilterBackend(__namedParameters): WebGLFilterBackend

Defined in: src/filters/WebGLFilterBackend.ts:56

number = config.textureSize

WebGLFilterBackend

aPosition: Float32Array

Defined in: src/filters/WebGLFilterBackend.ts:17

Define …


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: any

Defined in: src/filters/WebGLFilterBackend.ts:45

Contains GPU info for debug


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: any

Defined in: src/filters/WebGLFilterBackend.ts:35

Keyed map for shader cache


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: TTextureCache

Defined in: src/filters/WebGLFilterBackend.ts:40

Keyed map for texture cache


tileSize: number

Defined in: src/filters/WebGLFilterBackend.ts:12

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.

BaseFilter<string, Record<string, any>, Record<string, any>>[]

The filters to apply.

TexImageSource

The source to be filtered.

number

The width of the source input.

number

The height of the source input.

HTMLCanvasElement

The destination for filtered output to be drawn.

string

A key used to cache resources related to the source. If omitted, caching will be skipped.

undefined | TWebGLPipelineState


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.

any

A GPU info object with renderer and vendor strings.


clearWebGLCaches(): void

Defined in: src/filters/WebGLFilterBackend.ts:193

Wipe out WebGL-related caches.

void


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.

WebGLRenderingContext

TWebGLPipelineState

The 2D target canvas to copy on to.

void


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).

Required<WebGLFilterBackend>

WebGLRenderingContext

TWebGLPipelineState

The 2D target canvas to copy on to.

void


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.

WebGLRenderingContext

The GL context to use for creating the texture.

number

The width to initialize the texture at.

number

The height to initialize the texture.

TexImageSource

A source for the texture data.

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

null | WebGLTexture


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.

number

number

void


dispose(): void

Defined in: src/filters/WebGLFilterBackend.ts:178

Detach event listeners, remove references, and clean up caches.

void


evictCachesForKey(cacheKey): void

Defined in: src/filters/WebGLFilterBackend.ts:302

Clear out cached resources related to a source image that has been filtered previously.

string

The cache key provided when the source image was filtered.

void


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.

string

A cache key to use to find an existing texture.

TexImageSource

A source to use to create the texture cache entry if one does not already exist.

9728 | 9729

null | WebGLTexture


setupGLContext(width, height): void

Defined in: src/filters/WebGLFilterBackend.ts:65

Setup a WebGL context suitable for filtering, and bind any needed event handlers.

number

number

void