Java Code Examples for java.awt.BufferCapabilities#FlipContents

The following examples show how to use java.awt.BufferCapabilities#FlipContents . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CGLGraphicsConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
                 final int x1, final int y1, final int x2, final int y2,
                 final BufferCapabilities.FlipContents flipAction) {
    final Graphics g = peer.getGraphics();
    try {
        g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
    } finally {
        g.dispose();
    }
    if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
        final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
        try {
            bg.setBackground(peer.getBackground());
            bg.clearRect(0, 0, backBuffer.getWidth(null),
                         backBuffer.getHeight(null));
        } finally {
            bg.dispose();
        }
    }
}
 
Example 2
Source File: D3DSurfaceData.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a SurfaceData object representing the back buffer of a
 * double-buffered on-screen Window.
 */
public static D3DSurfaceData createData(WComponentPeer peer, Image image) {
    D3DGraphicsConfig gc = getGC(peer);
    if (gc == null || !peer.isAccelCapable()) {
        return null;
    }
    BufferCapabilities caps = peer.getBackBufferCaps();
    VSyncType vSyncType = VSYNC_DEFAULT;
    if (caps instanceof ExtendedBufferCapabilities) {
        vSyncType = ((ExtendedBufferCapabilities)caps).getVSync();
    }
    Rectangle r = peer.getBounds();
    BufferCapabilities.FlipContents flip = caps.getFlipContents();
    int swapEffect;
    if (flip == FlipContents.COPIED) {
        swapEffect = SWAP_COPY;
    } else if (flip == FlipContents.PRIOR) {
        swapEffect = SWAP_FLIP;
    } else { // flip == FlipContents.UNDEFINED || .BACKGROUND
        swapEffect = SWAP_DISCARD;
    }
    return new D3DSurfaceData(peer, gc, r.width, r.height,
                              image, peer.getColorModel(),
                              peer.getBackBuffersNum(),
                              swapEffect, vSyncType, FLIP_BACKBUFFER);
}
 
Example 3
Source File: CGLGraphicsConfig.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
                 final int x1, final int y1, final int x2, final int y2,
                 final BufferCapabilities.FlipContents flipAction) {
    final Graphics g = peer.getGraphics();
    try {
        g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
    } finally {
        g.dispose();
    }
    if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
        final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
        try {
            bg.setBackground(peer.getBackground());
            bg.clearRect(0, 0, backBuffer.getWidth(null),
                         backBuffer.getHeight(null));
        } finally {
            bg.dispose();
        }
    }
}
 
Example 4
Source File: CGLGraphicsConfig.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
                 final int x1, final int y1, final int x2, final int y2,
                 final BufferCapabilities.FlipContents flipAction) {
    final Graphics g = peer.getGraphics();
    try {
        g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
    } finally {
        g.dispose();
    }
    if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
        final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
        try {
            bg.setBackground(peer.getBackground());
            bg.clearRect(0, 0, backBuffer.getWidth(null),
                         backBuffer.getHeight(null));
        } finally {
            bg.dispose();
        }
    }
}
 
Example 5
Source File: CGLGraphicsConfig.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
                 final int x1, final int y1, final int x2, final int y2,
                 final BufferCapabilities.FlipContents flipAction) {
    final Graphics g = peer.getGraphics();
    try {
        g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
    } finally {
        g.dispose();
    }
    if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
        final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
        try {
            bg.setBackground(peer.getBackground());
            bg.clearRect(0, 0, backBuffer.getWidth(null),
                         backBuffer.getHeight(null));
        } finally {
            bg.dispose();
        }
    }
}
 
Example 6
Source File: D3DSurfaceData.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a SurfaceData object representing the back buffer of a
 * double-buffered on-screen Window.
 */
public static D3DSurfaceData createData(WComponentPeer peer, Image image) {
    D3DGraphicsConfig gc = getGC(peer);
    if (gc == null || !peer.isAccelCapable()) {
        return null;
    }
    BufferCapabilities caps = peer.getBackBufferCaps();
    VSyncType vSyncType = VSYNC_DEFAULT;
    if (caps instanceof ExtendedBufferCapabilities) {
        vSyncType = ((ExtendedBufferCapabilities)caps).getVSync();
    }
    Rectangle r = peer.getBounds();
    BufferCapabilities.FlipContents flip = caps.getFlipContents();
    int swapEffect;
    if (flip == FlipContents.COPIED) {
        swapEffect = SWAP_COPY;
    } else if (flip == FlipContents.PRIOR) {
        swapEffect = SWAP_FLIP;
    } else { // flip == FlipContents.UNDEFINED || .BACKGROUND
        swapEffect = SWAP_DISCARD;
    }
    return new D3DSurfaceData(peer, gc, r.width, r.height,
                              image, peer.getColorModel(),
                              peer.getBackBuffersNum(),
                              swapEffect, vSyncType, FLIP_BACKBUFFER);
}
 
Example 7
Source File: CGLGraphicsConfig.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
                 final int x1, final int y1, final int x2, final int y2,
                 final BufferCapabilities.FlipContents flipAction) {
    final Graphics g = peer.getGraphics();
    try {
        g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
    } finally {
        g.dispose();
    }
    if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
        final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
        try {
            bg.setBackground(peer.getBackground());
            bg.clearRect(0, 0, backBuffer.getWidth(null),
                         backBuffer.getHeight(null));
        } finally {
            bg.dispose();
        }
    }
}
 
Example 8
Source File: CGLGraphicsConfig.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
                 final int x1, final int y1, final int x2, final int y2,
                 final BufferCapabilities.FlipContents flipAction) {
    final Graphics g = peer.getGraphics();
    try {
        g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
    } finally {
        g.dispose();
    }
    if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
        final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
        try {
            bg.setBackground(peer.getBackground());
            bg.clearRect(0, 0, backBuffer.getWidth(null),
                         backBuffer.getHeight(null));
        } finally {
            bg.dispose();
        }
    }
}
 
Example 9
Source File: D3DSurfaceData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a SurfaceData object representing the back buffer of a
 * double-buffered on-screen Window.
 */
public static D3DSurfaceData createData(WComponentPeer peer, Image image) {
    D3DGraphicsConfig gc = getGC(peer);
    if (gc == null || !peer.isAccelCapable()) {
        return null;
    }
    BufferCapabilities caps = peer.getBackBufferCaps();
    VSyncType vSyncType = VSYNC_DEFAULT;
    if (caps instanceof ExtendedBufferCapabilities) {
        vSyncType = ((ExtendedBufferCapabilities)caps).getVSync();
    }
    Rectangle r = peer.getBounds();
    BufferCapabilities.FlipContents flip = caps.getFlipContents();
    int swapEffect;
    if (flip == FlipContents.COPIED) {
        swapEffect = SWAP_COPY;
    } else if (flip == FlipContents.PRIOR) {
        swapEffect = SWAP_FLIP;
    } else { // flip == FlipContents.UNDEFINED || .BACKGROUND
        swapEffect = SWAP_DISCARD;
    }
    return new D3DSurfaceData(peer, gc, r.width, r.height,
                              image, peer.getColorModel(),
                              peer.getBackBuffersNum(),
                              swapEffect, vSyncType, FLIP_BACKBUFFER);
}
 
Example 10
Source File: XComponentPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void flip(int x1, int y1, int x2, int y2,
                 BufferCapabilities.FlipContents flipAction)
{
    if (buffersLog.isLoggable(PlatformLogger.Level.FINE)) {
        buffersLog.fine("flip(" + flipAction + ")");
    }
    if (backBuffer == 0) {
        throw new IllegalStateException("Buffers have not been created");
    }
    graphicsConfig.flip(this, target, xBackBuffer,
                        x1, y1, x2, y2, flipAction);
}
 
Example 11
Source File: XComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void flip(int x1, int y1, int x2, int y2,
                 BufferCapabilities.FlipContents flipAction)
{
    if (buffersLog.isLoggable(PlatformLogger.Level.FINE)) {
        buffersLog.fine("flip(" + flipAction + ")");
    }
    if (backBuffer == 0) {
        throw new IllegalStateException("Buffers have not been created");
    }
    graphicsConfig.flip(this, target, xBackBuffer,
                        x1, y1, x2, y2, flipAction);
}
 
Example 12
Source File: X11GraphicsConfig.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps the given FlipContents constant to the associated XDBE swap
 * action constant.
 */
private static int getSwapAction(
    BufferCapabilities.FlipContents flipAction) {
    if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
        return 0x01;
    } else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
        return 0x02;
    } else if (flipAction == BufferCapabilities.FlipContents.COPIED) {
        return 0x03;
    } else {
        return 0x00; // UNDEFINED
    }
}
 
Example 13
Source File: XComponentPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void flip(int x1, int y1, int x2, int y2,
                 BufferCapabilities.FlipContents flipAction)
{
    if (buffersLog.isLoggable(PlatformLogger.Level.FINE)) {
        buffersLog.fine("flip(" + flipAction + ")");
    }
    if (backBuffer == 0) {
        throw new IllegalStateException("Buffers have not been created");
    }
    graphicsConfig.flip(this, target, xBackBuffer,
                        x1, y1, x2, y2, flipAction);
}
 
Example 14
Source File: X11GraphicsConfig.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps the given FlipContents constant to the associated XDBE swap
 * action constant.
 */
private static int getSwapAction(
    BufferCapabilities.FlipContents flipAction) {
    if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
        return 0x01;
    } else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
        return 0x02;
    } else if (flipAction == BufferCapabilities.FlipContents.COPIED) {
        return 0x03;
    } else {
        return 0x00; // UNDEFINED
    }
}
 
Example 15
Source File: X11GraphicsConfig.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps the given FlipContents constant to the associated XDBE swap
 * action constant.
 */
private static int getSwapAction(
    BufferCapabilities.FlipContents flipAction) {
    if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
        return 0x01;
    } else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
        return 0x02;
    } else if (flipAction == BufferCapabilities.FlipContents.COPIED) {
        return 0x03;
    } else {
        return 0x00; // UNDEFINED
    }
}
 
Example 16
Source File: X11GraphicsConfig.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 17
Source File: XComponentPeer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void flip(int x1, int y1, int x2, int y2,
                 BufferCapabilities.FlipContents flipAction)
{
    if (buffersLog.isLoggable(PlatformLogger.Level.FINE)) {
        buffersLog.fine("flip(" + flipAction + ")");
    }
    if (backBuffer == 0) {
        throw new IllegalStateException("Buffers have not been created");
    }
    graphicsConfig.flip(this, target, xBackBuffer,
                        x1, y1, x2, y2, flipAction);
}
 
Example 18
Source File: NullComponentPeer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void flip(int x1, int y1, int x2, int y2,
                 BufferCapabilities.FlipContents flipAction)
{
    throw new IllegalStateException(
        "Page-flipping is not allowed on a lightweight component");
}
 
Example 19
Source File: NullComponentPeer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void flip(int x1, int y1, int x2, int y2,
                 BufferCapabilities.FlipContents flipAction)
{
    throw new IllegalStateException(
        "Page-flipping is not allowed on a lightweight component");
}
 
Example 20
Source File: LWGraphicsConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Performs the native flip operation for the given target Component. Our
 * flip is implemented through normal drawImage() to the graphic object,
 * because of our components uses a graphic object of the container(in this
 * case we also apply necessary constrains)
 */
void flip(LWComponentPeer<?, ?> peer, Image backBuffer, int x1, int y1,
          int x2, int y2, BufferCapabilities.FlipContents flipAction);