src/TextureStore.js
function TextureStore(source, stage, opts) {
  opts = defaults(opts || {}, defaultOptions);

  this._source = source;
  this._stage = stage;

  // The current state.
  this._state = State.IDLE;

  // The number of startFrame calls yet to be matched by endFrame calls during
  // the current frame.
  this._delimCount = 0;

  // The cache proper: map cached tiles to their respective textures/assets.
  this._itemMap = new Map();

  // The subset of cached tiles that are currently visible.
  this._visible = new Set();

  // The subset of cached tiles that were visible recently, but are not
  // visible right now. Newly inserted tiles replace older ones.
  this._previouslyVisible = new LruSet(opts.previouslyVisibleCacheSize);

  // The subset of cached tiles that should never be evicted from the cache.
  // A tile may be pinned more than once; map each tile into a reference count.
  this._pinMap = new Map();

  // Temporary variables.
  this._newVisible = new Set();
  this._noLongerVisible = [];
  this._visibleAgain = [];
  this._evicted = [];
}
function TextureStore(source, stage, opts) {
  opts = defaults(opts || {}, defaultOptions);

  this._source = source;
  this._stage = stage;

  // The current state.
  this._state = State.IDLE;

  // The number of startFrame calls yet to be matched by endFrame calls during
  // the current frame.
  this._delimCount = 0;

  // The cache proper: map cached tiles to their respective textures/assets.
  this._itemMap = new Map();

  // The subset of cached tiles that are currently visible.
  this._visible = new Set();

  // The subset of cached tiles that were visible recently, but are not
  // visible right now. Newly inserted tiles replace older ones.
  this._previouslyVisible = new LruSet(opts.previouslyVisibleCacheSize);

  // The subset of cached tiles that should never be evicted from the cache.
  // A tile may be pinned more than once; map each tile into a reference count.
  this._pinMap = new Map();

  // Temporary variables.
  this._newVisible = new Set();
  this._noLongerVisible = [];
  this._visibleAgain = [];
  this._evicted = [];
}
function TextureStore ( source , stage , opts ) { opts = defaults ( opts || { } , defaultOptions ) ; this . _source = source ; this . _stage = stage ; // The current state. this . _state = State . IDLE ; // The number of startFrame calls yet to be matched by endFrame calls during // the current frame. this . _delimCount = 0 ; // The cache proper: map cached tiles to their respective textures/assets. this . _itemMap = new Map ( ) ; // The subset of cached tiles that are currently visible. this . _visible = new Set ( ) ; // The subset of cached tiles that were visible recently, but are not // visible right now. Newly inserted tiles replace older ones. this . _previouslyVisible = new LruSet ( opts . previouslyVisibleCacheSize ) ; // The subset of cached tiles that should never be evicted from the cache. // A tile may be pinned more than once; map each tile into a reference count. this . _pinMap = new Map ( ) ; // Temporary variables. this . _newVisible = new Set ( ) ; this . _noLongerVisible = [ ] ; this . _visibleAgain = [ ] ; this . _evicted = [ ] ; }
Signals that loading a texture has failed.

This event may follow {@link TextureStore#textureStartLoad} if the texture
fails to load.

@event TextureStore#textureError
@param {Tile} tile The tile for which the texture loading has failed.
 
@class TextureStore
@classdesc

A TextureStore maintains a cache of textures used to render a {@link Layer}.

A {@link 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 were previously visible are cached according to an LRU policy. Tiles
may be pinned to keep their respective textures cached even when they are
invisible; these textures do not count towards the previously visible limit.

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

@param {Source} source The underlying source.
@param {Stage} stage The underlying stage.
@param {Object} opts Options.
@param {Number} [opts.previouslyVisibleCacheSize=32] The maximum number of
previously visible textures to cache according to an LRU policy.
Signals that loading a texture has failed .