question: 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 ; }
target:  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.