public abstract class

OGLSurfaceData

extends SurfaceData
java.lang.Object
   ↳ sun.java2d.SurfaceData
     ↳ sun.java2d.opengl.OGLSurfaceData

Class Overview

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 PBUFFER OpenGLSurface TEXTURE OpenGLTexture FLIP_BACKBUFFER OpenGLSurface FBOBJECT OpenGLSurfaceRTT

Summary

Constants
int FBOBJECT
int FLIP_BACKBUFFER
int PBUFFER
int PF_BYTE_GRAY
int PF_INT_ARGB Pixel formats
int PF_INT_ARGB_PRE
int PF_INT_BGR
int PF_INT_BGRX
int PF_INT_RGB
int PF_INT_RGBX
int PF_USHORT_555_RGB
int PF_USHORT_555_RGBX
int PF_USHORT_565_RGB
int PF_USHORT_GRAY
int TEXTURE
int UNDEFINED OGL-specific surface types
int WINDOW
[Expand]
Inherited Constants
From interface java.awt.Transparency
Fields
protected static OGLDrawImage oglImagePipe
protected static OGLRenderer oglRenderPipe
protected static OGLTextRenderer oglTextPipe
protected static PixelToShapeConverter oglTxRenderPipe
protected int type
[Expand]
Inherited Fields
From class sun.java2d.SurfaceData
Protected Constructors
OGLSurfaceData(OGLGraphicsConfig gc, ColorModel cm, int type)
Public Methods
boolean canRenderLCDText(SunGraphics2D sg2d)
For now, we can only render LCD text if: - the fragment shader extension is available, and - blending is disabled, and - the source color 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.
boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy)
Performs a copyarea within this surface.
void flush()
Synchronously releases resources associated with this surface.
Raster getRaster(int x, int y, int w, int h)
Return a readable Raster which contains the pixels for the specified rectangular region of the destination surface.
SurfaceDataProxy makeProxyFor(SurfaceData srcData)
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.
void validatePipe(SunGraphics2D sg2d)
Protected Methods
MaskFill getMaskFill(SunGraphics2D sg2d)
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.
boolean initFBObject(long pData, boolean isOpaque, boolean texNonPow2, boolean texRect, int width, int height)
boolean initFlipBackbuffer(long pData)
abstract boolean initPbuffer(long pData, long pConfigInfo, boolean isOpaque, int width, int height)
void initSurface(int width, int height)
Initializes the appropriate OpenGL offscreen surface based on the value of the type parameter.
boolean initTexture(long pData, boolean isOpaque, boolean texNonPow2, boolean texRect, int width, int height)
[Expand]
Inherited Methods
From class sun.java2d.SurfaceData
From class java.lang.Object
From interface java.awt.Transparency
From interface sun.java2d.DisposerTarget
From interface sun.java2d.StateTrackable

Constants

public static final int FBOBJECT

Constant Value: 5 (0x00000005)

public static final int FLIP_BACKBUFFER

Constant Value: 4 (0x00000004)

public static final int PBUFFER

Constant Value: 2 (0x00000002)

public static final int PF_BYTE_GRAY

Constant Value: 9 (0x00000009)

public static final int PF_INT_ARGB

Pixel formats

Constant Value: 0 (0x00000000)

public static final int PF_INT_ARGB_PRE

Constant Value: 1 (0x00000001)

public static final int PF_INT_BGR

Constant Value: 4 (0x00000004)

public static final int PF_INT_BGRX

Constant Value: 5 (0x00000005)

public static final int PF_INT_RGB

Constant Value: 2 (0x00000002)

public static final int PF_INT_RGBX

Constant Value: 3 (0x00000003)

public static final int PF_USHORT_555_RGB

Constant Value: 7 (0x00000007)

public static final int PF_USHORT_555_RGBX

Constant Value: 8 (0x00000008)

public static final int PF_USHORT_565_RGB

Constant Value: 6 (0x00000006)

public static final int PF_USHORT_GRAY

Constant Value: 10 (0x0000000a)

public static final int TEXTURE

Constant Value: 3 (0x00000003)

public static final int UNDEFINED

OGL-specific surface types

Constant Value: 0 (0x00000000)

public static final int WINDOW

Constant Value: 1 (0x00000001)

Fields

protected static OGLDrawImage oglImagePipe

protected static OGLRenderer oglRenderPipe

protected static OGLTextRenderer oglTextPipe

protected static PixelToShapeConverter oglTxRenderPipe

protected int type

Protected Constructors

protected OGLSurfaceData (OGLGraphicsConfig gc, ColorModel cm, int type)

Public Methods

public boolean canRenderLCDText (SunGraphics2D sg2d)

For now, we can only render LCD text if: - the fragment shader extension is available, and - blending is disabled, and - the source color 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 x, int y, int w, int h, int dx, int dy)

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

public void flush ()

Synchronously releases resources associated with this surface.

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

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.

public SurfaceDataProxy makeProxyFor (SurfaceData srcData)

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.

public void validatePipe (SunGraphics2D sg2d)

Protected Methods

protected MaskFill getMaskFill (SunGraphics2D sg2d)

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.

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

protected boolean initFlipBackbuffer (long pData)

protected abstract boolean initPbuffer (long pData, long pConfigInfo, boolean isOpaque, int width, int height)

protected void initSurface (int width, 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.

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