use of sun.java2d.SurfaceData in project jdk8u_jdk by JetBrains.
the class XWindow method dispose.
public void dispose() {
SurfaceData oldData = surfaceData;
surfaceData = null;
if (oldData != null) {
oldData.invalidate();
}
XToolkit.targetDisposedPeer(target, this);
destroy();
}
use of sun.java2d.SurfaceData in project jdk8u_jdk by JetBrains.
the class GLXVolatileSurfaceManager method initAcceleratedSurface.
/**
* Create a pbuffer-based SurfaceData object (or init the backbuffer
* of an existing window if this is a double buffered GraphicsConfig)
*/
protected SurfaceData initAcceleratedSurface() {
SurfaceData sData;
Component comp = vImg.getComponent();
X11ComponentPeer peer = (comp != null) ? (X11ComponentPeer) comp.getPeer() : null;
try {
boolean createVSynced = false;
boolean forceback = false;
if (context instanceof Boolean) {
forceback = ((Boolean) context).booleanValue();
if (forceback && peer instanceof BackBufferCapsProvider) {
BackBufferCapsProvider provider = (BackBufferCapsProvider) peer;
BufferCapabilities caps = provider.getBackBufferCaps();
if (caps instanceof ExtendedBufferCapabilities) {
ExtendedBufferCapabilities ebc = (ExtendedBufferCapabilities) caps;
if (ebc.getVSync() == VSYNC_ON && ebc.getFlipContents() == COPIED) {
createVSynced = true;
forceback = false;
}
}
}
}
if (forceback) {
// peer must be non-null in this case
sData = GLXSurfaceData.createData(peer, vImg, FLIP_BACKBUFFER);
} else {
GLXGraphicsConfig gc = (GLXGraphicsConfig) vImg.getGraphicsConfig();
ColorModel cm = gc.getColorModel(vImg.getTransparency());
int type = vImg.getForcedAccelSurfaceType();
// use the forced type, otherwise choose one based on caps
if (type == OGLSurfaceData.UNDEFINED) {
type = gc.isCapPresent(CAPS_EXT_FBOBJECT) ? OGLSurfaceData.FBOBJECT : OGLSurfaceData.PBUFFER;
}
if (createVSynced) {
sData = GLXSurfaceData.createData(peer, vImg, type);
} else {
sData = GLXSurfaceData.createData(gc, vImg.getWidth(), vImg.getHeight(), cm, vImg, type);
}
}
} catch (NullPointerException ex) {
sData = null;
} catch (OutOfMemoryError er) {
sData = null;
}
return sData;
}
use of sun.java2d.SurfaceData in project jdk8u_jdk by JetBrains.
the class GLXGraphicsConfig method flip.
/**
* Performs the native GLX flip operation for the given target Component.
*/
@Override
public void flip(X11ComponentPeer peer, Component target, VolatileImage xBackBuffer, int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction) {
if (flipAction == BufferCapabilities.FlipContents.COPIED) {
SurfaceManager vsm = SurfaceManager.getManager(xBackBuffer);
SurfaceData sd = vsm.getPrimarySurfaceData();
if (sd instanceof GLXVSyncOffScreenSurfaceData) {
GLXVSyncOffScreenSurfaceData vsd = (GLXVSyncOffScreenSurfaceData) sd;
SurfaceData bbsd = vsd.getFlipSurface();
Graphics2D bbg = new SunGraphics2D(bbsd, Color.black, Color.white, null);
try {
bbg.drawImage(xBackBuffer, 0, 0, null);
} finally {
bbg.dispose();
}
} else {
Graphics g = peer.getGraphics();
try {
g.drawImage(xBackBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
} finally {
g.dispose();
}
return;
}
} else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
// not supported by GLX...
return;
}
OGLSurfaceData.swapBuffers(peer.getContentWindow());
if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
Graphics g = xBackBuffer.getGraphics();
try {
g.setColor(target.getBackground());
g.fillRect(0, 0, xBackBuffer.getWidth(), xBackBuffer.getHeight());
} finally {
g.dispose();
}
}
}
use of sun.java2d.SurfaceData in project jdk8u_jdk by JetBrains.
the class WComponentPeer method getGraphics.
@Override
@SuppressWarnings("deprecation")
public Graphics getGraphics() {
if (isDisposed()) {
return null;
}
Component target = (Component) getTarget();
Window window = SunToolkit.getContainingWindow(target);
if (window != null) {
Graphics g = ((WWindowPeer) window.getPeer()).getTranslucentGraphics();
// getTranslucentGraphics() returns non-null value for non-opaque windows only
if (g != null) {
// Non-opaque windows do not support heavyweight children.
// Redirect all painting to the Window's Graphics instead.
// The caller is responsible for calling the
// WindowPeer.updateWindow() after painting has finished.
int x = 0, y = 0;
for (Component c = target; c != window; c = c.getParent()) {
x += c.getX();
y += c.getY();
}
g.translate(x, y);
g.clipRect(0, 0, target.getWidth(), target.getHeight());
return g;
}
}
SurfaceData surfaceData = this.surfaceData;
if (surfaceData != null) {
/* Fix for bug 4746122. Color and Font shouldn't be null */
Color bgColor = background;
if (bgColor == null) {
bgColor = SystemColor.window;
}
Color fgColor = foreground;
if (fgColor == null) {
fgColor = SystemColor.windowText;
}
Font font = this.font;
if (font == null) {
font = defaultFont;
}
ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
return mgr.createGraphics(surfaceData, this, fgColor, bgColor, font);
}
return null;
}
use of sun.java2d.SurfaceData in project jdk8u_jdk by JetBrains.
the class D3DSurfaceToGDIWindowSurfaceTransform method Transform.
@Override
public synchronized void Transform(SurfaceData src, SurfaceData dst, Composite comp, Region clip, AffineTransform at, int hint, int srcx, int srcy, int dstx, int dsty, int width, int height) {
Blit convertsrc = Blit.getFromCache(src.getSurfaceType(), CompositeType.SrcNoEa, SurfaceType.IntArgbPre);
// use cached intermediate surface, if available
final SurfaceData cachedSrc = srcTmp != null ? srcTmp.get() : null;
// convert source to IntArgbPre
src = convertFrom(convertsrc, src, srcx, srcy, width, height, cachedSrc, BufferedImage.TYPE_INT_ARGB_PRE);
// transform IntArgbPre intermediate surface to D3D surface
performop.Transform(src, dst, comp, clip, at, hint, 0, 0, dstx, dsty, width, height);
if (src != cachedSrc) {
// cache the intermediate surface
srcTmp = new WeakReference<>(src);
}
}
Aggregations