Search in sources :

Example 31 with SurfaceData

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

the class XWindow method dispose.

public void dispose() {
    SurfaceData oldData = surfaceData;
    surfaceData = null;
    if (oldData != null) {
        oldData.invalidate();
    }
    XToolkit.targetDisposedPeer(target, this);
    destroy();
}
Also used : SurfaceData(sun.java2d.SurfaceData)

Example 32 with SurfaceData

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

the class GLXVolatileSurfaceManager 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();
    X11ComponentPeer peer = (comp != null) ? (X11ComponentPeer) comp.getPeer() : null;
    try {
        boolean createVSynced = false;
        boolean forceback = false;
        if (context instanceof Boolean) {
            forceback = ((Boolean) context).booleanValue();
            if (forceback && peer instanceof BackBufferCapsProvider) {
                BackBufferCapsProvider provider = (BackBufferCapsProvider) peer;
                BufferCapabilities caps = provider.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 = GLXSurfaceData.createData(peer, vImg, FLIP_BACKBUFFER);
        } else {
            GLXGraphicsConfig gc = (GLXGraphicsConfig) 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 = GLXSurfaceData.createData(peer, vImg, type);
            } else {
                sData = GLXSurfaceData.createData(gc, vImg.getWidth(), vImg.getHeight(), cm, vImg, type);
            }
        }
    } catch (NullPointerException ex) {
        sData = null;
    } catch (OutOfMemoryError er) {
        sData = null;
    }
    return sData;
}
Also used : X11ComponentPeer(sun.awt.X11ComponentPeer) 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) BackBufferCapsProvider(sun.java2d.BackBufferCapsProvider) Component(java.awt.Component)

Example 33 with SurfaceData

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

the class GLXGraphicsConfig method flip.

/**
     * Performs the native GLX flip operation for the given target Component.
     */
@Override
public void flip(X11ComponentPeer peer, Component target, VolatileImage xBackBuffer, int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction) {
    if (flipAction == BufferCapabilities.FlipContents.COPIED) {
        SurfaceManager vsm = SurfaceManager.getManager(xBackBuffer);
        SurfaceData sd = vsm.getPrimarySurfaceData();
        if (sd instanceof GLXVSyncOffScreenSurfaceData) {
            GLXVSyncOffScreenSurfaceData vsd = (GLXVSyncOffScreenSurfaceData) sd;
            SurfaceData bbsd = vsd.getFlipSurface();
            Graphics2D bbg = new SunGraphics2D(bbsd, Color.black, Color.white, null);
            try {
                bbg.drawImage(xBackBuffer, 0, 0, null);
            } finally {
                bbg.dispose();
            }
        } else {
            Graphics g = peer.getGraphics();
            try {
                g.drawImage(xBackBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
            } finally {
                g.dispose();
            }
            return;
        }
    } else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
        // not supported by GLX...
        return;
    }
    OGLSurfaceData.swapBuffers(peer.getContentWindow());
    if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
        Graphics g = xBackBuffer.getGraphics();
        try {
            g.setColor(target.getBackground());
            g.fillRect(0, 0, xBackBuffer.getWidth(), xBackBuffer.getHeight());
        } finally {
            g.dispose();
        }
    }
}
Also used : Graphics(java.awt.Graphics) GLXVSyncOffScreenSurfaceData(sun.java2d.opengl.GLXSurfaceData.GLXVSyncOffScreenSurfaceData) SurfaceData(sun.java2d.SurfaceData) GLXVSyncOffScreenSurfaceData(sun.java2d.opengl.GLXSurfaceData.GLXVSyncOffScreenSurfaceData) OGLSurfaceData(sun.java2d.opengl.OGLSurfaceData) SurfaceManager(sun.awt.image.SurfaceManager) SunGraphics2D(sun.java2d.SunGraphics2D) Graphics2D(java.awt.Graphics2D) SunGraphics2D(sun.java2d.SunGraphics2D)

Example 34 with SurfaceData

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

the class WComponentPeer method getGraphics.

@Override
@SuppressWarnings("deprecation")
public Graphics getGraphics() {
    if (isDisposed()) {
        return null;
    }
    Component target = (Component) getTarget();
    Window window = SunToolkit.getContainingWindow(target);
    if (window != null) {
        Graphics g = ((WWindowPeer) window.getPeer()).getTranslucentGraphics();
        // getTranslucentGraphics() returns non-null value for non-opaque windows only
        if (g != null) {
            // Non-opaque windows do not support heavyweight children.
            // Redirect all painting to the Window's Graphics instead.
            // The caller is responsible for calling the
            // WindowPeer.updateWindow() after painting has finished.
            int x = 0, y = 0;
            for (Component c = target; c != window; c = c.getParent()) {
                x += c.getX();
                y += c.getY();
            }
            g.translate(x, y);
            g.clipRect(0, 0, target.getWidth(), target.getHeight());
            return g;
        }
    }
    SurfaceData surfaceData = this.surfaceData;
    if (surfaceData != null) {
        /* Fix for bug 4746122. Color and Font shouldn't be null */
        Color bgColor = background;
        if (bgColor == null) {
            bgColor = SystemColor.window;
        }
        Color fgColor = foreground;
        if (fgColor == null) {
            fgColor = SystemColor.windowText;
        }
        Font font = this.font;
        if (font == null) {
            font = defaultFont;
        }
        ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
        return mgr.createGraphics(surfaceData, this, fgColor, bgColor, font);
    }
    return null;
}
Also used : D3DSurfaceData(sun.java2d.d3d.D3DSurfaceData) SurfaceData(sun.java2d.SurfaceData) OGLSurfaceData(sun.java2d.opengl.OGLSurfaceData) ScreenUpdateManager(sun.java2d.ScreenUpdateManager)

Example 35 with SurfaceData

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

the class D3DSurfaceToGDIWindowSurfaceTransform method Transform.

@Override
public synchronized void Transform(SurfaceData src, SurfaceData dst, Composite comp, Region clip, AffineTransform at, int hint, int srcx, int srcy, int dstx, int dsty, int width, int height) {
    Blit convertsrc = Blit.getFromCache(src.getSurfaceType(), CompositeType.SrcNoEa, SurfaceType.IntArgbPre);
    // use cached intermediate surface, if available
    final SurfaceData cachedSrc = srcTmp != null ? srcTmp.get() : null;
    // convert source to IntArgbPre
    src = convertFrom(convertsrc, src, srcx, srcy, width, height, cachedSrc, BufferedImage.TYPE_INT_ARGB_PRE);
    // transform IntArgbPre intermediate surface to D3D surface
    performop.Transform(src, dst, comp, clip, at, hint, 0, 0, dstx, dsty, width, height);
    if (src != cachedSrc) {
        // cache the intermediate surface
        srcTmp = new WeakReference<>(src);
    }
}
Also used : SurfaceData(sun.java2d.SurfaceData) GDIWindowSurfaceData(sun.java2d.windows.GDIWindowSurfaceData) Blit(sun.java2d.loops.Blit) TransformBlit(sun.java2d.loops.TransformBlit) ScaledBlit(sun.java2d.loops.ScaledBlit)

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