phaser - v4.0.0-rc.4
    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

    Constructors

    Properties

    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.

    Methods

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

      Parameters

      Returns void

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

      Returns void

    • Returns a DrawingContext of the given dimensions.

      Parameters

      • Optionalwidth: number

        The width of the DrawingContext.

      • Optionalheight: number

        The height of the DrawingContext.

      Returns 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