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

public abstract Class SurfaceManager

extends Object
Class Inheritance
Known Direct Subclasses
sun.awt.image.VolatileSurfaceManager, sun.awt.image.BufImgSurfaceManager
Imports
java.awt.GraphicsConfiguration, .GraphicsEnvironment, .Image, .ImageCapabilities, java.awt.image.BufferedImage, .VolatileImage, java.lang.ref.WeakReference, java.util.Collections, .Iterator, .Map, .WeakHashMap, sun.java2d.InvalidPipeException, .SurfaceData, .SurfaceDataProxy

The abstract base class that manages the various SurfaceData objects that represent an Image's contents. Subclasses can customize how the surfaces are organized, whether to cache the original contents in an accelerated surface, and so on.

The SurfaceManager also maintains an arbitrary "cache" mechanism which allows other agents to store data in it specific to their use of this image. The most common use of the caching mechanism is for destination SurfaceData objects to store cached copies of the source image.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
SurfaceManager.Factory

An interface for GraphicsConfiguration objects to implement if they create their own VolatileSurfaceManager implementations.

public static interface
SurfaceManager.FlushableCacheData

An interface for Objects used in the SurfaceManager cache to implement if they have data that should be flushed when the Image is flushed.

public abstract static class
pack-priv class
public static interface
SurfaceManager.ProxiedGraphicsConfig

An interface for GraphicsConfiguration objects to implement if their surfaces accelerate images using SurfaceDataProxy objects.

public static class

Field Summary

Modifier and TypeField and Description
private static SurfaceManager.ImageAccessor
private final Map<SurfaceManager.ProxyCache, WeakReference<SurfaceDataProxy>>
weakCache

This map holds references to SurfaceDataProxy per given ProxyCache.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
acceleratedSurfaceLost()

Notification that any accelerated surfaces associated with this manager have been "lost", which might mean that they need to be manually restored or recreated.

public synchronized void
flush()

Releases system resources in use by ancillary SurfaceData objects, such as surfaces cached in accelerated memory.

pack-priv void
flush(boolean deaccelerate)

public ImageCapabilities
getCapabilities(GraphicsConfiguration gc)

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

public static double
getImageScaleX(final Image img)

Returns a horizontal scale factor of the image.

public static double
getImageScaleY(final Image img)

Returns a vertical scale factor of the image.

public static SurfaceManager
getManager(Image img)

Returns the SurfaceManager object contained within the given Image.

public abstract SurfaceData
getPrimarySurfaceData()

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

public abstract SurfaceData
restoreContents()

Restores the primary surface being managed, and then returns the replacement surface.

public void
setAccelerationPriority(float priority)

Called when image's acceleration priority is changed.

public static void
public static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

imgaccessorback to summary
private static SurfaceManager.ImageAccessor imgaccessor
weakCacheback to summary
private final Map<SurfaceManager.ProxyCache, WeakReference<SurfaceDataProxy>> weakCache

This map holds references to SurfaceDataProxy per given ProxyCache. Unlike ProxyCache, which contains SurfaceDataProxy objects per given SurfaceManager, this map does not prevent contained proxies from being garbage collected. Therefore, ProxyCache can be considered an "owning" container for the SurfaceDataProxy objects, and this map is just a weak mapping for the bookkeeping purposes.

Constructor Detail

SurfaceManagerback to summary
public SurfaceManager()

Method Detail

acceleratedSurfaceLostback to summary
public void acceleratedSurfaceLost()

Notification that any accelerated surfaces associated with this manager have been "lost", which might mean that they need to be manually restored or recreated. The default implementation does nothing, but platform-specific variants which have accelerated surfaces should perform any necessary actions.

flushback to summary
public synchronized void flush()

Releases system resources in use by ancillary SurfaceData objects, such as surfaces cached in accelerated memory. Subclasses should override to release any of their flushable data.

The default implementation will visit all of the value objects in the cacheMap and flush them if they implement the FlushableCacheData interface.

flushback to summary
pack-priv void flush(boolean deaccelerate)
getCapabilitiesback to summary
public ImageCapabilities getCapabilities(GraphicsConfiguration gc)

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.

Since
1.5
See Also
java.awt.Image#getCapabilities
getImageScaleXback to summary
public static double getImageScaleX(final Image img)

Returns a horizontal scale factor of the image. This is utility method, which fetches information from the SurfaceData of the image.

See Also
SurfaceData#getDefaultScaleX
getImageScaleYback to summary
public static double getImageScaleY(final Image img)

Returns a vertical scale factor of the image. This is utility method, which fetches information from the SurfaceData of the image.

See Also
SurfaceData#getDefaultScaleY
getManagerback to summary
public static SurfaceManager getManager(Image img)

Returns the SurfaceManager object contained within the given Image.

getPrimarySurfaceDataback to summary
public abstract SurfaceData 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.

restoreContentsback to summary
public abstract SurfaceData restoreContents()

Restores the primary surface being managed, and then returns the replacement surface. This is called when an accelerated surface has been "lost", in an attempt to auto-restore its contents.

setAccelerationPriorityback to summary
public void setAccelerationPriority(float priority)

Called when image's acceleration priority is changed.

The default implementation will visit all of the value objects in the cacheMap when the priority gets set to 0.0 and flush them if they implement the FlushableCacheData interface.

setImageAccessorback to summary
public static void setImageAccessor(SurfaceManager.ImageAccessor ia)
setManagerback to summary
public static void setManager(Image img, SurfaceManager mgr)
sun.awt.image back to summary

public Interface SurfaceManager.Factory

Known Direct Subinterfaces
sun.java2d.opengl.OGLGraphicsConfig
Known Direct Implementers
sun.awt.X11GraphicsConfig

An interface for GraphicsConfiguration objects to implement if they create their own VolatileSurfaceManager implementations.

Method Summary

Modifier and TypeMethod and Description
public VolatileSurfaceManager
createVolatileManager(SunVolatileImage image, Object context)

Creates a new instance of a VolatileSurfaceManager given a compatible SunVolatileImage.

Method Detail

createVolatileManagerback to summary
public VolatileSurfaceManager createVolatileManager(SunVolatileImage image, Object context)

Creates a new instance of a VolatileSurfaceManager given a compatible SunVolatileImage. An optional context Object can be supplied as a way for the caller to pass pipeline-specific context data to the VolatileSurfaceManager (such as a backbuffer handle, for example).

sun.awt.image back to summary

public Interface SurfaceManager.FlushableCacheData

Known Direct Implementers
sun.java2d.SurfaceDataProxy

An interface for Objects used in the SurfaceManager cache to implement if they have data that should be flushed when the Image is flushed.

Method Summary

Modifier and TypeMethod and Description
public boolean
flush(boolean deaccelerated)

Flush all cached resources.

Method Detail

flushback to summary
public boolean flush(boolean deaccelerated)

Flush all cached resources. The deaccelerated parameter indicates if the flush is happening because the associated surface is no longer being accelerated (for instance the acceleration priority is set below the threshold needed for acceleration). Returns a boolean that indicates if the cached object is no longer needed and should be removed from the cache.

sun.awt.image back to summary

public abstract Class SurfaceManager.ImageAccessor

extends Object
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract SurfaceManager
public abstract void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ImageAccessorback to summary
public ImageAccessor()

Method Detail

getSurfaceManagerback to summary
public abstract SurfaceManager getSurfaceManager(Image img)
setSurfaceManagerback to summary
public abstract void setSurfaceManager(Image img, SurfaceManager mgr)
sun.awt.image back to summary

pack-priv Class SurfaceManager.ImageCapabilitiesGc

extends ImageCapabilities
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv GraphicsConfiguration

Constructor Summary

AccessConstructor and Description
public

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.

Inherited from java.awt.ImageCapabilities:
cloneisTrueVolatile

Field Detail

gcback to summary
pack-priv GraphicsConfiguration gc

Constructor Detail

ImageCapabilitiesGcback to summary
public ImageCapabilitiesGc(GraphicsConfiguration gc)

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.

sun.awt.image back to summary

public Interface SurfaceManager.ProxiedGraphicsConfig

Known Direct Subinterfaces
sun.java2d.opengl.OGLGraphicsConfig
Known Direct Implementers
sun.java2d.xr.XRGraphicsConfig, sun.awt.X11GraphicsConfig

An interface for GraphicsConfiguration objects to implement if their surfaces accelerate images using SurfaceDataProxy objects. Implementing this interface facilitates the default implementation of getImageCapabilities() above.

Method Summary

Modifier and TypeMethod and Description
public SurfaceManager.ProxyCache
getSurfaceDataProxyCache()

Return the cache that destination surfaces created on the given GraphicsConfiguration use to store SurfaceDataProxy objects for their cached copies.

Method Detail

getSurfaceDataProxyCacheback to summary
public SurfaceManager.ProxyCache getSurfaceDataProxyCache()

Return the cache that destination surfaces created on the given GraphicsConfiguration use to store SurfaceDataProxy objects for their cached copies.

sun.awt.image back to summary

public Class SurfaceManager.ProxyCache

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Map<SurfaceManager, SurfaceDataProxy>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public SurfaceDataProxy
get(SurfaceManager manager)

Return a cached SurfaceDataProxy object for a given SurfaceManager.

public void
put(SurfaceManager manager, SurfaceDataProxy proxy)

Store a cached SurfaceDataProxy object for a given SurfaceManager.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mapback to summary
private final Map<SurfaceManager, SurfaceDataProxy> map

Constructor Detail

ProxyCacheback to summary
public ProxyCache()

Method Detail

getback to summary
public SurfaceDataProxy get(SurfaceManager manager)

Return a cached SurfaceDataProxy object for a given SurfaceManager.

Note that the cache is maintained as a simple Map with no attempts to keep it up to date or invalidate it so any data stored here must either not be dependent on the state of the image or it must be individually tracked to see if it is outdated or obsolete.

The SurfaceData object of the primary (destination) surface has a StateTracker mechanism which can help track the validity and "currentness" of any data stored here. For convenience and expediency an object stored as cached data may implement the FlushableCacheData interface specified below so that it may be notified immediately if the flush() method is ever called.

putback to summary
public void put(SurfaceManager manager, SurfaceDataProxy proxy)

Store a cached SurfaceDataProxy object for a given SurfaceManager. See the get() method for notes on tracking the validity of data stored using this mechanism.