Top Description Fields Constructors Methods
sun.java2d.opengl

public abstract Class OGLSurfaceData

extends SurfaceData
implements AccelSurface
Class Inheritance
All Implemented Interfaces
sun.java2d.pipe.hw.AccelSurface, sun.java2d.Surface, sun.java2d.pipe.hw.BufferedContextProvider
Known Direct Subclasses
sun.java2d.opengl.GLXSurfaceData
Imports
java.awt.AlphaComposite, .Composite, .GraphicsConfiguration, .GraphicsEnvironment, .Rectangle, .Transparency, java.awt.image.ColorModel, .Raster, sun.awt.SunHints, sun.awt.image.PixelConverter, sun.java2d.pipe.hw.AccelSurface, sun.java2d.SunGraphics2D, .SurfaceData, .SurfaceDataProxy, sun.java2d.loops.CompositeType, .GraphicsPrimitive, .MaskFill, .SurfaceType, sun.java2d.pipe.ParallelogramPipe, .PixelToParallelogramConverter, .RenderBuffer, .TextPipe

This class describes an OpenGL "surface", that is, a region of pixels managed via OpenGL. An OGLSurfaceData can be tagged with one of three different SurfaceType objects for the purpose of registering loops, etc. This diagram shows the hierarchy of OGL SurfaceTypes: Any / \ OpenGLSurface OpenGLTexture | OpenGLSurfaceRTT OpenGLSurface This kind of surface can be rendered to using OpenGL APIs. It is also possible to copy an OpenGLSurface to another OpenGLSurface (or to itself). This is typically accomplished by calling MakeContextCurrent(dstSD, srcSD) and then calling glCopyPixels() (although there are other techniques to achieve the same goal). OpenGLTexture This kind of surface cannot be rendered to using OpenGL (in the same sense as in OpenGLSurface). However, it is possible to upload a region of pixels to an OpenGLTexture object via glTexSubImage2D(). One can also copy a surface of type OpenGLTexture to an OpenGLSurface by binding the texture to a quad and then rendering it to the destination surface (this process is known as "texture mapping"). OpenGLSurfaceRTT This kind of surface can be thought of as a sort of hybrid between OpenGLSurface and OpenGLTexture, in that one can render to this kind of surface as if it were of type OpenGLSurface, but the process of copying this kind of surface to another is more like an OpenGLTexture. (Note that "RTT" stands for "render-to-texture".) In addition to these SurfaceType variants, we have also defined some constants that describe in more detail the type of underlying OpenGL surface. This table helps explain the relationships between those "type" constants and their corresponding SurfaceType: OGL Type Corresponding SurfaceType -------- ------------------------- WINDOW OpenGLSurface TEXTURE OpenGLTexture FLIP_BACKBUFFER OpenGLSurface FBOBJECT OpenGLSurfaceRTT

Field Summary

Modifier and TypeField and Description
private static final String
DESC_OPENGL_SURFACE

SurfaceTypes

private static final String
private static final String
public static final int
FBOBJECT

OGL-specific surface types

private OGLGraphicsConfig
private static boolean
isBIOpShaderEnabled

This will be true if the biopshader system property has been enabled.

private static boolean
isFBObjectEnabled

This will be true if the fbobject system property has been enabled.

private static boolean
isGradShaderEnabled

This will be true if the gradshader system property has been enabled.

private static boolean
isLCDShaderEnabled

This will be true if the lcdshader system property has been enabled.

private int
private int
protected static ParallelogramPipe
protected static OGLDrawImage
protected static OGLRenderer
protected static OGLTextRenderer
protected static PixelToParallelogramConverter
pack-priv static final SurfaceType
pack-priv static final SurfaceType
pack-priv static final SurfaceType
public static final int
public static final int
public static final int
PF_INT_ARGB

Pixel formats

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
protected int
Inherited from sun.java2d.SurfaceData:
AAClipColorShapeAAClipColorViaShapeAAClipCompShapeAAClipCompViaShapeAAClipPaintShapeAAClipPaintViaShapeAAColorShapeAAColorViaPgramAAColorViaShapeAACompShapeAACompViaShapeAAPaintShapeAAPaintViaShapeaaTextRendererclipColorPipeclipColorTextclipCompPipeclipCompTextclipPaintPipeclipPaintTextcolorPipecolorPrimitivescolorTextcolorViaPgramcolorViaShapecompPipecompShapecompTextcompViaShapeimagepipelcdTextRendereroutlineTextRendererpaintPipepaintShapepaintTextpaintViaShapesolidTextRenderer

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
private boolean
public boolean
canRenderLCDText(SunGraphics2D sg2d)

Overrides sun.java2d.SurfaceData.canRenderLCDText.

For now, we can only render LCD text if: - the fragment shader extension is available, and - the source color is opaque, and - blending is SrcOverNoEa or disabled - and the destination is opaque Eventually, we could enhance the native OGL text rendering code and remove the above restrictions, but that would require significantly more code just to support a few uncommon cases.
public boolean
copyArea(SunGraphics2D sg2d, int
the x coordinate of the area in device space
x
,
int
the y coordinate of the area in device space
y
,
int
the width of the area in device space
w
,
int
the height of the area in device space
h
,
int dx, int dy)

Overrides sun.java2d.SurfaceData.copyArea.

Performs a copyarea within this surface.
pack-priv static void
dispose(long pData, OGLGraphicsConfig gc)

Disposes the native resources associated with the given OGLSurfaceData (referenced by the pData parameter).

public void
flush()

Overrides sun.java2d.SurfaceData.flush.

Synchronously releases resources associated with this surface.
public final OGLContext
getContext()

Implements sun.java2d.pipe.hw.BufferedContextProvider.getContext.

Returns the OGLContext for the GraphicsConfig associated with this surface.
private static SurfaceType
getCustomSurfaceType(int oglType)

Returns the appropriate SurfaceType corresponding to the given OpenGL surface type constant (e.g. TEXTURE -> OpenGLTexture).

protected MaskFill
getMaskFill(SunGraphics2D sg2d)

Overrides sun.java2d.SurfaceData.getMaskFill.

Returns a MaskFill object that can be used on this destination with the source (paint) and composite types determined by the given SunGraphics2D, or null if no such MaskFill object can be located.
public Rectangle
getNativeBounds()

Implements sun.java2d.pipe.hw.AccelSurface.getNativeBounds.

Returns real bounds of the native surface, which may differ from those returned by getBounds.
public long

Returns:

native resource of specified type or 0L if such resource doesn't exist or can not be retrieved.
getNativeResource
(int
the type of the requested resource
resType
)

Implements sun.java2d.pipe.hw.AccelSurface.getNativeResource.

Returns native resource of specified resType associated with this surface.
pack-priv final OGLGraphicsConfig
getOGLGraphicsConfig()

Returns the OGLGraphicsConfig associated with this surface.

public Raster
getRaster(int x, int y, int w, int h)

Implements abstract sun.java2d.SurfaceData.getRaster.

Return a readable Raster which contains the pixels for the specified rectangular region of the destination surface.
private native int
getTextureID(long pData)

public final int
getTextureID()

If this surface is backed by a texture object, returns the texture ID for that texture.

private native int
getTextureTarget(long pData)

public final int
getTextureTarget()

If this surface is backed by a texture object, returns the target for that texture (either GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB).

public final int
getType()

Implements sun.java2d.pipe.hw.AccelSurface.getType.

Returns one of the surface type constants defined above.
protected native boolean
initFBObject(long pData, boolean isOpaque, boolean texNonPow2, boolean texRect, int width, int height)

protected native boolean
initFlipBackbuffer(long pData)

protected void
initSurface(final int width, final int height)

Initializes the appropriate OpenGL offscreen surface based on the value of the type parameter.

private void
initSurfaceNow(int width, int height)

Note

This should only be called from the QFT under the AWT lock.

protected native boolean
initTexture(long pData, boolean isOpaque, boolean texNonPow2, boolean texRect, int width, int height)

pack-priv boolean
isOnScreen()

Returns true if the surface is an on-screen window surface or a FBO texture attached to an on-screen CALayer.

pack-priv boolean
isTexNonPow2Available()

Returns true if OpenGL textures can have non-power-of-two dimensions when using the basic GL_TEXTURE_2D target.

pack-priv boolean
isTexRectAvailable()

Returns true if OpenGL textures can have non-power-of-two dimensions when using the GL_TEXTURE_RECTANGLE_ARB target (only available when the GL_ARB_texture_rectangle extension is present).

public SurfaceDataProxy
makeProxyFor(SurfaceData srcData)

Overrides sun.java2d.SurfaceData.makeProxyFor.

This method is called on a destination SurfaceData to choose a proper SurfaceDataProxy subclass for a source SurfaceData to use to control when and with what surface to override a given image operation.
pack-priv static void
swapBuffers(long window)

public void
Inherited from sun.java2d.SurfaceData:
canRenderParallelogramscheckCustomCompositeconvertTogetBoundsgetColorModelgetDefaultScaleXgetDefaultScaleYgetDestinationgetDeviceConfigurationgetDisposerReferentgetNativeOpsgetPrimarySurfaceDatagetRenderLoopsgetReplacementgetSourceSurfaceDatagetStategetStateTrackergetSurfaceTypegetTransparencyinvalidateisNullisOpaqueGrayisSurfaceLostisValidmakeRenderLoopsmarkDirtypixelForpixelForrestoreContentsrgbForsetBlitProxyKeysetSurfaceLostuseTightBBoxes

Field Detail

DESC_OPENGL_SURFACEback to summary
private static final String DESC_OPENGL_SURFACE

SurfaceTypes

DESC_OPENGL_SURFACE_RTTback to summary
private static final String DESC_OPENGL_SURFACE_RTT
DESC_OPENGL_TEXTUREback to summary
private static final String DESC_OPENGL_TEXTURE
FBOBJECTback to summary
public static final int FBOBJECT

OGL-specific surface types

See Also
sun.java2d.pipe.hw.AccelSurface
graphicsConfigback to summary
private OGLGraphicsConfig graphicsConfig
isBIOpShaderEnabledback to summary
private static boolean isBIOpShaderEnabled

This will be true if the biopshader system property has been enabled.

isFBObjectEnabledback to summary
private static boolean isFBObjectEnabled

This will be true if the fbobject system property has been enabled.

isGradShaderEnabledback to summary
private static boolean isGradShaderEnabled

This will be true if the gradshader system property has been enabled.

isLCDShaderEnabledback to summary
private static boolean isLCDShaderEnabled

This will be true if the lcdshader system property has been enabled.

nativeHeightback to summary
private int nativeHeight
nativeWidthback to summary
private int nativeWidth
oglAAPgramPipeback to summary
protected static ParallelogramPipe oglAAPgramPipe
oglImagePipeback to summary
protected static OGLDrawImage oglImagePipe
oglRenderPipeback to summary
protected static OGLRenderer oglRenderPipe
oglTextPipeback to summary
protected static OGLTextRenderer oglTextPipe
oglTxRenderPipeback to summary
protected static PixelToParallelogramConverter oglTxRenderPipe
OpenGLSurfaceback to summary
pack-priv static final SurfaceType OpenGLSurface
OpenGLSurfaceRTTback to summary
pack-priv static final SurfaceType OpenGLSurfaceRTT
OpenGLTextureback to summary
pack-priv static final SurfaceType OpenGLTexture
PF_3BYTE_BGRback to summary
public static final int PF_3BYTE_BGR
PF_BYTE_GRAYback to summary
public static final int PF_BYTE_GRAY
PF_INT_ARGBback to summary
public static final int PF_INT_ARGB

Pixel formats

PF_INT_ARGB_PREback to summary
public static final int PF_INT_ARGB_PRE
PF_INT_BGRback to summary
public static final int PF_INT_BGR
PF_INT_BGRXback to summary
public static final int PF_INT_BGRX
PF_INT_RGBback to summary
public static final int PF_INT_RGB
PF_INT_RGBXback to summary
public static final int PF_INT_RGBX
PF_USHORT_555_RGBback to summary
public static final int PF_USHORT_555_RGB
PF_USHORT_555_RGBXback to summary
public static final int PF_USHORT_555_RGBX
PF_USHORT_565_RGBback to summary
public static final int PF_USHORT_565_RGB
PF_USHORT_GRAYback to summary
public static final int PF_USHORT_GRAY
typeback to summary
protected int type

Constructor Detail

OGLSurfaceDataback to summary
protected OGLSurfaceData(OGLGraphicsConfig gc, ColorModel cm, int type)

Method Detail

canHandleCompositeback to summary
private boolean canHandleComposite(Composite c)
canRenderLCDTextback to summary
public boolean canRenderLCDText(SunGraphics2D sg2d)

Overrides sun.java2d.SurfaceData.canRenderLCDText.

For now, we can only render LCD text if: - the fragment shader extension is available, and - the source color is opaque, and - blending is SrcOverNoEa or disabled - and the destination is opaque Eventually, we could enhance the native OGL text rendering code and remove the above restrictions, but that would require significantly more code just to support a few uncommon cases.

copyAreaback to summary
public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy)

Overrides sun.java2d.SurfaceData.copyArea.

Doc from sun.java2d.SurfaceData.copyArea.

Performs a copyarea within this surface. Returns false if there is no algorithm to perform the copyarea given the current settings of the SunGraphics2D.

Parameters
x:int

the x coordinate of the area in device space

y:int

the y coordinate of the area in device space

w:int

the width of the area in device space

h:int

the height of the area in device space

Annotations
@Override
disposeback to summary
pack-priv static void dispose(long pData, OGLGraphicsConfig gc)

Disposes the native resources associated with the given OGLSurfaceData (referenced by the pData parameter). This method is invoked from the native Dispose() method from the Disposer thread when the Java-level OGLSurfaceData object is about to go away. Note that we also pass a reference to the OGLGraphicsConfig for the purposes of making a context current.

flushback to summary
public void flush()

Overrides sun.java2d.SurfaceData.flush.

Doc from sun.java2d.SurfaceData.flush.

Synchronously releases resources associated with this surface.

getContextback to summary
public final OGLContext getContext()

Implements sun.java2d.pipe.hw.BufferedContextProvider.getContext.

Returns the OGLContext for the GraphicsConfig associated with this surface.

Returns:OGLContext

Doc from sun.java2d.pipe.hw.BufferedContextProvider.getContext.

associated context

getCustomSurfaceTypeback to summary
private static SurfaceType getCustomSurfaceType(int oglType)

Returns the appropriate SurfaceType corresponding to the given OpenGL surface type constant (e.g. TEXTURE -> OpenGLTexture).

getMaskFillback to summary
protected MaskFill getMaskFill(SunGraphics2D sg2d)

Overrides sun.java2d.SurfaceData.getMaskFill.

Doc from sun.java2d.SurfaceData.getMaskFill.

Returns a MaskFill object that can be used on this destination with the source (paint) and composite types determined by the given SunGraphics2D, or null if no such MaskFill object can be located. Subclasses can override this method if they wish to filter other attributes (such as the hardware capabilities of the destination surface) before returning a specific MaskFill object.

Annotations
@Override
getNativeBoundsback to summary
public Rectangle getNativeBounds()

Implements sun.java2d.pipe.hw.AccelSurface.getNativeBounds.

Doc from sun.java2d.pipe.hw.AccelSurface.getNativeBounds.

Returns real bounds of the native surface, which may differ from those returned by getBounds.

Returns:Rectangle

Rectangle representing native surface's bounds

getNativeResourceback to summary
public long getNativeResource(int resType)

Implements sun.java2d.pipe.hw.AccelSurface.getNativeResource.

Returns native resource of specified resType associated with this surface. Specifically, for OGLSurfaceData this method returns the the following:

TEXTURE              - texture id
Note: the resource returned by this method is only valid on the rendering thread.
Parameters
resType:int

Doc from sun.java2d.pipe.hw.AccelSurface.getNativeResource.

the type of the requested resource

Returns:long

native resource of specified type or 0L if such resource doesn't exist or can not be retrieved.

See Also
sun.java2d.pipe.hw.AccelSurface#getNativeResource
getOGLGraphicsConfigback to summary
pack-priv final OGLGraphicsConfig getOGLGraphicsConfig()

Returns the OGLGraphicsConfig associated with this surface.

getRasterback to summary
public Raster getRaster(int x, int y, int w, int h)

Implements abstract sun.java2d.SurfaceData.getRaster.

Doc from sun.java2d.SurfaceData.getRaster.

Return a readable Raster which contains the pixels for the specified rectangular region of the destination surface. The coordinate origin of the returned Raster is the same as the device space origin of the destination surface. In some cases the returned Raster might also be writeable. In most cases, the returned Raster might contain more pixels than requested.

getTextureIDback to summary
private native int getTextureID(long pData)
getTextureIDback to summary
public final int getTextureID()

If this surface is backed by a texture object, returns the texture ID for that texture. Otherwise, this method will return zero.

getTextureTargetback to summary
private native int getTextureTarget(long pData)
getTextureTargetback to summary
public final int getTextureTarget()

If this surface is backed by a texture object, returns the target for that texture (either GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB). Otherwise, this method will return zero.

getTypeback to summary
public final int getType()

Implements sun.java2d.pipe.hw.AccelSurface.getType.

Returns one of the surface type constants defined above.

Returns:int

Doc from sun.java2d.pipe.hw.AccelSurface.getType.

an integer representing this surface's type

initFBObjectback to summary
protected native boolean initFBObject(long pData, boolean isOpaque, boolean texNonPow2, boolean texRect, int width, int height)
initFlipBackbufferback to summary
protected native boolean initFlipBackbuffer(long pData)
initSurfaceback to summary
protected void initSurface(final int width, final int height)

Initializes the appropriate OpenGL offscreen surface based on the value of the type parameter. If the surface creation fails for any reason, an OutOfMemoryError will be thrown.

initSurfaceNowback to summary
private void initSurfaceNow(int width, int height)

Note

This should only be called from the QFT under the AWT lock. This method is kept separate from the initSurface() method below just to keep the code a bit cleaner.

initTextureback to summary
protected native boolean initTexture(long pData, boolean isOpaque, boolean texNonPow2, boolean texRect, int width, int height)
isOnScreenback to summary
pack-priv boolean isOnScreen()

Returns true if the surface is an on-screen window surface or a FBO texture attached to an on-screen CALayer. Needed by Mac OS X port.

isTexNonPow2Availableback to summary
pack-priv boolean isTexNonPow2Available()

Returns true if OpenGL textures can have non-power-of-two dimensions when using the basic GL_TEXTURE_2D target.

isTexRectAvailableback to summary
pack-priv boolean isTexRectAvailable()

Returns true if OpenGL textures can have non-power-of-two dimensions when using the GL_TEXTURE_RECTANGLE_ARB target (only available when the GL_ARB_texture_rectangle extension is present).

makeProxyForback to summary
public SurfaceDataProxy makeProxyFor(SurfaceData srcData)

Overrides sun.java2d.SurfaceData.makeProxyFor.

Doc from sun.java2d.SurfaceData.makeProxyFor.

This method is called on a destination SurfaceData to choose a proper SurfaceDataProxy subclass for a source SurfaceData to use to control when and with what surface to override a given image operation. The argument is the default SurfaceData for the source Image.

The type of the return object is chosen based on the acceleration capabilities of this SurfaceData and the type of the given source SurfaceData object.

In some cases the original SurfaceData will always be the best choice to use to blit to this SurfaceData. This can happen if the source image is a hardware surface of the same type as this one and so acceleration will happen without any caching. It may also be the case that the source image can never be accelerated on this SurfaceData - for example because it is translucent and there are no accelerated translucent image ops for this surface.

In those cases there is a special SurfaceDataProxy.UNCACHED instance that represents a NOP for caching purposes - it always returns the original sourceSD object as the replacement copy so no caching is ever performed.

Annotations
@Override
swapBuffersback to summary
pack-priv static void swapBuffers(long window)
validatePipeback to summary
public void validatePipe(SunGraphics2D sg2d)

Overrides sun.java2d.SurfaceData.validatePipe.