NASA World Wind

gov.nasa.worldwind.layers
Class TextureTile

java.lang.Object
  extended by gov.nasa.worldwind.util.Tile
      extended by gov.nasa.worldwind.layers.TextureTile
All Implemented Interfaces:
Cacheable, SurfaceTile, Comparable<Tile>
Direct Known Subclasses:
MercatorTextureTile, SurfaceObjectTileBuilder.SurfaceObjectTile, WMSTiledImageLayer.ComposeImageTile

public class TextureTile
extends Tile
implements SurfaceTile

This class manages the conversion and timing of image data to a JOGL Texture, and provides an interface for binding the texture and applying any texture transforms to align the texture and texture coordinates.


Field Summary
protected  boolean hasMipmapData
           
protected  AtomicLong updateTime
           
 
Constructor Summary
TextureTile(Sector sector)
           
TextureTile(Sector sector, Level level, int row, int col)
           
TextureTile(Sector sector, Level level, int row, int column, String cacheName)
           
 
Method Summary
 void applyInternalTransform(DrawContext dc, boolean textureIdentityActive)
           
protected  void applyResourceTextureTransform(DrawContext dc)
           
 boolean bind(DrawContext dc)
           
protected  TextureTile createSubTile(Sector sector, Level level, int row, int col)
          Creates a sub tile of this texture tile with the specified Sector, Level, row, and column.
protected  TileKey createSubTileKey(Level level, int row, int col)
          Returns a key for a sub tile of this texture tile with the specified Level, row, and column.
 TextureTile[] createSubTiles(Level nextLevel)
          Splits this texture tile into four tiles; one for each sub quadrant of this texture tile.
 boolean equals(Object o)
           
 Vec4 getCentroidPoint(Globe globe)
           
 List<? extends LatLon> getCorners()
           
 Extent getExtent(DrawContext dc)
           
 TextureTile getFallbackTile()
           
static MemoryCache getMemoryCache()
          Returns the memory cache used to cache tiles for this class and its subclasses, initializing the cache if it doesn't yet exist.
 long getSizeInBytes()
          Retrieves the approximate size of this object in bytes.
 Texture getTexture(GpuResourceCache tc)
           
 TextureData getTextureData()
          Returns the texture data most recently specified for the tile.
protected  TextureTile getTileFromMemoryCache(TileKey tileKey)
           
 long getUpdateTime()
           
 int hashCode()
           
protected  Texture initializeTexture(DrawContext dc)
           
 boolean isTextureExpired()
           
 boolean isTextureExpired(long expiryTime)
           
 boolean isTextureInMemory(GpuResourceCache tc)
           
 void setFallbackTile(TextureTile fallbackTile)
           
 void setTexture(GpuResourceCache tc, Texture texture)
           
 void setTextureData(TextureData textureData)
          Specifies new texture data for the tile.
protected  void setTextureParameters(DrawContext dc, Texture t)
           
 String toString()
           
protected  void updateMemoryCache()
           
 
Methods inherited from class gov.nasa.worldwind.util.Tile
compareTo, computeColumn, computeColumnLongitude, computeRow, computeRowLatitude, getCacheName, getColumn, getFormatSuffix, getHeight, getLabel, getLevel, getLevelName, getLevelNumber, getPath, getPathBase, getPriority, getResourceURL, getResourceURL, getRow, getSector, getTileKey, getWidth, setPriority
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.render.SurfaceTile
getSector
 

Field Detail

hasMipmapData

protected boolean hasMipmapData

updateTime

protected AtomicLong updateTime
Constructor Detail

TextureTile

public TextureTile(Sector sector)

TextureTile

public TextureTile(Sector sector,
                   Level level,
                   int row,
                   int col)

TextureTile

public TextureTile(Sector sector,
                   Level level,
                   int row,
                   int column,
                   String cacheName)
Method Detail

applyInternalTransform

public void applyInternalTransform(DrawContext dc,
                                   boolean textureIdentityActive)
Specified by:
applyInternalTransform in interface SurfaceTile

applyResourceTextureTransform

protected void applyResourceTextureTransform(DrawContext dc)

bind

public boolean bind(DrawContext dc)
Specified by:
bind in interface SurfaceTile

createSubTile

protected TextureTile createSubTile(Sector sector,
                                    Level level,
                                    int row,
                                    int col)
Creates a sub tile of this texture tile with the specified Sector, Level, row, and column. This is called by createSubTiles(gov.nasa.worldwind.util.Level), to construct a sub tile for each quadrant of this tile. Subclasses must override this method to return an instance of the derived version.

Parameters:
sector - the sub tile's sector.
level - the sub tile's level.
row - the sub tile's row.
col - the sub tile's column.
Returns:
a sub tile of this texture tile.

createSubTileKey

protected TileKey createSubTileKey(Level level,
                                   int row,
                                   int col)
Returns a key for a sub tile of this texture tile with the specified Level, row, and column. This is called by createSubTiles(gov.nasa.worldwind.util.Level), to create a sub tile key for each quadrant of this tile.

Parameters:
level - the sub tile's level.
row - the sub tile's row.
col - the sub tile's column.
Returns:
a sub tile of this texture tile.

createSubTiles

public TextureTile[] createSubTiles(Level nextLevel)
Splits this texture tile into four tiles; one for each sub quadrant of this texture tile. This attempts to retrieve each sub tile from the texture tile cache. This calls createSubTile(gov.nasa.worldwind.geom.Sector, gov.nasa.worldwind.util.Level, int, int) to create sub tiles not found in the cache.

Parameters:
nextLevel - the level for the sub tiles.
Returns:
a four-element array containing this texture tile's sub tiles.
Throws:
IllegalArgumentException - if the level is null.

equals

public boolean equals(Object o)
Overrides:
equals in class Tile

getCentroidPoint

public Vec4 getCentroidPoint(Globe globe)

getCorners

public List<? extends LatLon> getCorners()
Specified by:
getCorners in interface SurfaceTile

getExtent

public Extent getExtent(DrawContext dc)
Specified by:
getExtent in interface SurfaceTile

getFallbackTile

public TextureTile getFallbackTile()

getMemoryCache

public static MemoryCache getMemoryCache()
Returns the memory cache used to cache tiles for this class and its subclasses, initializing the cache if it doesn't yet exist.

Returns:
the memory cache associated with the tile.

getSizeInBytes

public long getSizeInBytes()
Description copied from interface: Cacheable
Retrieves the approximate size of this object in bytes. Implementors are encouraged to calculate the exact size for smaller objects, but use approximate values for objects that include such large components that the approximation would produce an error so small that the extra computation would be wasteful.

Specified by:
getSizeInBytes in interface Cacheable
Overrides:
getSizeInBytes in class Tile
Returns:
this Cacheable object's size in bytes

getTexture

public Texture getTexture(GpuResourceCache tc)

getTextureData

public TextureData getTextureData()
Returns the texture data most recently specified for the tile. New texture data is typically specified when a new image is read, either initially or in response to image expiration.

If texture data is non-null, a new texture is created from the texture data when the tile is next bound or otherwise initialized. The texture data field is then set to null. Subsequently setting texture data to be non-null causes a new texture to be created when the tile is next bound or initialized.

Returns:
the texture data, which may be null.

getTileFromMemoryCache

protected TextureTile getTileFromMemoryCache(TileKey tileKey)

getUpdateTime

public long getUpdateTime()

hashCode

public int hashCode()
Overrides:
hashCode in class Tile

initializeTexture

protected Texture initializeTexture(DrawContext dc)

isTextureExpired

public boolean isTextureExpired()

isTextureExpired

public boolean isTextureExpired(long expiryTime)

isTextureInMemory

public boolean isTextureInMemory(GpuResourceCache tc)

setFallbackTile

public void setFallbackTile(TextureTile fallbackTile)

setTexture

public void setTexture(GpuResourceCache tc,
                       Texture texture)

setTextureData

public void setTextureData(TextureData textureData)
Specifies new texture data for the tile. New texture data is typically specified when a new image is read, either initially or in response to image expiration.

If texture data is non-null, a new texture is created from the texture data when the tile is next bound or otherwise initialized. The texture data field is then set to null. Subsequently setting texture data to be non-null causes a new texture to be created when the tile is next bound or initialized.

When a texture is created from the texture data, the texture data field is set to null to indicate that the data has been converted to a texture and its resources may be released.

Parameters:
textureData - the texture data, which may be null.

setTextureParameters

protected void setTextureParameters(DrawContext dc,
                                    Texture t)

toString

public String toString()
Overrides:
toString in class Tile

updateMemoryCache

protected void updateMemoryCache()

NASA World Wind