/*
* 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.
*/
class D3DBlitLoops {
static void register() {
GraphicsPrimitive[] primitives = {
// prevent D3DSurface -> Screen blits
// surface->surface ops
new D3DSurfaceToSurfaceBlit(),
new D3DSurfaceToSurfaceScale(),
new D3DSurfaceToSurfaceTransform(),
// render-to-texture surface->surface ops
new D3DRTTSurfaceToSurfaceBlit(),
new D3DRTTSurfaceToSurfaceScale(),
// surface->sw ops
// sw->surface ops
// REMIND: we don't have a native sw loop to back this loop up
// new D3DSwToSurfaceBlit(SurfaceType.ByteIndexedBm,
// D3DSurfaceData.ST_BYTE_INDEXED_BM),
// REMIND: we don't have a native sw loop to back this loop up
// new D3DSwToSurfaceScale(SurfaceType.ByteIndexedBm,
// D3DSurfaceData.ST_BYTE_INDEXED_BM),
// REMIND: we don't have a native sw loop to back this loop up
// new D3DSwToSurfaceTransform(SurfaceType.ByteIndexedBm,
// D3DSurfaceData.ST_BYTE_INDEXED_BM),
// texture->surface ops
new D3DTextureToSurfaceBlit(),
new D3DTextureToSurfaceScale(),
new D3DTextureToSurfaceTransform(),
// sw->texture ops
// REMIND: we don't have a native sw loop to back this loop up
// new D3DSwToTextureBlit(SurfaceType.ByteIndexedBm,
// D3DSurfaceData.ST_BYTE_INDEXED_BM),
};
}
/**
* The following offsets are used to pack the parameters in
* createPackedParams(). (They are also used at the native level when
* unpacking the params.)
*/
/**
* Packs the given parameters into a single int value in order to save
* space on the rendering queue.
*/
{
return
((srctype << OFFSET_SRCTYPE) |
(hint << OFFSET_HINT ) |
}
/**
* Enqueues a BLIT operation with the given parameters. Note that the
* RenderQueue lock must be held before calling this method.
*/
int packedParams,
{
// assert rq.lock.isHeldByCurrentThread();
}
{
int ctxflags = 0;
}
try {
// make sure the RenderQueue keeps a hard reference to the
// source (sysmem) SurfaceData to prevent it from being
// disposed while the operation is processed on the QFT
if (texture) {
// make sure we have a current context before uploading
// the sysmem data to the texture object
} else {
ctxflags);
}
// always flush immediately, since we (currently) have no means
// of tracking changes to the system memory surface
} finally {
}
// flush immediately when copying to the screen to improve
// responsiveness of applications using VI or BI backbuffers
mgr.runUpdateNow();
}
}
/**
* Note: The srcImg and biop parameters are only used when invoked
* from the D3DBufImgOps.renderImageWithOp() method; in all other cases,
* this method can be called with null values for those two parameters,
* and they will be effectively ignored.
*/
boolean texture)
{
int ctxflags = 0;
}
boolean rtt = false;
try {
rtt = false;
} else {
// the source is a backbuffer, or render-to-texture
// surface; we set rtt to true to differentiate this kind
// of surface from a regular texture object
rtt = true;
}
ctxflags);
}
}
} finally {
}
// we only have to flush immediately when copying from a
// (non-texture) surface to the screen; otherwise Swing apps
// might appear unresponsive until the auto-flush completes
mgr.runUpdateNow();
}
}
}
super(D3DSurfaceData.D3DSurface,
}
{
false);
}
}
super(D3DSurfaceData.D3DSurface,
}
{
false);
}
}
super(D3DSurfaceData.D3DSurface,
}
int w, int h)
{
false);
}
}
super(D3DSurfaceData.D3DSurfaceRTT,
}
{
true);
}
}
super(D3DSurfaceData.D3DSurfaceRTT,
}
{
true);
}
}
super(D3DSurfaceData.D3DSurfaceRTT,
}
{
true);
}
}
private int typeval;
// REMIND: destination will actually be opaque/premultiplied...
super(D3DSurfaceData.D3DSurface,
dstType);
}
int w, int h)
{
try {
// make sure the RenderQueue keeps a hard reference to the
// destination (sysmem) SurfaceData to prevent it from being
// disposed while the operation is processed on the QFT
// always flush immediately
} finally {
}
}
}
private int typeval;
super(srcType,
}
{
typeval, false);
}
}
private int typeval;
super(srcType,
}
{
typeval, false);
}
}
private int typeval;
super(srcType,
}
{
typeval, false);
}
}
private int typeval;
super(srcType,
}
{
typeval, true);
}
}
super(D3DSurfaceData.D3DTexture,
}
{
true);
}
}
super(D3DSurfaceData.D3DTexture,
}
{
true);
}
}
super(D3DSurfaceData.D3DTexture,
}
int w, int h)
{
true);
}
}
/**
* This general Blit implemenation converts any source surface to an
* intermediate IntArgbPre surface, and then uses the more specific
* IntArgbPre->D3DSurface/Texture loop to get the intermediate
* (premultiplied) surface down to D3D.
*/
{
}
int w, int h)
{
// use cached intermediate surface, if available
}
// convert source to IntArgbPre
// copy IntArgbPre intermediate surface to D3D surface
// cache the intermediate surface
}
}
}
/*
* The following classes prohibit copying D3DSurfaces to the screen
* (the D3D->sysmem->GDI path is known to be very very slow).
*
* Note: we used to disable hw acceleration for the surafce manager associated
* with the source surface in these loops but it proved to be too cautious.
*
* In most cases d3d->screen copy happens only during some transitional
* period where the accelerated destination surface is being recreated or
* restored (for example, when Swing's backbuffer VI is copied to the screen
* but the D3DScreenSurfaceManager couldn't restore its surface).
*
* An exception is if for some reason we could not enable accelerated on-screen
* rendering for this window for some permanent reason (like window being too
* small, or a present BufferStrategy).
*
* This meant that we'd disable hw acceleration after the first failure
* completely (at least until the src image is recreated which in case of
* Swing back-buffer happens only after resize).
*
* Now we delegate to the VISM to figure out if the acceleration needs to
* be disabled or if we can wait for a while until the onscreen accelerated
* can resume (by marking the source surface lost and making sure the
* VISM has a chance to use the backup surface).
*
*/
super(D3DSurfaceData.D3DSurface,
}
{
// see comment above
}
}
super(D3DSurfaceData.D3DSurface,
}
{
// see comment above
}
}
super(D3DSurfaceData.D3DSurface,
}
int w, int h)
{
// see comment above
}
}