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

public abstract Class EffectPeer<T extends RenderState>

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.scenario.effect.impl.prism.PrCropPeer, com.sun.scenario.effect.impl.prism.PrFloodPeer, com.sun.scenario.effect.impl.prism.PrMergePeer, com.sun.scenario.effect.impl.prism.PrReflectionPeer, com.sun.scenario.effect.impl.prism.ps.PPSEffectPeer, com.sun.scenario.effect.impl.prism.ps.PPStoPSWDisplacementMapPeer, com.sun.scenario.effect.impl.sw.java.JSWEffectPeer, com.sun.scenario.effect.impl.sw.sse.SSEEffectPeer
Type Parameters
<T>
an optional subclass of RenderState that can be assumed as the return value for the getRenderState() method
Imports
com.sun.scenario.effect.Effect, .Effect.AccelType, .FilterContext, .ImageData, com.sun.javafx.geom.Rectangle, com.sun.javafx.geom.transform.BaseTransform, .NoninvertibleTransformException, com.sun.scenario.effect.impl.state.RenderState

The abstract base class for all Effect implementation peers.

Field Summary

Modifier and TypeField and Description
private Rectangle
private final Rectangle
private Effect
private final FilterContext
private final Rectangle[]
private final Rectangle[]
private final BaseTransform[]
private int
private final Renderer
private T
private final String

Constructor Summary

AccessConstructor and Description
protected
EffectPeer(FilterContext fctx, Renderer renderer, String uniqueName)

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Disposes resources associated with this peer.

public abstract ImageData
filter(Effect effect, T renderState, BaseTransform transform, Rectangle outputClip, ImageData... inputs)

public Effect.AccelType
protected final Rectangle
protected final Rectangle
protected Effect
protected final FilterContext
protected final Rectangle

Returns:

the valid bounds of the source Image
getInputBounds
(int
the index of the source input
inputIndex
)

Returns the "valid" bounds of the source image for the given input.

protected final Rectangle

Returns:

the native surface bounds
getInputNativeBounds
(int
the index of the source input
inputIndex
)

Returns the bounds of the native surface for the given input.

protected final BaseTransform
getInputTransform(int inputIndex)

public final int
protected Renderer
protected T
public Rectangle
getResultBounds(BaseTransform transform, Rectangle outputClip, ImageData... inputDatas)

protected Object
protected float[]

Returns:

an array of four float values
getSourceRegion
(int
the index of the source input
inputIndex
)

Returns an array of four floats that represent the mapping of the data for the specified input to the given effect area.

pack-priv static float[]

Returns:

an array of four float values
getSourceRegion
(Rectangle
the logical bounds of the input data
srcBounds
,
Rectangle
the actual dimensions of the input image containing the input data in its upper left
srcNativeBounds
,
Rectangle
the logical bounds of the resulting effect output
dstBounds
)

Returns an array of four floats that represent the mapping of the specified source region for the specified effect area.

public int

Returns:

the number of texture coordinates stored in the coords array (either 4 or 8)
getTextureCoordinates
(int
the index of the input whose texture coordinates are being queried
inputIndex
,
float[]
An array that can hold up to 8 floats for returning the texture coordinates.
coords
,
float
The X coordinate of the origin of the source texture in the untransformed coordinate space.
srcX
,
float
The Y coordinate of the origin of the source texture in the untransformed coordinate space.
srcY
,
float
the native width of the source texture
srcNativeWidth
,
float
the native height of the source texture
srcNativeHeight
,
Rectangle
the output bounds that the texture is being stretched over
dstBounds
,
BaseTransform
the transform to be implicitly applied to the source texture as it is mapped onto the destination
transform
)

Returns either 4 or 8 source texture coordinates depending on the transform being applied to the source.

public static int

Returns:

the number of texture coordinates stored in the coords array (either 4 or 8)
getTextureCoordinates
(float[]
An array that can hold up to 8 floats for returning the texture coordinates.
coords
,
float
The X coordinate of the origin of the source texture in the untransformed coordinate space.
srcX
,
float
The Y coordinate of the origin of the source texture in the untransformed coordinate space.
srcY
,
float
the native width of the source texture
srcNativeWidth
,
float
the native height of the source texture
srcNativeHeight
,
Rectangle
the output bounds that the texture is being stretched over
dstBounds
,
BaseTransform
the transform to be implicitly applied to the source texture as it is mapped onto the destination
transform
)

Returns either 4 or 8 source texture coordinates depending on the transform being applied to the source.

public String

Returns:

the unique name of this peer
getUniqueName
()

Returns the unique name of this peer.

public boolean
protected boolean

Returns:

true if the coordinate system has an upper-left origin
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 final void
protected final void
setDestNativeBounds(int w, int h)

protected void
setEffect(Effect effect)

protected final void
setInputBounds(int inputIndex, Rectangle r)

protected final void
setInputNativeBounds(int inputIndex, Rectangle r)

protected final void
setInputTransform(int inputIndex, BaseTransform tx)

public void
setPass(int pass)

protected void
setRenderState(T renderState)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

destBoundsback to summary
private Rectangle destBounds
destNativeBoundsback to summary
private final Rectangle destNativeBounds
effectback to summary
private Effect effect
fctxback to summary
private final FilterContext fctx
inputBoundsback to summary
private final Rectangle[] inputBounds
inputNativeBoundsback to summary
private final Rectangle[] inputNativeBounds
inputTransformsback to summary
private final BaseTransform[] inputTransforms
passback to summary
private int pass
rendererback to summary
private final Renderer renderer
renderStateback to summary
private T renderState
uniqueNameback to summary
private final String uniqueName

Constructor Detail

EffectPeerback to summary
protected EffectPeer(FilterContext fctx, Renderer renderer, String uniqueName)

Method Detail

disposeback to summary
public void dispose()

Disposes resources associated with this peer.

Warning

may be called from the rendering thread.

filterback to summary
public abstract ImageData filter(Effect effect, T renderState, BaseTransform transform, Rectangle outputClip, ImageData... inputs)
getAccelTypeback to summary
public Effect.AccelType getAccelType()
getDestBoundsback to summary
protected final Rectangle getDestBounds()
getDestNativeBoundsback to summary
protected final Rectangle getDestNativeBounds()
getEffectback to summary
protected Effect getEffect()
getFilterContextback to summary
protected final FilterContext getFilterContext()
getInputBoundsback to summary
protected final Rectangle getInputBounds(int inputIndex)

Returns the "valid" bounds of the source image for the given input. Since Effect implementations try to recycle temporary Images, it is quite possible that the input bounds returned by this method will differ from the size of the associated input Image. For example, this method may return (0, 0, 210, 180) even though the associated Image has dimensions of 230x200 pixels. Pixels in the input Image outside these "valid" bounds are undefined and should be avoided.

Parameters
inputIndex:int

the index of the source input

Returns:Rectangle

the valid bounds of the source Image

getInputNativeBoundsback to summary
protected final Rectangle getInputNativeBounds(int inputIndex)

Returns the bounds of the native surface for the given input. It is quite possible that the input native bounds returned by this method will differ from the size of the associated input (Java-level) Image. This is common for the OGL and D3D backends of Java 2D, where on older hardware the dimensions of a VRAM surface (e.g. texture) must be a power of two. For example, this method may return (0, 0, 256, 256) even though the associated (Volatile)Image has dimensions of 230x200 pixels.

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).

Parameters
inputIndex:int

the index of the source input

Returns:Rectangle

the native surface bounds

getInputTransformback to summary
protected final BaseTransform getInputTransform(int inputIndex)
getPassback to summary
public final int getPass()
getRendererback to summary
protected Renderer getRenderer()
getRenderStateback to summary
protected T getRenderState()
getResultBoundsback to summary
public Rectangle getResultBounds(BaseTransform transform, Rectangle outputClip, ImageData... inputDatas)
getSamplerDataback to summary
protected Object getSamplerData(int i)
getSourceRegionback to summary
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. The interpretation of the returned values is entirely dependent on the algorithm of the pixel shader, but typical values are in the "unit" coordinate space of the destination effect area, where (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.

Parameters
inputIndex:int

the index of the source input

Returns:float[]

an array of four float values

getSourceRegionback to summary
pack-priv static float[] getSourceRegion(Rectangle srcBounds, Rectangle srcNativeBounds, Rectangle dstBounds)

Returns an array of four floats that represent the mapping of the specified source region for the specified effect area. The returned values are in the "unit" coordinate space of the source native surface, where (0,0) is at the upper-left corner, and (1,1) is at the lower-right corner. For example, if the native input surface (i.e. texture) is 256x256 pixels, and the effect output region is at the same coordinates as the input region and is 200x200, this method will return (0, 0, 200/256, 220/256). The returned array contains the values in order (x1, y1, x2, y2).

Subclasses can override this method to provide more sophisticated positioning behavior.

Parameters
srcBounds:Rectangle

the logical bounds of the input data

srcNativeBounds:Rectangle

the actual dimensions of the input image containing the input data in its upper left

dstBounds:Rectangle

the logical bounds of the resulting effect output

Returns:float[]

an array of four float values

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

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).
Parameters
inputIndex:int

the index of the input whose texture coordinates are being queried

coords:float[]

An array that can hold up to 8 floats for returning the texture coordinates.

srcX:float

The X coordinate of the origin of the source texture in the untransformed coordinate space.

srcY:float

The Y coordinate of the origin of the source texture in the untransformed coordinate space.

srcNativeWidth:float

the native width of the source texture

srcNativeHeight:float

the native height of the source texture

dstBounds:Rectangle

the output bounds that the texture is being stretched over

transform:BaseTransform

the transform to be implicitly applied to the source texture as it is mapped onto the destination

Returns:int

the number of texture coordinates stored in the coords array (either 4 or 8)

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

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]
Parameters
coords:float[]

An array that can hold up to 8 floats for returning the texture coordinates.

srcX:float

The X coordinate of the origin of the source texture in the untransformed coordinate space.

srcY:float

The Y coordinate of the origin of the source texture in the untransformed coordinate space.

srcNativeWidth:float

the native width of the source texture

srcNativeHeight:float

the native height of the source texture

dstBounds:Rectangle

the output bounds that the texture is being stretched over

transform:BaseTransform

the transform to be implicitly applied to the source texture as it is mapped onto the destination

Returns:int

the number of texture coordinates stored in the coords array (either 4 or 8)

getUniqueNameback to summary
public String getUniqueName()

Returns the unique name of this peer. This value can be used as the key value in a hashmap of cached peer instances. In the case of hardware peers, this value is typically the name of the shader that is used by the peer.

Returns:String

the unique name of this peer

isImageDataCompatibleback to summary
public boolean isImageDataCompatible(ImageData id)
isOriginUpperLeftback to summary
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.

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).

Returns:boolean

true if the coordinate system has an upper-left origin

setDestBoundsback to summary
protected final void setDestBounds(Rectangle r)
setDestNativeBoundsback to summary
protected final void setDestNativeBounds(int w, int h)
setEffectback to summary
protected void setEffect(Effect effect)
setInputBoundsback to summary
protected final void setInputBounds(int inputIndex, Rectangle r)
setInputNativeBoundsback to summary
protected final void setInputNativeBounds(int inputIndex, Rectangle r)
setInputTransformback to summary
protected final void setInputTransform(int inputIndex, BaseTransform tx)
setPassback to summary
public void setPass(int pass)
setRenderStateback to summary
protected void setRenderState(T renderState)