public abstract class NGNode extends 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 |
protected static class |
NGNode.RenderRootResult
*
Identifying render roots *
*
|
Modifier and Type | Field and Description |
---|---|
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.
|
protected BaseBounds |
contentBounds
The cached bounds.
|
protected int |
cullingBits
Marks position of this node in dirty regions.
|
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.
|
protected int |
dirtyChildrenAccumulated
How many children are going to be accumulated
|
protected static Affine3D |
TEMP_TRANSFORM |
protected BaseBounds |
transformedBounds
The cached transformed bounds.
|
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.
|
void |
applyClip(BaseBounds clipBounds,
DirtyRegionContainer drc) |
void |
applyEffect(EffectFilter effectFilter,
DirtyRegionContainer drc,
DirtyRegionPool regionPool) |
void |
applyTransform(BaseTransform tx,
DirtyRegionContainer drc) |
protected void |
clearDirty()
Clears the dirty flag.
|
void |
clearDirtyTree() |
void |
clearPainted()
Walks down the tree clearing the "painted" bits for each node.
|
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.
|
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() |
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() |
protected boolean |
isRectClip(BaseTransform xform,
boolean permitRoundedRectangle)
Returns whether a clip represented by this node can be rendered using
axis aligned rect clip.
|
boolean |
isVisible()
Gets whether this node's visible property is set
|
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.
|
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.
|
void |
printDirtyOpts(StringBuilder s,
List<NGNode> roots)
Fills the given StringBuilder with text representing the structure of the NG graph insofar as dirty
opts is concerned.
|
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.
|
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.
|
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(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.
|
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.
|
String |
toString() |
protected void |
visualsChanged()
Invoked by subclasses whenever some change to the geometry or visuals
has occurred.
|
protected static final Affine3D TEMP_TRANSFORM
protected BaseBounds transformedBounds
protected BaseBounds contentBounds
protected NGNode.DirtyFlag dirty
protected boolean childDirty
protected int dirtyChildrenAccumulated
protected static final int DIRTY_CHILDREN_ACCUMULATED_THRESHOLD
protected int cullingBits
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)
public final void setName(String value)
public final 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)
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()
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.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.public final void printDirtyOpts(StringBuilder s, List<NGNode> roots)
s
- A StringBuilder to fill with the output.roots
- The list of render roots (may be empty, must not be null).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 pathprotected final void invalidateOpaqueRegion()
hasOpaqueRegion()
call must invoke this method
or the opaque region calculations will be wrong.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 nullprotected void doRender(Graphics g)
protected boolean needsBlending()
protected void renderEffect(Graphics g)
protected abstract void renderContent(Graphics g)
protected abstract boolean hasOverlappingContents()
public void release()
public void applyTransform(BaseTransform tx, DirtyRegionContainer drc)
public void applyClip(BaseBounds clipBounds, DirtyRegionContainer drc)
public void applyEffect(EffectFilter effectFilter, DirtyRegionContainer drc, DirtyRegionPool regionPool)
Copyright © 2020. All rights reserved.