Search in sources :

Example 6 with VolatileImage

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)");
    }
}
Also used : VolatileImage(java.awt.image.VolatileImage) GraphicsEnvironment(java.awt.GraphicsEnvironment) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 7 with VolatileImage

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;
}
Also used : VolatileImage(java.awt.image.VolatileImage)

Example 8 with VolatileImage

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());
}
Also used : VolatileImage(java.awt.image.VolatileImage) Point(java.awt.Point) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 9 with VolatileImage

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;
    }
}
Also used : Win32GraphicsConfig(sun.awt.Win32GraphicsConfig) D3DSurfaceData(sun.java2d.d3d.D3DSurfaceData) SurfaceData(sun.java2d.SurfaceData) OGLSurfaceData(sun.java2d.opengl.OGLSurfaceData) SunVolatileImage(sun.awt.image.SunVolatileImage) VolatileImage(java.awt.image.VolatileImage) ScreenUpdateManager(sun.java2d.ScreenUpdateManager)

Example 10 with VolatileImage

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);
}
Also used : Win32GraphicsConfig(sun.awt.Win32GraphicsConfig) SunVolatileImage(sun.awt.image.SunVolatileImage) VolatileImage(java.awt.image.VolatileImage)

Aggregations

VolatileImage (java.awt.image.VolatileImage)53 GraphicsConfiguration (java.awt.GraphicsConfiguration)30 BufferedImage (java.awt.image.BufferedImage)29 Graphics2D (java.awt.Graphics2D)24 GraphicsEnvironment (java.awt.GraphicsEnvironment)21 Graphics (java.awt.Graphics)6 AffineTransform (java.awt.geom.AffineTransform)6 Rectangle (java.awt.Rectangle)5 File (java.io.File)5 GraphicsDevice (java.awt.GraphicsDevice)3 Shape (java.awt.Shape)3 IOException (java.io.IOException)3 DestSurfaceProvider (sun.java2d.DestSurfaceProvider)3 Surface (sun.java2d.Surface)3 AWTException (java.awt.AWTException)2 Font (java.awt.Font)2 GradientPaint (java.awt.GradientPaint)2 Image (java.awt.Image)2 ImageCapabilities (java.awt.ImageCapabilities)2 Paint (java.awt.Paint)2