sun.java2d.d3d.D3DSurfaceData.D3DWindowSurfaceData Java Examples

The following examples show how to use sun.java2d.d3d.D3DSurfaceData.D3DWindowSurfaceData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #2
Source File: D3DScreenUpdateManager.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #3
Source File: D3DScreenUpdateManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #4
Source File: D3DScreenUpdateManager.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Restores the passed surface if it was lost, resets the lost status.
 * @param sd surface to be validated
 * @return true if surface wasn't lost or if restoration was successful,
 * false otherwise
 */
private boolean validate(D3DWindowSurfaceData sd) {
    if (sd.isSurfaceLost()) {
        try {
            sd.restoreSurface();
            // if succeeded, first fill the surface with bg color
            // note: use the non-synch method to avoid incorrect lock order
            Color bg = sd.getPeer().getBackgroundNoSync();
            SunGraphics2D sg2d = new SunGraphics2D(sd, bg, bg, null);
            sg2d.fillRect(0, 0, sd.getBounds().width, sd.getBounds().height);
            sg2d.dispose();
            // now clean the dirty status so that we don't flip it
            // next time before it gets repainted; it is safe
            // to do without the lock because we will issue a
            // repaint anyway so we will not lose any rendering
            sd.markClean();
            // since the surface was successfully restored we need to
            // repaint whole window to repopulate the back-buffer
            repaintPeerTarget(sd.getPeer());
        } catch (InvalidPipeException ipe) {
            return false;
        }
    }
    return true;
}
 
Example #5
Source File: D3DScreenUpdateManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Restores the passed surface if it was lost, resets the lost status.
 * @param sd surface to be validated
 * @return true if surface wasn't lost or if restoration was successful,
 * false otherwise
 */
private boolean validate(D3DWindowSurfaceData sd) {
    if (sd.isSurfaceLost()) {
        try {
            sd.restoreSurface();
            // if succeeded, first fill the surface with bg color
            // note: use the non-synch method to avoid incorrect lock order
            Color bg = sd.getPeer().getBackgroundNoSync();
            SunGraphics2D sg2d = new SunGraphics2D(sd, bg, bg, null);
            sg2d.fillRect(0, 0, sd.getBounds().width, sd.getBounds().height);
            sg2d.dispose();
            // now clean the dirty status so that we don't flip it
            // next time before it gets repainted; it is safe
            // to do without the lock because we will issue a
            // repaint anyway so we will not lose any rendering
            sd.markClean();
            // since the surface was successfully restored we need to
            // repaint whole window to repopulate the back-buffer
            repaintPeerTarget(sd.getPeer());
        } catch (InvalidPipeException ipe) {
            return false;
        }
    }
    return true;
}
 
Example #6
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #7
Source File: D3DScreenUpdateManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Restores the passed surface if it was lost, resets the lost status.
 * @param sd surface to be validated
 * @return true if surface wasn't lost or if restoration was successful,
 * false otherwise
 */
private boolean validate(D3DWindowSurfaceData sd) {
    if (sd.isSurfaceLost()) {
        try {
            sd.restoreSurface();
            // if succeeded, first fill the surface with bg color
            // note: use the non-synch method to avoid incorrect lock order
            Color bg = sd.getPeer().getBackgroundNoSync();
            SunGraphics2D sg2d = new SunGraphics2D(sd, bg, bg, null);
            sg2d.fillRect(0, 0, sd.getBounds().width, sd.getBounds().height);
            sg2d.dispose();
            // now clean the dirty status so that we don't flip it
            // next time before it gets repainted; it is safe
            // to do without the lock because we will issue a
            // repaint anyway so we will not lose any rendering
            sd.markClean();
            // since the surface was successfully restored we need to
            // repaint whole window to repopulate the back-buffer
            repaintPeerTarget(sd.getPeer());
        } catch (InvalidPipeException ipe) {
            return false;
        }
    }
    return true;
}
 
Example #8
Source File: D3DScreenUpdateManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #9
Source File: D3DScreenUpdateManager.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Restores the passed surface if it was lost, resets the lost status.
 * @param sd surface to be validated
 * @return true if surface wasn't lost or if restoration was successful,
 * false otherwise
 */
private boolean validate(D3DWindowSurfaceData sd) {
    if (sd.isSurfaceLost()) {
        try {
            sd.restoreSurface();
            // if succeeded, first fill the surface with bg color
            // note: use the non-synch method to avoid incorrect lock order
            Color bg = sd.getPeer().getBackgroundNoSync();
            SunGraphics2D sg2d = new SunGraphics2D(sd, bg, bg, null);
            sg2d.fillRect(0, 0, sd.getBounds().width, sd.getBounds().height);
            sg2d.dispose();
            // now clean the dirty status so that we don't flip it
            // next time before it gets repainted; it is safe
            // to do without the lock because we will issue a
            // repaint anyway so we will not lose any rendering
            sd.markClean();
            // since the surface was successfully restored we need to
            // repaint whole window to repopulate the back-buffer
            repaintPeerTarget(sd.getPeer());
        } catch (InvalidPipeException ipe) {
            return false;
        }
    }
    return true;
}
 
Example #10
Source File: D3DScreenUpdateManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Restores the passed surface if it was lost, resets the lost status.
 * @param sd surface to be validated
 * @return true if surface wasn't lost or if restoration was successful,
 * false otherwise
 */
private boolean validate(D3DWindowSurfaceData sd) {
    if (sd.isSurfaceLost()) {
        try {
            sd.restoreSurface();
            // if succeeded, first fill the surface with bg color
            // note: use the non-synch method to avoid incorrect lock order
            Color bg = sd.getPeer().getBackgroundNoSync();
            SunGraphics2D sg2d = new SunGraphics2D(sd, bg, bg, null);
            sg2d.fillRect(0, 0, sd.getBounds().width, sd.getBounds().height);
            sg2d.dispose();
            // now clean the dirty status so that we don't flip it
            // next time before it gets repainted; it is safe
            // to do without the lock because we will issue a
            // repaint anyway so we will not lose any rendering
            sd.markClean();
            // since the surface was successfully restored we need to
            // repaint whole window to repopulate the back-buffer
            repaintPeerTarget(sd.getPeer());
        } catch (InvalidPipeException ipe) {
            return false;
        }
    }
    return true;
}
 
Example #11
Source File: D3DScreenUpdateManager.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Restores the passed surface if it was lost, resets the lost status.
 * @param sd surface to be validated
 * @return true if surface wasn't lost or if restoration was successful,
 * false otherwise
 */
private boolean validate(D3DWindowSurfaceData sd) {
    if (sd.isSurfaceLost()) {
        try {
            sd.restoreSurface();
            // if succeeded, first fill the surface with bg color
            // note: use the non-synch method to avoid incorrect lock order
            Color bg = sd.getPeer().getBackgroundNoSync();
            SunGraphics2D sg2d = new SunGraphics2D(sd, bg, bg, null);
            sg2d.fillRect(0, 0, sd.getBounds().width, sd.getBounds().height);
            sg2d.dispose();
            // now clean the dirty status so that we don't flip it
            // next time before it gets repainted; it is safe
            // to do without the lock because we will issue a
            // repaint anyway so we will not lose any rendering
            sd.markClean();
            // since the surface was successfully restored we need to
            // repaint whole window to repopulate the back-buffer
            repaintPeerTarget(sd.getPeer());
        } catch (InvalidPipeException ipe) {
            return false;
        }
    }
    return true;
}
 
Example #12
Source File: D3DScreenUpdateManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #13
Source File: D3DScreenUpdateManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #14
Source File: D3DScreenUpdateManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #15
Source File: D3DScreenUpdateManager.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #16
Source File: D3DScreenUpdateManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Restores the passed surface if it was lost, resets the lost status.
 * @param sd surface to be validated
 * @return true if surface wasn't lost or if restoration was successful,
 * false otherwise
 */
private boolean validate(D3DWindowSurfaceData sd) {
    if (sd.isSurfaceLost()) {
        try {
            sd.restoreSurface();
            // if succeeded, first fill the surface with bg color
            // note: use the non-synch method to avoid incorrect lock order
            Color bg = sd.getPeer().getBackgroundNoSync();
            SunGraphics2D sg2d = new SunGraphics2D(sd, bg, bg, null);
            sg2d.fillRect(0, 0, sd.getBounds().width, sd.getBounds().height);
            sg2d.dispose();
            // now clean the dirty status so that we don't flip it
            // next time before it gets repainted; it is safe
            // to do without the lock because we will issue a
            // repaint anyway so we will not lose any rendering
            sd.markClean();
            // since the surface was successfully restored we need to
            // repaint whole window to repopulate the back-buffer
            repaintPeerTarget(sd.getPeer());
        } catch (InvalidPipeException ipe) {
            return false;
        }
    }
    return true;
}
 
Example #17
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Restores the passed surface if it was lost, resets the lost status.
 * @param sd surface to be validated
 * @return true if surface wasn't lost or if restoration was successful,
 * false otherwise
 */
private boolean validate(D3DWindowSurfaceData sd) {
    if (sd.isSurfaceLost()) {
        try {
            sd.restoreSurface();
            // if succeeded, first fill the surface with bg color
            // note: use the non-synch method to avoid incorrect lock order
            Color bg = sd.getPeer().getBackgroundNoSync();
            SunGraphics2D sg2d = new SunGraphics2D(sd, bg, bg, null);
            sg2d.fillRect(0, 0, sd.getBounds().width, sd.getBounds().height);
            sg2d.dispose();
            // now clean the dirty status so that we don't flip it
            // next time before it gets repainted; it is safe
            // to do without the lock because we will issue a
            // repaint anyway so we will not lose any rendering
            sd.markClean();
            // since the surface was successfully restored we need to
            // repaint whole window to repopulate the back-buffer
            repaintPeerTarget(sd.getPeer());
        } catch (InvalidPipeException ipe) {
            return false;
        }
    }
    return true;
}
 
Example #18
Source File: D3DScreenUpdateManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #19
Source File: D3DScreenUpdateManager.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #20
Source File: D3DScreenUpdateManager.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
Example #21
Source File: D3DScreenUpdateManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void dropScreenSurface(SurfaceData sd) {
    if (d3dwSurfaces != null && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        removeGdiSurface(d3dw);
        d3dwSurfaces.remove(d3dw);
    }
}
 
Example #22
Source File: D3DScreenUpdateManager.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds a surface to the list of tracked surfaces.
 *
 * @param d3dw the surface to be added
 */
private void trackScreenSurface(SurfaceData sd) {
    if (!done && sd instanceof D3DWindowSurfaceData) {
        synchronized (this) {
            if (d3dwSurfaces == null) {
                d3dwSurfaces = new ArrayList<D3DWindowSurfaceData>();
            }
            D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
            if (!d3dwSurfaces.contains(d3dw)) {
                d3dwSurfaces.add(d3dw);
            }
        }
        startUpdateThread();
    }
}
 
Example #23
Source File: D3DScreenUpdateManager.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Remove the gdi surface corresponding to the passed d3dw surface
 * from list of the cached gdi surfaces.
 *
 * @param d3dw surface for which associated gdi surface is to be removed
 */
private void removeGdiSurface(final D3DWindowSurfaceData d3dw) {
    if (gdiSurfaces != null) {
        GDIWindowSurfaceData gdisd = gdiSurfaces.get(d3dw);
        if (gdisd != null) {
            gdisd.invalidate();
            gdiSurfaces.remove(d3dw);
        }
    }
}
 
Example #24
Source File: D3DScreenUpdateManager.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates (or returns a cached one) gdi surface for the same peer as
 * the passed d3dw surface has.
 *
 * @param d3dw surface used as key into the cache
 * @return gdi window surface associated with the d3d window surfaces' peer
 */
private synchronized SurfaceData getGdiSurface(D3DWindowSurfaceData d3dw) {
    if (gdiSurfaces == null) {
        gdiSurfaces =
            new HashMap<D3DWindowSurfaceData, GDIWindowSurfaceData>();
    }
    GDIWindowSurfaceData gdisd = gdiSurfaces.get(d3dw);
    if (gdisd == null) {
        gdisd = GDIWindowSurfaceData.createData(d3dw.getPeer());
        gdiSurfaces.put(d3dw, gdisd);
    }
    return gdisd;
}
 
Example #25
Source File: D3DScreenUpdateManager.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates (or returns a cached one) gdi surface for the same peer as
 * the passed d3dw surface has.
 *
 * @param d3dw surface used as key into the cache
 * @return gdi window surface associated with the d3d window surfaces' peer
 */
private synchronized SurfaceData getGdiSurface(D3DWindowSurfaceData d3dw) {
    if (gdiSurfaces == null) {
        gdiSurfaces =
            new HashMap<D3DWindowSurfaceData, GDIWindowSurfaceData>();
    }
    GDIWindowSurfaceData gdisd = gdiSurfaces.get(d3dw);
    if (gdisd == null) {
        gdisd = GDIWindowSurfaceData.createData(d3dw.getPeer());
        gdiSurfaces.put(d3dw, gdisd);
    }
    return gdisd;
}
 
Example #26
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates (or returns a cached one) gdi surface for the same peer as
 * the passed d3dw surface has.
 *
 * @param d3dw surface used as key into the cache
 * @return gdi window surface associated with the d3d window surfaces' peer
 */
private synchronized SurfaceData getGdiSurface(D3DWindowSurfaceData d3dw) {
    if (gdiSurfaces == null) {
        gdiSurfaces =
            new HashMap<D3DWindowSurfaceData, GDIWindowSurfaceData>();
    }
    GDIWindowSurfaceData gdisd = gdiSurfaces.get(d3dw);
    if (gdisd == null) {
        gdisd = GDIWindowSurfaceData.createData(d3dw.getPeer());
        gdiSurfaces.put(d3dw, gdisd);
    }
    return gdisd;
}
 
Example #27
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds a surface to the list of tracked surfaces.
 *
 * @param d3dw the surface to be added
 */
private void trackScreenSurface(SurfaceData sd) {
    if (!done && sd instanceof D3DWindowSurfaceData) {
        synchronized (this) {
            if (d3dwSurfaces == null) {
                d3dwSurfaces = new ArrayList<D3DWindowSurfaceData>();
            }
            D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
            if (!d3dwSurfaces.contains(d3dw)) {
                d3dwSurfaces.add(d3dw);
            }
        }
        startUpdateThread();
    }
}
 
Example #28
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void dropScreenSurface(SurfaceData sd) {
    if (d3dwSurfaces != null && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        removeGdiSurface(d3dw);
        d3dwSurfaces.remove(d3dw);
    }
}
 
Example #29
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds a surface to the list of tracked surfaces.
 *
 * @param d3dw the surface to be added
 */
private void trackScreenSurface(SurfaceData sd) {
    if (!done && sd instanceof D3DWindowSurfaceData) {
        synchronized (this) {
            if (d3dwSurfaces == null) {
                d3dwSurfaces = new ArrayList<D3DWindowSurfaceData>();
            }
            D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
            if (!d3dwSurfaces.contains(d3dw)) {
                d3dwSurfaces.add(d3dw);
            }
        }
        startUpdateThread();
    }
}
 
Example #30
Source File: D3DScreenUpdateManager.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void dropScreenSurface(SurfaceData sd) {
    if (d3dwSurfaces != null && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        removeGdiSurface(d3dw);
        d3dwSurfaces.remove(d3dw);
    }
}