use of sun.java2d.ScreenUpdateManager in project jdk8u_jdk by JetBrains.
the class WComponentPeer method replaceSurfaceData.
/**
* Multi-buffer version of replaceSurfaceData. This version is called
* by createBuffers(), which needs to acquire the same locks in the same
* order, but also needs to perform additional functions inside the
* locks.
*/
public void replaceSurfaceData(int newNumBackBuffers, BufferCapabilities caps) {
SurfaceData oldData = null;
VolatileImage oldBB = null;
synchronized (((Component) target).getTreeLock()) {
synchronized (this) {
if (pData == 0) {
return;
}
numBackBuffers = newNumBackBuffers;
ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
oldData = surfaceData;
mgr.dropScreenSurface(oldData);
createScreenSurface(true);
if (oldData != null) {
oldData.invalidate();
}
oldBB = backBuffer;
if (numBackBuffers > 0) {
// set the caps first, they're used when creating the bb
backBufferCaps = caps;
Win32GraphicsConfig gc = (Win32GraphicsConfig) getGraphicsConfiguration();
backBuffer = gc.createBackBuffer(this);
} else if (backBuffer != null) {
backBufferCaps = null;
backBuffer = null;
}
}
}
// but then we'd run into deadlock issues
if (oldData != null) {
oldData.flush();
// null out the old data to make it collected faster
oldData = null;
}
if (oldBB != null) {
oldBB.flush();
// null out the old data to make it collected faster
oldData = null;
}
}
use of sun.java2d.ScreenUpdateManager in project jdk8u_jdk by JetBrains.
the class WComponentPeer method createScreenSurface.
public void createScreenSurface(boolean isResize) {
Win32GraphicsConfig gc = (Win32GraphicsConfig) getGraphicsConfiguration();
ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
surfaceData = mgr.createScreenSurface(gc, this, numBackBuffers, isResize);
}
use of sun.java2d.ScreenUpdateManager 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;
}
Aggregations