NASA World Wind

gov.nasa.worldwind.cache
Interface GpuResourceCache

All Known Implementing Classes:
BasicGpuResourceCache

public interface GpuResourceCache

Implements a cache of OpenGL resources that are stored on the GPU or registered with it. This includes texture, vertex buffer and display list resource IDs returned by the corresponding OpenGL functions. The cache holds the most recently used resources that fit within its capacity.


Field Summary
static String DISPLAY_LISTS
          Identifies resources as Display List IDs.
static String TEXTURE
          Identifies resources as textures.
static String VBO_BUFFERS
          Identifies resources as Vertex Buffer IDs.
 
Method Summary
 void clear()
          Removes all entries from this cache.
 boolean contains(Object key)
          Indicates whether a resource is in the cache.
 Object get(Object key)
          Finds and returns a resource from this cache.
 long getCapacity()
          Indicates this cache's capacity in bytes.
 long getFreeCapacity()
          Indicates this cache's memory capacity not used by its cached objects.
 long getLowWater()
          Indicates the cache's low water size.
 int getNumObjects()
          Indicates the number of resources in this cache.
 Texture getTexture(Object key)
          Finds and returns a texture resource from this cache.
 long getUsedCapacity()
          Indicates the amount of memory used by cached objects in this cache.
 void put(Object key, Object resource, String resourceType, long size)
          Adds a new resource to this cache.
 void put(Object key, Texture texture)
          Add a resource to this cache.
 void remove(Object key)
          Removes a resource from this cache.
 void setCapacity(long newCapacity)
          Specifies this cache's capacity, the amount of memory the cache manages.
 void setLowWater(long loWater)
          Specifies the low water size for this cache.
 

Field Detail

DISPLAY_LISTS

static final String DISPLAY_LISTS
Identifies resources as Display List IDs. Corresponding object must be of type int[] and contain the display list resource IDs.

See Also:
Constant Field Values

TEXTURE

static final String TEXTURE
Identifies resources as textures. Corresponding object must be of type Texture.

See Also:
Constant Field Values

VBO_BUFFERS

static final String VBO_BUFFERS
Identifies resources as Vertex Buffer IDs. Corresponding object must be of type int[] and contain the VBO resource IDs.

See Also:
Constant Field Values
Method Detail

clear

void clear()
Removes all entries from this cache.


contains

boolean contains(Object key)
Indicates whether a resource is in the cache.

Parameters:
key - the resource's key.
Returns:
true if the resource is in the cache, otherwise false.

get

Object get(Object key)
Finds and returns a resource from this cache.

Parameters:
key - the resource's key.
Returns:
the resource associated with the key, or null if the key is not found in the cache.
Throws:
IllegalArgumentException - if the key is null.

getCapacity

long getCapacity()
Indicates this cache's capacity in bytes.

Returns:
this cache's capacity in bytes.

getFreeCapacity

long getFreeCapacity()
Indicates this cache's memory capacity not used by its cached objects.

Returns:
the number of bytes of this cache's memory capacity not used by its cached objects.
See Also:
getCapacity()

getLowWater

long getLowWater()
Indicates the cache's low water size.

Returns:
the cache's low water size, in bytes.
See Also:
setLowWater(long)

getNumObjects

int getNumObjects()
Indicates the number of resources in this cache.

Returns:
the number of resources in this cache.

getTexture

Texture getTexture(Object key)
Finds and returns a texture resource from this cache.

Parameters:
key - the texture resource's key.
Returns:
the texture resource associated with the key, or null if the key is not found in the cache.
Throws:
IllegalArgumentException - if the key is null.

getUsedCapacity

long getUsedCapacity()
Indicates the amount of memory used by cached objects in this cache.

Returns:
the number of bytes of memory used by objects in this cache, as determined by the size associated with each resource.
See Also:
getCapacity()

put

void put(Object key,
         Object resource,
         String resourceType,
         long size)
Adds a new resource to this cache.

Parameters:
key - the key identifying the resource.
resource - the resource cached.
resourceType - the type of resource, one of the resource-type constants described above.
size - the size of the resource, expressed as the number of bytes it requires on the GPU.
See Also:
put(Object, com.jogamp.opengl.util.texture.Texture)

put

void put(Object key,
         Texture texture)
Add a resource to this cache.

Parameters:
key - the key identifying the resource.
texture - the resource to add to this cache.
Throws:
IllegalArgumentException - if either argument is null.

remove

void remove(Object key)
Removes a resource from this cache.

Parameters:
key - the resource's key.
Throws:
IllegalArgumentException - if the key is null.

setCapacity

void setCapacity(long newCapacity)
Specifies this cache's capacity, the amount of memory the cache manages. When new resources are added to this cache and would exceed the cache's capacity, the cache's least recently used resources are removed from it until its low water level is reached.

Parameters:
newCapacity - the number of bytes allowed for the cache's resources. Values less than or equal to 0 are ignored and cause no change to this cache's capacity.
See Also:
setLowWater(long)

setLowWater

void setLowWater(long loWater)
Specifies the low water size for this cache. When resources added to the cache would exceed the cache's capacity, existing resources are removed until the amount of memory used is at or below the low water size.

Parameters:
loWater - the size to reduce this cache to when added resources would exceed the cache's capacity. Values less than or equal to 0 are ignored and cause no change to this cache's low water size.
See Also:
setCapacity(long), remove(Object)

NASA World Wind