Class: TextureStore

TextureStore(geometry, source, stage, opts)

A TextureStore maintains a cache of textures used to render a Layer.

A Stage communicates with the TextureStore through the startFrame(), markTile() and endFrame() methods, which indicate the tiles that are visible in the current frame. Textures for visible tiles are loaded and retained as long as the tiles remain visible. A limited amount of textures whose tiles used to be visible are cached according to an LRU policy. Tiles may be pinned to ensure that their textures are never unloaded, even when the tiles are invisible.

Multiple layers belonging to the same underlying WebGlStage may share the same TextureStore. Layers belonging to distinct WebGlStage instances, or belonging to a CssStage or a FlashStage, may not do so due to restrictions on the use of textures across stages.

Constructor

new TextureStore(geometry, source, stage, opts)

Parameters:
Name Type Description
geometry Geometry

the underlying geometry.

source Source

the underlying source.

stage Stage

the underlying stage.

opts Object

options.

Properties
Name Type Attributes Default Description
previouslyVisibleCacheSize Number <optional>
32

the non-visible texture LRU cache size.

Methods

clear()

Remove all textures from the TextureStore, including pinned textures.

clearNotPinned()

Remove all textures in the TextureStore, excluding unpinned textures.

destroy()

Destructor.

endFrame()

Signal the end of a frame. Called from Stage.

markTile(tile)

Mark a tile within the current frame. Called from Stage.

Parameters:
Name Type Description
tile Tile

the tile to mark

pin(tile) → {number}

Pin a tile. Textures for pinned tiles are never evicted from the store. Upon pinning, the texture is created if not already present. Pins are reference-counted; a tile may be pinned multiple times and must be unpinned the corresponding number of times. Pinning is useful e.g. to ensure that the lowest-resolution level of an image is always available to fall back onto.

Parameters:
Name Type Description
tile Tile

the tile to pin

Returns:

the pin reference count.

Type
number

query(tile) → {Object|boolean|boolean|boolean|boolean|boolean|number}

Return the state of a tile.

Parameters:
Name Type Description
tile Tile

the tile to query

Returns:
  • state

    Type
    Object
  • state.visible whether the tile is in the visible set

    Type
    boolean
  • state.previouslyVisible whether the tile is in the previously visible set

    Type
    boolean
  • state.hasAsset whether the asset for the tile is present

    Type
    boolean
  • state.hasTexture whether the texture for the tile is present

    Type
    boolean
  • state.pinned whether the tile is pinned

    Type
    boolean
  • state.pinCount the pin reference count for the tile

    Type
    number

source() → {Source}

Return the underlying Source.

Returns:
Type
Source

stage() → {Stage}

Return the underlying Stage.

Returns:
Type
Stage

startFrame()

Signal the beginning of a frame. Called from Stage.

unpin(tile) → {number}

Unpin a tile. Pins are reference-counted; a tile may be pinned multiple times and must be unpinned the corresponding number of times.

Parameters:
Name Type Description
tile Tile

the tile to unpin

Returns:

the pin reference count.

Type
number