Search in sources :

Example 1 with WComponentPeer

use of sun.awt.windows.WComponentPeer in project jdk8u_jdk by JetBrains.

the class D3DVolatileSurfaceManager method initAcceleratedSurface.

/**
     * Create a pbuffer-based SurfaceData object (or init the backbuffer
     * of an existing window if this is a double buffered GraphicsConfig).
     */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;
    Component comp = vImg.getComponent();
    WComponentPeer peer = (comp != null) ? (WComponentPeer) comp.getPeer() : null;
    try {
        boolean forceback = false;
        if (context instanceof Boolean) {
            forceback = ((Boolean) context).booleanValue();
        }
        if (forceback) {
            // peer must be non-null in this case
            sData = D3DSurfaceData.createData(peer, vImg);
        } else {
            D3DGraphicsConfig gc = (D3DGraphicsConfig) vImg.getGraphicsConfig();
            ColorModel cm = gc.getColorModel(vImg.getTransparency());
            int type = vImg.getForcedAccelSurfaceType();
            // use the forced type, otherwise use RT_TEXTURE
            if (type == UNDEFINED) {
                type = RT_TEXTURE;
            }
            sData = D3DSurfaceData.createData(gc, vImg.getWidth(), vImg.getHeight(), cm, vImg, type);
        }
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    } catch (InvalidPipeException ipe) {
        sData = null;
    }
    return sData;
}
Also used : InvalidPipeException(sun.java2d.InvalidPipeException) SurfaceData(sun.java2d.SurfaceData) GDIWindowSurfaceData(sun.java2d.windows.GDIWindowSurfaceData) ColorModel(java.awt.image.ColorModel) WComponentPeer(sun.awt.windows.WComponentPeer) Component(java.awt.Component)

Example 2 with WComponentPeer

use of sun.awt.windows.WComponentPeer 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)

Example 3 with WComponentPeer

use of sun.awt.windows.WComponentPeer in project jdk8u_jdk by JetBrains.

the class WGLVolatileSurfaceManager method initAcceleratedSurface.

/**
     * Create a pbuffer-based SurfaceData object (or init the backbuffer
     * of an existing window if this is a double buffered GraphicsConfig).
     */
protected SurfaceData initAcceleratedSurface() {
    SurfaceData sData;
    Component comp = vImg.getComponent();
    WComponentPeer peer = (comp != null) ? (WComponentPeer) comp.getPeer() : null;
    try {
        boolean createVSynced = false;
        boolean forceback = false;
        if (context instanceof Boolean) {
            forceback = ((Boolean) context).booleanValue();
            if (forceback) {
                BufferCapabilities caps = peer.getBackBufferCaps();
                if (caps instanceof ExtendedBufferCapabilities) {
                    ExtendedBufferCapabilities ebc = (ExtendedBufferCapabilities) caps;
                    if (ebc.getVSync() == VSYNC_ON && ebc.getFlipContents() == COPIED) {
                        createVSynced = true;
                        forceback = false;
                    }
                }
            }
        }
        if (forceback) {
            // peer must be non-null in this case
            sData = WGLSurfaceData.createData(peer, vImg, FLIP_BACKBUFFER);
        } else {
            WGLGraphicsConfig gc = (WGLGraphicsConfig) vImg.getGraphicsConfig();
            ColorModel cm = gc.getColorModel(vImg.getTransparency());
            int type = vImg.getForcedAccelSurfaceType();
            // use the forced type, otherwise choose one based on caps
            if (type == OGLSurfaceData.UNDEFINED) {
                type = gc.isCapPresent(CAPS_EXT_FBOBJECT) ? OGLSurfaceData.FBOBJECT : OGLSurfaceData.PBUFFER;
            }
            if (createVSynced) {
                sData = WGLSurfaceData.createData(peer, vImg, type);
            } else {
                sData = WGLSurfaceData.createData(gc, vImg.getWidth(), vImg.getHeight(), cm, vImg, type);
            }
        }
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }
    return sData;
}
Also used : ExtendedBufferCapabilities(sun.java2d.pipe.hw.ExtendedBufferCapabilities) SurfaceData(sun.java2d.SurfaceData) ExtendedBufferCapabilities(sun.java2d.pipe.hw.ExtendedBufferCapabilities) BufferCapabilities(java.awt.BufferCapabilities) ColorModel(java.awt.image.ColorModel) WComponentPeer(sun.awt.windows.WComponentPeer) Component(java.awt.Component)

Aggregations

WComponentPeer (sun.awt.windows.WComponentPeer)3 Component (java.awt.Component)2 ColorModel (java.awt.image.ColorModel)2 SurfaceData (sun.java2d.SurfaceData)2 GDIWindowSurfaceData (sun.java2d.windows.GDIWindowSurfaceData)2 BufferCapabilities (java.awt.BufferCapabilities)1 SurfaceManager (sun.awt.image.SurfaceManager)1 VolatileSurfaceManager (sun.awt.image.VolatileSurfaceManager)1 InvalidPipeException (sun.java2d.InvalidPipeException)1 ExtendedBufferCapabilities (sun.java2d.pipe.hw.ExtendedBufferCapabilities)1