use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class VolatileImageBug method main.
public static void main(String[] args) {
boolean iaeThrown = false;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
try {
VolatileImage volatileImage = gc.createCompatibleVolatileImage(0, 0);
} catch (IllegalArgumentException iae) {
iaeThrown = true;
}
if (!iaeThrown) {
throw new RuntimeException("IllegalArgumentException not thrown " + "for createCompatibleVolatileImage(0,0)");
}
}
use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class SourceClippingBlitTest method getVImage.
static VolatileImage getVImage(GraphicsConfiguration gc, int w, int h) {
VolatileImage image = gc.createCompatibleVolatileImage(w, h, Transparency.OPAQUE);
image.validate(gc);
initImage(gc, image);
return image;
}
use of java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class SourceClippingBlitTest method render.
public void render(Graphics g, Image image, Rectangle srcRect, Rectangle dstRect) {
int w = getWidth();
int h = getHeight();
g.setColor(Color.green);
g.fillRect(0, 0, w, h);
int bltWidth = srcRect.width;
int bltHeight = srcRect.height;
VolatileImage vi = null;
if (image instanceof VolatileImage) {
vi = (VolatileImage) image;
}
do {
if (vi != null) {
GraphicsConfiguration gc = getGraphicsConfiguration();
if (vi.validate(gc) != VolatileImage.IMAGE_OK) {
initImage(gc, vi);
}
}
g.drawImage(image, dstRect.x, dstRect.y, dstRect.x + bltWidth, dstRect.y + bltHeight, srcRect.x, srcRect.y, srcRect.x + bltWidth, srcRect.y + bltHeight, Color.red, null);
} while (vi != null && vi.contentsLost());
}
use of java.awt.image.VolatileImage 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 java.awt.image.VolatileImage in project jdk8u_jdk by JetBrains.
the class WComponentPeer method flip.
@Override
public void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction) {
VolatileImage backBuffer = this.backBuffer;
if (backBuffer == null) {
throw new IllegalStateException("Buffers have not been created");
}
Win32GraphicsConfig gc = (Win32GraphicsConfig) getGraphicsConfiguration();
gc.flip(this, (Component) target, backBuffer, x1, y1, x2, y2, flipAction);
}
Aggregations