public abstract class BaseResourceFactory extends java.lang.Object implements ResourceFactory
Modifier and Type | Field and Description |
---|---|
private java.util.Map<Image,Texture> |
clampTexCache |
private Texture |
glyphTexture |
private java.util.WeakHashMap<ResourceFactoryListener,java.lang.Boolean> |
listenerMap |
private java.util.Map<Image,Texture> |
mipmapTexCache |
private Texture |
regionTexture |
private java.util.Map<Image,Texture> |
repeatTexCache |
private boolean |
superShaderAllowed |
Constructor and Description |
---|
BaseResourceFactory() |
BaseResourceFactory(java.util.Map<Image,Texture> clampTexCache,
java.util.Map<Image,Texture> repeatTexCache,
java.util.Map<Image,Texture> mipmapTexCache) |
Modifier and Type | Method and Description |
---|---|
void |
addFactoryListener(ResourceFactoryListener l) |
protected boolean |
canClampToEdge() |
protected boolean |
canClampToZero() |
protected boolean |
canRepeat() |
protected void |
clearTextureCache() |
protected void |
clearTextureCache(java.util.Map<Image,Texture> texCache) |
Texture |
createFloatTexture(int width,
int height) |
Texture |
createMaskTexture(int width,
int height,
Texture.WrapMode wrapMode) |
Texture |
createTexture(Image image,
Texture.Usage usageHint,
Texture.WrapMode wrapMode)
Returns a new
Texture containing the pixels from the given
image with the indicated texture edge wrap mode. |
Texture |
createTexture(Image image,
Texture.Usage usageHint,
Texture.WrapMode wrapMode,
boolean useMipmap)
Returns a new
Texture containing the pixels from the given
image with the indicated texture edge wrap mode. |
Texture |
getCachedTexture(Image image,
Texture.WrapMode wrapMode)
Returns a
Texture for the given image set up to use or
simulate the indicated wrap mode. |
Texture |
getCachedTexture(Image image,
Texture.WrapMode wrapMode,
boolean useMipmap)
Returns a
Texture for the given image set up to use or
simulate the indicated wrap mode. |
protected ResourceFactoryListener[] |
getFactoryListeners() |
Texture |
getGlyphTexture() |
Texture |
getRegionTexture() |
boolean |
isDeviceReady()
Returns status of this graphics device.
|
boolean |
isSuperShaderAllowed() |
boolean |
isWrapModeSupported(Texture.WrapMode mode)
Returns true iff the indicated
wrap mode is directly
supported (i.e. |
protected void |
notifyReleased()
Called when the factory's data is released
|
protected void |
notifyReset()
Called when the factory is reset.
|
void |
removeFactoryListener(ResourceFactoryListener l) |
void |
setGlyphTexture(Texture texture) |
void |
setRegionTexture(Texture texture) |
(package private) static long |
sizeWithMipMap(int w,
int h,
PixelFormat format) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createArcRep, createEllipseRep, createMesh, createMeshView, createPathRep, createPhongMaterial, createPresentable, createRoundRectRep, createRTTexture, createRTTexture, createTexture, createTexture, createTexture, dispose, getMaximumTextureSize, getRTTHeight, getRTTWidth, getTextureResourcePool, isCompatibleTexture, isFormatSupported
private final java.util.WeakHashMap<ResourceFactoryListener,java.lang.Boolean> listenerMap
private Texture regionTexture
private Texture glyphTexture
private boolean superShaderAllowed
public void addFactoryListener(ResourceFactoryListener l)
addFactoryListener
in interface ResourceFactory
public void removeFactoryListener(ResourceFactoryListener l)
removeFactoryListener
in interface ResourceFactory
public boolean isDeviceReady()
ResourceFactory
isDeviceReady
in interface ResourceFactory
protected void clearTextureCache()
protected ResourceFactoryListener[] getFactoryListeners()
protected void notifyReset()
protected void notifyReleased()
static long sizeWithMipMap(int w, int h, PixelFormat format)
public Texture getCachedTexture(Image image, Texture.WrapMode wrapMode)
ResourceFactory
Texture
for the given image set up to use or
simulate the indicated wrap mode.
If no texture could be found in the cache, this method will create a
new texture and put it in the cache before returning it.
NOTE: the caller of this method should not hold a reference to the
cached texture beyond its immediate needs since the cache may be
cleared at any time.getCachedTexture
in interface ResourceFactory
image
- the pixel data to be uploaded if the texture is new or
needs new fringe pixels to simulate a new wrap modewrapMode
- the mode that describes the behavior for samples
outside the content areapublic Texture getCachedTexture(Image image, Texture.WrapMode wrapMode, boolean useMipmap)
ResourceFactory
Texture
for the given image set up to use or
simulate the indicated wrap mode.
If no texture could be found in the cache, this method will create a
new texture and put it in the cache before returning it.
NOTE: the caller of this method should not hold a reference to the
cached texture beyond its immediate needs since the cache may be
cleared at any time.getCachedTexture
in interface ResourceFactory
image
- the pixel data to be uploaded if the texture is new or
needs new fringe pixels to simulate a new wrap modewrapMode
- the mode that describes the behavior for samples
outside the contentuseMipmap
- the flag indicates should mipmapping be used for this
texturepublic Texture createTexture(Image image, Texture.Usage usageHint, Texture.WrapMode wrapMode)
ResourceFactory
Texture
containing the pixels from the given
image with the indicated texture edge wrap mode.
Note that the dimensions of the returned texture may be larger
than those of the given image.
Equivalent to (but perhaps more efficient than):
PixelFormat format = image.getPixelFormat();
int w = image.getWidth();
int h = image.getHeight();
Texture tex = createTexture(format, usageHint, wrapMode, w, h);
tex.update(image, 0, 0, w, h);
createTexture
in interface ResourceFactory
image
- the pixel data to be uploaded to the new textureusageHint
- the Dynamic vs. Static nature of the texture datawrapMode
- the desired edge behavior (clamping vs. wrapping)public Texture createTexture(Image image, Texture.Usage usageHint, Texture.WrapMode wrapMode, boolean useMipmap)
ResourceFactory
Texture
containing the pixels from the given
image with the indicated texture edge wrap mode.
Note that the dimensions of the returned texture may be larger
than those of the given image.
Equivalent to (but perhaps more efficient than):
PixelFormat format = image.getPixelFormat();
int w = image.getWidth();
int h = image.getHeight();
Texture tex = createTexture(format, usageHint, wrapMode, w, h, useMipmap);
tex.update(image, 0, 0, w, h);
createTexture
in interface ResourceFactory
image
- the pixel data to be uploaded to the new textureusageHint
- the Dynamic vs. Static nature of the texture datawrapMode
- the desired edge behavior (clamping vs. wrapping)useMipmap
- the flag indicates should texture be created with mipmappublic Texture createMaskTexture(int width, int height, Texture.WrapMode wrapMode)
createMaskTexture
in interface ResourceFactory
public Texture createFloatTexture(int width, int height)
createFloatTexture
in interface ResourceFactory
public void setRegionTexture(Texture texture)
setRegionTexture
in interface ResourceFactory
public Texture getRegionTexture()
getRegionTexture
in interface ResourceFactory
public void setGlyphTexture(Texture texture)
setGlyphTexture
in interface ResourceFactory
public Texture getGlyphTexture()
getGlyphTexture
in interface ResourceFactory
public boolean isSuperShaderAllowed()
isSuperShaderAllowed
in interface ResourceFactory
protected boolean canClampToZero()
protected boolean canClampToEdge()
protected boolean canRepeat()
public boolean isWrapModeSupported(Texture.WrapMode mode)
ResourceFactory
wrap mode
is directly
supported (i.e. not simulated) by the underlying pipeline and platform.isWrapModeSupported
in interface ResourceFactory
mode
- the desired WrapMode