Top Description Inners Fields Constructors Methods
com.sun.scenario.effect.impl.state

public abstract Class LinearConvolveRenderState

extends Object
implements RenderState
Class Inheritance
All Implemented Interfaces
com.sun.scenario.effect.impl.state.RenderState
Known Direct Subclasses
com.sun.scenario.effect.impl.state.BoxRenderState, com.sun.scenario.effect.impl.state.GaussianRenderState
Imports
com.sun.javafx.PlatformUtil, com.sun.javafx.geom.Rectangle, com.sun.scenario.effect.Color4f, .FilterContext, .ImageData, com.sun.scenario.effect.impl.EffectPeer, .Renderer, java.nio.FloatBuffer

The LinearConvolveRenderState object manages the strategies of applying a 1 or 2 pass linear convolution to an input and calculates the necessary data for the filter shader to compute the convolution. The object is constructed based on the transform that was provided for the entire filter operation and determines its strategy. Methods prefixed by getInput*() return information about the general plan for obtaining and managing the input source image. After the input effect is called with the information from the getInput*() methods and its result ImageData is obtained, the validatePassInput() method is used to examine the size and transform of the supplied input and determine the parameters needed to perform the convolution for the first pass. Once validated, the methods prefixed by getPass*() return information for applying the convolution for that validated pass. If necessary, the validatePassInput() method is called on the results of the first pass to calculate further data for the second pass. Finally the getResultTransform() method is used to possibly transform the final resulting ImageData of the last pass.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
pack-priv static final float[]
public static final int
public static final int
pack-priv static final float

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract int

Returns:

the intended kernel size for the requested pass
getInputKernelSize
(int
the pass for which the intended kernel size is desired
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 getInputKernelSize(int) method.

public abstract int

Returns:

the pixel kernel size of the current pass
getPassKernelSize
()

Returns the appropriate kernel size for the pass that was last validated using validateInput().

public EffectPeer<? extends LinearConvolveRenderState>

Returns:

the EffectPeer to use for this pass, or null
getPassPeer
(Renderer
the Renderer being used for this filter operation
r
,
FilterContext
the FilterContext being used for this filter operation
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.

public abstract Rectangle

Returns:

the bounds of the result image for the current pass
getPassResultBounds
(Rectangle
the bounds of the input image
srcdimension
,
Rectangle
the area needed for the final result
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.

public abstract float[]

Returns:

the array of 4 floats representing the shadow color components
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.

public LinearConvolveRenderState.PassType

Returns:

the appropriate PassType that describes the filtering operation for this pass of the algorithm
getPassType
()

Return a hint about the way that the weights will be applied to the pixels for the currently validated pass.

public abstract float[]

Returns:

an array of 4 floats representing [ incdx, incdy, startdx, startdy ]
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.

public abstract FloatBuffer

Returns:

a FloatBuffer containing the kernel convolution weights
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.

public abstract int

Returns:

the maximum number of valid float4 elements in the weights buffer
getPassWeightsArrayLength
()

Returns the maximum number of valid float4 elements that should be referenced from the buffer returned by getWeights() for the currently validated pass.

public static int

Returns:

the number of convolution weights which will be applied by the associated peer.
getPeerSize
(int
the number of computed convolution kernel weights
ksize
)

Returns the peer sample count for a given kernel size.

public abstract Color4f

Returns:

the Color4f for the shadow color, or null
getShadowColor
()

Returns the Color4f representing the shadow color if this is a shadow operation.

public abstract boolean

Returns:

true if the operation is a global NOP
isNop
()

Returns true if the resulting operation is globally a NOP operation.

public abstract boolean

Returns:

true if the current pass is a NOP
isPassNop
()

Returns true if the operation of the currently validated pass would be a NOP operation.

public abstract boolean

Returns:

true if this is a shadow operation
isShadow
()

Returns true if this is a shadow convolution operation where a constant color is substituted for the color components of the output.

pack-priv static boolean

Returns:

true if the accumulated value will be close enough to size
nearOne
(float
the value being summed across the pixels
v
,
int
the number of pixels being summed across
size
)

Returns true if summing v over size pixels ends up close enough to size.0 that we will not have shifted the sampling by enough to see any changes.

pack-priv static boolean

Returns:

true if the accumulated value will be negligible
nearZero
(float
the value being summed across the pixels
v
,
int
the number of pixels being summed across
size
)

Returns true if summing v over size pixels ends up close enough to 0.0 that we will not have shifted the sampling by enough to see any changes.

public abstract ImageData

Returns:

the ImageData to be used for the actual convolution operation
validatePassInput
(ImageData
the ImageData object supplied by the source effect
src
,
int
the pass of the operation being applied (usually horizontal for pass 0 and vertical for pass 1)
pass
)

Validates the RenderState object for a given pass of the convolution.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BLACK_COMPONENTSback to summary
pack-priv static final float[] BLACK_COMPONENTS
MAX_COMPILED_KERNEL_SIZEback to summary
public static final int MAX_COMPILED_KERNEL_SIZE
MAX_KERNEL_SIZEback to summary
public static final int MAX_KERNEL_SIZE
MIN_EFFECT_RADIUSback to summary
pack-priv static final float MIN_EFFECT_RADIUS

Constructor Detail

LinearConvolveRenderStateback to summary
public LinearConvolveRenderState()

Method Detail

getInputKernelSizeback to summary
public abstract 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 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.

Parameters
pass:int

the pass for which the intended kernel size is desired

Returns:int

the intended kernel size for the requested pass

getPassKernelSizeback to summary
public abstract int getPassKernelSize()

Returns the appropriate kernel size for the pass that was last validated using validateInput().

Returns:int

the pixel kernel size of the current pass

getPassPeerback to summary
public EffectPeer<? extends LinearConvolveRenderState> 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.

Parameters
r:Renderer

the Renderer being used for this filter operation

fctx:FilterContext

the FilterContext being used for this filter operation

Returns:EffectPeer<? extends LinearConvolveRenderState>

the EffectPeer to use for this pass, or null

getPassResultBoundsback to summary
public abstract 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. The image may be further scaled after the shader operation is through to obtain the final result bounds. This value is only of use to the actual shader to understand exactly how much room to allocate for the shader result.

Parameters
srcdimension:Rectangle

the bounds of the input image

outputClip:Rectangle

the area needed for the final result

Returns:Rectangle

the bounds of the result image for the current pass

getPassShadowColorComponentsback to summary
public abstract 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. This method will only be called if isShadow() returns true.

Returns:float[]

the array of 4 floats representing the shadow color components

getPassTypeback to summary
public LinearConvolveRenderState.PassType getPassType()

Return a hint about the way that the weights will be applied to the pixels for the currently validated pass.

Returns:LinearConvolveRenderState.PassType

the appropriate PassType that describes the filtering operation for this pass of the algorithm

getPassVectorback to summary
public abstract 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. The values are stored in the array in the following order:

    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.
Returns:float[]

an array of 4 floats representing [ incdx, incdy, startdx, startdy ]

getPassWeightsback to summary
public abstract 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.

Returns:FloatBuffer

a FloatBuffer containing the kernel convolution weights

getPassWeightsArrayLengthback to summary
public abstract 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.

Returns:int

the maximum number of valid float4 elements in the weights buffer

getPeerSizeback to summary
public static int getPeerSize(int ksize)

Returns the peer sample count for a given kernel size. There are only a few peers defined to operate on specific sizes of convolution kernel. If there are peers defined only for kernel sizes of 8 and 16 and a given effect has a linear convolution kernel with 5 weights, then the peer for size 8 will be used and the buffer of weights must be padded out to the appropriate size with 0s so that the shader constant pool will be fully initialized and the extra unneeded convolution samples will be ignored by the 0 weights.

Parameters
ksize:int

the number of computed convolution kernel weights

Returns:int

the number of convolution weights which will be applied by the associated peer.

getShadowColorback to summary
public abstract Color4f getShadowColor()

Returns the Color4f 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.

Returns:Color4f

the Color4f for the shadow color, or null

isNopback to summary
public abstract boolean isNop()

Returns true if the resulting operation is globally a NOP operation. This condition is calculated at the start of the render operation and is based on whether the perturbations of the convolution kernel would be noticeable at all in the coordinate space of the output.

Returns:boolean

true if the operation is a global NOP

isPassNopback to summary
public abstract boolean isPassNop()

Returns true if the operation of the currently validated pass would be a NOP operation.

Returns:boolean

true if the current pass is a NOP

isShadowback to summary
public abstract boolean isShadow()

Returns true if this is a shadow convolution operation where a constant color is substituted for the color components of the output. This value is dependent only on the original Effect from which this RenderState was instantiated and does not vary as the filter operation progresses.

Returns:boolean

true if this is a shadow operation

nearOneback to summary
pack-priv static boolean nearOne(float v, int size)

Returns true if summing v over size pixels ends up close enough to size.0 that we will not have shifted the sampling by enough to see any changes. "Close enough" in this context is measured by whether or not using the coordinate in a linear interpolating sampling operation on 8-bit per sample images will cause the next pixel over to be blended in.

Parameters
v:float

the value being summed across the pixels

size:int

the number of pixels being summed across

Returns:boolean

true if the accumulated value will be close enough to size

nearZeroback to summary
pack-priv static boolean nearZero(float v, int size)

Returns true if summing v over size pixels ends up close enough to 0.0 that we will not have shifted the sampling by enough to see any changes. "Close enough" in this context is measured by whether or not using the coordinate in a linear interpolating sampling operation on 8-bit per sample images will cause the next pixel over to be blended in.

Parameters
v:float

the value being summed across the pixels

size:int

the number of pixels being summed across

Returns:boolean

true if the accumulated value will be negligible

validatePassInputback to summary
public abstract ImageData validatePassInput(ImageData src, int pass)

Validates the RenderState 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.

Parameters
src:ImageData

the ImageData object supplied by the source effect

pass:int

the pass of the operation being applied (usually horizontal for pass 0 and vertical for pass 1)

Returns:ImageData

the ImageData to be used for the actual convolution operation

com.sun.scenario.effect.impl.state back to summary

public final Enum LinearConvolveRenderState.PassType

extends Enum<LinearConvolveRenderState.PassType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final LinearConvolveRenderState.PassType
GENERAL_VECTOR

The kernel on this pass can be applied in any direction or with any kind of offset.

public static final LinearConvolveRenderState.PassType
HORIZONTAL_CENTERED

The kernel on this pass will be applied horizontally with the kernel centered symmetrically around each pixel.

public static final LinearConvolveRenderState.PassType
VERTICAL_CENTERED

The kernel on this pass will be applied vertically with the kernel centered symmetrically around each pixel.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static LinearConvolveRenderState.PassType
public static LinearConvolveRenderState.PassType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

GENERAL_VECTORback to summary
public static final LinearConvolveRenderState.PassType GENERAL_VECTOR

The kernel on this pass can be applied in any direction or with any kind of offset. No assumptions are made about the offset and delta of the kernel vector.

HORIZONTAL_CENTEREDback to summary
public static final LinearConvolveRenderState.PassType HORIZONTAL_CENTERED

The kernel on this pass will be applied horizontally with the kernel centered symmetrically around each pixel. The specific conditions indicated by this type are:

  • The kernel is an odd size (2*k+1)
  • The data for destination pixel (x,y) is taken from pixels x-k,y through (x+k,y) with the weights applied in that same order.
  • If the bounds of the source image are (x,y,w,h) then the bounds of the destination will be (x-k,y,w+2*k,h).
VERTICAL_CENTEREDback to summary
public static final LinearConvolveRenderState.PassType VERTICAL_CENTERED

The kernel on this pass will be applied vertically with the kernel centered symmetrically around each pixel. The specific conditions indicated by this type are:

  • The kernel is an odd size (2*k+1)
  • The data for destination pixel (x,y) is taken from pixels x,y-k through (x,y+k) with the weights applied in that same order.
  • If the bounds of the source image are (x,y,w,h) then the bounds of the destination will be (x,y-k,w,h+2*k).

Constructor Detail

PassTypeback to summary
private PassType()

Method Detail

valueOfback to summary
public static LinearConvolveRenderState.PassType valueOf(String name)
valuesback to summary
public static LinearConvolveRenderState.PassType[] values()