Package 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
Fields Modifier and Type Field Description static java.lang.String
DISPLAY_LISTS
Identifies resources as Display List IDs.static java.lang.String
TEXTURE
Identifies resources as textures.static java.lang.String
VBO_BUFFERS
Identifies resources as Vertex Buffer IDs.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Removes all entries from this cache.boolean
contains(java.lang.Object key)
Indicates whether a resource is in the cache.java.lang.Object
get(java.lang.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.com.jogamp.opengl.util.texture.Texture
getTexture(java.lang.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(java.lang.Object key, com.jogamp.opengl.util.texture.Texture texture)
Add a resource to this cache.void
put(java.lang.Object key, java.lang.Object resource, java.lang.String resourceType, long size)
Adds a new resource to this cache.void
remove(java.lang.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
-
TEXTURE
static final java.lang.String TEXTURE
Identifies resources as textures. Corresponding object must be of typeTexture
.- See Also:
- Constant Field Values
-
VBO_BUFFERS
static final java.lang.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
-
DISPLAY_LISTS
static final java.lang.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
-
-
Method Detail
-
put
void put(java.lang.Object key, java.lang.Object resource, java.lang.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(java.lang.Object key, com.jogamp.opengl.util.texture.Texture texture)
Add a resource to this cache.- Parameters:
key
- the key identifying the resource.texture
- the resource to add to this cache.- Throws:
java.lang.IllegalArgumentException
- if either argument is null.
-
get
java.lang.Object get(java.lang.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:
java.lang.IllegalArgumentException
- if the key is null.
-
contains
boolean contains(java.lang.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.
-
getTexture
com.jogamp.opengl.util.texture.Texture getTexture(java.lang.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:
java.lang.IllegalArgumentException
- if the key is null.
-
remove
void remove(java.lang.Object key)
Removes a resource from this cache.- Parameters:
key
- the resource's key.- Throws:
java.lang.IllegalArgumentException
- if the key is null.
-
clear
void clear()
Removes all entries from this cache.
-
getNumObjects
int getNumObjects()
Indicates the number of resources in this cache.- Returns:
- the number of resources in this cache.
-
getCapacity
long getCapacity()
Indicates this cache's capacity in bytes.- Returns:
- this cache's capacity in bytes.
-
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()
-
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()
-
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)
-
getLowWater
long getLowWater()
Indicates the cache's low water size.- Returns:
- the cache's low water size, in bytes.
- See Also:
setLowWater(long)
-
-