Constructor
new TextureStore(source, stage, opts)
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
source |
Source | The underlying source. |
||||||||||
stage |
Stage | The underlying stage. |
||||||||||
opts |
Object | Options. Properties
|
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 as visible 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) → {TileState}
Return the state of a tile.
Parameters:
Name | Type | Description |
---|---|---|
tile |
Tile | The tile to query. |
Returns:
- Type
- TileState
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
Events
textureCancel
Signals that loading a texture has been cancelled.
This event may follow TextureStore#textureStartLoad if the texture becomes unnecessary before it finishes loading.
Parameters:
Name | Type | Description |
---|---|---|
tile |
Tile | The tile for which the texture loading was cancelled. |
textureError
Signals that loading a texture has failed.
This event may follow TextureStore#textureStartLoad if the texture fails to load.
Parameters:
Name | Type | Description |
---|---|---|
tile |
Tile | The tile for which the texture loading has failed. |
textureInvalid
Signals that a texture has been invalidated.
This event may be raised for a texture with an underlying dynamic asset. It may only occur while the texture is loaded, i.e., in between TextureStore#textureLoad and TextureStore#textureUnload.
Parameters:
Name | Type | Description |
---|---|---|
tile |
Tile | The tile for which the texture was invalidated. |
textureLoad
Signals that a texture has been loaded.
Parameters:
Name | Type | Description |
---|---|---|
tile |
Tile | The tile for which the texture was loaded. |
textureStartLoad
Signals that a texture has started to load.
This event is followed by either TextureStore#textureLoad, TextureStore#textureError or TextureStore#textureCancel.
Parameters:
Name | Type | Description |
---|---|---|
tile |
Tile | The tile for which the texture has started to load. |
textureUnload
Signals that a texture has been unloaded.
Parameters:
Name | Type | Description |
---|---|---|
tile |
Tile | The tile for which the texture was unloaded. |