Search in sources :

Example 36 with SurfaceData

use of sun.java2d.SurfaceData in project jdk8u_jdk by JetBrains.

the class D3DDrawImage method renderImageXform.

@Override
protected void renderImageXform(SunGraphics2D sg, Image img, AffineTransform tx, int interpType, int sx1, int sy1, int sx2, int sy2, Color bgColor) {
    //     - an appropriate TransformBlit primitive could not be found
    if (interpType != AffineTransformOp.TYPE_BICUBIC) {
        SurfaceData dstData = sg.surfaceData;
        SurfaceData srcData = dstData.getSourceSurfaceData(img, sg.TRANSFORM_GENERIC, sg.imageComp, bgColor);
        if (srcData != null && !isBgOperation(srcData, bgColor)) {
            SurfaceType srcType = srcData.getSurfaceType();
            SurfaceType dstType = dstData.getSurfaceType();
            TransformBlit blit = TransformBlit.getFromCache(srcType, sg.imageComp, dstType);
            if (blit != null) {
                blit.Transform(srcData, dstData, sg.composite, sg.getCompClip(), tx, interpType, sx1, sy1, 0, 0, sx2 - sx1, sy2 - sy1);
                return;
            }
        }
    }
    super.renderImageXform(sg, img, tx, interpType, sx1, sy1, sx2, sy2, bgColor);
}
Also used : TransformBlit(sun.java2d.loops.TransformBlit) SurfaceData(sun.java2d.SurfaceData) SurfaceType(sun.java2d.loops.SurfaceType)

Example 37 with SurfaceData

use of sun.java2d.SurfaceData 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 38 with SurfaceData

use of sun.java2d.SurfaceData in project jdk8u_jdk by JetBrains.

the class D3DScreenUpdateManager method getReplacementScreenSurface.

@Override
public SurfaceData getReplacementScreenSurface(WComponentPeer peer, SurfaceData sd) {
    SurfaceData newSurface = super.getReplacementScreenSurface(peer, sd);
    // if some outstanding graphics context wants to get a replacement we
    // need to make sure that the new surface (if it is accelerated) is
    // being tracked
    trackScreenSurface(newSurface);
    return newSurface;
}
Also used : SurfaceData(sun.java2d.SurfaceData) D3DWindowSurfaceData(sun.java2d.d3d.D3DSurfaceData.D3DWindowSurfaceData) GDIWindowSurfaceData(sun.java2d.windows.GDIWindowSurfaceData)

Example 39 with SurfaceData

use of sun.java2d.SurfaceData 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

SurfaceData (sun.java2d.SurfaceData)39 ColorModel (java.awt.image.ColorModel)9 SunGraphics2D (sun.java2d.SunGraphics2D)7 Blit (sun.java2d.loops.Blit)7 TransformBlit (sun.java2d.loops.TransformBlit)7 ScaledBlit (sun.java2d.loops.ScaledBlit)6 SurfaceType (sun.java2d.loops.SurfaceType)6 GDIWindowSurfaceData (sun.java2d.windows.GDIWindowSurfaceData)5 Component (java.awt.Component)4 BufferedImage (java.awt.image.BufferedImage)4 OGLSurfaceData (sun.java2d.opengl.OGLSurfaceData)4 BufferCapabilities (java.awt.BufferCapabilities)3 Graphics (java.awt.Graphics)3 Raster (java.awt.image.Raster)3 WeakReference (java.lang.ref.WeakReference)3 SurfaceManager (sun.awt.image.SurfaceManager)3 InvalidPipeException (sun.java2d.InvalidPipeException)3 D3DSurfaceData (sun.java2d.d3d.D3DSurfaceData)3 Graphics2D (java.awt.Graphics2D)2 PaintContext (java.awt.PaintContext)2