public class BoxRenderState extends LinearConvolveRenderState
LinearConvolveRenderState.PassTypeRenderState.EffectCoordinateSpace| Modifier and Type | Field and Description |
|---|---|
private int |
blurPasses |
private float |
inputSizeH |
private float |
inputSizeV |
private BaseTransform |
inputtx |
private boolean |
isShadow |
private static int[] |
MAX_BOX_SIZES |
private float |
passSize |
private BaseTransform |
resulttx |
private float[] |
samplevectors |
private Color4f |
shadowColor |
private RenderState.EffectCoordinateSpace |
space |
private float |
spread |
private int |
spreadPass |
private boolean |
swCompatible |
private int |
validatedPass |
private java.nio.FloatBuffer |
weights |
private float |
weightsValidSize |
private float |
weightsValidSpread |
BLACK_COMPONENTS, MAX_COMPILED_KERNEL_SIZE, MAX_KERNEL_SIZE, MIN_EFFECT_RADIUSRenderSpaceRenderState, UnclippedUserSpaceRenderState, UserSpaceRenderState| Constructor and Description |
|---|
BoxRenderState(float hsize,
float vsize,
int blurPasses,
float spread,
boolean isShadow,
Color4f shadowColor,
BaseTransform filtertx) |
| Modifier and Type | Method and Description |
|---|---|
int |
getBlurPasses() |
int |
getBoxPixelSize(int pass) |
RenderState.EffectCoordinateSpace |
getEffectTransformSpace()
Return a hint indicating which coordinate space should be used for
the pixel filtering for this particular filtering operation.
|
Rectangle |
getInputClip(int i,
Rectangle filterClip)
Return the clip for the indicated input based on the indicated output
clip.
|
int |
getInputKernelSize(int pass)
Returns the size of the desired convolution kernel for the given pass
as it would be applied in the coordinate space indicated by the
LinearConvolveRenderState.getInputKernelSize(int) method. |
BaseTransform |
getInputTransform(BaseTransform filterTransform)
Return the transform that should be used to obtain pixel input from the
Effect inputs for this filter operation. |
static int |
getKernelSize(int passSize,
int blurPasses) |
static int |
getMaxSizeForKernelSize(int kernelSize,
int blurPasses) |
int |
getPassKernelSize()
Returns the appropriate kernel size for the pass that was last
validated using validateInput().
|
EffectPeer<BoxRenderState> |
getPassPeer(Renderer r,
FilterContext fctx)
Return the
EffectPeer to be used to perform the currently
validated pass of the convolution operation, or null if this pass
is a NOP. |
Rectangle |
getPassResultBounds(Rectangle srcdimension,
Rectangle outputClip)
Returns the size of the scaled result image needed to hold the output
for the currently validated pass with the indicated input dimensions
and output clip.
|
float[] |
getPassShadowColorComponents()
For a shadow convolution operation, return the 4 float versions of
the color components, in the range
[0, 1] for the shadow color
to be substituted for the input colors. |
float[] |
getPassVector()
Returns an array of 4 floats used to initialize a float4 Shader
constant with the relative starting location of the first weight
in the convolution kernel and the incremental offset between each
sample to be weighted and accumulated.
|
java.nio.FloatBuffer |
getPassWeights()
A
FloatBuffer padded out to the required size as specified by
the #getPeerSize() method filled with the convolution weights
needed for the currently validated pass. |
int |
getPassWeightsArrayLength()
Returns the maximum number of valid float4 elements that should be
referenced from the buffer returned by getWeights() for the currently
validated pass.
|
BaseTransform |
getResultTransform(BaseTransform filterTransform)
Return the transform that should be used to transform the results of
the filter operation.
|
Color4f |
getShadowColor()
Returns the
Color4f representing the shadow color if this
is a shadow operation. |
float |
getSpread() |
boolean |
isNop()
Returns true if the resulting operation is globally a NOP operation.
|
boolean |
isPassNop()
Returns true if the operation of the currently validated pass would
be a NOP operation.
|
boolean |
isShadow()
Returns true if this is a shadow convolution operation where a
constant color is substituted for the color components of the
output.
|
ImageData |
validatePassInput(ImageData src,
int pass)
Validates the
RenderState object for a given pass of the
convolution. |
private void |
validateWeights() |
getPassType, getPeerSize, nearOne, nearZeroprivate static final int[] MAX_BOX_SIZES
private final boolean isShadow
private final int blurPasses
private final float spread
private Color4f shadowColor
private RenderState.EffectCoordinateSpace space
private BaseTransform inputtx
private BaseTransform resulttx
private final float inputSizeH
private final float inputSizeV
private final int spreadPass
private float[] samplevectors
private int validatedPass
private float passSize
private java.nio.FloatBuffer weights
private float weightsValidSize
private float weightsValidSpread
private boolean swCompatible
public BoxRenderState(float hsize,
float vsize,
int blurPasses,
float spread,
boolean isShadow,
Color4f shadowColor,
BaseTransform filtertx)
public static int getMaxSizeForKernelSize(int kernelSize,
int blurPasses)
public static int getKernelSize(int passSize,
int blurPasses)
public int getBoxPixelSize(int pass)
public int getBlurPasses()
public float getSpread()
public boolean isShadow()
LinearConvolveRenderStateEffect from which
this RenderState was instantiated and does not vary as the
filter operation progresses.isShadow in class LinearConvolveRenderStatepublic Color4f getShadowColor()
LinearConvolveRenderStateColor4f representing the shadow color if this
is a shadow operation.
This value is dependent only on the original Effect from which
this RenderState was instantiated and does not vary as the
filter operation progresses.getShadowColor in class LinearConvolveRenderStateColor4f for the shadow color, or nullpublic float[] getPassShadowColorComponents()
LinearConvolveRenderState[0, 1] for the shadow color
to be substituted for the input colors.
This method will only be called if LinearConvolveRenderState.isShadow() returns true.getPassShadowColorComponents in class LinearConvolveRenderStatepublic RenderState.EffectCoordinateSpace getEffectTransformSpace()
RenderStategetEffectTransform() and getResultTransform() methods will always be used to get the actual
transforms to be used to get input data and transform the results, but
this method can help to set the expectations of the caller to optimize
techniques.EffectSpace value to describe the expected output
from the getEffectTransform(...) and getResultTransform(...)
methods.public BaseTransform getInputTransform(BaseTransform filterTransform)
RenderStateEffect inputs for this filter operation.
The returned transform is handed to all input Effect objects
to obtain pixel data for the inputs.
Typically, the output of getInputTransform(transform) and
getResultTransform(transform) could be concatenated to produce
the original filterTransform.filterTransform - the BaseTransform object for the filter operationBaseTransform object to use for the input effectspublic BaseTransform getResultTransform(BaseTransform filterTransform)
RenderStategetInputTransform(transform) and
getResultTransform(transform) could be concatenated to produce
the original filterTransform.filterTransform - the BaseTransform object for the filter operationBaseTransform object to be applied to the result
texturepublic EffectPeer<BoxRenderState> getPassPeer(Renderer r, FilterContext fctx)
LinearConvolveRenderStateEffectPeer to be used to perform the currently
validated pass of the convolution operation, or null if this pass
is a NOP.getPassPeer in class LinearConvolveRenderStater - the Renderer being used for this filter operationfctx - the FilterContext being used for this filter operationEffectPeer to use for this pass, or nullpublic Rectangle getInputClip(int i, Rectangle filterClip)
RenderStatei - the index of the input being processedfilterClip - the output clip supplied to the given filter operationpublic ImageData validatePassInput(ImageData src, int pass)
LinearConvolveRenderStateRenderState object for a given pass of the
convolution.
The supplied source image is provided so that the RenderState
object can determine if it needs to change its strategy for how the
convolution operation will be performed and to scale its data for
the getPass*() methods relative to the source dimensions and
transform.validatePassInput in class LinearConvolveRenderStatesrc - the ImageData object supplied by the source effectpass - the pass of the operation being applied (usually horizontal
for pass 0 and vertical for pass 1)ImageData to be used for the actual convolution
operationpublic Rectangle getPassResultBounds(Rectangle srcdimension, Rectangle outputClip)
LinearConvolveRenderStategetPassResultBounds in class LinearConvolveRenderStatesrcdimension - the bounds of the input imageoutputClip - the area needed for the final resultpublic float[] getPassVector()
LinearConvolveRenderState
shadervec.x = vector[0] = incdx // X delta between subsequent samples
shadervec.y = vector[1] = incdy // Y delta between subsequent samples
shadervec.z = vector[2] = startdx // X offset to first convolution sample
shadervec.w = vector[3] = startdy // Y offset to first convolution sample
These values are used in the shader loop as follows:
samplelocation = outputpixellocation.xy + shadervec.zw;
for (each weight) {
sum += weight * sample(samplelocation.xy);
samplelocation.xy += shadervec.xy;
}
The values are relative to the texture coordinate space which are
normalized to the range [0,1] over the source texture.getPassVector in class LinearConvolveRenderState[ incdx, incdy, startdx, startdy ]public int getPassWeightsArrayLength()
LinearConvolveRenderStategetPassWeightsArrayLength in class LinearConvolveRenderStatepublic java.nio.FloatBuffer getPassWeights()
LinearConvolveRenderStateFloatBuffer padded out to the required size as specified by
the #getPeerSize() method filled with the convolution weights
needed for the currently validated pass.getPassWeights in class LinearConvolveRenderStateFloatBuffer containing the kernel convolution weightsprivate void validateWeights()
public int getInputKernelSize(int pass)
LinearConvolveRenderStateLinearConvolveRenderState.getInputKernelSize(int) method.
This value is calculated at the start of the render operation and
does not vary as the filter operation progresses, but it may not
represent the actual kernel size used when the indicated pass actually
occurs if the #validatePassInput() method needs to choose
different values when it sees the incoming image source.getInputKernelSize in class LinearConvolveRenderStatepass - the pass for which the intended kernel size is desiredpublic int getPassKernelSize()
LinearConvolveRenderStategetPassKernelSize in class LinearConvolveRenderStatepublic boolean isNop()
LinearConvolveRenderStateisNop in class LinearConvolveRenderStatepublic boolean isPassNop()
LinearConvolveRenderStateisPassNop in class LinearConvolveRenderState