summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/classes/share/javax/media/j3d/ImageComponent2DRetained.java56
-rw-r--r--src/classes/share/javax/media/j3d/ImageComponent3DRetained.java33
-rw-r--r--src/classes/share/javax/media/j3d/ImageComponentRetained.java175
-rw-r--r--src/classes/share/javax/media/j3d/TextureRetained.java71
-rw-r--r--src/native/d3d/D3dDeviceInfo.cpp64
5 files changed, 65 insertions, 334 deletions
diff --git a/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java b/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java
index 5053098..c5b6a67 100644
--- a/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java
+++ b/src/classes/share/javax/media/j3d/ImageComponent2DRetained.java
@@ -314,62 +314,6 @@ class ImageComponent2DRetained extends ImageComponentRetained {
sendMessage(SUBIMAGE_CHANGED, info);
}
}
-
- ImageComponentRetained createNextLevelMipMapImage() {
-
- int xScale, yScale, newWidth, newHeight;
-
- if (width > 1) {
- newWidth = width >> 1;
- xScale = 2;
- } else {
- newWidth = 1;
- xScale = 1;
- }
- if (height > 1) {
- newHeight = height >> 1;
- yScale = 2;
- } else {
- newHeight = 1;
- yScale = 1;
- }
-
- // XXXXX Fix to Issue 425 : NullPointerException in automatic mipmap generation
- if (imageData == null) {
- // This is a byRef, support format and is a RenderedImage case.
- // See ImageComponent2DRetained.set(RenderedImage image)
- RenderedImage ri = (RenderedImage) getRefImage(0);
-
- assert !(ri instanceof BufferedImage);
-
- // Create a buffered image from renderImage
- ColorModel cm = ri.getColorModel();
- WritableRaster wRaster = ri.copyData(null);
- ri = new BufferedImage(cm,
- wRaster,
- cm.isAlphaPremultiplied()
- ,null);
-
-
- // Create image data object with buffer for image. */
- imageData = createRenderedImageDataObject(null);
- copySupportedImageToImageData(ri, 0, imageData);
-
- }
-
- assert imageData != null;
- // XXXXX
-
- ImageComponent2DRetained newImage = new ImageComponent2DRetained();
- newImage.processParams(getFormat(), newWidth, newHeight, 1);
- newImage.setImageFormatType(getImageFormatType());
- newImage.setUnitsPerPixel(getUnitsPerPixel());
- newImage.imageData = newImage.createRenderedImageDataObject(null);
-
- newImage.scaleImage(xScale, yScale, 0, this);
-
- return newImage;
- }
void clearLive(int refCount) {
super.clearLive(refCount);
diff --git a/src/classes/share/javax/media/j3d/ImageComponent3DRetained.java b/src/classes/share/javax/media/j3d/ImageComponent3DRetained.java
index 0e32fb2..ed8c575 100644
--- a/src/classes/share/javax/media/j3d/ImageComponent3DRetained.java
+++ b/src/classes/share/javax/media/j3d/ImageComponent3DRetained.java
@@ -361,37 +361,4 @@ class ImageComponent3DRetained extends ImageComponentRetained {
sendMessage(SUBIMAGE_CHANGED, info);
}
}
-
- ImageComponentRetained createNextLevelMipMapImage() {
-
- int xScale, yScale, newWidth, newHeight;
-
- if (width > 1) {
- newWidth = width >> 1;
- xScale = 2;
- } else {
- newWidth = 1;
- xScale = 1;
- }
- if (height > 1) {
- newHeight = height >> 1;
- yScale = 2;
- } else {
- newHeight = 1;
- yScale = 1;
- }
-
- ImageComponent3DRetained newImage = new ImageComponent3DRetained();
- newImage.processParams(getFormat(), newWidth, newHeight, depth);
- newImage.setImageFormatType(getImageFormatType());
- newImage.setUnitsPerPixel(getUnitsPerPixel());
- newImage.imageData = newImage.createRenderedImageDataObject(null);
-
- for (int i = 0; i < depth; i++) {
- newImage.scaleImage(xScale, yScale, i, this);
- }
-
- return newImage;
-
- }
}
diff --git a/src/classes/share/javax/media/j3d/ImageComponentRetained.java b/src/classes/share/javax/media/j3d/ImageComponentRetained.java
index 8d0b056..80112ec 100644
--- a/src/classes/share/javax/media/j3d/ImageComponentRetained.java
+++ b/src/classes/share/javax/media/j3d/ImageComponentRetained.java
@@ -129,8 +129,6 @@ abstract class ImageComponentRetained extends NodeComponentRetained {
// of any changes of this ImageComponent.
ArrayList userList = new ArrayList();
- abstract ImageComponentRetained createNextLevelMipMapImage();
-
/**
* Retrieves the width of this image component object.
* @return the width of this image component object
@@ -2096,179 +2094,6 @@ abstract class ImageComponentRetained extends NodeComponentRetained {
}
- void scaleImage(int xScale, int yScale, int depthIndex, ImageComponentRetained origImage) {
-
- byte[] dstByteBuffer = null;
- byte[] srcByteBuffer = null;
- int[] dstIntBuffer = null;
- int[] srcIntBuffer = null;
- int dStart, sStart;
-
- switch(imageData.getType()) {
- case TYPE_BYTE_ARRAY:
- dstByteBuffer = imageData.getAsByteArray();
- srcByteBuffer = origImage.imageData.getAsByteArray();
- dStart = depthIndex * width * height * unitsPerPixel;
- sStart = depthIndex * origImage.width * origImage.height * unitsPerPixel;
- scaleImage(xScale, yScale, dStart, sStart, origImage, dstByteBuffer, srcByteBuffer);
- break;
- case TYPE_INT_ARRAY:
- dstIntBuffer = imageData.getAsIntArray();
- srcIntBuffer = origImage.imageData.getAsIntArray();
- dStart = depthIndex * width * height * unitsPerPixel;
- sStart = depthIndex * origImage.width * origImage.height * unitsPerPixel;
- scaleImage(xScale, yScale, dStart, sStart, origImage, dstIntBuffer, srcIntBuffer);
- break;
- default:
- assert false;
- }
-
- }
-
- void scaleImage(int xScale, int yScale, int dStart, int sStart, ImageComponentRetained origImage,
- byte[] dData, byte[] sData) {
-
- int dOffset = 0;
- int sOffset = 0;
- int sLineIncr = unitsPerPixel * origImage.width;
- int sPixelIncr = unitsPerPixel << 1;
-
- assert ((xScale != 1) || (yScale != 1));
-
- if (yScale == 1) {
- for (int x = 0; x < width; x++) {
- for (int k = 0; k < unitsPerPixel; k++) {
- dData[dStart + dOffset + k] = (byte)
- (((int)(sData[sStart + sOffset + k] & 0xff) +
- (int)(sData[sStart + sOffset + k
- + unitsPerPixel] & 0xff) + 1) >> 1);
- }
- dOffset += unitsPerPixel;
- sOffset += sPixelIncr;
- }
- } else if (xScale == 1) {
- for (int y = 0; y < height; y++) {
- for (int k = 0; k < unitsPerPixel; k++) {
- dData[dStart + dOffset + k] = (byte)
- (((int)(sData[sStart + sOffset + k] & 0xff) +
- (int)(sData[sStart + sOffset + k
- + sLineIncr] & 0xff) + 1) >> 1);
- }
- dOffset += unitsPerPixel;
- sOffset += sLineIncr;
- }
- } else {
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- for (int k = 0; k < unitsPerPixel; k++) {
- dData[dStart + dOffset + k] = (byte)
- (((int)(sData[sStart + sOffset + k] & 0xff) +
- (int)(sData[sStart + sOffset + k
- + unitsPerPixel] & 0xff) +
- (int)(sData[sStart + sOffset + k
- + sLineIncr] & 0xff) +
- (int)(sData[sStart + sOffset + k + sLineIncr +
- + unitsPerPixel] & 0xff) + 2) >> 2);
- }
- dOffset += unitsPerPixel;
- sOffset += sPixelIncr;
- }
- sOffset += sLineIncr;
- }
- }
- }
-
- void scaleImage(int xScale, int yScale, int dStart, int sStart, ImageComponentRetained origImage,
- int[] dData, int[] sData) {
-
- int dOffset = 0;
- int sOffset = 0;
- int sLineIncr = origImage.width;
- int sPixelIncr = 2;
-
- assert ((xScale != 1) || (yScale != 1));
-
- int sTemp1, sTemp2;
- int[] comp = new int[4];
- if (yScale == 1) {
- for (int x = 0; x < width; x++) {
- sTemp1 = sData[sStart + sOffset];
- sTemp2 = sData[sStart + sOffset + 1];
- // Unpack and compute
- for (int k = 0; k < numberOfComponents; k++) {
- comp[k] = ((sTemp1 & 0xff) + (sTemp2 & 0xff) + 1) >> 1;
- sTemp1 = sTemp1 >> 8;
- sTemp2 = sTemp2 >> 8;
- }
- // Pack back computed value.
- sTemp1 = comp[numberOfComponents - 1];
- if(numberOfComponents > 1) {
- for (int k = numberOfComponents - 2; k >= 0; k--) {
- sTemp1 = (sTemp1 << 8) + comp[k];
- }
- }
- dData[dStart + dOffset] = sTemp1;
-
- dOffset += 1;
- sOffset += sPixelIncr;
- }
- } else if (xScale == 1) {
- for (int y = 0; y < height; y++) {
- sTemp1 = sData[sStart + sOffset];
- sTemp2 = sData[sStart + sOffset + sLineIncr];
- // Unpack and compute
- for (int k = 0; k < numberOfComponents; k++) {
- comp[k] = ((sTemp1 & 0xff) + (sTemp2 & 0xff) + 1) >> 1;
- sTemp1 = sTemp1 >> 8;
- sTemp2 = sTemp2 >> 8;
- }
- // Pack back computed value.
- sTemp1 = comp[numberOfComponents - 1];
- if(numberOfComponents > 1) {
- for (int k = numberOfComponents - 2; k >= 0; k--) {
- sTemp1 = (sTemp1 << 8) + comp[k];
- }
- }
- dData[dStart + dOffset] = sTemp1;
-
- dOffset += 1;
- sOffset += sLineIncr;
- }
- } else {
- int sTemp3, sTemp4;
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- sTemp1 = sData[sStart + sOffset];
- sTemp2 = sData[sStart + sOffset + 1];
- sTemp3 = sData[sStart + sOffset + sLineIncr];
- sTemp4 = sData[sStart + sOffset + sLineIncr + 1];
- // Unpack and compute
- for (int k = 0; k < numberOfComponents; k++) {
- comp[k] = ((sTemp1 & 0xff) + (sTemp2 & 0xff) +
- (sTemp3 & 0xff) + (sTemp4 & 0xff) + 2) >> 2;
- sTemp1 = sTemp1 >> 8;
- sTemp2 = sTemp2 >> 8;
- sTemp3 = sTemp3 >> 8;
- sTemp4 = sTemp4 >> 8;
- }
- // Pack back computed value.
- sTemp1 = comp[numberOfComponents - 1];
- if(numberOfComponents > 1) {
- for (int k = numberOfComponents - 2; k >= 0; k--) {
- sTemp1 = (sTemp1 << 8) + comp[k];
- }
- }
- dData[dStart + dOffset] = sTemp1;
-
- dOffset += 1;
- sOffset += sPixelIncr;
- }
- sOffset += sLineIncr;
- }
- }
- }
-
-
// Add a user to the userList
synchronized void addUser(NodeComponentRetained node) {
userList.add(node);
diff --git a/src/classes/share/javax/media/j3d/TextureRetained.java b/src/classes/share/javax/media/j3d/TextureRetained.java
index eb13480..43aef4d 100644
--- a/src/classes/share/javax/media/j3d/TextureRetained.java
+++ b/src/classes/share/javax/media/j3d/TextureRetained.java
@@ -68,17 +68,19 @@ abstract class TextureRetained extends NodeComponentRetained {
int format = Texture.RGB; // Texture format
int width = 1; // Width in pixels (2**n)
int height = 1; // Height in pixels (2**m)
- private boolean widthOrHeightIsNPOT = false; // true if width or height is non power of two
- ImageComponentRetained images[][]; // Array of images (one for each mipmap level)
- boolean imagesLoaded = false; // TRUE if all mipmap levels are loaded
- int mipmapLevels; // Number of MIPMAP levels needed
- int maxLevels = 0; // maximum number of levels needed for
- // the mipmapMode of this texture
- int maxMipMapLevels = 0; // maximum number of mipmap levels that
- // can be defined for this texture
+ // true if width or height is non power of two
+ private boolean widthOrHeightIsNPOT = false;
+ // Array of images (one for each mipmap level)
+ ImageComponentRetained images[][];
+ // maximum number of levels needed for the mipmapMode of this texture
+ int maxLevels = 0;
+ // maximum number of mipmap levels that can be defined for this texture
+ private int maxMipMapLevels = 0;
+ // true if hardware auto mipmap generation is requested.
+ private boolean useAutoMipMapGeneration = false;
+
int numFaces = 1; // For CubeMap, it is 6
-
int baseLevel = 0;
int maximumLevel = 0;
float minimumLod = -1000.0f;
@@ -206,7 +208,7 @@ abstract class TextureRetained extends NodeComponentRetained {
maximumLevel = 0;
maxLevels = 1;
}
-
+
images = new ImageComponentRetained[numFaces][maxLevels];
for (int j = 0; j < numFaces; j++) {
@@ -214,8 +216,6 @@ abstract class TextureRetained extends NodeComponentRetained {
images[j][i] = null;
}
}
- imagesLoaded = false;
-
}
final int getFormat() {
@@ -1897,7 +1897,6 @@ abstract class TextureRetained extends NodeComponentRetained {
mirrorTexture.boundaryColor.set(boundaryColor);
mirrorTexture.enable = enable;
mirrorTexture.userSpecifiedEnable = enable;
- mirrorTexture.imagesLoaded = imagesLoaded;
mirrorTexture.enable = enable;
mirrorTexture.numFaces = numFaces;
mirrorTexture.resourceCreationMask = 0x0;
@@ -1952,30 +1951,28 @@ abstract class TextureRetained extends NodeComponentRetained {
// implicit mipmap generation
if (mipmapMode == Texture.BASE_LEVEL &&
- (minFilter == Texture.NICEST ||
- minFilter == Texture.MULTI_LEVEL_POINT ||
- minFilter == Texture.MULTI_LEVEL_LINEAR)) {
- mirrorTexture.maxLevels = maxMipMapLevels;
-
- if ((mirrorTexture.images == null) ||
- (mirrorTexture.images.length < numFaces) ||
- (mirrorTexture.images[0].length < mirrorTexture.maxLevels)) {
- mirrorTexture.images =
- new ImageComponentRetained[numFaces][mirrorTexture.maxLevels];
- }
-
- for (int j = 0; j < numFaces; j++) {
- mirrorTexture.images[j][0] = images[j][0];
-
- // add texture to the userList of the images
- if (images[j][0] != null) {
- images[j][0].addUser(mirrorTexture);
- }
-
- for (int i = 1; i < mirrorTexture.maxLevels; i++) {
- mirrorTexture.images[j][i] =
- mirrorTexture.images[j][i-1].createNextLevelMipMapImage();
- }
+ (minFilter == Texture.NICEST ||
+ minFilter == Texture.MULTI_LEVEL_POINT ||
+ minFilter == Texture.MULTI_LEVEL_LINEAR)) {
+ // TODO : Should this be 1 ? --- Chien.
+ // mirrorTexture.maxLevels = maxMipMapLevels;
+ mirrorTexture.maxLevels = 1;
+ mirrorTexture.useAutoMipMapGeneration = true;
+
+ if ((mirrorTexture.images == null) ||
+ (mirrorTexture.images.length < numFaces) ||
+ !(mirrorTexture.images[0].length == mirrorTexture.maxLevels)) {
+ mirrorTexture.images =
+ new ImageComponentRetained[numFaces][mirrorTexture.maxLevels];
+ }
+
+ for (int j = 0; j < numFaces; j++) {
+ mirrorTexture.images[j][0] = images[j][0];
+
+ // add texture to the userList of the images
+ if (images[j][0] != null) {
+ images[j][0].addUser(mirrorTexture);
+ }
}
}
else {
diff --git a/src/native/d3d/D3dDeviceInfo.cpp b/src/native/d3d/D3dDeviceInfo.cpp
index 7ae16e7..f018663 100644
--- a/src/native/d3d/D3dDeviceInfo.cpp
+++ b/src/native/d3d/D3dDeviceInfo.cpp
@@ -25,7 +25,7 @@ D3dDeviceInfo::~D3dDeviceInfo()
VOID D3dDeviceInfo::setCaps(D3DCAPS9 *d3dCaps) {
BOOL supportNPOT;
-
+
if (deviceType == D3DDEVTYPE_HAL ){
isHardware = true;
isHardwareTnL = (d3dCaps->DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT);
@@ -72,7 +72,7 @@ VOID D3dDeviceInfo::setCaps(D3DCAPS9 *d3dCaps) {
// As OpenGL is UNCONDITIONAL, it is not used by Java3D
//supportNPOT = true;
}
- }else{
+ } else {
//UNconditional: Textures do not need to be a power of 2 in size
supportNPOT = true;
}
@@ -95,8 +95,7 @@ VOID D3dDeviceInfo::setCaps(D3DCAPS9 *d3dCaps) {
printf("Java3D: Supported Shaders = %d.%d in mode %s ",
HIBYTE(LOWORD(vsVersion)),
LOBYTE(LOWORD(vsVersion)),
- dt);
-
+ dt);
}
//supportStreamOffset =
@@ -119,7 +118,7 @@ VOID D3dDeviceInfo::setCaps(D3DCAPS9 *d3dCaps) {
texBorderModeSupport = ((d3dCaps->TextureAddressCaps & D3DPTADDRESSCAPS_BORDER) != 0);
texLerpSupport = ((d3dCaps->TextureOpCaps & D3DTEXOPCAPS_LERP) != 0);
-
+
canRenderWindowed = true;//((d3dCaps->Caps2 & D3DCAPS2_CANRENDERWINDOWED) != 0);
maxPrimitiveCount = d3dCaps->MaxPrimitiveCount;
@@ -166,43 +165,42 @@ VOID D3dDeviceInfo::setCaps(D3DCAPS9 *d3dCaps) {
supportRasterPresImmediate = false;
if (((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGTABLE) != 0) &&
- ((d3dCaps->RasterCaps & D3DPRASTERCAPS_WFOG) != 0)) {
+ ((d3dCaps->RasterCaps & D3DPRASTERCAPS_WFOG) != 0)) {
// use pixel w-fog
fogMode = D3DRS_FOGTABLEMODE;
rangeFogEnable = false;
}
- else
- if (((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGVERTEX) != 0) &&
- ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGRANGE) != 0))
-
- {
- // use vertex range based fog
- fogMode = D3DRS_FOGVERTEXMODE;
- rangeFogEnable = true;
- }
- else
- if ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGTABLE) != 0) {
- // use pixel z-fog
- fogMode = D3DRS_FOGTABLEMODE;
- rangeFogEnable = false;
- }
- else
- if (D3DPRASTERCAPS_FOGVERTEX) {
- // use vertex z-fog
- fogMode = D3DRS_FOGVERTEXMODE;
- rangeFogEnable = false;
- }
- else {
- if (debug) {
- printf("[Java 3D] Fog not support in this device !\n");
- }
- }
+ else if (((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGVERTEX) != 0) &&
+ ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGRANGE) != 0)) {
+ // use vertex range based fog
+ fogMode = D3DRS_FOGVERTEXMODE;
+ rangeFogEnable = true;
+ }
+ else if ((d3dCaps->RasterCaps & D3DPRASTERCAPS_FOGTABLE) != 0) {
+ // use pixel z-fog
+ fogMode = D3DRS_FOGTABLEMODE;
+ rangeFogEnable = false;
+ }
+ else if (D3DPRASTERCAPS_FOGVERTEX) {
+ // use vertex z-fog
+ fogMode = D3DRS_FOGVERTEXMODE;
+ rangeFogEnable = false;
+ }
+ else {
+ if (debug) {
+ printf("[Java 3D] Fog not support in this device !\n");
+ }
+ }
texMask = 0;
-
+
if(supportNPOT){
texMask |= javax_media_j3d_Canvas3D_TEXTURE_NON_POWER_OF_TWO;
}
+
+ if((d3dCaps->Caps2 & D3DCAPS2_CANAUTOGENMIPMAP) != 0) {
+ texMask |= javax_media_j3d_Canvas3D_TEXTURE_AUTO_MIPMAP_GENERATION;
+ }
if ((d3dCaps->TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP) &&
(maxTextureDepth > 0)) {