public int validate(GraphicsConfiguration gc){
  int returnCode=VolatileImage.IMAGE_OK;
  boolean lostSurfaceTmp=lostSurface;
  lostSurface=false;
  if (isAccelerationEnabled()) {
    if (!isConfigValid(gc)) {
      returnCode=VolatileImage.IMAGE_INCOMPATIBLE;
    }
 else     if (sdAccel == null) {
      sdAccel=initAcceleratedSurface();
      if (sdAccel != null) {
        sdCurrent=sdAccel;
        sdBackup=null;
        returnCode=VolatileImage.IMAGE_RESTORED;
      }
 else {
        sdCurrent=getBackupSurface();
      }
    }
 else     if (sdAccel.isSurfaceLost()) {
      try {
        restoreAcceleratedSurface();
        sdCurrent=sdAccel;
        sdAccel.setSurfaceLost(false);
        sdBackup=null;
        returnCode=VolatileImage.IMAGE_RESTORED;
      }
 catch (      sun.java2d.InvalidPipeException e) {
        sdCurrent=getBackupSurface();
      }
    }
 else     if (lostSurfaceTmp) {
      returnCode=VolatileImage.IMAGE_RESTORED;
    }
  }
 else   if (sdAccel != null) {
    sdCurrent=getBackupSurface();
    sdAccel=null;
    returnCode=VolatileImage.IMAGE_RESTORED;
  }
  if ((returnCode != VolatileImage.IMAGE_INCOMPATIBLE) && (sdCurrent != sdPrevious)) {
    sdPrevious=sdCurrent;
    returnCode=VolatileImage.IMAGE_RESTORED;
  }
  if (returnCode == VolatileImage.IMAGE_RESTORED) {
    initContents();
  }
  return returnCode;
}

public int validate ( GraphicsConfiguration gc ) { int returnCode = VolatileImage . IMAGE_OK ; boolean lostSurfaceTmp = lostSurface ; lostSurface = false ; if ( isAccelerationEnabled ( ) ) { if ( ! isConfigValid ( gc ) ) { returnCode = VolatileImage . IMAGE_INCOMPATIBLE ; } else if ( sdAccel == null ) { sdAccel = initAcceleratedSurface ( ) ; if ( sdAccel != null ) { sdCurrent = sdAccel ; sdBackup = null ; returnCode = VolatileImage . IMAGE_RESTORED ; } else { sdCurrent = getBackupSurface ( ) ; } } else if ( sdAccel . isSurfaceLost ( ) ) { try { restoreAcceleratedSurface ( ) ; sdCurrent = sdAccel ; sdAccel . setSurfaceLost ( false ) ; sdBackup = null ; returnCode = VolatileImage . IMAGE_RESTORED ; } catch ( sun . java2d . InvalidPipeException e ) { sdCurrent = getBackupSurface ( ) ; } } else if ( lostSurfaceTmp ) { returnCode = VolatileImage . IMAGE_RESTORED ; } } else if ( sdAccel != null ) { sdCurrent = getBackupSurface ( ) ; sdAccel = null ; returnCode = VolatileImage . IMAGE_RESTORED ; } if ( ( returnCode != VolatileImage . IMAGE_INCOMPATIBLE ) && ( sdCurrent != sdPrevious ) ) { sdPrevious = sdCurrent ; returnCode = VolatileImage . IMAGE_RESTORED ; } if ( returnCode == VolatileImage . IMAGE_RESTORED ) { initContents ( ) ; } return returnCode ; }
get the image ready for rendering . this method is called to make sure that the accelerated surfacedata exists and is ready to be used . users call this method prior to any set of rendering to or from the image , to make sure the image is ready and compatible with the given graphicsconfiguration . the image may not be " ready " if either we had problems creating it in the first place ( e . g . , there was no space in vram ) or if the surface became lost ( e . g . , some other app or the os caused vram surfaces to be removed ) . note that we want to return restored in any situation where the surfacedata is different than it was last time . so whether it ' s software or hardware , if we have a different surfacedata object , then the contents have been altered and we must reflect that change to the user .
