public abstract class NGNode
extends java.lang.Object
During synchronization, the FX scene graph will pass down to us the transform which takes us from local space to parent space, the content bounds (ie: geom bounds), and the transformed bounds (ie: boundsInParent), and the clippedBounds. The effect bounds have already been passed to the Effect peer (if there is one).
Whenever the transformedBounds of the NGNode are changed, we update the dirtyBounds, so that the next time we need to accumulate dirty regions, we will have the information we need to make sure we create an appropriate dirty region.
NGNode maintains a single "dirty" flag, which indicates that this node itself is dirty and must contribute to the dirty region. More specifically, it indicates that this node is now dirty with respect to the back buffer. Any rendering of the scene which will go on the back buffer will cause the dirty flag to be cleared, whereas a rendering of the scene which is for an intermediate image will not clear this dirty flag.
Modifier and Type | Class and Description |
---|---|
static class |
NGNode.DirtyFlag |
private static class |
NGNode.EffectDirtyBoundsHelper |
private static class |
NGNode.PassThrough
A custom effect implementation that has a filter() method that
simply wraps the given pre-rendered PrDrawable in an ImageData
and returns that result.
|
protected static class |
NGNode.RenderRootResult
*
Identifying render roots *
*
|
Modifier and Type | Field and Description |
---|---|
private CacheFilter |
cacheFilter
A filter used when the node is cached.
|
protected boolean |
childDirty
If this node is an NGGroup, then this flag will be used to indicate
whether one or more of its children is dirty.
|
private NGNode |
clipNode
The node used for specifying the clipping shape for this node.
|
protected BaseBounds |
contentBounds
The cached bounds.
|
protected int |
cullingBits
Marks position of this node in dirty regions.
|
private boolean |
depthTest
The depth test flag for this node.
|
protected NGNode.DirtyFlag |
dirty
Indicates that this NGNode is itself dirty and needs its full bounds
included in the next repaint.
|
protected static int |
DIRTY_CHILDREN_ACCUMULATED_THRESHOLD
Do not iterate over all children in group.
|
(package private) static int |
DIRTY_REGION_CONTAINS_NODE_BOUNDS |
(package private) static int |
DIRTY_REGION_CONTAINS_OR_INTERSECTS_NODE_BOUNDS |
(package private) static int |
DIRTY_REGION_INTERSECTS_NODE_BOUNDS
Statics for defining what the culling bits are.
|
(package private) BaseBounds |
dirtyBounds
We keep a reference to the last transform bounds that were valid
and known.
|
protected int |
dirtyChildrenAccumulated
How many children are going to be accumulated
|
private EffectFilter |
effectFilter
A filter used whenever an effect is placed on the node.
|
private static java.lang.Boolean |
effectsSupported |
private DirtyHint |
hint |
private boolean |
isClip
True if this node is a clip.
|
private java.lang.String |
name
Used for debug purposes.
|
private Blend.Mode |
nodeBlendMode
The blend mode that controls how the pixels of this node blend into
the rest of the scene behind it.
|
private float |
opacity
The opacity of this node.
|
private RectBounds |
opaqueRegion
A cached representation of the opaque region for this node.
|
private boolean |
opaqueRegionInvalid
To avoid object churn we keep opaqueRegion around, and just toggle this
boolean to indicate whether we need to recompute the opaqueRegion.
|
private int |
painted
Used for debug purposes.
|
private NGNode |
parent
The parent of the node.
|
private static GraphicsPipeline |
pipeline |
private static BoxBounds |
TEMP_BOUNDS
Temporary bounds for use by this class or subclasses, designed to
reduce the amount of garbage we generate.
|
private static Point2D[] |
TEMP_POINTS2D_4 |
private static RectBounds |
TEMP_RECT_BOUNDS |
protected static Affine3D |
TEMP_TRANSFORM |
private BaseTransform |
transform
The transform for this node.
|
protected BaseBounds |
transformedBounds
The cached transformed bounds.
|
private boolean |
visible
Whether the node is visible.
|
Modifier | Constructor and Description |
---|---|
protected |
NGNode() |
Modifier and Type | Method and Description |
---|---|
int |
accumulateDirtyRegions(RectBounds clip,
RectBounds dirtyRegionTemp,
DirtyRegionPool regionPool,
DirtyRegionContainer dirtyRegionContainer,
BaseTransform tx,
GeneralTransform3D pvTx)
Accumulates and returns the dirty regions in transformed coordinates for
this node.
|
(package private) int |
accumulateGroupDirtyRegion(RectBounds clip,
RectBounds dirtyRegionTemp,
DirtyRegionPool regionPool,
DirtyRegionContainer dirtyRegionContainer,
BaseTransform tx,
GeneralTransform3D pvTx)
Accumulates the dirty region of an NGGroup.
|
(package private) int |
accumulateNodeDirtyRegion(RectBounds clip,
RectBounds dirtyRegionTemp,
DirtyRegionContainer dirtyRegionContainer,
BaseTransform tx,
GeneralTransform3D pvTx)
Accumulates the dirty region of a node.
|
void |
applyClip(BaseBounds clipBounds,
DirtyRegionContainer drc) |
void |
applyEffect(EffectFilter effectFilter,
DirtyRegionContainer drc,
DirtyRegionPool regionPool) |
void |
applyTransform(BaseTransform tx,
DirtyRegionContainer drc) |
private static int |
ccw(double px,
double py,
Point2D a,
Point2D b) |
(package private) static boolean |
checkBoundsInQuad(RectBounds untransformedQuad,
RectBounds innerBounds,
BaseTransform tx,
GeneralTransform3D pvTx) |
protected void |
clearDirty()
Clears the dirty flag.
|
void |
clearDirtyTree() |
void |
clearPainted()
Walks down the tree clearing the "painted" bits for each node.
|
private BaseBounds |
computeBounds(BaseBounds bounds,
BaseTransform tx) |
private BaseBounds |
computeDirtyRegion(RectBounds dirtyRegionTemp,
BaseTransform tx,
GeneralTransform3D pvTx)
Computes the dirty region for this Node.
|
(package private) NGNode.RenderRootResult |
computeNodeRenderRoot(NodePath path,
RectBounds dirtyRegion,
int cullingIndex,
BaseTransform tx,
GeneralTransform3D pvTx)
Check if this node can serve as rendering root for this dirty region.
|
protected RectBounds |
computeOpaqueRegion(RectBounds opaqueRegion)
Computes and returns the opaque region for this node.
|
protected BaseBounds |
computePadding(BaseBounds region)
LCD Text creates some painful situations where, due to the LCD text
algorithm, we end up with some pixels touched that are normally outside
the bounds.
|
(package private) NGNode.RenderRootResult |
computeRenderRoot(NodePath path,
RectBounds dirtyRegion,
int cullingIndex,
BaseTransform tx,
GeneralTransform3D pvTx)
Searches for the last node that covers all of the specified dirty region with an opaque region,
in this node's subtree.
|
void |
doPreCulling(DirtyRegionContainer drc,
BaseTransform tx,
GeneralTransform3D pvTx)
Culling support for multiple dirty regions.
|
protected void |
doRender(Graphics g)
Invoked only by the final render method.
|
void |
drawDirtyOpts(BaseTransform tx,
GeneralTransform3D pvTx,
Rectangle clipBounds,
int[] colorBuffer,
int dirtyRegionIndex)
Helper method draws rectangles indicating the overdraw rectangles.
|
void |
effectChanged()
Called by the FX scene graph when an effect in the effect chain on the node
changes internally.
|
protected void |
geometryChanged() |
CacheFilter |
getCacheFilter() |
NGNode |
getClipNode() |
BaseBounds |
getClippedBounds(BaseBounds bounds,
BaseTransform tx) |
BaseBounds |
getCompleteBounds(BaseBounds bounds,
BaseTransform tx) |
BaseBounds |
getContentBounds(BaseBounds bounds,
BaseTransform tx) |
protected Effect |
getEffect() |
BaseBounds |
getEffectBounds(BaseBounds bounds,
BaseTransform tx) |
EffectFilter |
getEffectFilter() |
(package private) static FilterContext |
getFilterContext(Graphics g)
*
Filters (Cache, Effect, etc).
|
java.lang.String |
getName()
Used for debug purposes.
|
Blend.Mode |
getNodeBlendMode() |
float |
getOpacity() |
RectBounds |
getOpaqueRegion()
Gets the opaque region for this node, if there is one, or returns null.
|
NGNode |
getParent()
Gets the parent of this node.
|
void |
getRenderRoot(NodePath path,
RectBounds dirtyRegion,
int cullingIndex,
BaseTransform tx,
GeneralTransform3D pvTx)
Called after preCullingBits in order to get the node
from which we should begin drawing.
|
BaseTransform |
getTransform() |
protected boolean |
hasOpaqueRegion()
Called only on NGNode subclasses which override
supportsOpaqueRegions() to return
true, this method will return whether or not this NGNode is in a state where it has
an opaque region to actually return. |
protected abstract boolean |
hasOverlappingContents() |
protected boolean |
hasVisuals()
Marks if the node has some visuals and that the bounds change
should be taken into account when using the dirty region.
|
protected void |
invalidateCache()
Invalidates the cache, if it is in use.
|
protected void |
invalidateCacheByTranslation(DirtyHint hint)
Mark the cache as invalid due to a translation of a child.
|
protected void |
invalidateOpaqueRegion()
Invalidates any cached representation of the opaque region for this node.
|
boolean |
isClean()
Gets whether this SGNode is clean.
|
boolean |
isContentBounds2D()
Return true if contentBounds is purely a 2D bounds, ie.
|
boolean |
isDepthTest() |
(package private) boolean |
isOpaqueRegionInvalid()
This method exists only for the sake of testing.
|
(package private) boolean |
isReadbackSupported(Graphics g)
*
Static Helper Methods.
|
protected boolean |
isRectClip(BaseTransform xform,
boolean permitRoundedRectangle)
Returns whether a clip represented by this node can be rendered using
axis aligned rect clip.
|
(package private) boolean |
isShape3D() |
boolean |
isVisible()
Gets whether this node's visible property is set
|
(package private) void |
markCullRegions(DirtyRegionContainer drc,
int cullingRegionsBitsOfParent,
BaseTransform tx,
GeneralTransform3D pvTx)
Marks placement of the node in dirty region encoded into 2 bit flag:
00 - node outside dirty region
01 - node intersecting dirty region
11 - node completely within dirty region
32 bits = 15 regions max.
|
void |
markDirty()
Makes this node dirty, meaning that it needs to be included in the
next repaint to the back buffer, and its bounds should be included
in the dirty region.
|
private void |
markDirtyByTranslation()
Mark the node as DIRTY_BY_TRANSLATION.
|
protected void |
markTreeDirty()
Notifies the parent (whether an NGGroup or just a NGNode) that
a child has become dirty.
|
protected void |
markTreeDirtyNoIncrement() |
protected boolean |
needsBlending()
Return true if this node has a blend mode that requires special
processing.
|
private static boolean |
pointInConvexQuad(double x,
double y,
Point2D[] rect) |
void |
printDirtyOpts(java.lang.StringBuilder s,
java.util.List<NGNode> roots)
Fills the given StringBuilder with text representing the structure of the NG graph insofar as dirty
opts is concerned.
|
private void |
printDirtyOpts(java.lang.StringBuilder s,
NGNode node,
BaseTransform tx,
java.lang.String prefix,
java.util.List<NGNode> roots)
Used for debug purposes.
|
void |
release()
*
Stuff *
*
|
void |
render(Graphics g)
Render the tree of nodes to the specified G (graphics) object
descending from this node as the root.
|
private void |
renderCached(Graphics g) |
(package private) void |
renderClip(Graphics g) |
protected abstract void |
renderContent(Graphics g) |
protected void |
renderEffect(Graphics g) |
void |
renderForcedContent(Graphics gOptional)
Called on every render pulse for all nodes in case they have render-time
operations that must be completed on a pulse, but were not otherwise
rendered by the ordinary damage management logic.
|
(package private) void |
renderForClip(Graphics g) |
private void |
renderNodeBlendMode(Graphics g) |
private void |
renderOpacity(Graphics g) |
private void |
renderRectClip(Graphics g,
NGRectangle clipNode) |
void |
setCachedAsBitmap(boolean cached,
CacheHint cacheHint)
Called by the FX scene graph whenever "cached" or "cacheHint" changes.
|
void |
setClipNode(NGNode clipNode)
Called by the FX scene graph whenever the clip node for this node changes.
|
void |
setContentBounds(BaseBounds bounds)
Called by the FX scene graph to tell us what our new content bounds are.
|
void |
setDepthTest(boolean depthTest)
Called by the FX scene graph whenever the derived depth test flag for
the node changes.
|
void |
setEffect(Effect effect)
Called by the FX scene graph to set the effect.
|
void |
setName(java.lang.String value)
Used for debug purposes.
|
void |
setNodeBlendMode(Blend.Mode blendMode)
Set by the FX scene graph.
|
void |
setOpacity(float opacity)
Called by the FX scene graph whenever the opacity for the node changes.
|
void |
setParent(NGNode parent)
Only called by this class, or by the NGGroup class.
|
private void |
setParent(NGNode parent,
boolean isClip) |
void |
setTransformedBounds(BaseBounds bounds,
boolean byTransformChangeOnly)
Called by the FX scene graph to tell us what our transformed bounds are.
|
void |
setTransformMatrix(BaseTransform tx)
Called by the FX scene graph to tell us what our transform matrix is.
|
void |
setVisible(boolean value)
Called by the FX scene graph to tell us whether we should be visible or not.
|
protected boolean |
supportsOpaqueRegions()
Gets whether this NGNode supports opaque regions at all.
|
java.lang.String |
toString() |
protected void |
visualsChanged()
Invoked by subclasses whenever some change to the geometry or visuals
has occurred.
|
private static final GraphicsPipeline pipeline
private static final java.lang.Boolean effectsSupported
private java.lang.String name
private static final BoxBounds TEMP_BOUNDS
private static final RectBounds TEMP_RECT_BOUNDS
protected static final Affine3D TEMP_TRANSFORM
static final int DIRTY_REGION_INTERSECTS_NODE_BOUNDS
static final int DIRTY_REGION_CONTAINS_NODE_BOUNDS
static final int DIRTY_REGION_CONTAINS_OR_INTERSECTS_NODE_BOUNDS
private BaseTransform transform
protected BaseBounds transformedBounds
protected BaseBounds contentBounds
BaseBounds dirtyBounds
private boolean visible
protected NGNode.DirtyFlag dirty
private NGNode parent
private boolean isClip
private NGNode clipNode
private float opacity
private Blend.Mode nodeBlendMode
private boolean depthTest
private CacheFilter cacheFilter
private EffectFilter effectFilter
protected boolean childDirty
protected int dirtyChildrenAccumulated
protected static final int DIRTY_CHILDREN_ACCUMULATED_THRESHOLD
protected int cullingBits
private DirtyHint hint
private RectBounds opaqueRegion
private boolean opaqueRegionInvalid
private int painted
private static Point2D[] TEMP_POINTS2D_4
public void setVisible(boolean value)
value
- whether it is visiblepublic void setContentBounds(BaseBounds bounds)
bounds
- must not be nullpublic void setTransformedBounds(BaseBounds bounds, boolean byTransformChangeOnly)
bounds
- must not be nullpublic void setTransformMatrix(BaseTransform tx)
tx
- must not be nullpublic void setClipNode(NGNode clipNode)
clipNode
- can be null if the clip node is being clearedpublic void setOpacity(float opacity)
opacity
- A value between 0 and 1.public void setNodeBlendMode(Blend.Mode blendMode)
blendMode
- may be null to indicate "default"public void setDepthTest(boolean depthTest)
depthTest
- indicates whether to perform a depth test operation
(if the window has a depth buffer).public void setCachedAsBitmap(boolean cached, CacheHint cacheHint)
cached
- specifies whether or not this node should be cachedcacheHint
- never null, indicates some hint as to how to cachepublic void setEffect(Effect effect)
effect
- the effect (can be null to clear it)public void effectChanged()
public boolean isContentBounds2D()
public NGNode getParent()
public void setParent(NGNode parent)
private void setParent(NGNode parent, boolean isClip)
public final void setName(java.lang.String value)
public final java.lang.String getName()
protected final Effect getEffect()
public boolean isVisible()
public final BaseTransform getTransform()
public final float getOpacity()
public final Blend.Mode getNodeBlendMode()
public final boolean isDepthTest()
public final CacheFilter getCacheFilter()
public final EffectFilter getEffectFilter()
public final NGNode getClipNode()
public BaseBounds getContentBounds(BaseBounds bounds, BaseTransform tx)
private BaseBounds computeBounds(BaseBounds bounds, BaseTransform tx)
public final BaseBounds getClippedBounds(BaseBounds bounds, BaseTransform tx)
public final BaseBounds getEffectBounds(BaseBounds bounds, BaseTransform tx)
public final BaseBounds getCompleteBounds(BaseBounds bounds, BaseTransform tx)
protected void visualsChanged()
protected void geometryChanged()
public final void markDirty()
private void markDirtyByTranslation()
protected final void markTreeDirtyNoIncrement()
protected final void markTreeDirty()
public final boolean isClean()
protected void clearDirty()
public void clearPainted()
public void clearDirtyTree()
protected final void invalidateCache()
protected final void invalidateCacheByTranslation(DirtyHint hint)
public int accumulateDirtyRegions(RectBounds clip, RectBounds dirtyRegionTemp, DirtyRegionPool regionPool, DirtyRegionContainer dirtyRegionContainer, BaseTransform tx, GeneralTransform3D pvTx)
This method only accumulates dirty regions for parts of the tree which lie inside the clip since there is no point in accumulating dirty regions which lie outside the clip. The returned dirty regions bounds the same object as that passed into the function. The returned dirty regions bounds will always be adjusted such that they do not extend beyond the clip.
The given transform is the accumulated transform up to but not including the transform of this node.
clip
- must not be null, the clip in scene coordinates, supplied by the
rendering system. At most, this is usually the bounds of the window's
content area, however it might be smaller.dirtyRegionTemp
- must not be null, the dirty region in scene coordinates.
When this method is initially invoked by the rendering system, the
dirtyRegion should be marked as invalid.dirtyRegionContainer
- must not be null, the container of dirty regions in scene
coordinates.tx
- must not be null, the accumulated transform up to but not
including this node's transform. When this method concludes, it must
restore this transform if it was changed within the function.pvTx
- must not be null, it's the perspective transform of the current
perspective camera or identity transform if parallel camera is used.int accumulateNodeDirtyRegion(RectBounds clip, RectBounds dirtyRegionTemp, DirtyRegionContainer dirtyRegionContainer, BaseTransform tx, GeneralTransform3D pvTx)
int accumulateGroupDirtyRegion(RectBounds clip, RectBounds dirtyRegionTemp, DirtyRegionPool regionPool, DirtyRegionContainer dirtyRegionContainer, BaseTransform tx, GeneralTransform3D pvTx)
private BaseBounds computeDirtyRegion(RectBounds dirtyRegionTemp, BaseTransform tx, GeneralTransform3D pvTx)
dirtyRegionTemp
- A temporary RectBounds that this method can use for scratch.
In the case that no perspective transform occurs, it is best if
the returned BaseBounds is this instance.tx
- Any transform that needs to be appliedpvTx
- must not be null, it's the perspective transform of the current
perspective camera or identity transform if parallel camera is used.protected BaseBounds computePadding(BaseBounds region)
protected boolean hasVisuals()
public final void doPreCulling(DirtyRegionContainer drc, BaseTransform tx, GeneralTransform3D pvTx)
drc
- Array of dirty regions. Cannot be null.tx
- The transform for this render operation. Cannot be null.pvTx
- Perspective camera transformation. Cannot be null.void markCullRegions(DirtyRegionContainer drc, int cullingRegionsBitsOfParent, BaseTransform tx, GeneralTransform3D pvTx)
drc
- The array of dirty regions.cullingRegionsBitsOfParent
- culling bits of parent. -1 if there's no parent.tx
- The transform for this render operation. Cannot be null.pvTx
- Perspective camera transform. Cannot be null.public final void printDirtyOpts(java.lang.StringBuilder s, java.util.List<NGNode> roots)
s
- A StringBuilder to fill with the output.roots
- The list of render roots (may be empty, must not be null).private final void printDirtyOpts(java.lang.StringBuilder s, NGNode node, BaseTransform tx, java.lang.String prefix, java.util.List<NGNode> roots)
s
- The String buildernode
- The node that we're printing out information abouttx
- The transformprefix
- Some prefix to put in front of the node output (mostly spacing)roots
- The different dirty roots, if any.public void drawDirtyOpts(BaseTransform tx, GeneralTransform3D pvTx, Rectangle clipBounds, int[] colorBuffer, int dirtyRegionIndex)
tx
- The scene->parent transform.pvTx
- The perspective camera transform.clipBounds
- The bounds in scene coordinatescolorBuffer
- A pixel array where each pixel contains a color indicating how many times
it has been "drawn"dirtyRegionIndex
- the index of the dirty region we're gathering information for. This is
needed so we can shift the "painted" field to find out if this node
was drawn in this dirty region.public final void getRenderRoot(NodePath path, RectBounds dirtyRegion, int cullingIndex, BaseTransform tx, GeneralTransform3D pvTx)
path
- node path to store the node pathNGNode.RenderRootResult computeRenderRoot(NodePath path, RectBounds dirtyRegion, int cullingIndex, BaseTransform tx, GeneralTransform3D pvTx)
path
- the NodePath to populate with the path to the render root. Cannot be null.dirtyRegion
- the current dirty region. Cannot be null.cullingIndex
- index of culling informationtx
- current transform. Cannot be null.pvTx
- current perspective transform. Cannot be null.private static boolean pointInConvexQuad(double x, double y, Point2D[] rect)
final NGNode.RenderRootResult computeNodeRenderRoot(NodePath path, RectBounds dirtyRegion, int cullingIndex, BaseTransform tx, GeneralTransform3D pvTx)
path
- the NodePath to populate with the path to the render root. Cannot be null.dirtyRegion
- the current dirty region. Cannot be null.cullingIndex
- index of culling information, -1 means culling information should not be usedtx
- current transform. Cannot be null.pvTx
- current perspective transform. Cannot be null.static boolean checkBoundsInQuad(RectBounds untransformedQuad, RectBounds innerBounds, BaseTransform tx, GeneralTransform3D pvTx)
protected final void invalidateOpaqueRegion()
hasOpaqueRegion()
call must invoke this method
or the opaque region calculations will be wrong.final boolean isOpaqueRegionInvalid()
public final RectBounds getOpaqueRegion()
protected boolean supportsOpaqueRegions()
protected boolean hasOpaqueRegion()
supportsOpaqueRegions()
to return
true, this method will return whether or not this NGNode is in a state where it has
an opaque region to actually return. If this method returns true, a subsequent call to
computeOpaqueRegion(com.sun.javafx.geom.RectBounds)
must return
a non-null result. Any state used in the computation of this method, when it changes, must
result in a call to invalidateOpaqueRegion()
.protected RectBounds computeOpaqueRegion(RectBounds opaqueRegion)
opaqueRegion
- protected boolean isRectClip(BaseTransform xform, boolean permitRoundedRectangle)
public final void render(Graphics g)
g
- The graphics object we're rendering to. This must never be null.public void renderForcedContent(Graphics gOptional)
gOptional
- the Graphics object that was used to render the
Scene, or nullboolean isShape3D()
protected void doRender(Graphics g)
protected boolean needsBlending()
private void renderNodeBlendMode(Graphics g)
private void renderRectClip(Graphics g, NGRectangle clipNode)
void renderClip(Graphics g)
void renderForClip(Graphics g)
private void renderOpacity(Graphics g)
private void renderCached(Graphics g)
protected void renderEffect(Graphics g)
protected abstract void renderContent(Graphics g)
protected abstract boolean hasOverlappingContents()
boolean isReadbackSupported(Graphics g)
static FilterContext getFilterContext(Graphics g)
public void release()
public java.lang.String toString()
toString
in class java.lang.Object
public void applyTransform(BaseTransform tx, DirtyRegionContainer drc)
public void applyClip(BaseBounds clipBounds, DirtyRegionContainer drc)
public void applyEffect(EffectFilter effectFilter, DirtyRegionContainer drc, DirtyRegionPool regionPool)