Class WebGLFilterBackend

Hierarchy

  • WebGLFilterBackend

Constructors

Properties

aPosition: Float32Array = ...

Define ...

canvas: HTMLCanvasElement
gl: WebGLRenderingContext

The Webgl context that will execute the operations for filtering

gpuInfo: any

Contains GPU info for debug

imageBuffer?: ArrayBuffer

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

Keyed map for shader cache

resources: TPipelineResources = {}

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

Keyed map for texture cache

tileSize: number

Methods

  • Attempts to apply the requested filters to the source provided, drawing the filtered output to the provided target canvas.

    Parameters

    • filters: BaseFilter[]

      The filters to apply.

    • source: TexImageSource

      The source to be filtered.

    • width: number

      The width of the source input.

    • height: number

      The height of the source input.

    • targetCanvas: HTMLCanvasElement

      The destination for filtered output to be drawn.

    • Optional cacheKey: string

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

    Returns undefined | TWebGLPipelineState

  • Attempt to extract GPU information strings from a WebGL context.

    Useful information when debugging or blacklisting specific GPUs.

    Returns any

    A GPU info object with renderer and vendor strings.

  • Pick a method to copy data from GL context to 2d canvas. In some browsers using drawImage should be faster, but is also bugged for a small combination of old hardware and drivers. putImageData is faster than drawImage for that specific operation.

    Parameters

    • width: number
    • height: number

    Returns void

  • 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

    • gl: WebGLRenderingContext
    • pipelineState: TWebGLPipelineState

      The 2D target canvas to copy on to.

    Returns void

  • Create a WebGL texture object.

    Accepts specific dimensions to initialize the texture to or a source image.

    Parameters

    • gl: WebGLRenderingContext

      The GL context to use for creating the texture.

    • width: number

      The width to initialize the texture at.

    • height: number

      The height to initialize the texture.

    • Optional textureImageSource: TexImageSource

      A source for the texture data.

    • Optional filter: number

      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

    Returns null | WebGLTexture

  • Create a canvas element and associated WebGL context and attaches them as class properties to the GLFilterBackend class.

    Parameters

    • width: number
    • height: number

    Returns void

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

    Parameters

    • cacheKey: string

      The cache key provided when the source image was filtered.

    Returns void

  • 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

    • uniqueId: string

      A cache key to use to find an existing texture.

    • textureImageSource: TexImageSource

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

    • Optional filter: number

    Returns null | WebGLTexture

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

    Parameters

    • width: number
    • height: number

    Returns void

Generated using TypeDoc