sun.awt.image.SurfaceManager Java Examples

The following examples show how to use sun.awt.image.SurfaceManager. 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: D3DVolatileSurfaceManager.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
                }
            }
        }
    }
}
 
Example #2
Source File: D3DSurfaceData.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If acceleration should no longer be used for this surface.
 * This implementation flags to the manager that it should no
 * longer attempt to re-create a D3DSurface.
 */
void disableAccelerationForSurface() {
    if (offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        if (sm instanceof D3DVolatileSurfaceManager) {
            setSurfaceLost(true);
            ((D3DVolatileSurfaceManager)sm).setAccelerationEnabled(false);
        }
    }
}
 
Example #3
Source File: D3DVolatileSurfaceManager.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
                }
            }
        }
    }
}
 
Example #4
Source File: D3DVolatileSurfaceManager.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
                }
            }
        }
    }
}
 
Example #5
Source File: D3DSurfaceData.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * We need to let the surface manager know that the surface is lost so
 * that for example BufferStrategy.contentsLost() returns correct result.
 * Normally the status of contentsLost is set in validate(), but in some
 * cases (like Swing's buffer per window) we intentionally don't call
 * validate from the toolkit thread but only check for the BS status.
 */
@Override
public void setSurfaceLost(boolean lost) {
    super.setSurfaceLost(lost);
    if (lost && offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        sm.acceleratedSurfaceLost();
    }
}
 
Example #6
Source File: D3DVolatileSurfaceManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
                }
            }
        }
    }
}
 
Example #7
Source File: D3DSurfaceData.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If acceleration should no longer be used for this surface.
 * This implementation flags to the manager that it should no
 * longer attempt to re-create a D3DSurface.
 */
void disableAccelerationForSurface() {
    if (offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        if (sm instanceof D3DVolatileSurfaceManager) {
            setSurfaceLost(true);
            ((D3DVolatileSurfaceManager)sm).setAccelerationEnabled(false);
        }
    }
}
 
Example #8
Source File: D3DSurfaceData.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * We need to let the surface manager know that the surface is lost so
 * that for example BufferStrategy.contentsLost() returns correct result.
 * Normally the status of contentsLost is set in validate(), but in some
 * cases (like Swing's buffer per window) we intentionally don't call
 * validate from the toolkit thread but only check for the BS status.
 */
@Override
public void setSurfaceLost(boolean lost) {
    super.setSurfaceLost(lost);
    if (lost && offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        sm.acceleratedSurfaceLost();
    }
}
 
Example #9
Source File: D3DVolatileSurfaceManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
                }
            }
        }
    }
}
 
Example #10
Source File: D3DVolatileSurfaceManager.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
                }
            }
        }
    }
}
 
Example #11
Source File: D3DSurfaceData.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If acceleration should no longer be used for this surface.
 * This implementation flags to the manager that it should no
 * longer attempt to re-create a D3DSurface.
 */
void disableAccelerationForSurface() {
    if (offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        if (sm instanceof D3DVolatileSurfaceManager) {
            setSurfaceLost(true);
            ((D3DVolatileSurfaceManager)sm).setAccelerationEnabled(false);
        }
    }
}
 
Example #12
Source File: D3DSurfaceData.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * We need to let the surface manager know that the surface is lost so
 * that for example BufferStrategy.contentsLost() returns correct result.
 * Normally the status of contentsLost is set in validate(), but in some
 * cases (like Swing's buffer per window) we intentionally don't call
 * validate from the toolkit thread but only check for the BS status.
 */
@Override
public void setSurfaceLost(boolean lost) {
    super.setSurfaceLost(lost);
    if (lost && offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        sm.acceleratedSurfaceLost();
    }
}
 
Example #13
Source File: D3DSurfaceData.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * We need to let the surface manager know that the surface is lost so
 * that for example BufferStrategy.contentsLost() returns correct result.
 * Normally the status of contentsLost is set in validate(), but in some
 * cases (like Swing's buffer per window) we intentionally don't call
 * validate from the toolkit thread but only check for the BS status.
 */
@Override
public void setSurfaceLost(boolean lost) {
    super.setSurfaceLost(lost);
    if (lost && offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        sm.acceleratedSurfaceLost();
    }
}
 
Example #14
Source File: D3DSurfaceData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * We need to let the surface manager know that the surface is lost so
 * that for example BufferStrategy.contentsLost() returns correct result.
 * Normally the status of contentsLost is set in validate(), but in some
 * cases (like Swing's buffer per window) we intentionally don't call
 * validate from the toolkit thread but only check for the BS status.
 */
@Override
public void setSurfaceLost(boolean lost) {
    super.setSurfaceLost(lost);
    if (lost && offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        sm.acceleratedSurfaceLost();
    }
}
 
Example #15
Source File: D3DVolatileSurfaceManager.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
                }
            }
        }
    }
}
 
Example #16
Source File: D3DSurfaceData.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If acceleration should no longer be used for this surface.
 * This implementation flags to the manager that it should no
 * longer attempt to re-create a D3DSurface.
 */
void disableAccelerationForSurface() {
    if (offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        if (sm instanceof D3DVolatileSurfaceManager) {
            setSurfaceLost(true);
            ((D3DVolatileSurfaceManager)sm).setAccelerationEnabled(false);
        }
    }
}
 
Example #17
Source File: D3DVolatileSurfaceManager.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
                }
            }
        }
    }
}
 
Example #18
Source File: D3DSurfaceData.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * We need to let the surface manager know that the surface is lost so
 * that for example BufferStrategy.contentsLost() returns correct result.
 * Normally the status of contentsLost is set in validate(), but in some
 * cases (like Swing's buffer per window) we intentionally don't call
 * validate from the toolkit thread but only check for the BS status.
 */
@Override
public void setSurfaceLost(boolean lost) {
    super.setSurfaceLost(lost);
    if (lost && offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        sm.acceleratedSurfaceLost();
    }
}
 
Example #19
Source File: D3DSurfaceData.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * We need to let the surface manager know that the surface is lost so
 * that for example BufferStrategy.contentsLost() returns correct result.
 * Normally the status of contentsLost is set in validate(), but in some
 * cases (like Swing's buffer per window) we intentionally don't call
 * validate from the toolkit thread but only check for the BS status.
 */
@Override
public void setSurfaceLost(boolean lost) {
    super.setSurfaceLost(lost);
    if (lost && offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        sm.acceleratedSurfaceLost();
    }
}
 
Example #20
Source File: D3DSurfaceData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If acceleration should no longer be used for this surface.
 * This implementation flags to the manager that it should no
 * longer attempt to re-create a D3DSurface.
 */
void disableAccelerationForSurface() {
    if (offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        if (sm instanceof D3DVolatileSurfaceManager) {
            setSurfaceLost(true);
            ((D3DVolatileSurfaceManager)sm).setAccelerationEnabled(false);
        }
    }
}
 
Example #21
Source File: D3DSurfaceData.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * We need to let the surface manager know that the surface is lost so
 * that for example BufferStrategy.contentsLost() returns correct result.
 * Normally the status of contentsLost is set in validate(), but in some
 * cases (like Swing's buffer per window) we intentionally don't call
 * validate from the toolkit thread but only check for the BS status.
 */
@Override
public void setSurfaceLost(boolean lost) {
    super.setSurfaceLost(lost);
    if (lost && offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        sm.acceleratedSurfaceLost();
    }
}
 
Example #22
Source File: D3DVolatileSurfaceManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
                }
            }
        }
    }
}
 
Example #23
Source File: D3DVolatileSurfaceManager.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
                }
            }
        }
    }
}
 
Example #24
Source File: D3DSurfaceData.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If acceleration should no longer be used for this surface.
 * This implementation flags to the manager that it should no
 * longer attempt to re-create a D3DSurface.
 */
void disableAccelerationForSurface() {
    if (offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        if (sm instanceof D3DVolatileSurfaceManager) {
            setSurfaceLost(true);
            ((D3DVolatileSurfaceManager)sm).setAccelerationEnabled(false);
        }
    }
}
 
Example #25
Source File: D3DSurfaceData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If acceleration should no longer be used for this surface.
 * This implementation flags to the manager that it should no
 * longer attempt to re-create a D3DSurface.
 */
void disableAccelerationForSurface() {
    if (offscreenImage != null) {
        SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
        if (sm instanceof D3DVolatileSurfaceManager) {
            setSurfaceLost(true);
            ((D3DVolatileSurfaceManager)sm).setAccelerationEnabled(false);
        }
    }
}
 
Example #26
Source File: SurfaceData.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Restores the contents of the given Image and then returns the new
 * SurfaceData object in use by the Image's SurfaceManager.
 */
public static SurfaceData restoreContents(Image img) {
    SurfaceManager sMgr = SurfaceManager.getManager(img);
    return sMgr.restoreContents();
}
 
Example #27
Source File: SurfaceData.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This method is called on a destination SurfaceData to choose
 * the best SurfaceData from a source Image for an imaging
 * operation, with help from its SurfaceManager.
 * The method may determine that the default SurfaceData was
 * really the best choice in the first place, or it may decide
 * to use a cached surface.  Some general decisions about whether
 * acceleration is enabled are made by this method, but any
 * decision based on the type of the source image is made in
 * the makeProxyFor method below when it comes up with the
 * appropriate SurfaceDataProxy instance.
 * The parameters describe the type of imaging operation being performed.
 * <p>
 * If a blitProxyKey was supplied by the subclass then it is
 * used to potentially override the choice of source SurfaceData.
 * The outline of this process is:
 * <ol>
 * <li> Image pipeline asks destSD to find an appropriate
 *      srcSD for a given source Image object.
 * <li> destSD gets the SurfaceManager of the source Image
 *      and first retrieves the default SD from it using
 *      getPrimarySurfaceData()
 * <li> destSD uses its "blit proxy key" (if set) to look for
 *      some cached data stored in the source SurfaceManager
 * <li> If the cached data is null then makeProxyFor() is used
 *      to create some cached data which is stored back in the
 *      source SurfaceManager under the same key for future uses.
 * <li> The cached data will be a SurfaceDataProxy object.
 * <li> The SurfaceDataProxy object is then consulted to
 *      return a replacement SurfaceData object (typically
 *      a cached copy if appropriate, or the original if not).
 * </ol>
 */
public SurfaceData getSourceSurfaceData(Image img,
                                        int txtype,
                                        CompositeType comp,
                                        Color bgColor)
{
    SurfaceManager srcMgr = SurfaceManager.getManager(img);
    SurfaceData srcData = srcMgr.getPrimarySurfaceData();
    if (img.getAccelerationPriority() > 0.0f &&
        blitProxyKey != null)
    {
        SurfaceDataProxy sdp =
            (SurfaceDataProxy) srcMgr.getCacheData(blitProxyKey);
        if (sdp == null || !sdp.isValid()) {
            if (srcData.getState() == State.UNTRACKABLE) {
                sdp = SurfaceDataProxy.UNCACHED;
            } else {
                sdp = makeProxyFor(srcData);
            }
            srcMgr.setCacheData(blitProxyKey, sdp);
        }
        srcData = sdp.replaceData(srcData, txtype, comp, bgColor);
    }
    return srcData;
}
 
Example #28
Source File: Image.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void setSurfaceManager(Image img, SurfaceManager mgr) {
    img.surfaceManager = mgr;
}
 
Example #29
Source File: SunGraphics2D.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private boolean isHiDPIImage(final Image img) {
    return (SurfaceManager.getImageScale(img) != 1) ||
           (resolutionVariantHint != SunHints.INTVAL_RESOLUTION_VARIANT_OFF
                && img instanceof MultiResolutionImage);
}
 
Example #30
Source File: Image.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
public SurfaceManager getSurfaceManager(Image img) {
    return img.surfaceManager;
}