APIdia Launch Partner
Top Description Fields Constructors Methods
sun.java2d.pipe

public abstract Class BufferedContext

extends Object
Class Inheritance
Known Direct Subclasses
sun.java2d.opengl.OGLContext
Imports
java.awt.AlphaComposite, .Color, .Composite, .Paint, java.awt.geom.AffineTransform, java.lang.annotation.Native, java.lang.ref.Reference, .WeakReference, sun.java2d.InvalidPipeException, .SunGraphics2D, sun.java2d.loops.XORComposite, sun.java2d.pipe.hw.AccelSurface

Base context class for managing state in a single-threaded rendering environment. Each state-setting operation (e.g. SET_COLOR) is added to the provided RenderQueue, which will be processed at a later time by a single thread. Note that the RenderQueue lock must be acquired before calling the validate() method (or any other method in this class). See the RenderQueue class comments for a sample usage scenario.
See Also
RenderQueue

Field Summary

Modifier and TypeField and Description
private final RenderBuffer
protected static BufferedContext
currentContext

This is a reference to the most recently validated BufferedContext.

private boolean
public static final int
NO_CONTEXT_FLAGS

Indicates that no flags are needed; take all default code paths.

private final RenderQueue
public static final int
SRC_IS_OPAQUE

Indicates that the source surface (or color value, if it is a simple rendering operation) is opaque (has an alpha value of 1.0).

private AffineTransform
public static final int
USE_MASK

Indicates that the operation uses an alpha mask, which may determine the code path that is used when setting up the current paint state.

private int
private int
private Reference<Region>
private Reference<Composite>
private Reference<AccelSurface>
private Reference<Paint>
private Reference<AccelSurface>
private boolean

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public final RenderQueue

Returns:

a render queue
getRenderQueue
()

Returns a singleton RenderQueue object used by the rendering pipeline.

public final void
invalidateContext()

Resets this context's surfaces and all attributes.

private void
private void
private void
private void
private void
setComposite(Composite comp, int flags)

private void
private void
private static <T> boolean
stateChanged(Reference<T> ref, T obj)

private void
validate(AccelSurface srcData, AccelSurface dstData, Region clip, Composite comp, AffineTransform xform, Paint paint, SunGraphics2D sg2d, int flags)

Validates the given parameters against the current state for this context.

public static void
validateContext(AccelSurface srcData, AccelSurface dstData, Region clip, Composite comp, AffineTransform xform, Paint paint, SunGraphics2D sg2d, int flags)

Fetches the BufferedContextContext associated with the dst.

public static void
validateContext(AccelSurface surface)

Fetches the BufferedContext associated with the surface and disables all context state settings.

private static <T> Reference<T>
wrapState(T obj)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufback to summary
private final RenderBuffer buf
currentContextback to summary
protected static BufferedContext currentContext

This is a reference to the most recently validated BufferedContext. If this value is null, it means that there is no current context. It is provided here so that validate() only needs to do a quick reference check to see if the BufferedContext passed to that method is the same as the one we've cached here.

isValidatedPaintJustAColorback to summary
private boolean isValidatedPaintJustAColor
NO_CONTEXT_FLAGSback to summary
public static final int NO_CONTEXT_FLAGS

Indicates that no flags are needed; take all default code paths.

Annotations
@Native
rqback to summary
private final RenderQueue rq
SRC_IS_OPAQUEback to summary
public static final int SRC_IS_OPAQUE

Indicates that the source surface (or color value, if it is a simple rendering operation) is opaque (has an alpha value of 1.0). If this flag is present, it allows us to disable blending in certain situations in order to improve performance.

Annotations
@Native
transformback to summary
private AffineTransform transform
USE_MASKback to summary
public static final int USE_MASK

Indicates that the operation uses an alpha mask, which may determine the code path that is used when setting up the current paint state.

Annotations
@Native
validatedFlagsback to summary
private int validatedFlags
validatedRGBback to summary
private int validatedRGB
validClipRefback to summary
private Reference<Region> validClipRef
validCompRefback to summary
private Reference<Composite> validCompRef
validDstDataRefback to summary
private Reference<AccelSurface> validDstDataRef
validPaintRefback to summary
private Reference<Paint> validPaintRef
validSrcDataRefback to summary
private Reference<AccelSurface> validSrcDataRef
xformInUseback to summary
private boolean xformInUse

Constructor Detail

BufferedContextback to summary
protected BufferedContext(RenderQueue rq)

Method Detail

getRenderQueueback to summary
public final RenderQueue getRenderQueue()

Returns a singleton RenderQueue object used by the rendering pipeline.

Returns:RenderQueue

a render queue

See Also
RenderQueue
invalidateContextback to summary
public final void invalidateContext()

Resets this context's surfaces and all attributes.

Note

must be called while the RenderQueue lock is held.

See Also
RenderQueue#lock, RenderQueue#unlock
resetClipback to summary
private void resetClip()
resetCompositeback to summary
private void resetComposite()
resetTransformback to summary
private void resetTransform()
setClipback to summary
private void setClip(Region clip)
setCompositeback to summary
private void setComposite(Composite comp, int flags)
setSurfacesback to summary
private void setSurfaces(AccelSurface srcData, AccelSurface dstData)
setTransformback to summary
private void setTransform(AffineTransform xform)
stateChangedback to summary
private static <T> boolean stateChanged(Reference<T> ref, T obj)
validateback to summary
private void validate(AccelSurface srcData, AccelSurface dstData, Region clip, Composite comp, AffineTransform xform, Paint paint, SunGraphics2D sg2d, int flags)

Validates the given parameters against the current state for this context. If this context is not current, it will be made current for the given source and destination surfaces, and the viewport will be updated. Then each part of the context state (clip, composite, etc.) is checked against the previous value. If the value has changed since the last call to validate(), it will be updated accordingly. Note that the SunGraphics2D parameter is only used for the purposes of validating a (non-null) Paint parameter. In all other cases it is safe to pass a null SunGraphics2D and it will be ignored.

Note

must be called while the RenderQueue lock is held. It's assumed that the type of surfaces has been checked by the Renderer

Exceptions
InvalidPipeException:
if either src or dest surface is not valid or lost
validateContextback to summary
public static void validateContext(AccelSurface srcData, AccelSurface dstData, Region clip, Composite comp, AffineTransform xform, Paint paint, SunGraphics2D sg2d, int flags)

Fetches the BufferedContextContext associated with the dst. surface and validates the context using the given parameters. Most rendering operations will call this method first in order to set the necessary state before issuing rendering commands.

Note

must be called while the RenderQueue lock is held. It's assumed that the type of surfaces has been checked by the Renderer

Exceptions
InvalidPipeException:
if either src or dest surface is not valid or lost
See Also
RenderQueue#lock, RenderQueue#unlock
validateContextback to summary
public static void validateContext(AccelSurface surface)

Fetches the BufferedContext associated with the surface and disables all context state settings.

Note

must be called while the RenderQueue lock is held. It's assumed that the type of surfaces has been checked by the Renderer

Exceptions
InvalidPipeException:
if the surface is not valid or lost
See Also
RenderQueue#lock, RenderQueue#unlock
wrapStateback to summary
private static <T> Reference<T> wrapState(T obj)