public abstract class BaseTexture<T extends ManagedResource> extends java.lang.Object implements Texture
Texture.Usage, Texture.WrapMode| Modifier and Type | Field and Description |
|---|---|
protected int |
contentHeight |
protected int |
contentWidth |
private int |
contentX |
private int |
contentY |
private PixelFormat |
format |
private int |
lastImageSerial |
private boolean |
linearFiltering |
private int |
maxContentHeight |
private int |
maxContentWidth |
private int |
physicalHeight |
private int |
physicalWidth |
protected T |
resource |
private boolean |
useMipmap |
private Texture.WrapMode |
wrapMode |
| Modifier | Constructor and Description |
|---|---|
protected |
BaseTexture(BaseTexture<T> sharedTex,
Texture.WrapMode newMode,
boolean useMipmap) |
protected |
BaseTexture(T resource,
PixelFormat format,
Texture.WrapMode wrapMode,
int width,
int height) |
protected |
BaseTexture(T resource,
PixelFormat format,
Texture.WrapMode wrapMode,
int physicalWidth,
int physicalHeight,
int contentX,
int contentY,
int contentWidth,
int contentHeight,
boolean useMipmap) |
protected |
BaseTexture(T resource,
PixelFormat format,
Texture.WrapMode wrapMode,
int physicalWidth,
int physicalHeight,
int contentX,
int contentY,
int contentWidth,
int contentHeight,
int maxContentWidth,
int maxContentHeight,
boolean useMipmap) |
| Modifier and Type | Method and Description |
|---|---|
void |
assertLocked() |
protected void |
checkUpdateParams(java.nio.Buffer buf,
PixelFormat fmt,
int dstx,
int dsty,
int srcx,
int srcy,
int srcw,
int srch,
int srcscan) |
void |
contentsNotUseful() |
void |
contentsUseful() |
protected abstract Texture |
createSharedTexture(Texture.WrapMode newMode)
Create a new version of this texture which shares the same
ManagedResource reference. |
void |
dispose() |
int |
getContentHeight()
Returns the content height of this texture, in pixels.
|
int |
getContentWidth()
Returns the content width of this texture, in pixels.
|
int |
getContentX()
Returns the content x-origin of this texture relative to the upper-left
corner, in pixels.
|
int |
getContentY()
Returns the content y-origin of this texture relative to the upper-left
corner, in pixels.
|
int |
getLastImageSerial() |
boolean |
getLinearFiltering()
Returns whether linear (smooth) filtering will be used when
rendering this texture.
|
int |
getLockCount() |
int |
getMaxContentHeight()
Returns the max content height of this texture, in pixels.
|
int |
getMaxContentWidth()
Returns the max content width of this texture, in pixels.
|
int |
getPhysicalHeight()
Returns the physical height of this texture, in pixels.
|
int |
getPhysicalWidth()
Returns the physical width of this texture, in pixels.
|
PixelFormat |
getPixelFormat()
Returns the
PixelFormat of this texture. |
Texture |
getSharedTexture(Texture.WrapMode altMode)
Constructs an alternate version of this
Texture with an
alternate WrapMode if the two modes allow the underlying texture
to be shared, otherwise a null value is returned. |
boolean |
getUseMipmap()
Returns the true if mipmapping is used for this texture.
|
Texture.WrapMode |
getWrapMode()
Returns the
WrapMode for this texture. |
boolean |
isLocked() |
boolean |
isSurfaceLost()
Called by code wanting to know if the RTTexture's surface is lost.
|
void |
lock() |
void |
makePermanent() |
void |
setContentHeight(int contentH)
Allows the content height, which is the current height of the actual content
in pixels, to be adjusted.
|
void |
setContentWidth(int contentW)
Allows the content width, which is the current width of the actual content
in pixels, to be adjusted.
|
void |
setLastImageSerial(int serial) |
void |
setLinearFiltering(boolean linear)
Sets whether linear filtering will be used when rendering this texture.
|
java.lang.String |
toString() |
void |
unlock() |
void |
update(Image img)
Updates this texture using the contents of the given
Image. |
void |
update(Image img,
int dstx,
int dsty)
Updates this texture using the contents of the given
Image. |
void |
update(Image img,
int dstx,
int dsty,
int w,
int h)
Updates this texture using the contents of the given
Image. |
void |
update(Image img,
int dstx,
int dsty,
int srcw,
int srch,
boolean skipFlush)
Updates this texture using the contents of the given
Image. |
protected final T extends ManagedResource resource
private final PixelFormat format
private final int physicalWidth
private final int physicalHeight
private final int contentX
private final int contentY
protected int contentWidth
protected int contentHeight
private final int maxContentWidth
private final int maxContentHeight
private final Texture.WrapMode wrapMode
private final boolean useMipmap
private boolean linearFiltering
private int lastImageSerial
protected BaseTexture(BaseTexture<T> sharedTex, Texture.WrapMode newMode, boolean useMipmap)
protected BaseTexture(T resource, PixelFormat format, Texture.WrapMode wrapMode, int width, int height)
protected BaseTexture(T resource, PixelFormat format, Texture.WrapMode wrapMode, int physicalWidth, int physicalHeight, int contentX, int contentY, int contentWidth, int contentHeight, boolean useMipmap)
protected BaseTexture(T resource, PixelFormat format, Texture.WrapMode wrapMode, int physicalWidth, int physicalHeight, int contentX, int contentY, int contentWidth, int contentHeight, int maxContentWidth, int maxContentHeight, boolean useMipmap)
public final PixelFormat getPixelFormat()
TexturePixelFormat of this texture.getPixelFormat in interface TexturePixelFormat of this texturepublic final int getPhysicalWidth()
TexturegetPhysicalWidth in interface Texturepublic final int getPhysicalHeight()
TexturegetPhysicalHeight in interface Texturepublic final int getContentX()
TexturegetContentX in interface Texturepublic final int getContentY()
TexturegetContentY in interface Texturepublic final int getContentWidth()
TextureFor example, if the hardware does not support non-power-of-two textures, and you call ResourceFactory.createTexture(400, 200), the returned Texture will have physical dimensions of 512x256, but the content dimensions will be 400x200.
getContentWidth in interface Texturepublic final int getContentHeight()
TextureFor example, if the hardware does not support non-power-of-two textures, and you call ResourceFactory.createTexture(400, 200), the returned Texture will have physical dimensions of 512x256, but the content dimensions will be 400x200.
getContentHeight in interface Texturepublic int getMaxContentWidth()
TextureFor example, if the hardware does not support non-power-of-two textures, and you call ResourceFactory.createTexture(400, 200), the returned Texture will have physical dimensions of 512x256 and the max content dimensions will be 512x256 minus any padding needed by the implementation to simulate edge conditions., but the content dimensions will be 400x200.
getMaxContentWidth in interface Texturepublic int getMaxContentHeight()
TextureFor example, if the hardware does not support non-power-of-two textures, and you call ResourceFactory.createTexture(400, 200), the returned Texture will have physical dimensions of 512x256 and the max content dimensions will be 512x256 minus any padding needed by the implementation to simulate edge conditions., but the content dimensions will be 400x200.
getMaxContentHeight in interface Texturepublic void setContentWidth(int contentW)
TexturesetContentWidth in interface TexturecontentW - The actual new width of user pixels.public void setContentHeight(int contentH)
TexturesetContentHeight in interface TexturecontentH - The actual new height of user pixels.public final Texture.WrapMode getWrapMode()
TextureWrapMode for this texture.getWrapMode in interface TextureWrapMode for this texturepublic boolean getUseMipmap()
TexturegetUseMipmap in interface TextureuseMipmap flag for this texturepublic Texture getSharedTexture(Texture.WrapMode altMode)
TextureTexture with an
alternate WrapMode if the two modes allow the underlying texture
to be shared, otherwise a null value is returned.
This method can only be used to create a shared texture for
REPEAT or CLAMP_TO_EDGE textures, which must
necessarily have content that spans their entire physical dimensions
(if their content was smaller then they would have a _SIMULATED
type of wrap mode).
This method expects the texture to be already locked (and checked for
a valid surface) and if it returns a non-null value then that return
value will have an outstanding lock in addition to retaining the lock
on the original texture.
Note that if the requested WrapMode is the same as the wrap
mode of this texture, then this same object will be returned after
having its lock count increased by 1.
Thus, in all cases, the caller is responsible for locking this texture
before the call, and eventually unlocking this texture after the call,
and also for eventually unlocking the return value if it is non-null.getSharedTexture in interface Textureprotected abstract Texture createSharedTexture(Texture.WrapMode newMode)
ManagedResource reference.
The lock counts for the shared resource reference are not
changed in the processing of this method.newMode - the WrapMode to use for the new texture.Texture object sharing the underlying resource.public final boolean getLinearFiltering()
TexturegetLinearFiltering in interface Texturepublic void setLinearFiltering(boolean linear)
TexturesetLinearFiltering in interface Texturelinear - if true, enables linear filtering; if false, enables
nearest neighbor filteringpublic final int getLastImageSerial()
getLastImageSerial in interface Texturepublic final void setLastImageSerial(int serial)
setLastImageSerial in interface Texturepublic final int getLockCount()
getLockCount in interface Texturepublic final void assertLocked()
assertLocked in interface Texturepublic final void makePermanent()
makePermanent in interface Texturepublic final void contentsUseful()
contentsUseful in interface Texturepublic final void contentsNotUseful()
contentsNotUseful in interface Texturepublic final boolean isSurfaceLost()
TextureisSurfaceLost in interface Texturepublic final void dispose()
dispose in interface GraphicsResourcepublic void update(Image img)
TextureImage.
The upper-left corner of the image data will be positioned
at (contentX, contentY) of the texture, and the full width and height
of the image will be uploaded.
This method will cause the vertex buffer to be flushed prior to
uploading the pixels.
This is equivalent to calling:
update(img, 0, 0);
public void update(Image img, int dstx, int dsty)
TextureImage.
The upper-left corner of the image data will be positioned
at (contentX+dstx, contentY+dsty) of the texture, and the full width
and height of the image will be uploaded.
This method will cause the vertex buffer to be flushed prior to
uploading the pixels.
This is equivalent to calling:
update(img, dstx, dsty, img.getWidth(), img.getHeight());
public void update(Image img, int dstx, int dsty, int w, int h)
TextureImage.
The upper-left corner of the image data will be positioned
at (contentX+dstx, contentY+dsty) of the texture, and the source
region to be uploaded will be srcw by srch pixels.
This method will cause the vertex buffer to be flushed prior to
uploading the pixels.
This is equivalent to calling:
update(img, dstx, dsty, srcw, srch, false);
update in interface Textureimg - the image data to be uploaded to this texturedstx - the x-offset of the image data, in pixels, relative to the
contentX of this texturedsty - the y-offset of the image data, in pixels, relative to the
contentY of this texturew - the width of the pixel region from the source imageh - the height of the pixel region from the source imagepublic void update(Image img, int dstx, int dsty, int srcw, int srch, boolean skipFlush)
TextureImage.
The upper-left corner of the image data will be positioned
at (contentX+dstx, contentY+dsty) of the texture, and the source
region to be uploaded will be srcw by srch pixels.
This method will cause the vertex buffer to be flushed unless
skipFlush is true.
This is equivalent to calling:
update(img.getPixelBuffer(), img.getPixelFormat(),
dstx, dsty, img.getMinX(), img.getMinY(),
srcw, srch, img.getScanlineStride(), skipFlush);
update in interface Textureimg - the image data to be uploaded to this texturedstx - the x-offset of the image data, in pixels, relative to the
contentX of this texturedsty - the y-offset of the image data, in pixels, relative to the
contentY of this texturesrcw - the width of the pixel region from the source imagesrch - the height of the pixel region from the source imageskipFlush - if true, the vertex buffer will not be flushedprotected void checkUpdateParams(java.nio.Buffer buf,
PixelFormat fmt,
int dstx,
int dsty,
int srcx,
int srcy,
int srcw,
int srch,
int srcscan)
public java.lang.String toString()
toString in class java.lang.Object