Search in sources :

Example 6 with SurfaceManager

use of sun.awt.image.SurfaceManager in project jdk8u_jdk by JetBrains.

the class D3DGraphicsConfig method flip.

/**
     * Performs the native D3D flip operation for the given target Component.
     */
@Override
public void flip(WComponentPeer peer, Component target, VolatileImage backBuffer, int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction) {
    // REMIND: we should actually get a surface data for the
    // backBuffer's VI
    SurfaceManager d3dvsm = SurfaceManager.getManager(backBuffer);
    SurfaceData sd = d3dvsm.getPrimarySurfaceData();
    if (sd instanceof D3DSurfaceData) {
        D3DSurfaceData d3dsd = (D3DSurfaceData) sd;
        D3DSurfaceData.swapBuffers(d3dsd, x1, y1, x2, y2);
    } else {
        // the surface was likely lost could not have been restored
        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) {
        Graphics g = backBuffer.getGraphics();
        try {
            g.setColor(target.getBackground());
            g.fillRect(0, 0, backBuffer.getWidth(), backBuffer.getHeight());
        } finally {
            g.dispose();
        }
    }
}
Also used : Graphics(java.awt.Graphics) SurfaceData(sun.java2d.SurfaceData) SurfaceManager(sun.awt.image.SurfaceManager)

Example 7 with SurfaceManager

use of sun.awt.image.SurfaceManager in project jdk8u_jdk by JetBrains.

the class D3DVolatileSurfaceManager method handleVItoScreenOp.

/**
     * If the destination surface's peer can potentially handle accelerated
     * on-screen rendering then it is likely that the condition which resulted
     * in VI to Screen operation is temporary, so this method sets the
     * restore countdown in hope that the on-screen accelerated rendering will
     * resume. In the meantime the backup surface of the VISM will be used.
     *
     * The countdown is needed because otherwise we may never break out
     * of "do { vi.validate()..} while(vi.lost)" loop since validate() could
     * restore the source surface every time and it will get lost again on the
     * next copy attempt, and we would never get a chance to use the backup
     * surface. By using the countdown we allow the backup surface to be used
     * while the screen surface gets sorted out, or if it for some reason can
     * never be restored.
     *
     * If the destination surface's peer could never do accelerated onscreen
     * rendering then the acceleration for the SurfaceManager associated with
     * the source surface is disabled forever.
     */
static void handleVItoScreenOp(SurfaceData src, SurfaceData dst) {
    if (src instanceof D3DSurfaceData && dst instanceof GDIWindowSurfaceData) {
        D3DSurfaceData d3dsd = (D3DSurfaceData) src;
        SurfaceManager mgr = SurfaceManager.getManager((Image) d3dsd.getDestination());
        if (mgr instanceof D3DVolatileSurfaceManager) {
            D3DVolatileSurfaceManager vsm = (D3DVolatileSurfaceManager) mgr;
            if (vsm != null) {
                d3dsd.setSurfaceLost(true);
                GDIWindowSurfaceData wsd = (GDIWindowSurfaceData) dst;
                WComponentPeer p = wsd.getPeer();
                if (D3DScreenUpdateManager.canUseD3DOnScreen(p, (Win32GraphicsConfig) p.getGraphicsConfiguration(), p.getBackBuffersNum())) {
                    // 10 is only chosen to be greater than the number of
                    // times a sane person would call validate() inside
                    // a validation loop, and to reduce thrashing between
                    // accelerated and backup surfaces
                    vsm.setRestoreCountdown(10);
                } else {
                    vsm.setAccelerationEnabled(false);
                }
            }
        }
    }
}
Also used : GDIWindowSurfaceData(sun.java2d.windows.GDIWindowSurfaceData) VolatileSurfaceManager(sun.awt.image.VolatileSurfaceManager) SurfaceManager(sun.awt.image.SurfaceManager) WComponentPeer(sun.awt.windows.WComponentPeer)

Aggregations

SurfaceManager (sun.awt.image.SurfaceManager)7 Graphics (java.awt.Graphics)3 SurfaceData (sun.java2d.SurfaceData)3 Graphics2D (java.awt.Graphics2D)2 SunGraphics2D (sun.java2d.SunGraphics2D)2 GDIWindowSurfaceData (sun.java2d.windows.GDIWindowSurfaceData)2 VolatileSurfaceManager (sun.awt.image.VolatileSurfaceManager)1 WComponentPeer (sun.awt.windows.WComponentPeer)1 GLXVSyncOffScreenSurfaceData (sun.java2d.opengl.GLXSurfaceData.GLXVSyncOffScreenSurfaceData)1 OGLSurfaceData (sun.java2d.opengl.OGLSurfaceData)1 WGLSurfaceData (sun.java2d.opengl.WGLSurfaceData)1