/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
public class D3DVolatileSurfaceManager
extends VolatileSurfaceManager
{
private boolean accelerationEnabled;
private int restoreCountdown;
/*
* We will attempt to accelerate this image only under the
* following conditions:
* - the image is opaque OR
* - the image is translucent AND
* - the GraphicsConfig supports the FBO extension OR
* - the GraphicsConfig has a stored alpha channel
*/
}
protected boolean isAccelerationEnabled() {
return accelerationEnabled;
}
}
/**
* Create a pbuffer-based SurfaceData object (or init the backbuffer
* of an existing window if this is a double buffered GraphicsConfig).
*/
try {
boolean forceback = false;
}
if (forceback) {
// peer must be non-null in this case
} else {
// if acceleration type is forced (type != UNDEFINED) then
// use the forced type, otherwise use RT_TEXTURE
type = RT_TEXTURE;
}
type);
}
} catch (NullPointerException ex) {
} catch (OutOfMemoryError er) {
} catch (InvalidPipeException ipe) {
}
return sData;
}
}
/**
* Set the number of iterations for restoreAcceleratedSurface to fail
* before attempting to restore the accelerated surface.
*
* @see #restoreAcceleratedSurface
* @see #handleVItoScreenOp
*/
}
/**
* Note that we create a new surface instead of restoring
* an old one. This will help with D3DContext revalidation.
*/
protected void restoreAcceleratedSurface() {
synchronized (this) {
if (restoreCountdown > 0) {
throw new
InvalidPipeException("Will attempt to restore surface " +
" in " + restoreCountdown);
}
}
} else {
throw new InvalidPipeException("could not restore surface");
// REMIND: alternatively, we could try this:
// ((D3DSurfaceData)sdAccel).restoreSurface();
}
}
/**
* We're asked to restore contents by the accelerated surface, which means
* that it had been lost.
*/
return super.restoreContents();
}
/**
* 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.
*/
if (src instanceof D3DSurfaceData &&
dst instanceof GDIWindowSurfaceData)
{
if (mgr instanceof D3DVolatileSurfaceManager) {
d3dsd.setSurfaceLost(true);
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
} else {
vsm.setAccelerationEnabled(false);
}
}
}
}
}
public void initContents() {
super.initContents();
}
}
}