T
- an optional subclass of RenderState that can be assumed as the
return value for the getRenderState() methodpublic abstract class EffectPeer<T extends RenderState> extends Object
Effect
implementation peers.Modifier | Constructor and Description |
---|---|
protected |
EffectPeer(FilterContext fctx,
Renderer renderer,
String uniqueName) |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Disposes resources associated with this peer.
|
abstract ImageData |
filter(Effect effect,
T renderState,
BaseTransform transform,
Rectangle outputClip,
ImageData... inputs) |
Effect.AccelType |
getAccelType() |
protected Rectangle |
getDestBounds() |
protected Rectangle |
getDestNativeBounds() |
protected Effect |
getEffect() |
protected FilterContext |
getFilterContext() |
protected Rectangle |
getInputBounds(int inputIndex)
Returns the "valid" bounds of the source image for the given input.
|
protected Rectangle |
getInputNativeBounds(int inputIndex)
Returns the bounds of the native surface for the given input.
|
protected BaseTransform |
getInputTransform(int inputIndex) |
int |
getPass() |
protected Renderer |
getRenderer() |
protected T |
getRenderState() |
Rectangle |
getResultBounds(BaseTransform transform,
Rectangle outputClip,
ImageData... inputDatas) |
protected Object |
getSamplerData(int i) |
protected float[] |
getSourceRegion(int inputIndex)
Returns an array of four floats that represent the mapping of the
data for the specified input to the given effect area.
|
static int |
getTextureCoordinates(float[] coords,
float srcX,
float srcY,
float srcNativeWidth,
float srcNativeHeight,
Rectangle dstBounds,
BaseTransform transform)
Returns either 4 or 8 source texture coordinates depending on the
transform being applied to the source.
|
int |
getTextureCoordinates(int inputIndex,
float[] coords,
float srcX,
float srcY,
float srcNativeWidth,
float srcNativeHeight,
Rectangle dstBounds,
BaseTransform transform)
Returns either 4 or 8 source texture coordinates depending on the
transform being applied to the source.
|
String |
getUniqueName()
Returns the unique name of this peer.
|
boolean |
isImageDataCompatible(ImageData id) |
protected boolean |
isOriginUpperLeft()
Returns true if the native coordinate system has its origin at
the upper-left corner of the destination surface; otherwise, returns
false, indicating that the origin is at the lower-left corner.
|
protected void |
setDestBounds(Rectangle r) |
protected void |
setDestNativeBounds(int w,
int h) |
protected void |
setEffect(Effect effect) |
protected void |
setInputBounds(int inputIndex,
Rectangle r) |
protected void |
setInputNativeBounds(int inputIndex,
Rectangle r) |
protected void |
setInputTransform(int inputIndex,
BaseTransform tx) |
void |
setPass(int pass) |
protected void |
setRenderState(T renderState) |
protected EffectPeer(FilterContext fctx, Renderer renderer, String uniqueName)
public boolean isImageDataCompatible(ImageData id)
public abstract ImageData filter(Effect effect, T renderState, BaseTransform transform, Rectangle outputClip, ImageData... inputs)
public void dispose()
public Effect.AccelType getAccelType()
protected final FilterContext getFilterContext()
protected Renderer getRenderer()
public String getUniqueName()
protected Effect getEffect()
protected void setEffect(Effect effect)
protected T getRenderState()
protected void setRenderState(T renderState)
public final int getPass()
public void setPass(int pass)
protected final Rectangle getInputBounds(int inputIndex)
inputIndex
- the index of the source inputprotected final void setInputBounds(int inputIndex, Rectangle r)
protected final BaseTransform getInputTransform(int inputIndex)
protected final void setInputTransform(int inputIndex, BaseTransform tx)
protected final Rectangle getInputNativeBounds(int inputIndex)
This method is useful in cases where it is necessary to access adjacent pixels in a native surface. For example, the horizontal distance between two texel centers of a native surface can be calculated as (1f/inputNativeBounds.width); for the vertical distance, (1f/inputNativeBounds.height).
inputIndex
- the index of the source inputprotected final void setInputNativeBounds(int inputIndex, Rectangle r)
public Rectangle getResultBounds(BaseTransform transform, Rectangle outputClip, ImageData... inputDatas)
protected float[] getSourceRegion(int inputIndex)
(0,0)
is at the upper-left corner, and (1,1)
is at
the lower-right corner.
The returned array contains the values in order (x1, y1, x2, y2).
The default implementation converts the logical destination effect
region into the coordinate space of the native surface of the
specified source input according to the
getSourceRegion(Rectangle, Rectangle, Rectangle)
method.
Subclasses can override this method to provide more sophisticated positioning behavior.
inputIndex
- the index of the source inputpublic int getTextureCoordinates(int inputIndex, float[] coords, float srcX, float srcY, float srcNativeWidth, float srcNativeHeight, Rectangle dstBounds, BaseTransform transform)
If the mapping is rectilinear then 4 floats are returned. The texture coordinates are thus mapped using the following table:
dx1,dy1 => ret[0], ret[1] dx2,dy1 => ret[2], ret[1] dx1,dy2 => ret[0], ret[3] dx2,dy2 => ret[2], ret[3]If the mapping is non-rectilinear then 8 floats are returned and the texture coordinates are mapped using the following table (note that the dx1,dy1 and dx2,dy2 mappings are still from the same indices as in the 4 float return value):
dx1,dy1 => ret[0], ret[1] dx2,dy1 => ret[4], ret[5] dx1,dy2 => ret[6], ret[7] dx2,dy2 => ret[2], ret[3]The default implementation of this method simply calls the static method
getTextureCoordinates(float[],float,float,float,float,Rectangle,BaseTransform)
.inputIndex
- the index of the input whose texture coordinates
are being queriedcoords
- An array that can hold up to 8 floats for returning
the texture coordinates.srcX
- The X coordinate of the origin of the source texture
in the untransformed coordinate space.srcY
- The Y coordinate of the origin of the source texture
in the untransformed coordinate space.srcNativeWidth
- the native width of the source texturesrcNativeHeight
- the native height of the source texturedstBounds
- the output bounds that the texture is
being stretched overtransform
- the transform to be implicitly applied to the
source texture as it is mapped onto the destinationcoords
array (either 4 or 8)public static int getTextureCoordinates(float[] coords, float srcX, float srcY, float srcNativeWidth, float srcNativeHeight, Rectangle dstBounds, BaseTransform transform)
If the mapping is rectilinear then 4 floats are returned. The texture coordinates are thus mapped using the following table:
dx1,dy1 => ret[0], ret[1] dx2,dy1 => ret[2], ret[1] dx1,dy2 => ret[0], ret[3] dx2,dy2 => ret[2], ret[3]If the mapping is non-rectilinear then 8 floats are returned and the texture coordinates are mapped using the following table (note that the dx1,dy1 and dx2,dy2 mappings are still from the same indices as in the 4 float return value):
dx1,dy1 => ret[0], ret[1] dx2,dy1 => ret[4], ret[5] dx1,dy2 => ret[6], ret[7] dx2,dy2 => ret[2], ret[3]
coords
- An array that can hold up to 8 floats for returning
the texture coordinates.srcX
- The X coordinate of the origin of the source texture
in the untransformed coordinate space.srcY
- The Y coordinate of the origin of the source texture
in the untransformed coordinate space.srcNativeWidth
- the native width of the source texturesrcNativeHeight
- the native height of the source texturedstBounds
- the output bounds that the texture is
being stretched overtransform
- the transform to be implicitly applied to the
source texture as it is mapped onto the destinationcoords
array (either 4 or 8)protected final void setDestBounds(Rectangle r)
protected final Rectangle getDestBounds()
protected final Rectangle getDestNativeBounds()
protected final void setDestNativeBounds(int w, int h)
protected Object getSamplerData(int i)
protected boolean isOriginUpperLeft()
This method may be useful in determining the direction of adjacent pixels in an OpenGL surface (since many OpenGL methods take parameters assuming a lower-left origin).
Copyright © 2020. All rights reserved.