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

public abstract Class Effect

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.scenario.effect.Identity, com.sun.scenario.effect.Offset, com.sun.javafx.sg.prism.NGCanvas.RenderInput, com.sun.javafx.sg.prism.NGCanvas.EffectInput, com.sun.javafx.sg.prism.NGNode.PassThrough, com.sun.javafx.sg.prism.NGNode.EffectDirtyBoundsHelper, com.sun.javafx.sg.prism.NodeEffectInput, com.sun.scenario.effect.FilterEffect, com.sun.scenario.effect.DelegateEffect
Imports
java.util.ArrayList, .Collections, .List, com.sun.scenario.effect.impl.Renderer, com.sun.scenario.effect.impl.state.AccessHelper, com.sun.javafx.geom.Point2D, .BaseBounds, .DirtyRegionContainer, .DirtyRegionPool, .RectBounds, .Rectangle, com.sun.javafx.geom.transform.BaseTransform

The base class for all filter effects.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Effect.AccelType

A set of values that represent the possible levels of acceleration for an Effect implementation.

Field Summary

Modifier and TypeField and Description
public static final Effect
DefaultInput

A convenient constant for using a readable value to specify a null value for input Effects in method and constructor parameter lists.

private final List<Effect>
private final int
private final List<Effect>

Constructor Summary

AccessConstructor and Description
protected
Effect()

Constructs an Effect with no inputs.

protected
Effect(Effect
the input Effect
input
)

Constructs an Effect with exactly one input.

protected
Effect(Effect
the first input Effect
input1
,
Effect
the second input Effect
input2
)

Constructs an Effect with exactly two inputs.

Method Summary

Modifier and TypeMethod and Description
public static BaseBounds
combineBounds(BaseBounds... inputBounds)

public static Rectangle
combineBounds(Rectangle... inputBounds)

public static Filterable

Returns:

a new image with the given dimensions, or null if one can't be created
createCompatibleImage
(FilterContext
the FilterContext for the target screen device
fctx
,
int
the width of the image
w
,
int
the height of the image
h
)

Returns a new image that is most compatible with the given FilterContext.

protected ImageData
public abstract ImageData

Returns:

the ImageData holding the result of this filter operation or null if the filter had no output or used the renderHelper to render its results directly.
filter
(FilterContext
the FilterContext that determines the environment (e.g. the graphics device or code path) on which the filter operation will be performed
fctx
,
BaseTransform
an optional transform under which the filter and its inputs will be viewed
transform
,
Rectangle
the device space (pixel) bounds of the output image or window or clip into which the result of the Effect will be rendered, or null if the output dimensions are not known.
outputClip
,
Object
an object which might be used to render the results of the effect directly.
renderHelper
,
Effect
the default input Effect to be used in all cases where a filter has a null input.
defaultInput
)

Applies this filter effect to the series of images represented by the input Effects and/or the given defaultInput viewed under the given transform.

public abstract Effect.AccelType

Returns:

one of the AccelType values
getAccelType
(FilterContext fctx)

Returns one of the AccelType values, indicating whether this Effect is accelerated in hardware for the given FilterContext.

public abstract BaseBounds

Returns:

the bounding box of this filter
getBounds
(BaseTransform
the transform the effect will be viewed under
transform
,
Effect
the default input Effect to be used in all cases where a filter has a null input
defaultInput
)

Returns the bounding box that will be affected by this filter operation when viewed under the specified transform, given its list of input Effects and the specified defaultInput effect.

public static Filterable

Returns:

an image with the given dimensions or null if one can't be created
getCompatibleImage
(FilterContext
the FilterContext for the target screen device
fctx
,
int
the width of the image
w
,
int
the height of the image
h
)

Returns an image that is most compatible with the given FilterContext.

pack-priv Effect
getDefaultedInput(int inputIndex, Effect defaultInput)

pack-priv static Effect
getDefaultedInput(Effect listedInput, Effect defaultInput)

public DirtyRegionContainer

Returns:

the dirty region container
getDirtyRegions
(Effect
the default input Effect to be used in all cases where a filter has a null input
defaultInput
,
DirtyRegionPool
the pool of dirty regions
regionPool
)

Returns the dirty region container containing dirty regions affected by this filter operation.

public final List<Effect>

Returns:

the list of input Effects
getInputs
()

Returns the (immutable) list of input Effects, or an empty list if no inputs were specified at construction time.

public int

Returns:

the number of inputs for this Effect
getNumInputs
()

Returns the number of inputs processed by this Effect.

public Rectangle
getResultBounds(BaseTransform transform, Rectangle outputClip, ImageData... inputDatas)

pack-priv Object
getState()

Returns state object that is associated with this effect instance.

public abstract boolean

Returns:

true if this effect may reduce opacity of some pixels of one of it's input (and thus the default input) or it's relevant input(s) might have reduced opaque pixels of the default input already.
reducesOpaquePixels
()

Whether an opacity for any pixel is different (lower) than the corresponding pixel in the default input.

public static void
releaseCompatibleImage(FilterContext
the FilterContext for the target screen device
fctx
,
Filterable
the image to be released
image
)

Releases an image created by the getCompatibleImage() method back into the shared pool.

protected void
setInput(int
the index of the input Effect
index
,
Effect
the input Effect
input
)

Sets the indexed input for this Effect to a specific Effect or to the default input if input is null.

public Point2D

Returns:

the transformed point in the coordinate space of the result
transform
(Point2D
the point in the coordinate space of the primary content input to be transformed
p
,
Effect
the default input Effect to be used in all cases where a filter has a null input
defaultInput
)

Transform the specified point p from the coordinate space of the primary content input to the coordinate space of the effect output.

public static BaseBounds
public Point2D

Returns:

the untransformed point in the coordinate space of the primary content input
untransform
(Point2D
the point in the coordinate space of the result output to be transformed
p
,
Effect
the default input Effect to be used in all cases where a filter has a null input
defaultInput
)

Transform the specified point p from the coordinate space of the output of the effect into the coordinate space of the primary content input.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DefaultInputback to summary
public static final Effect DefaultInput

A convenient constant for using a readable value to specify a null value for input Effects in method and constructor parameter lists. Specifying effect.setInput(DefaultInput) is equivalent to specifying effect.setInput(null).

inputsback to summary
private final List<Effect> inputs
maxInputsback to summary
private final int maxInputs
unmodifiableInputsback to summary
private final List<Effect> unmodifiableInputs

Constructor Detail

Effectback to summary
protected Effect()

Constructs an Effect with no inputs.

Effectback to summary
protected Effect(Effect input)

Constructs an Effect with exactly one input.

Parameters
input:Effect

the input Effect

Effectback to summary
protected Effect(Effect input1, Effect input2)

Constructs an Effect with exactly two inputs.

Parameters
input1:Effect

the first input Effect

input2:Effect

the second input Effect

Method Detail

combineBoundsback to summary
public static BaseBounds combineBounds(BaseBounds... inputBounds)
combineBoundsback to summary
public static Rectangle combineBounds(Rectangle... inputBounds)
createCompatibleImageback to summary
public static Filterable createCompatibleImage(FilterContext fctx, int w, int h)

Returns a new image that is most compatible with the given FilterContext. This method will select the image type that is most appropriate for use with the current rendering pipeline, graphics hardware, and screen pixel layout. The image will be cleared prior to being returned. This method may return null if the image can't be created so callers have to check for return value.

Parameters
fctx:FilterContext

the FilterContext for the target screen device

w:int

the width of the image

h:int

the height of the image

Returns:Filterable

a new image with the given dimensions, or null if one can't be created

Exceptions
IllegalArgumentException:
if gc is null, or if either w or h is non-positive
ensureTransformback to summary
protected ImageData ensureTransform(FilterContext fctx, ImageData original, BaseTransform transform, Rectangle clip)
filterback to summary
public abstract ImageData filter(FilterContext fctx, BaseTransform transform, Rectangle outputClip, Object renderHelper, Effect defaultInput)

Applies this filter effect to the series of images represented by the input Effects and/or the given defaultInput viewed under the given transform. The filter does not need to create pixel data for any pixels that fall outside of the destination device-space (pixel) bounds specified by the outputClip Rectangle.

The filter might be able to use the renderHelper object to render the results directly on its own if the object is not null and implements an interface, such as ImageHelper, that the filter recognizes. If the effect renders itself then it will return a null for the ImageData result.

Note that the ImageData object returned by this method must be validated prior to use with ImageData#validate(com.sun.scenario.effect.FilterContext) method.

      boolean valid;

      do {
          ImageData res = filter(fctx, transform, clip, renderer, defaultInput);
          if (res == null) {
              break;
          }
          if (valid = res.validate(fctx)) {
              // Render res.getImage() to the appropriate destination
              // or use it as an input to another chain of effects.
          }
          res.unref();
      } while (!valid);
      

Parameters
fctx:FilterContext

the FilterContext that determines the environment (e.g. the graphics device or code path) on which the filter operation will be performed

transform:BaseTransform

an optional transform under which the filter and its inputs will be viewed

outputClip:Rectangle

the device space (pixel) bounds of the output image or window or clip into which the result of the Effect will be rendered, or null if the output dimensions are not known.

renderHelper:Object

an object which might be used to render the results of the effect directly.

defaultInput:Effect

the default input Effect to be used in all cases where a filter has a null input.

Returns:ImageData

the ImageData holding the result of this filter operation or null if the filter had no output or used the renderHelper to render its results directly.

getAccelTypeback to summary
public abstract Effect.AccelType getAccelType(FilterContext fctx)

Returns one of the AccelType values, indicating whether this Effect is accelerated in hardware for the given FilterContext.

Returns:Effect.AccelType

one of the AccelType values

getBoundsback to summary
public abstract BaseBounds getBounds(BaseTransform transform, Effect defaultInput)

Returns the bounding box that will be affected by this filter operation when viewed under the specified transform, given its list of input Effects and the specified defaultInput effect. Note that the returned bounds can be smaller or larger than one or more of the inputs.

Parameters
transform:BaseTransform

the transform the effect will be viewed under

defaultInput:Effect

the default input Effect to be used in all cases where a filter has a null input

Returns:BaseBounds

the bounding box of this filter

getCompatibleImageback to summary
public static Filterable getCompatibleImage(FilterContext fctx, int w, int h)

Returns an image that is most compatible with the given FilterContext. This method will select the image type that is most appropriate for use with the current rendering pipeline, graphics hardware, and screen pixel layout. The image will be cleared prior to being returned.

Note that the framework attempts to pool images for recycling purposes whenever possible. Therefore, when finished using an image returned by this method, it is highly recommended that you release the image back to the shared pool for others to use. This method may return null if the image can't be created so callers have to check for return value.

Parameters
fctx:FilterContext

the FilterContext for the target screen device

w:int

the width of the image

h:int

the height of the image

Returns:Filterable

an image with the given dimensions or null if one can't be created

Exceptions
IllegalArgumentException:
if gc is null, or if either w or h is non-positive
See Also
releaseCompatibleImage
getDefaultedInputback to summary
pack-priv Effect getDefaultedInput(int inputIndex, Effect defaultInput)
getDefaultedInputback to summary
pack-priv static Effect getDefaultedInput(Effect listedInput, Effect defaultInput)
getDirtyRegionsback to summary
public DirtyRegionContainer getDirtyRegions(Effect defaultInput, DirtyRegionPool regionPool)

Returns the dirty region container containing dirty regions affected by this filter operation.

Parameters
defaultInput:Effect

the default input Effect to be used in all cases where a filter has a null input

regionPool:DirtyRegionPool

the pool of dirty regions

Returns:DirtyRegionContainer

the dirty region container

getInputsback to summary
public final List<Effect> getInputs()

Returns the (immutable) list of input Effects, or an empty list if no inputs were specified at construction time.

Returns:List<Effect>

the list of input Effects

getNumInputsback to summary
public int getNumInputs()

Returns the number of inputs processed by this Effect.

Returns:int

the number of inputs for this Effect

getResultBoundsback to summary
public Rectangle getResultBounds(BaseTransform transform, Rectangle outputClip, ImageData... inputDatas)
getStateback to summary
pack-priv Object getState()

Returns state object that is associated with this effect instance. Subclasses may override this method to return some sort of state object that contains implementation details that are hidden from the public API. Classes outside this package can use the AccessHelper class to get access to this package-private method.

reducesOpaquePixelsback to summary
public abstract boolean reducesOpaquePixels()

Whether an opacity for any pixel is different (lower) than the corresponding pixel in the default input. It is always safe to return true from this method, though the consequences may be that the caller chooses to not utilize a planned optimization.

Returns:boolean

true if this effect may reduce opacity of some pixels of one of it's input (and thus the default input) or it's relevant input(s) might have reduced opaque pixels of the default input already.

releaseCompatibleImageback to summary
public static void releaseCompatibleImage(FilterContext fctx, Filterable image)

Releases an image created by the getCompatibleImage() method back into the shared pool.

Parameters
fctx:FilterContext

the FilterContext for the target screen device

image:Filterable

the image to be released

See Also
getCompatibleImage
setInputback to summary
protected void setInput(int index, Effect input)

Sets the indexed input for this Effect to a specific Effect or to the default input if input is null.

Parameters
index:int

the index of the input Effect

input:Effect

the input Effect

Exceptions
IllegalArgumentException:
if index is less than zero or greater than or equal to the number of inputs specified at construction time
transformback to summary
public Point2D transform(Point2D p, Effect defaultInput)

Transform the specified point p from the coordinate space of the primary content input to the coordinate space of the effect output. In essence, this method asks the question "Which output coordinate is most affected by the data at the specified coordinate in the primary source input?"

The definition of which input represents the primary content input and how the coordinate space of that input compares to the coordinate space of the result varies from effect to effect. Note that some effects may have a reasonable definition of how to map source coordinates to destination coordinates, but not the reverse. In particular, effects which map source coordinates discontiguously into the result may have several output coordinates that are affected by a given input coordinate and may choose to return one of many equally valid answers, or an undefined result such as NaN, or some other anomalous value. Most effects perform simple transformations of the color of each pixel and so represent an identity transform and return the point unchanged.

Parameters
p:Point2D

the point in the coordinate space of the primary content input to be transformed

defaultInput:Effect

the default input Effect to be used in all cases where a filter has a null input

Returns:Point2D

the transformed point in the coordinate space of the result

transformBoundsback to summary
public static BaseBounds transformBounds(BaseTransform tx, BaseBounds r)
untransformback to summary
public Point2D untransform(Point2D p, Effect defaultInput)

Transform the specified point p from the coordinate space of the output of the effect into the coordinate space of the primary content input. In essence, this method asks the question "Which source coordinate contributes most to the definition of the output at the specified coordinate?"

The definition of which input represents the primary content input and how the coordinate space of that input compares to the coordinate space of the result varies from effect to effect. Note that some effects may have a reasonable definition of how to map destination coordinates back to source coordinates, but not the reverse. In particular, effects which produce entirely synthetic results not based on any content input may not be able to give a meaningful result to this query and may return undefined coordinates such as 0, Infinity, or NaN. Most effects perform simple transformations of the color of each pixel and so represent an identity transform and return the point unchanged.

Parameters
p:Point2D

the point in the coordinate space of the result output to be transformed

defaultInput:Effect

the default input Effect to be used in all cases where a filter has a null input

Returns:Point2D

the untransformed point in the coordinate space of the primary content input

com.sun.scenario.effect back to summary

public final Enum Effect.AccelType

extends Enum<Effect.AccelType>
Class Inheritance

A set of values that represent the possible levels of acceleration for an Effect implementation.
See Also
Effect#getAccelType

Field Summary

Modifier and TypeField and Description
public static final Effect.AccelType
DIRECT3D

Indicates that this Effect is being accelerated in graphics hardware via Direct3D.

public static final Effect.AccelType
FIXED

Indicates that this Effect is implemented in software (i.e., running on the CPU), accelerated using native fixed-point arithmetic.

public static final Effect.AccelType
INTRINSIC

Indicates that this Effect is implemented on top of intrinsic operations built in to the Java 2D APIs.

public static final Effect.AccelType
NONE

Indicates that this Effect is implemented in software (i.e., running on the CPU), without any special acceleration.

public static final Effect.AccelType
OPENGL

Indicates that this Effect is being accelerated in graphics hardware via OpenGL.

public static final Effect.AccelType
SIMD

Indicates that this Effect is implemented in software (i.e., running on the CPU), accelerated using native SIMD instructions (e.g. SSE).

private String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration.

public static Effect.AccelType
public static Effect.AccelType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

DIRECT3Dback to summary
public static final Effect.AccelType DIRECT3D

Indicates that this Effect is being accelerated in graphics hardware via Direct3D.

FIXEDback to summary
public static final Effect.AccelType FIXED

Indicates that this Effect is implemented in software (i.e., running on the CPU), accelerated using native fixed-point arithmetic.

INTRINSICback to summary
public static final Effect.AccelType INTRINSIC

Indicates that this Effect is implemented on top of intrinsic operations built in to the Java 2D APIs.

NONEback to summary
public static final Effect.AccelType NONE

Indicates that this Effect is implemented in software (i.e., running on the CPU), without any special acceleration.

OPENGLback to summary
public static final Effect.AccelType OPENGL

Indicates that this Effect is being accelerated in graphics hardware via OpenGL.

SIMDback to summary
public static final Effect.AccelType SIMD

Indicates that this Effect is implemented in software (i.e., running on the CPU), accelerated using native SIMD instructions (e.g. SSE).

textback to summary
private String text

Constructor Detail

AccelTypeback to summary
private AccelType(String text)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Enum.toString.

Doc from java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists.

Returns:String

the name of this enum constant

Annotations
@Override
valueOfback to summary
public static Effect.AccelType valueOf(String name)
valuesback to summary
public static Effect.AccelType[] values()