@lightningjs/renderer
    Preparing search index...

    Class TextureAbstract

    Represents a source of texture data for a CoreContextTexture.

    Texture sources are used to populate a CoreContextTexture when that texture is loaded. Texture data retrieved by the CoreContextTexture by the getTextureData method. It's the responsibility of the concerete Texture subclass to implement this method appropriately.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    ctxTexture: undefined | CoreContextTexture
    maxRetryCount: number
    memUsed: number = 0
    preventCleanup: boolean = false
    renderable: boolean = false
    renderableOwners: any[] = []
    retryCount: number = 0

    Memory used by this texture in bytes

    This is tracked by the TextureMemoryManager and updated when the texture is loaded/freed. Set to 0 when texture is not loaded.

    state: TextureState = 'initial'
    textureData: null | TextureData = null
    type: TextureType = TextureType.generic

    Accessors

    Methods

    • Checks if the texture can be safely cleaned up. Considers the renderable state, startup grace period, and renderable owners.

      Returns boolean

    • Destroy the texture.

      Returns void

      This method is called when the texture is no longer needed and should be cleaned up.

    • Free the core context texture for this Texture.

      Returns void

      The ctxTexture is created by the renderer and lives on the GPU.

    • Free the source texture data for this Texture.

      Returns void

      The texture data is the source data that is used to populate the CoreContextTexture. e.g. ImageData that is downloaded from a URL.

    • Get the texture data for this texture.

      Returns Promise<TextureData>

      The texture data for this texture.

      This method is called by the CoreContextTexture when the texture is loaded. The texture data is then used to populate the CoreContextTexture.

    • Get the texture source for this texture.

      Returns Promise<TextureData>

      This method is called by the CoreContextTexture when the texture is loaded. The texture source is then used to populate the CoreContextTexture.

    • Checks if the texture is within the startup grace period. During this period, textures are protected from cleanup to prevent race conditions during app initialization.

      Returns boolean

    • Load the core context texture for this Texture. The ctxTexture is created by the renderer and lives on the GPU.

      Returns CoreContextTexture

    • Parameters

      • event: string
      • Optionallistener: (target: any, data: any) => void

      Returns void

    • Event called when the Texture becomes renderable or unrenderable.

      Parameters

      • isRenderable: boolean

        true if this Texture has renderable owners.

      Returns void

      Used by subclasses like SubTexture propogate then renderability of the Texture to other referenced Textures.

    • Release the texture data and core context texture for this Texture without changing state.

      Returns void

      The ctxTexture is created by the renderer and lives on the GPU.

    • Add/remove an owner to/from the Texture based on its renderability.

      Parameters

      • owner: string | number
      • renderable: boolean

      Returns void

      Any object can own a texture, be it a CoreNode or even the state object from a Text Renderer.

      When the reference to the texture that an owner object holds is replaced or cleared it must call this with renderable=false to release the owner association.

    • Make a cache key for this texture.

      Parameters

      • props: unknown

      Returns string | false

      A cache key for this texture or false if the texture type does not support caching.

      Each concrete Texture subclass must implement this method to provide an appropriate cache key for the texture type including the texture's properties that uniquely identify a copy of the texture. If the texture type does not support caching, then this method should return false.

    • Resolve the default values for the texture's properties.

      Parameters

      • props: unknown

      Returns Record<string, any>

      The default values for the texture's properties.

      Each concrete Texture subclass must implement this method to provide default values for the texture's optional properties.