PokéRogue
    Preparing search index...

    A pool of DrawingContexts.

    This class is used internally by the WebGLRenderer to manage DrawingContexts. It attempts to reuse DrawingContexts efficiently. When get is called, it will return a DrawingContext of the given dimensions, using the following priority:

    1. A spare DrawingContext that has the same dimensions.
    2. A spare DrawingContext that has not been used recently, resized.
    3. A new DrawingContext, within the maximum pool size.
    4. The oldest spare DrawingContext, resized.
    5. A new DrawingContext, exceeding the maximum pool size.

    We assume that DrawingContexts of a given size are likely to be reused from frame to frame, so we try to preserve them for greater efficiency.

    Index
    • Parameters

      • renderer: WebGLRenderer

        The renderer that owns this DrawingContextPool.

      • maxAge: number

        The maximum age of a pooled DrawingContext in milliseconds, after which it becomes eligible for resizing and reuse.

      • maxPoolSize: number

        The soft maximum number of DrawingContexts to keep in the pool. The pool may exceed this limit temporarily if demand requires it.

      Returns DrawingContextPool

    agePool: DrawingContext[]

    The pool of DrawingContexts by age. This is an array of DrawingContexts, oldest first.

    maxAge: number

    The maximum age of a DrawingContext in milliseconds. After this time, the DrawingContext will be available for resizing.

    maxPoolSize: number

    The maximum number of DrawingContexts to store. This is not a hard limit, but the pool will attempt to reuse DrawingContexts rather than create new ones.

    renderer: WebGLRenderer

    The renderer that owns this DrawingContextPool.

    sizePool: object

    The pool of DrawingContexts by size. This is an object with keys of the form ${width}x${height}. Each value is an array of DrawingContexts.

    • Adds a DrawingContext to the pool. This is used by a DrawingContext to signal that it is available for reuse.

      Parameters

      • drawingContext: DrawingContext

        The DrawingContext to add to the pool.

      Returns void

    • Clears the DrawingContextPool. This will not destroy any DrawingContexts that are currently in use.

      Returns void

    • Returns a DrawingContext of the requested dimensions, following the pool's priority order: an exact-size spare, an aged spare resized, a newly created context within the pool limit, the oldest spare resized, or finally a newly created context that exceeds the pool limit. If width or height are omitted, the renderer's current dimensions are used. Both values are clamped to the renderer's maximum texture size.

      Parameters

      • Optionalwidth: number

        The width of the DrawingContext.

      • Optionalheight: number

        The height of the DrawingContext.

      Returns DrawingContext

      The DrawingContext.

    • Prunes the DrawingContextPool down to the maximum pool size. Oldest DrawingContexts will be destroyed first. This will not destroy any DrawingContexts that are currently in use.

      Returns void

    • Sets the maximum age of a DrawingContext in milliseconds.

      Parameters

      • maxAge: number

        The maximum age of a DrawingContext in milliseconds.

      Returns void

    • Sets the maximum number of DrawingContexts to store.

      Parameters

      • maxPoolSize: number

        The maximum number of DrawingContexts to store.

      Returns void