Search in sources :

Example 1 with ScreenUpdateManager

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

the class WComponentPeer method replaceSurfaceData.

/**
     * Multi-buffer version of replaceSurfaceData.  This version is called
     * by createBuffers(), which needs to acquire the same locks in the same
     * order, but also needs to perform additional functions inside the
     * locks.
     */
public void replaceSurfaceData(int newNumBackBuffers, BufferCapabilities caps) {
    SurfaceData oldData = null;
    VolatileImage oldBB = null;
    synchronized (((Component) target).getTreeLock()) {
        synchronized (this) {
            if (pData == 0) {
                return;
            }
            numBackBuffers = newNumBackBuffers;
            ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
            oldData = surfaceData;
            mgr.dropScreenSurface(oldData);
            createScreenSurface(true);
            if (oldData != null) {
                oldData.invalidate();
            }
            oldBB = backBuffer;
            if (numBackBuffers > 0) {
                // set the caps first, they're used when creating the bb
                backBufferCaps = caps;
                Win32GraphicsConfig gc = (Win32GraphicsConfig) getGraphicsConfiguration();
                backBuffer = gc.createBackBuffer(this);
            } else if (backBuffer != null) {
                backBufferCaps = null;
                backBuffer = null;
            }
        }
    }
    // but then we'd run into deadlock issues
    if (oldData != null) {
        oldData.flush();
        // null out the old data to make it collected faster
        oldData = null;
    }
    if (oldBB != null) {
        oldBB.flush();
        // null out the old data to make it collected faster
        oldData = null;
    }
}
Also used : Win32GraphicsConfig(sun.awt.Win32GraphicsConfig) D3DSurfaceData(sun.java2d.d3d.D3DSurfaceData) SurfaceData(sun.java2d.SurfaceData) OGLSurfaceData(sun.java2d.opengl.OGLSurfaceData) SunVolatileImage(sun.awt.image.SunVolatileImage) VolatileImage(java.awt.image.VolatileImage) ScreenUpdateManager(sun.java2d.ScreenUpdateManager)

Example 2 with ScreenUpdateManager

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

the class WComponentPeer method createScreenSurface.

public void createScreenSurface(boolean isResize) {
    Win32GraphicsConfig gc = (Win32GraphicsConfig) getGraphicsConfiguration();
    ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
    surfaceData = mgr.createScreenSurface(gc, this, numBackBuffers, isResize);
}
Also used : Win32GraphicsConfig(sun.awt.Win32GraphicsConfig) ScreenUpdateManager(sun.java2d.ScreenUpdateManager)

Example 3 with ScreenUpdateManager

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

Aggregations

ScreenUpdateManager (sun.java2d.ScreenUpdateManager)3 Win32GraphicsConfig (sun.awt.Win32GraphicsConfig)2 SurfaceData (sun.java2d.SurfaceData)2 D3DSurfaceData (sun.java2d.d3d.D3DSurfaceData)2 OGLSurfaceData (sun.java2d.opengl.OGLSurfaceData)2 VolatileImage (java.awt.image.VolatileImage)1 SunVolatileImage (sun.awt.image.SunVolatileImage)1