下面列出了怎么用sun.awt.X11ComponentPeer的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Attempts to create an XDBE-based backbuffer for the given peer. If
* the requested configuration is not natively supported, an AWTException
* is thrown. Otherwise, if the backbuffer creation is successful, a
* handle to the native backbuffer is returned.
*/
public long createBackBuffer(X11ComponentPeer peer,
int numBuffers, BufferCapabilities caps)
throws AWTException
{
if (!X11GraphicsDevice.isDBESupported()) {
throw new AWTException("Page flipping is not supported");
}
if (numBuffers > 2) {
throw new AWTException(
"Only double or single buffering is supported");
}
BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
long window = peer.getContentWindow();
int swapAction = getSwapAction(caps.getFlipContents());
return createBackBuffer(window, swapAction);
}
/**
* Creates a SurfaceData object representing the back buffer of a
* double-buffered on-screen Window.
*/
public static GLXOffScreenSurfaceData createData(X11ComponentPeer peer,
Image image,
int type)
{
GLXGraphicsConfig gc = getGC(peer);
Rectangle r = peer.getBounds();
if (type == FLIP_BACKBUFFER) {
return new GLXOffScreenSurfaceData(peer, gc, r.width, r.height,
image, peer.getColorModel(),
FLIP_BACKBUFFER);
} else {
return new GLXVSyncOffScreenSurfaceData(peer, gc, r.width, r.height,
image, peer.getColorModel(),
type);
}
}
/**
* Attempts to create an XDBE-based backbuffer for the given peer. If
* the requested configuration is not natively supported, an AWTException
* is thrown. Otherwise, if the backbuffer creation is successful, a
* handle to the native backbuffer is returned.
*/
public long createBackBuffer(X11ComponentPeer peer,
int numBuffers, BufferCapabilities caps)
throws AWTException
{
if (!X11GraphicsDevice.isDBESupported()) {
throw new AWTException("Page flipping is not supported");
}
if (numBuffers > 2) {
throw new AWTException(
"Only double or single buffering is supported");
}
BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
long window = peer.getContentWindow();
int swapAction = getSwapAction(caps.getFlipContents());
return createBackBuffer(window, swapAction);
}
/**
* Creates a SurfaceData object representing the back buffer of a
* double-buffered on-screen Window.
*/
public static GLXOffScreenSurfaceData createData(X11ComponentPeer peer,
Image image,
int type)
{
GLXGraphicsConfig gc = getGC(peer);
Rectangle r = peer.getBounds();
if (type == FLIP_BACKBUFFER) {
return new GLXOffScreenSurfaceData(peer, gc, r.width, r.height,
image, peer.getColorModel(),
FLIP_BACKBUFFER);
} else {
return new GLXVSyncOffScreenSurfaceData(peer, gc, r.width, r.height,
image, peer.getColorModel(),
type);
}
}
/**
* Attempts to create an XDBE-based backbuffer for the given peer. If
* the requested configuration is not natively supported, an AWTException
* is thrown. Otherwise, if the backbuffer creation is successful, a
* handle to the native backbuffer is returned.
*/
public long createBackBuffer(X11ComponentPeer peer,
int numBuffers, BufferCapabilities caps)
throws AWTException
{
if (!X11GraphicsDevice.isDBESupported()) {
throw new AWTException("Page flipping is not supported");
}
if (numBuffers > 2) {
throw new AWTException(
"Only double or single buffering is supported");
}
BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
long window = peer.getContentWindow();
int swapAction = getSwapAction(caps.getFlipContents());
return createBackBuffer(window, swapAction);
}
/**
* Creates a SurfaceData object representing the back buffer of a
* double-buffered on-screen Window.
*/
public static GLXOffScreenSurfaceData createData(X11ComponentPeer peer,
Image image,
int type)
{
GLXGraphicsConfig gc = getGC(peer);
Rectangle r = peer.getBounds();
if (type == FLIP_BACKBUFFER) {
return new GLXOffScreenSurfaceData(peer, gc, r.width, r.height,
image, peer.getColorModel(),
FLIP_BACKBUFFER);
} else {
return new GLXVSyncOffScreenSurfaceData(peer, gc, r.width, r.height,
image, peer.getColorModel(),
type);
}
}
/**
* Attempts to create a GLX-based backbuffer for the given peer. If
* the requested configuration is not natively supported, an AWTException
* is thrown. Otherwise, if the backbuffer creation is successful, a
* value of 1 is returned.
*/
@Override
public long createBackBuffer(X11ComponentPeer peer,
int numBuffers, BufferCapabilities caps)
throws AWTException
{
if (numBuffers > 2) {
throw new AWTException(
"Only double or single buffering is supported");
}
BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
throw new AWTException("FlipContents.PRIOR is not supported");
}
// non-zero return value means backbuffer creation was successful
// (checked in X11ComponentPeer.flip(), etc.)
return 1;
}
/**
* Attempts to create a GLX-based backbuffer for the given peer. If
* the requested configuration is not natively supported, an AWTException
* is thrown. Otherwise, if the backbuffer creation is successful, a
* value of 1 is returned.
*/
@Override
public long createBackBuffer(X11ComponentPeer peer,
int numBuffers, BufferCapabilities caps)
throws AWTException
{
if (numBuffers > 2) {
throw new AWTException(
"Only double or single buffering is supported");
}
BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
throw new AWTException("FlipContents.PRIOR is not supported");
}
// non-zero return value means backbuffer creation was successful
// (checked in X11ComponentPeer.flip(), etc.)
return 1;
}
/**
* Creates a SurfaceData object representing the back buffer of a
* double-buffered on-screen Window.
*/
public static GLXOffScreenSurfaceData createData(X11ComponentPeer peer,
Image image,
int type)
{
GLXGraphicsConfig gc = getGC(peer);
Rectangle r = peer.getBounds();
if (type == FLIP_BACKBUFFER) {
return new GLXOffScreenSurfaceData(peer, gc, r.width, r.height,
image, peer.getColorModel(),
FLIP_BACKBUFFER);
} else {
return new GLXVSyncOffScreenSurfaceData(peer, gc, r.width, r.height,
image, peer.getColorModel(),
type);
}
}
/**
* Attempts to create an XDBE-based backbuffer for the given peer. If
* the requested configuration is not natively supported, an AWTException
* is thrown. Otherwise, if the backbuffer creation is successful, a
* handle to the native backbuffer is returned.
*/
public long createBackBuffer(X11ComponentPeer peer,
int numBuffers, BufferCapabilities caps)
throws AWTException
{
if (!X11GraphicsDevice.isDBESupported()) {
throw new AWTException("Page flipping is not supported");
}
if (numBuffers > 2) {
throw new AWTException(
"Only double or single buffering is supported");
}
BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
long window = peer.getContentWindow();
int swapAction = getSwapAction(caps.getFlipContents());
return createBackBuffer(window, swapAction);
}
/**
* Creates a SurfaceData object representing the back buffer of a
* double-buffered on-screen Window.
*/
public static GLXOffScreenSurfaceData createData(X11ComponentPeer peer,
Image image,
int type)
{
GLXGraphicsConfig gc = getGC(peer);
Rectangle r = peer.getBounds();
if (type == FLIP_BACKBUFFER) {
return new GLXOffScreenSurfaceData(peer, gc, r.width, r.height,
image, peer.getColorModel(),
FLIP_BACKBUFFER);
} else {
return new GLXVSyncOffScreenSurfaceData(peer, gc, r.width, r.height,
image, peer.getColorModel(),
type);
}
}
/**
* Attempts to create an XDBE-based backbuffer for the given peer. If
* the requested configuration is not natively supported, an AWTException
* is thrown. Otherwise, if the backbuffer creation is successful, a
* handle to the native backbuffer is returned.
*/
public long createBackBuffer(X11ComponentPeer peer,
int numBuffers, BufferCapabilities caps)
throws AWTException
{
if (!X11GraphicsDevice.isDBESupported()) {
throw new AWTException("Page flipping is not supported");
}
if (numBuffers > 2) {
throw new AWTException(
"Only double or single buffering is supported");
}
BufferCapabilities configCaps = getBufferCapabilities();
if (!configCaps.isPageFlipping()) {
throw new AWTException("Page flipping is not supported");
}
long window = peer.getContentWindow();
int swapAction = getSwapAction(caps.getFlipContents());
return createBackBuffer(window, swapAction);
}
public static GLXGraphicsConfig getGC(X11ComponentPeer peer) {
if (peer != null) {
return (GLXGraphicsConfig)peer.getGraphicsConfiguration();
} else {
// REMIND: this should rarely (never?) happen, but what if
// default config is not GLX?
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice();
return (GLXGraphicsConfig)gd.getDefaultConfiguration();
}
}
/**
* Performs the native XDBE flip operation for the given target Component.
*/
public void flip(X11ComponentPeer peer,
Component target, VolatileImage xBackBuffer,
int x1, int y1, int x2, int y2,
BufferCapabilities.FlipContents flipAction)
{
long window = peer.getContentWindow();
int swapAction = getSwapAction(flipAction);
swapBuffers(window, swapAction);
}
public GLXVSyncOffScreenSurfaceData(X11ComponentPeer peer,
GLXGraphicsConfig gc,
int width, int height,
Image image, ColorModel cm,
int type)
{
super(peer, gc, width, height, image, cm, type);
flipSurface = GLXSurfaceData.createData(peer, image, FLIP_BACKBUFFER);
}
public GLXOffScreenSurfaceData(X11ComponentPeer peer,
GLXGraphicsConfig gc,
int width, int height,
Image image, ColorModel cm,
int type)
{
super(peer, gc, cm, type);
this.width = width;
this.height = height;
offscreenImage = image;
initSurface(width, height);
}
protected X11SurfaceData(X11ComponentPeer peer,
X11GraphicsConfig gc,
SurfaceType sType,
ColorModel cm) {
super(sType, cm);
this.peer = peer;
this.graphicsConfig = gc;
this.solidloops = graphicsConfig.getSolidLoops(sType);
this.depth = cm.getPixelSize();
initOps(peer, graphicsConfig, depth);
if (isAccelerationEnabled()) {
setBlitProxyKey(gc.getProxyKey());
}
}
public static X11GraphicsConfig getGC(X11ComponentPeer peer) {
if (peer != null) {
return (X11GraphicsConfig) peer.getGraphicsConfiguration();
} else {
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice();
return (X11GraphicsConfig)gd.getDefaultConfiguration();
}
}
public static GLXGraphicsConfig getGC(X11ComponentPeer peer) {
if (peer != null) {
return (GLXGraphicsConfig)peer.getGraphicsConfiguration();
} else {
// REMIND: this should rarely (never?) happen, but what if
// default config is not GLX?
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice();
return (GLXGraphicsConfig)gd.getDefaultConfiguration();
}
}
/**
* Performs the native XDBE flip operation for the given target Component.
*/
public void flip(X11ComponentPeer peer,
Component target, VolatileImage xBackBuffer,
int x1, int y1, int x2, int y2,
BufferCapabilities.FlipContents flipAction)
{
long window = peer.getContentWindow();
int swapAction = getSwapAction(flipAction);
swapBuffers(window, swapAction);
}
protected X11SurfaceData(X11ComponentPeer peer,
X11GraphicsConfig gc,
SurfaceType sType,
ColorModel cm) {
super(sType, cm);
this.peer = peer;
this.graphicsConfig = gc;
this.solidloops = graphicsConfig.getSolidLoops(sType);
this.depth = cm.getPixelSize();
initOps(peer, graphicsConfig, depth);
if (isAccelerationEnabled()) {
setBlitProxyKey(gc.getProxyKey());
}
}
public GLXOffScreenSurfaceData(X11ComponentPeer peer,
GLXGraphicsConfig gc,
int width, int height,
Image image, ColorModel cm,
int type)
{
super(peer, gc, cm, type);
scale = gc.getDevice().getScaleFactor();
this.width = width * scale;
this.height = height * scale;
offscreenImage = image;
initSurface(this.width, this.height);
}
protected X11SurfaceData(X11ComponentPeer peer,
X11GraphicsConfig gc,
SurfaceType sType,
ColorModel cm) {
super(sType, cm);
this.peer = peer;
this.graphicsConfig = gc;
this.solidloops = graphicsConfig.getSolidLoops(sType);
this.depth = cm.getPixelSize();
initOps(peer, graphicsConfig, depth);
if (isAccelerationEnabled()) {
setBlitProxyKey(gc.getProxyKey());
}
}
public X11WindowSurfaceData(X11ComponentPeer peer,
X11GraphicsConfig gc,
SurfaceType sType) {
super(peer, gc, sType, peer.getColorModel());
if (isDrawableValid()) {
makePipes();
}
}
public GLXVSyncOffScreenSurfaceData(X11ComponentPeer peer,
GLXGraphicsConfig gc,
int width, int height,
Image image, ColorModel cm,
int type)
{
super(peer, gc, width, height, image, cm, type);
flipSurface = GLXSurfaceData.createData(peer, image, FLIP_BACKBUFFER);
}
public GLXOffScreenSurfaceData(X11ComponentPeer peer,
GLXGraphicsConfig gc,
int width, int height,
Image image, ColorModel cm,
int type)
{
super(peer, gc, cm, type);
this.width = width;
this.height = height;
offscreenImage = image;
initSurface(width, height);
}
protected GLXSurfaceData(X11ComponentPeer peer, GLXGraphicsConfig gc,
ColorModel cm, int type)
{
super(gc, cm, type);
this.peer = peer;
this.graphicsConfig = gc;
initOps(gc, peer, graphicsConfig.getAData());
}
public static X11GraphicsConfig getGC(X11ComponentPeer peer) {
if (peer != null) {
return (X11GraphicsConfig) peer.getGraphicsConfiguration();
} else {
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice();
return (X11GraphicsConfig)gd.getDefaultConfiguration();
}
}
protected GLXSurfaceData(X11ComponentPeer peer, GLXGraphicsConfig gc,
ColorModel cm, int type)
{
super(gc, cm, type);
this.peer = peer;
this.graphicsConfig = gc;
initOps(peer, graphicsConfig.getAData());
}
public static GLXGraphicsConfig getGC(X11ComponentPeer peer) {
if (peer != null) {
return (GLXGraphicsConfig)peer.getGraphicsConfiguration();
} else {
// REMIND: this should rarely (never?) happen, but what if
// default config is not GLX?
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = env.getDefaultScreenDevice();
return (GLXGraphicsConfig)gd.getDefaultConfiguration();
}
}