public abstract class BaseTexture<T extends ManagedResource> extends Object implements Texture
Texture.Usage, Texture.WrapMode
Modifier and Type | Field and Description |
---|---|
protected int |
contentHeight |
protected int |
contentWidth |
protected T |
resource |
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(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.
|
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
protected int contentWidth
protected int contentHeight
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()
Texture
PixelFormat
of this texture.getPixelFormat
in interface Texture
PixelFormat
of this texturepublic final int getPhysicalWidth()
Texture
getPhysicalWidth
in interface Texture
public final int getPhysicalHeight()
Texture
getPhysicalHeight
in interface Texture
public final int getContentX()
Texture
getContentX
in interface Texture
public final int getContentY()
Texture
getContentY
in interface Texture
public final int getContentWidth()
Texture
For 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 Texture
public final int getContentHeight()
Texture
For 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 Texture
public int getMaxContentWidth()
Texture
For 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 Texture
public int getMaxContentHeight()
Texture
For 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 Texture
public void setContentWidth(int contentW)
Texture
setContentWidth
in interface Texture
contentW
- The actual new width of user pixels.public void setContentHeight(int contentH)
Texture
setContentHeight
in interface Texture
contentH
- The actual new height of user pixels.public final Texture.WrapMode getWrapMode()
Texture
WrapMode
for this texture.getWrapMode
in interface Texture
WrapMode
for this texturepublic boolean getUseMipmap()
Texture
getUseMipmap
in interface Texture
useMipmap
flag for this texturepublic Texture getSharedTexture(Texture.WrapMode altMode)
Texture
Texture
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 Texture
protected 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()
Texture
getLinearFiltering
in interface Texture
public void setLinearFiltering(boolean linear)
Texture
setLinearFiltering
in interface Texture
linear
- if true, enables linear filtering; if false, enables
nearest neighbor filteringpublic final int getLastImageSerial()
getLastImageSerial
in interface Texture
public final void setLastImageSerial(int serial)
setLastImageSerial
in interface Texture
public final int getLockCount()
getLockCount
in interface Texture
public final void assertLocked()
assertLocked
in interface Texture
public final void makePermanent()
makePermanent
in interface Texture
public final void contentsUseful()
contentsUseful
in interface Texture
public final void contentsNotUseful()
contentsNotUseful
in interface Texture
public final boolean isSurfaceLost()
Texture
isSurfaceLost
in interface Texture
public final void dispose()
dispose
in interface GraphicsResource
public void update(Image img)
Texture
Image
.
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)
Texture
Image
.
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)
Texture
Image
.
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 Texture
img
- 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)
Texture
Image
.
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 Texture
img
- 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(Buffer buf, PixelFormat fmt, int dstx, int dsty, int srcx, int srcy, int srcw, int srch, int srcscan)
Copyright © 2020. All rights reserved.