public class PerspectiveTransform extends CoreEffect<RenderState>
Effect.AccelType
Modifier and Type | Field and Description |
---|---|
private float[] |
devcoords |
private float |
llx |
private float |
lly |
private float |
lrx |
private float |
lry |
private PerspectiveTransformState |
state |
private float[][] |
tx |
private float |
ulx |
private float |
uly |
private float |
urx |
private float |
ury |
DefaultInput
Constructor and Description |
---|
PerspectiveTransform() |
PerspectiveTransform(Effect input) |
Modifier and Type | Method and Description |
---|---|
ImageData |
filter(FilterContext fctx,
BaseTransform transform,
Rectangle outputClip,
java.lang.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 . |
RectBounds |
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. |
DirtyRegionContainer |
getDirtyRegions(Effect defaultInput,
DirtyRegionPool regionPool)
Returns the dirty region container containing dirty regions affected
by this filter operation.
|
Effect |
getInput()
Returns the input for this
Effect . |
RenderState |
getRenderState(FilterContext fctx,
BaseTransform transform,
Rectangle outputClip,
java.lang.Object renderHelper,
Effect defaultInput)
Returns the object representing the rendering strategy and state for
the filter operation characterized by the specified arguments.
|
Rectangle |
getResultBounds(BaseTransform transform,
Rectangle outputClip,
ImageData... inputDatas) |
(package private) java.lang.Object |
getState()
Returns state object that is associated with this effect instance.
|
boolean |
reducesOpaquePixels()
Whether an opacity for any pixel is different (lower)
than the corresponding pixel in the default input.
|
void |
setInput(Effect input)
Sets the input for this
Effect to a specific
Effect or to the default input if input is
null . |
void |
setQuadMapping(float ulx,
float uly,
float urx,
float ury,
float lrx,
float lry,
float llx,
float lly) |
private void |
setUnitQuadMapping(float ulx,
float uly,
float urx,
float ury,
float lrx,
float lry,
float llx,
float lly)
Sets the transform to map the unit square to the indicated
quadrilateral coordinates.
|
private void |
setupDevCoords(BaseTransform transform) |
private void |
setupTransforms(BaseTransform transform) |
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. |
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. |
filterImageDatas, getAccelType, getPeer, updatePeerKey, updatePeerKey
untransformClip
combineBounds, combineBounds, createCompatibleImage, ensureTransform, getCompatibleImage, getDefaultedInput, getDefaultedInput, getInputs, getNumInputs, releaseCompatibleImage, setInput, transformBounds
private float[][] tx
private float ulx
private float uly
private float urx
private float ury
private float lrx
private float lry
private float llx
private float lly
private float[] devcoords
private final PerspectiveTransformState state
public PerspectiveTransform()
public PerspectiveTransform(Effect input)
java.lang.Object getState()
Effect
public final Effect getInput()
Effect
.Effect
public void setInput(Effect input)
Effect
to a specific
Effect
or to the default input if input
is
null
.input
- the input for this Effect
private void setUnitQuadMapping(float ulx, float uly, float urx, float ury, float lrx, float lry, float llx, float lly)
T(0, 0) = (ulx, uly) T(0, 1) = (urx, ury) T(1, 1) = (lrx, lry) T(1, 0) = (llx, lly)Note that the upper left corner of the unit square
(0, 0)
is mapped to the coordinates specified by (ulx, uly)
and
so on around the unit square in a clockwise direction.ulx
- The X coordinate to which (0, 0)
is mapped.uly
- The Y coordinate to which (0, 0)
is mapped.urx
- The X coordinate to which (1, 0)
is mapped.ury
- The Y coordinate to which (1, 0)
is mapped.lrx
- The X coordinate to which (1, 1)
is mapped.lry
- The Y coordinate to which (1, 1)
is mapped.llx
- The X coordinate to which (0, 1)
is mapped.lly
- The Y coordinate to which (0, 1)
is mapped.public final void setQuadMapping(float ulx, float uly, float urx, float ury, float lrx, float lry, float llx, float lly)
public RectBounds getBounds(BaseTransform transform, Effect defaultInput)
Effect
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.getBounds
in class FilterEffect<RenderState>
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 inputprivate void setupDevCoords(BaseTransform transform)
public ImageData filter(FilterContext fctx, BaseTransform transform, Rectangle outputClip, java.lang.Object renderHelper, Effect defaultInput)
Effect
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);
filter
in class FilterEffect<RenderState>
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 Rectangle getResultBounds(BaseTransform transform, Rectangle outputClip, ImageData... inputDatas)
getResultBounds
in class Effect
public Point2D transform(Point2D p, Effect defaultInput)
Effect
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.
transform
in class FilterEffect<RenderState>
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)
Effect
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.
untransform
in class FilterEffect<RenderState>
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 inputprivate void setupTransforms(BaseTransform transform)
public RenderState getRenderState(FilterContext fctx, BaseTransform transform, Rectangle outputClip, java.lang.Object renderHelper, Effect defaultInput)
FilterEffect
FilterContext
object may be null.
outputClip
and renderHelper
may always be null just
as they may be null for a given filter operation.getRenderState
in class FilterEffect<RenderState>
fctx
- the context object that would be used by the Renderer
if this call is preparing for a render operation, or nulltransform
- the transform for the output of this operationoutputClip
- the clip rectangle that may restrict this operation, or nullrenderHelper
- the rendering helper object that can be used to shortcut
this operation under certain conditions, or nulldefaultInput
- the Effect
to be used in place of any null inputspublic boolean reducesOpaquePixels()
Effect
reducesOpaquePixels
in class Effect
public DirtyRegionContainer getDirtyRegions(Effect defaultInput, DirtyRegionPool regionPool)
Effect
getDirtyRegions
in class Effect
defaultInput
- the default input Effect
to be used in
all cases where a filter has a null inputregionPool
- the pool of dirty regions