public abstract class Effect extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Effect.AccelType
A set of values that represent the possible levels of acceleration
for an
Effect implementation. |
Modifier and Type | Field and Description |
---|---|
static Effect |
DefaultInput
A convenient constant for using a readable value to specify
a
null value for input Effect s in method and
constructor parameter lists. |
Modifier | Constructor and Description |
---|---|
protected |
Effect()
Constructs an
Effect with no inputs. |
protected |
Effect(Effect input)
Constructs an
Effect with exactly one input. |
protected |
Effect(Effect input1,
Effect input2)
Constructs an
Effect with exactly two inputs. |
Modifier and Type | Method and Description |
---|---|
static BaseBounds |
combineBounds(BaseBounds... inputBounds) |
static Rectangle |
combineBounds(Rectangle... inputBounds) |
static Filterable |
createCompatibleImage(FilterContext fctx,
int w,
int h)
Returns a new image that is most compatible with the
given
FilterContext . |
protected ImageData |
ensureTransform(FilterContext fctx,
ImageData original,
BaseTransform transform,
Rectangle clip) |
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
Effect s and/or the given defaultInput
viewed under the given transform . |
abstract Effect.AccelType |
getAccelType(FilterContext fctx)
Returns one of the
AccelType values, indicating
whether this Effect is accelerated in hardware for the
given FilterContext . |
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 Effect s and the specified
defaultInput effect. |
static Filterable |
getCompatibleImage(FilterContext fctx,
int w,
int h)
Returns an image that is most compatible with the
given
FilterContext . |
DirtyRegionContainer |
getDirtyRegions(Effect defaultInput,
DirtyRegionPool regionPool)
Returns the dirty region container containing dirty regions affected
by this filter operation.
|
List<Effect> |
getInputs()
Returns the (immutable) list of input
Effect s, or an empty
list if no inputs were specified at construction time. |
int |
getNumInputs()
Returns the number of inputs processed by this
Effect . |
Rectangle |
getResultBounds(BaseTransform transform,
Rectangle outputClip,
ImageData... inputDatas) |
abstract boolean |
reducesOpaquePixels()
Whether an opacity for any pixel is different (lower)
than the corresponding pixel in the default input.
|
static void |
releaseCompatibleImage(FilterContext fctx,
Filterable image)
Releases an image created by the
getCompatibleImage() method
back into the shared pool. |
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 . |
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. |
static BaseBounds |
transformBounds(BaseTransform tx,
BaseBounds r) |
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. |
public static final Effect DefaultInput
null
value for input Effect
s in method and
constructor parameter lists.
Specifying effect.setInput(DefaultInput)
is equivalent
to specifying effect.setInput(null)
.protected Effect()
Effect
with no inputs.protected Effect(Effect input)
Effect
with exactly one input.input
- the input Effect
public int getNumInputs()
Effect
.Effect
public final List<Effect> getInputs()
Effect
s, or an empty
list if no inputs were specified at construction time.Effect
sprotected void setInput(int index, Effect input)
Effect
to a specific
Effect
or to the default input if input
is
null
.index
- the index of the input Effect
input
- the input Effect
IllegalArgumentException
- if index
is less than
zero or greater than or equal to the number of inputs specified
at construction timepublic static BaseBounds combineBounds(BaseBounds... inputBounds)
public Rectangle getResultBounds(BaseTransform transform, Rectangle outputClip, ImageData... inputDatas)
public abstract ImageData filter(FilterContext fctx, BaseTransform transform, Rectangle outputClip, Object renderHelper, Effect defaultInput)
Effect
s 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);
fctx
- the FilterContext
that determines the
environment (e.g. the graphics device or code path) on which
the filter operation will be performedtransform
- an optional transform under which the filter and
its inputs will be viewedoutputClip
- 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
- an object which might be used to render
the results of the effect directly.defaultInput
- the default input Effect
to be used in
all cases where a filter has a null input.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.public static BaseBounds transformBounds(BaseTransform tx, BaseBounds r)
protected ImageData ensureTransform(FilterContext fctx, ImageData original, BaseTransform transform, Rectangle clip)
public DirtyRegionContainer getDirtyRegions(Effect defaultInput, DirtyRegionPool regionPool)
defaultInput
- the default input Effect
to be used in
all cases where a filter has a null inputdrc
- the container of dirty regions in scene coordinates.regionPool
- the pool of dirty regionspublic abstract BaseBounds getBounds(BaseTransform transform, Effect defaultInput)
transform
,
given its list of input Effect
s and the specified
defaultInput
effect.
Note that the returned bounds can be smaller or larger than one
or more of the inputs.transform
- the transform the effect will be viewed underdefaultInput
- the default input Effect
to be used in
all cases where a filter has a null inputpublic Point2D transform(Point2D p, Effect defaultInput)
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.
p
- the point in the coordinate space of the primary content
input to be transformeddefaultInput
- the default input Effect
to be used in
all cases where a filter has a null inputpublic Point2D untransform(Point2D p, Effect defaultInput)
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.
p
- the point in the coordinate space of the result output
to be transformeddefaultInput
- the default input Effect
to be used in
all cases where a filter has a null inputpublic static Filterable createCompatibleImage(FilterContext fctx, int w, int h)
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.fctx
- the FilterContext
for the target screen devicew
- the width of the imageh
- the height of the imageIllegalArgumentException
- if gc
is null, or if
either w
or h
is non-positivepublic static Filterable getCompatibleImage(FilterContext fctx, int w, int h)
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.
fctx
- the FilterContext
for the target screen devicew
- the width of the imageh
- the height of the imageIllegalArgumentException
- if gc
is null, or if
either w
or h
is non-positivereleaseCompatibleImage(com.sun.scenario.effect.FilterContext, com.sun.scenario.effect.Filterable)
public static void releaseCompatibleImage(FilterContext fctx, Filterable image)
getCompatibleImage()
method
back into the shared pool.fctx
- the FilterContext
for the target screen deviceimage
- the image to be releasedgetCompatibleImage(com.sun.scenario.effect.FilterContext, int, int)
public abstract boolean reducesOpaquePixels()
public abstract Effect.AccelType getAccelType(FilterContext fctx)
AccelType
values, indicating
whether this Effect
is accelerated in hardware for the
given FilterContext
.config
- the FilterContext
that will be used
for performing the filter operationAccelType
valuesCopyright © 2020. All rights reserved.