APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.awt.image

public abstract Class VolatileSurfaceManager

extends SurfaceManager
implements DisplayChangedListener
Class Inheritance
All Implemented Interfaces
sun.awt.DisplayChangedListener, java.util.EventListener
Known Direct Subclasses
sun.java2d.opengl.GLXVolatileSurfaceManager, sun.java2d.x11.X11VolatileSurfaceManager, sun.java2d.xr.XRVolatileSurfaceManager, sun.awt.image.BufImgVolatileSurfaceManager
Imports
java.awt.Graphics, .GraphicsConfiguration, .GraphicsEnvironment, .ImageCapabilities, java.awt.geom.AffineTransform, java.awt.image.BufferedImage, .VolatileImage, sun.awt.DisplayChangedListener, sun.java2d.SunGraphicsEnvironment, .SurfaceData

This SurfaceManager variant manages an accelerated volatile surface, if it is possible to create that surface. If there is limited accelerated memory, or if the volatile surface disappears due to an operating system event, the VolatileSurfaceManager will attempt to restore the accelerated surface. If that fails, a system memory surface will be created in its place.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
protected AffineTransform
atCurrent

A reference to the AffineTransform corresponding to the graphics configuration of the volatile image.

protected Object
context

Context for extra initialization parameters.

protected boolean
lostSurface

Tracks loss of surface contents; queryable by user to see whether contents need to be restored.

protected SurfaceData
sdAccel

The accelerated SurfaceData object.

protected SurfaceData
sdBackup

The software-based SurfaceData object.

protected SurfaceData
sdCurrent

The current SurfaceData object.

protected SurfaceData
sdPrevious

A record-keeping object.

protected SunVolatileImage
vImg

A reference to the VolatileImage whose contents are being managed.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
acceleratedSurfaceLost()

Overrides sun.awt.image.SurfaceManager.acceleratedSurfaceLost.

If the accelerated surface is the current SurfaceData for this manager, sets the variable lostSurface to true, which indicates that something happened to the image under management.

public boolean
contentsLost()

Returns true if rendering data was lost since the last validate call.

public void
displayChanged()

Implements sun.awt.DisplayChangedListener.displayChanged.

Called from SunGraphicsEnv when there has been a display mode change.

public void
flush()

Overrides sun.awt.image.SurfaceManager.flush.

Releases any associated hardware memory for this image by calling flush on sdAccel.

protected SurfaceData
getBackupSurface()

Creates a software-based surface (of type BufImgSurfaceData).

public ImageCapabilities
getCapabilities(GraphicsConfiguration gc)

Overrides sun.awt.image.SurfaceManager.getCapabilities.

Returns an ImageCapabilities object which can be inquired as to the specific capabilities of this Image.

public SurfaceData
getPrimarySurfaceData()

Implements abstract sun.awt.image.SurfaceManager.getPrimarySurfaceData.

Returns the main SurfaceData object that "owns" the pixels for this SurfaceManager.

protected abstract SurfaceData
initAcceleratedSurface()

Creates a new accelerated surface that is compatible with the current GraphicsConfiguration.

public void
initContents()

Set contents of the current SurfaceData to default state (i.e. clear the background).

public void
initialize()

This init function is separate from the constructor because the things we are doing here necessitate the object's existence.

protected abstract boolean
isAccelerationEnabled()

Returns true if acceleration is enabled.

protected boolean
isConfigValid(GraphicsConfiguration gc)

Called by validate() to see whether the GC passed in is ok for rendering to.

public void
paletteChanged()

Implements sun.awt.DisplayChangedListener.paletteChanged.

When device palette changes, need to force a new copy of the image into our hardware cache to update the color indices of the pixels (indexed mode only).

protected void
restoreAcceleratedSurface()

Restore sdAccel in case it was lost.

public SurfaceData
restoreContents()

Implements abstract sun.awt.image.SurfaceManager.restoreContents.

Called from a SurfaceData object, indicating that our accelerated surface has been lost and should be restored (perhaps using a backup system memory surface).

public int
validate(GraphicsConfiguration gc)

Get the image ready for rendering.

Inherited from sun.awt.image.SurfaceManager:
flushgetImageScaleXgetImageScaleYgetManagersetAccelerationPrioritysetImageAccessorsetManager

Field Detail

atCurrentback to summary
protected AffineTransform atCurrent

A reference to the AffineTransform corresponding to the graphics configuration of the volatile image. Affine Transformation is usually derived from the screen device. During the displayChanged() callback, the existing transform is compared with the updated screen transform to determine whether the software backed surface needs to be re-created

contextback to summary
protected Object context

Context for extra initialization parameters.

lostSurfaceback to summary
protected boolean lostSurface

Tracks loss of surface contents; queryable by user to see whether contents need to be restored.

sdAccelback to summary
protected SurfaceData sdAccel

The accelerated SurfaceData object.

sdBackupback to summary
protected SurfaceData sdBackup

The software-based SurfaceData object. Only create when first asked to (otherwise it is a waste of memory as it will only be used in situations of surface loss).

sdCurrentback to summary
protected SurfaceData sdCurrent

The current SurfaceData object.

sdPreviousback to summary
protected SurfaceData sdPrevious

A record-keeping object. This keeps track of which SurfaceData was in use during the last call to validate(). This lets us see whether the SurfaceData object has changed since then and allows us to return the correct returnCode to the user in the validate() call.

vImgback to summary
protected SunVolatileImage vImg

A reference to the VolatileImage whose contents are being managed.

Constructor Detail

VolatileSurfaceManagerback to summary
protected VolatileSurfaceManager(SunVolatileImage vImg, Object context)

Method Detail

acceleratedSurfaceLostback to summary
public void acceleratedSurfaceLost()

Overrides sun.awt.image.SurfaceManager.acceleratedSurfaceLost.

If the accelerated surface is the current SurfaceData for this manager, sets the variable lostSurface to true, which indicates that something happened to the image under management. This variable is used in the validate method to tell the caller that the surface contents need to be restored.

contentsLostback to summary
public boolean contentsLost()

Returns true if rendering data was lost since the last validate call.

See Also
java.awt.image.VolatileImage#contentsLost
displayChangedback to summary
public void displayChanged()

Implements sun.awt.DisplayChangedListener.displayChanged.

Called from SunGraphicsEnv when there has been a display mode change. Note that we simply invalidate hardware surfaces here; we do not attempt to recreate or re-render them. This is to avoid threading conflicts with the native toolkit and associated threads. Instead, we just nullify the old surface data object and wait for a future method in the rendering process to recreate the surface.

flushback to summary
public void flush()

Overrides sun.awt.image.SurfaceManager.flush.

Releases any associated hardware memory for this image by calling flush on sdAccel. This method forces a lostSurface situation so any future operations on the image will need to revalidate the image first.

getBackupSurfaceback to summary
protected SurfaceData getBackupSurface()

Creates a software-based surface (of type BufImgSurfaceData). The software representation is only created when needed, which is only during some situation in which the hardware surface cannot be allocated. This allows apps to at least run, albeit more slowly than they would otherwise.

getCapabilitiesback to summary
public ImageCapabilities getCapabilities(GraphicsConfiguration gc)

Overrides sun.awt.image.SurfaceManager.getCapabilities.

Doc from sun.awt.image.SurfaceManager.getCapabilities.

Returns an ImageCapabilities object which can be inquired as to the specific capabilities of this Image. The capabilities object will return true for isAccelerated() if the image has a current and valid SurfaceDataProxy object cached for the specified GraphicsConfiguration parameter.

This class provides a default implementation of the ImageCapabilities that will try to determine if there is an associated SurfaceDataProxy object and if it is up to date, but only works for GraphicsConfiguration objects which implement the ProxiedGraphicsConfig interface defined below. In practice, all configs which can be accelerated are currently implementing that interface.

A null GraphicsConfiguration returns a value based on whether the image is currently accelerated on its default GraphicsConfiguration.

Annotations
@Override
getPrimarySurfaceDataback to summary
public SurfaceData getPrimarySurfaceData()

Implements abstract sun.awt.image.SurfaceManager.getPrimarySurfaceData.

Doc from sun.awt.image.SurfaceManager.getPrimarySurfaceData.

Returns the main SurfaceData object that "owns" the pixels for this SurfaceManager. This SurfaceData is used as the destination surface in a rendering operation and is the most authoritative storage for the current state of the pixels, though other versions might be cached in other locations for efficiency.

initAcceleratedSurfaceback to summary
protected abstract SurfaceData initAcceleratedSurface()

Creates a new accelerated surface that is compatible with the current GraphicsConfiguration. Returns the new accelerated SurfaceData object, or null if the surface creation was not successful. Platform-specific subclasses should initialize an accelerated surface (e.g. a DirectDraw surface on Windows, an OpenGL FBO, or an X11 pixmap).

initContentsback to summary
public void initContents()

Set contents of the current SurfaceData to default state (i.e. clear the background).

initializeback to summary
public void initialize()

This init function is separate from the constructor because the things we are doing here necessitate the object's existence. Otherwise, we end up calling into a subclass' overridden method during construction, before that subclass is completely constructed.

isAccelerationEnabledback to summary
protected abstract boolean isAccelerationEnabled()

Returns true if acceleration is enabled. If not, we simply use the backup SurfaceData object and return quickly from most methods in this class.

isConfigValidback to summary
protected boolean isConfigValid(GraphicsConfiguration gc)

Called by validate() to see whether the GC passed in is ok for rendering to. This generic implementation checks to see whether the GC is either null or is from the same device as the one that this image was created on. Platform- specific implementations may perform other checks as appropriate.

paletteChangedback to summary
public void paletteChanged()

Implements sun.awt.DisplayChangedListener.paletteChanged.

When device palette changes, need to force a new copy of the image into our hardware cache to update the color indices of the pixels (indexed mode only).

restoreAcceleratedSurfaceback to summary
protected void restoreAcceleratedSurface()

Restore sdAccel in case it was lost. Do nothing in this default case; platform-specific implementations may do more in this situation as appropriate.

restoreContentsback to summary
public SurfaceData restoreContents()

Implements abstract sun.awt.image.SurfaceManager.restoreContents.

Called from a SurfaceData object, indicating that our accelerated surface has been lost and should be restored (perhaps using a backup system memory surface). Returns the newly restored primary SurfaceData object.

validateback to summary
public int validate(GraphicsConfiguration gc)

Get the image ready for rendering. This method is called to make sure that the accelerated SurfaceData exists and is ready to be used. Users call this method prior to any set of rendering to or from the image, to make sure the image is ready and compatible with the given GraphicsConfiguration. The image may not be "ready" if either we had problems creating it in the first place (e.g., there was no space in vram) or if the surface became lost (e.g., some other app or the OS caused vram surfaces to be removed). Note that we want to return RESTORED in any situation where the SurfaceData is different than it was last time. So whether it's software or hardware, if we have a different SurfaceData object, then the contents have been altered and we must reflect that change to the user.

sun.awt.image back to summary

private Class VolatileSurfaceManager.AcceleratedImageCapabilities

extends ImageCapabilities
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
isAccelerated()

Overrides java.awt.ImageCapabilities.isAccelerated.

Returns true if the object whose capabilities are encapsulated in this ImageCapabilities can be or is accelerated.

public boolean
isTrueVolatile()

Overrides java.awt.ImageCapabilities.isTrueVolatile.

Returns true if the VolatileImage described by this ImageCapabilities can lose its surfaces.

Inherited from java.awt.ImageCapabilities:
clone

Constructor Detail

AcceleratedImageCapabilitiesback to summary
pack-priv AcceleratedImageCapabilities()

Method Detail

isAcceleratedback to summary
public boolean isAccelerated()

Overrides java.awt.ImageCapabilities.isAccelerated.

Doc from java.awt.ImageCapabilities.isAccelerated.

Returns true if the object whose capabilities are encapsulated in this ImageCapabilities can be or is accelerated.

Annotations
@Override
isTrueVolatileback to summary
public boolean isTrueVolatile()

Overrides java.awt.ImageCapabilities.isTrueVolatile.

Doc from java.awt.ImageCapabilities.isTrueVolatile.

Returns true if the VolatileImage described by this ImageCapabilities can lose its surfaces.

Annotations
@Override