Top Description Inners Fields Constructors Methods
com.sun.javafx.sg.prism

public abstract Class NGNode

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.javafx.sg.prism.NGShape, com.sun.javafx.sg.prism.NGShape3D, com.sun.javafx.sg.prism.NGSubScene, com.sun.javafx.sg.prism.NGExternalNode, com.sun.javafx.sg.prism.NGCamera, com.sun.javafx.sg.prism.NGCanvas, com.sun.javafx.sg.prism.NGGroup, com.sun.javafx.sg.prism.NGImageView, com.sun.javafx.sg.prism.NGLightBase
Imports
javafx.scene.CacheHint, java.util.ArrayList, .List, com.sun.glass.ui.Screen, com.sun.javafx.geom.BaseBounds, .BoxBounds, .DirtyRegionContainer, .DirtyRegionPool, .Point2D, .RectBounds, .Rectangle, com.sun.javafx.geom.transform.Affine3D, .BaseTransform, .GeneralTransform3D, .NoninvertibleTransformException, com.sun.prism.CompositeMode, .Graphics, .GraphicsPipeline, .RTTexture, .ReadbackGraphics, com.sun.prism.impl.PrismSettings, com.sun.scenario.effect.Blend, .Effect, .FilterContext, .ImageData, com.sun.scenario.effect.impl.prism.PrDrawable, .PrEffectHelper, .PrFilterContext, com.sun.javafx.logging.PulseLogger

NGNode is the abstract base class peer of Node, forming the basis for Prism and Scenario render graphs.

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
private static class
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 enum
NGNode.RenderRootResult

* Identifying render roots * *

Field Summary

Modifier and TypeField 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 final int
DIRTY_CHILDREN_ACCUMULATED_THRESHOLD

Do not iterate over all children in group.

pack-priv static final int
pack-priv static final int
pack-priv static final int
DIRTY_REGION_INTERSECTS_NODE_BOUNDS

Statics for defining what the culling bits are.

pack-priv 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 final Boolean
private DirtyHint
private boolean
isClip

True if this node is a clip.

private 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 final GraphicsPipeline
private static final BoxBounds
TEMP_BOUNDS

Temporary bounds for use by this class or subclasses, designed to reduce the amount of garbage we generate.

private static Point2D[]
private static final RectBounds
protected static final Affine3D
private BaseTransform
transform

The transform for this node.

protected BaseBounds
transformedBounds

The cached transformed bounds.

private double
viewOrder

The view order of this node.

private boolean
visible

Whether the node is visible.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The dirty region container. If the returned value is null, then that means the clip should be used as the dirty region. This is a special case indicating that there is no more need to walk the tree but we can take a shortcut. Note that returning null is *always* safe. Returning something other than null is simply an optimization for cases where the dirty region is substantially smaller than the clip.

Todo

Only made non-final for the sake of testing (see javafx-sg-prism tests) (JDK-8090845)

accumulateDirtyRegions
(final RectBounds
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.
clip
,
final RectBounds
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.
dirtyRegionTemp
,
DirtyRegionPool regionPool, final DirtyRegionContainer
must not be null, the container of dirty regions in scene coordinates.
dirtyRegionContainer
,
final BaseTransform
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.
tx
,
final GeneralTransform3D
must not be null, it's the perspective transform of the current perspective camera or identity transform if parallel camera is used.
pvTx
)

Accumulates and returns the dirty regions in transformed coordinates for this node.

pack-priv int
accumulateGroupDirtyRegion(final RectBounds clip, final RectBounds dirtyRegionTemp, final DirtyRegionPool regionPool, DirtyRegionContainer dirtyRegionContainer, final BaseTransform tx, final GeneralTransform3D pvTx)

Accumulates the dirty region of an NGGroup.

pack-priv int
accumulateNodeDirtyRegion(final RectBounds clip, final RectBounds dirtyRegionTemp, final DirtyRegionContainer dirtyRegionContainer, final BaseTransform tx, final GeneralTransform3D pvTx)

Accumulates the dirty region of a node.

public void
applyClip(final BaseBounds clipBounds, DirtyRegionContainer drc)

public void
applyEffect(final EffectFilter effectFilter, DirtyRegionContainer drc, DirtyRegionPool regionPool)

public void
private static int
ccw(double px, double py, Point2D a, Point2D b)

pack-priv static boolean
checkBoundsInQuad(RectBounds untransformedQuad, RectBounds innerBounds, BaseTransform tx, GeneralTransform3D pvTx)

public void
clearDirty()

Clears the dirty flag.

public void
clearPainted()

Walks down the tree clearing the "painted" bits for each node.

private BaseBounds
private BaseBounds
computeDirtyRegion(final RectBounds
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.
dirtyRegionTemp
,
final BaseTransform
Any transform that needs to be applied
tx
,
final GeneralTransform3D
must not be null, it's the perspective transform of the current perspective camera or identity transform if parallel camera is used.
pvTx
)

Computes the dirty region for this Node.

pack-priv final NGNode.RenderRootResult

Returns:

NO_RENDER_ROOT if this node does not have an opaque region that fills the entire dirty region. Returns HAS_RENDER_ROOT if the opaque region fills the dirty region.
computeNodeRenderRoot
(NodePath
the NodePath to populate with the path to the render root. Cannot be null.
path
,
RectBounds
the current dirty region. Cannot be null.
dirtyRegion
,
int
index of culling information, -1 means culling information should not be used
cullingIndex
,
BaseTransform
current transform. Cannot be null.
tx
,
GeneralTransform3D
current perspective transform. Cannot be null.
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.

pack-priv NGNode.RenderRootResult

Returns:

The result of visiting this node.
computeRenderRoot
(NodePath
the NodePath to populate with the path to the render root. Cannot be null.
path
,
RectBounds
the current dirty region. Cannot be null.
dirtyRegion
,
int
index of culling information
cullingIndex
,
BaseTransform
current transform. Cannot be null.
tx
,
GeneralTransform3D
current perspective transform. Cannot be null.
pvTx
)

Searches for the last node that covers all of the specified dirty region with an opaque region, in this node's subtree.

public final void
doPreCulling(DirtyRegionContainer
Array of dirty regions. Cannot be null.
drc
,
BaseTransform
The transform for this render operation. Cannot be null.
tx
,
GeneralTransform3D
Perspective camera transformation. Cannot be null.
pvTx
)

Culling support for multiple dirty regions.

protected void
doRender(Graphics g)

Invoked only by the final render method.

public void
drawDirtyOpts(final BaseTransform
The scene->parent transform.
tx
,
final GeneralTransform3D
The perspective camera transform.
pvTx
,
Rectangle
The bounds in scene coordinates
clipBounds
,
int[]
A pixel array where each pixel contains a color indicating how many times it has been "drawn"
colorBuffer
,
int
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.
dirtyRegionIndex
)

Helper method draws rectangles indicating the overdraw rectangles.

public void
effectChanged()

Called by the FX scene graph when an effect in the effect chain on the node changes internally.

protected void
public final CacheFilter
public final NGNode
public final BaseBounds
public final BaseBounds
public BaseBounds
protected final Effect
public final BaseBounds
public final EffectFilter
pack-priv static FilterContext
getFilterContext(Graphics g)

* Filters (Cache, Effect, etc).

public final String
getName()

Used for debug purposes.

public final Blend.Mode
public final float
public final RectBounds

Returns:

The opaque region for this node, or null.
getOpaqueRegion
()

Gets the opaque region for this node, if there is one, or returns null.

public NGNode
getParent()

Gets the parent of this node.

public final void
getRenderRoot(NodePath
node path to store the node path
path
,
RectBounds dirtyRegion, int cullingIndex, BaseTransform tx, GeneralTransform3D pvTx)

Called after preCullingBits in order to get the node from which we should begin drawing.

public final BaseTransform
protected boolean

Returns:

Whether this NGNode currently has an opaque region.
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
protected boolean

Returns:

true if the node has some visuals
hasVisuals
()

Marks if the node has some visuals and that the bounds change should be taken into account when using the dirty region.

protected final void
invalidateCache()

Invalidates the cache, if it is in use.

protected final void
invalidateCacheByTranslation(DirtyHint hint)

Mark the cache as invalid due to a translation of a child.

protected final void
invalidateOpaqueRegion()

Invalidates any cached representation of the opaque region for this node.

public final boolean
isClean()

Gets whether this SGNode is clean.

public boolean
isContentBounds2D()

Return true if contentBounds is purely a 2D bounds, ie.

public final boolean
pack-priv final boolean

Returns:

value of opaqueRegionInvalid
isOpaqueRegionInvalid
()

This method exists only for the sake of testing.

pack-priv boolean
isReadbackSupported(Graphics g)

* Static Helper Methods.

protected boolean

Returns:

whether this rectangle is axis aligned when rendered given node's and rendering transform
isRectClip
(BaseTransform xform, boolean permitRoundedRectangle)

Returns whether a clip represented by this node can be rendered using axis aligned rect clip.

pack-priv boolean
public boolean
isVisible()

Gets whether this node's visible property is set

pack-priv void
markCullRegions(DirtyRegionContainer
The array of dirty regions.
drc
,
int
culling bits of parent. -1 if there's no parent.
cullingRegionsBitsOfParent
,
BaseTransform
The transform for this render operation. Cannot be null.
tx
,
GeneralTransform3D
Perspective camera transform. Cannot be null.
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.

public final 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 final void
markTreeDirty()

Notifies the parent (whether an NGGroup or just a NGNode) that a child has become dirty.

protected final void
protected boolean

Returns:

true if this node needs special blending support
needsBlending
()

Return true if this node has a blend mode that requires special processing.

private static boolean
pointInConvexQuad(double x, double y, Point2D[] rect)

public final void
printDirtyOpts(StringBuilder
A StringBuilder to fill with the output.
s
,
List<NGNode>
The list of render roots (may be empty, must not be null).
roots
)

Fills the given StringBuilder with text representing the structure of the NG graph insofar as dirty opts is concerned.

private final void
printDirtyOpts(StringBuilder
The String builder
s
,
NGNode
The node that we're printing out information about
node
,
BaseTransform
The transform
tx
,
String
Some prefix to put in front of the node output (mostly spacing)
prefix
,
List<NGNode>
The different dirty roots, if any.
roots
)

Used for debug purposes.

public void
release()

* Stuff * *

public final void
render(Graphics
The graphics object we're rendering to. This must never be null.
g
)

Render the tree of nodes to the specified G (graphics) object descending from this node as the root.

private void
pack-priv void
protected abstract void
protected void
public void
renderForcedContent(Graphics
the Graphics object that was used to render the Scene, or null
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.

pack-priv void
private void
private void
private void
public void
setCachedAsBitmap(boolean
specifies whether or not this node should be cached
cached
,
CacheHint
never null, indicates some hint as to how to cache
cacheHint
)

Called by the FX scene graph whenever "cached" or "cacheHint" changes.

public void
setClipNode(NGNode
can be null if the clip node is being cleared
clipNode
)

Called by the FX scene graph whenever the clip node for this node changes.

public void
setContentBounds(BaseBounds
must not be null
bounds
)

Called by the FX scene graph to tell us what our new content bounds are.

public void
setDepthTest(boolean
indicates whether to perform a depth test operation (if the window has a depth buffer).
depthTest
)

Called by the FX scene graph whenever the derived depth test flag for the node changes.

public void
setEffect(Effect
the effect (can be null to clear it)
effect
)

Called by the FX scene graph to set the effect.

public final void
setName(String value)

Used for debug purposes.

public void
setNodeBlendMode(Blend.Mode
may be null to indicate "default"
blendMode
)

Set by the FX scene graph.

public void
setOpacity(float
A value between 0 and 1.
opacity
)

Called by the FX scene graph whenever the opacity for the node changes.

public void
setParent(NGNode parent)

Only called by this class, or by the NGGroup class.

private void
setParent(NGNode parent, boolean isClip)

public void
setTransformedBounds(BaseBounds
must not be null
bounds
,
boolean byTransformChangeOnly)

Called by the FX scene graph to tell us what our transformed bounds are.

public void
setTransformMatrix(BaseTransform
must not be null
tx
)

Called by the FX scene graph to tell us what our transform matrix is.

public void
setViewOrder(double
A value between the range of negative Double.MAX_VALUE and positive Double.MAX_VALUE.
viewOrder
)

Called by the FX scene graph whenever the view order for the node changes.

public void
setVisible(boolean
whether it is visible
value
)

Called by the FX scene graph to tell us whether we should be visible or not.

protected boolean

Returns:

Whether this NGNode implementation supports opaque regions. This could also have been implemented via an interface that some NGNodes implemented, but then we'd have instanceof checks which I'd rather avoid.
supportsOpaqueRegions
()

Gets whether this NGNode supports opaque regions at all.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected void
visualsChanged()

Invoked by subclasses whenever some change to the geometry or visuals has occurred.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait