public class

BufferedContext

extends Object
java.lang.Object
   ↳ sun.java2d.pipe.BufferedContext

Class Overview

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.

Summary

Constants
int NO_CONTEXT_FLAGS Indicates that no flags are needed; take all default code paths.
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).
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.
Fields
protected RenderBuffer buf
protected static BufferedContext currentContext This is a reference to the most recently validated BufferedContext.
protected RenderQueue rq
Protected Constructors
BufferedContext(RenderQueue rq)
Public Methods
void invalidateSurfaces()
Invalidates the surfaces associated with this context.
void validate(SurfaceData srcData, SurfaceData dstData, Region clip, Composite comp, AffineTransform xform, Paint paint, SunGraphics2D sg2d, int flags)
Validates the given parameters against the current state for this context.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int NO_CONTEXT_FLAGS

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

Constant Value: 0 (0x00000000)

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.

Constant Value: 1 (0x00000001)

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.

Constant Value: 2 (0x00000002)

Fields

protected RenderBuffer buf

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.

protected RenderQueue rq

Protected Constructors

protected BufferedContext (RenderQueue rq)

Public Methods

public void invalidateSurfaces ()

Invalidates the surfaces associated with this context. This is useful when the context is no longer needed, and we want to break the chain caused by these surface references.

public void validate (SurfaceData srcData, SurfaceData 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.