aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/share
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2007-03-22 23:39:52 +0000
committerChien Yang <[email protected]>2007-03-22 23:39:52 +0000
commite9005593c05ad268256398f2901febdc14d95b26 (patch)
tree786be7466d9fd36b17acdd0819c0398b58813776 /src/classes/share
parent2eb98ec71dd26765a179b0005898bf63991be0b3 (diff)
1) Fixed Issue 470 : Need informative error message for mismatched NioImageBuffer
2) Code cleanup. git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@801 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes/share')
-rw-r--r--src/classes/share/javax/media/j3d/ExceptionStrings.properties1
-rw-r--r--src/classes/share/javax/media/j3d/ImageComponent2D.java6
-rw-r--r--src/classes/share/javax/media/j3d/ImageComponentRetained.java79
-rw-r--r--src/classes/share/javax/media/j3d/Texture3DRetained.java10
-rw-r--r--src/classes/share/javax/media/j3d/TextureCubeMapRetained.java10
-rw-r--r--src/classes/share/javax/media/j3d/TextureRetained.java58
6 files changed, 82 insertions, 82 deletions
diff --git a/src/classes/share/javax/media/j3d/ExceptionStrings.properties b/src/classes/share/javax/media/j3d/ExceptionStrings.properties
index 4e65926..40e0553 100644
--- a/src/classes/share/javax/media/j3d/ExceptionStrings.properties
+++ b/src/classes/share/javax/media/j3d/ExceptionStrings.properties
@@ -374,6 +374,7 @@ ImageComponent1=ImageComponent: no capability to get height
ImageComponent2=ImageComponent: no capability to get format
ImageComponent3=ImageComponent: This image is being used by a Canvas3D as an off-screen buffer.
ImageComponent4=ImageComponent: The image class of this object is ImageClass.NIO_IMAGE_BUFFER.
+ImageComponent5=ImageComponent: Mismatch in the number of components between format and image buffer.
ImageComponent2D0=ImageComponent2D: no capability to get image
ImageComponent2D1=ImageComponent2D: no capability to set image
ImageComponent2D2=ImageComponent2D: must be in BY_REFERENCE mode to use this method
diff --git a/src/classes/share/javax/media/j3d/ImageComponent2D.java b/src/classes/share/javax/media/j3d/ImageComponent2D.java
index cce5849..d8124db 100644
--- a/src/classes/share/javax/media/j3d/ImageComponent2D.java
+++ b/src/classes/share/javax/media/j3d/ImageComponent2D.java
@@ -234,6 +234,9 @@ public class ImageComponent2D extends ImageComponent {
*
* @exception IllegalArgumentException if the yUp flag is false.
*
+ * @exception IllegalArgumentException if the number of components in format
+ * does not match the number of components in image.
+ *
* @since Java 3D 1.5
*/
public ImageComponent2D(int format,
@@ -339,6 +342,9 @@ public class ImageComponent2D extends ImageComponent {
* specified image is not equal to the width and height of this
* ImageComponent object.
*
+ * @exception IllegalArgumentException if the number of components in format
+ * does not match the number of components in image.
+ *
* @since Java 3D 1.5
*/
public void set(NioImageBuffer image) {
diff --git a/src/classes/share/javax/media/j3d/ImageComponentRetained.java b/src/classes/share/javax/media/j3d/ImageComponentRetained.java
index 80112ec..b1744c6 100644
--- a/src/classes/share/javax/media/j3d/ImageComponentRetained.java
+++ b/src/classes/share/javax/media/j3d/ImageComponentRetained.java
@@ -603,54 +603,63 @@ abstract class ImageComponentRetained extends NodeComponentRetained {
switch(numberOfComponents) {
case 4:
- if(nioImageType == NioImageBuffer.ImageType.TYPE_4BYTE_ABGR) {
- // TODO : This approach will lead to a very slow path
- // for unsupported case.
- if(abgrSupported) {
- imageFormatType = ImageFormatType.TYPE_BYTE_ABGR;
- } else {
- // Unsupported format on HW, switch to slow copy.
+ switch(nioImageType) {
+ case TYPE_4BYTE_ABGR:
+ // TODO : This approach will lead to a very slow path
+ // for unsupported case.
+ if(abgrSupported) {
+ imageFormatType = ImageFormatType.TYPE_BYTE_ABGR;
+ } else {
+ // Unsupported format on HW, switch to slow copy.
+ imageFormatType = ImageFormatType.TYPE_BYTE_RGBA;
+ isSupported = false;
+ }
+ unitsPerPixel = 4;
+ break;
+ case TYPE_4BYTE_RGBA:
imageFormatType = ImageFormatType.TYPE_BYTE_RGBA;
- isSupported = false;
- }
- unitsPerPixel = 4;
- } else if(nioImageType == NioImageBuffer.ImageType.TYPE_4BYTE_RGBA) {
- imageFormatType = ImageFormatType.TYPE_BYTE_RGBA;
- unitsPerPixel = 4;
- } else if(nioImageType == NioImageBuffer.ImageType.TYPE_INT_ARGB) {
- imageFormatType = ImageFormatType.TYPE_INT_ARGB;
- unitsPerPixel = 1;
- } else {
- throw new RuntimeException("Not yet implemented");
+ unitsPerPixel = 4;
+ break;
+ case TYPE_INT_ARGB:
+ imageFormatType = ImageFormatType.TYPE_INT_ARGB;
+ unitsPerPixel = 1;
+ break;
+ default:
+ throw new IllegalArgumentException(J3dI18N.getString("ImageComponent5"));
+
}
break;
-
case 3:
- if(nioImageType == NioImageBuffer.ImageType.TYPE_3BYTE_BGR) {
- imageFormatType = ImageFormatType.TYPE_BYTE_BGR;
- unitsPerPixel = 3;
- } else if(nioImageType == NioImageBuffer.ImageType.TYPE_3BYTE_RGB) {
- imageFormatType = ImageFormatType.TYPE_BYTE_RGB;
- unitsPerPixel = 3;
- } else if(nioImageType == NioImageBuffer.ImageType.TYPE_INT_BGR) {
- imageFormatType = ImageFormatType.TYPE_INT_BGR;
- unitsPerPixel = 1;
- } else if(nioImageType == NioImageBuffer.ImageType.TYPE_INT_RGB) {
- imageFormatType = ImageFormatType.TYPE_INT_RGB;
- unitsPerPixel = 1;
- } else {
- throw new RuntimeException("Not yet implemented");
+ switch(nioImageType) {
+ case TYPE_3BYTE_BGR:
+ imageFormatType = ImageFormatType.TYPE_BYTE_BGR;
+ unitsPerPixel = 3;
+ break;
+ case TYPE_3BYTE_RGB:
+ imageFormatType = ImageFormatType.TYPE_BYTE_RGB;
+ unitsPerPixel = 3;
+ break;
+ case TYPE_INT_BGR:
+ imageFormatType = ImageFormatType.TYPE_INT_BGR;
+ unitsPerPixel = 1;
+ break;
+ case TYPE_INT_RGB:
+ imageFormatType = ImageFormatType.TYPE_INT_RGB;
+ unitsPerPixel = 1;
+ break;
+ default:
+ throw new IllegalArgumentException(J3dI18N.getString("ImageComponent5"));
}
break;
case 2:
- throw new RuntimeException("Not yet implemented");
+ throw new IllegalArgumentException(J3dI18N.getString("ImageComponent5"));
case 1:
if(nioImageType == NioImageBuffer.ImageType.TYPE_BYTE_GRAY) {
imageFormatType = ImageFormatType.TYPE_BYTE_GRAY;
unitsPerPixel = 1;
} else {
- throw new RuntimeException("Not yet implemented");
+ throw new IllegalArgumentException(J3dI18N.getString("ImageComponent5"));
}
break;
diff --git a/src/classes/share/javax/media/j3d/Texture3DRetained.java b/src/classes/share/javax/media/j3d/Texture3DRetained.java
index e79d537..2d361e9 100644
--- a/src/classes/share/javax/media/j3d/Texture3DRetained.java
+++ b/src/classes/share/javax/media/j3d/Texture3DRetained.java
@@ -109,15 +109,12 @@ class Texture3DRetained extends TextureRetained {
int width, int height, int depth,
int boundaryWidth, int imageDataType,
Object imageData) {
-
- boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures &
- Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0);
Pipeline.getPipeline().updateTexture3DImage(cv.ctx,
numLevels, level,
textureFormat, imageFormat,
width, height, depth,
- boundaryWidth, imageDataType, imageData, useAutoMipMap);
+ boundaryWidth, imageDataType, imageData, useAutoMipMapGeneration(cv));
}
// Wrapper around the native call for 3D textures
@@ -128,16 +125,13 @@ class Texture3DRetained extends TextureRetained {
int imgXOffset, int imgYOffset, int imgZOffset,
int tilew, int tileh, int width, int height, int depth,
int imageDataType, Object imageData) {
-
- boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures &
- Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0);
Pipeline.getPipeline().updateTexture3DSubImage(cv.ctx,
level, xoffset, yoffset, zoffset,
textureFormat, imageFormat,
imgXOffset, imgYOffset, imgZOffset,
tilew, tileh, width, height, depth,
- imageDataType, imageData, useAutoMipMap);
+ imageDataType, imageData, useAutoMipMapGeneration(cv));
}
diff --git a/src/classes/share/javax/media/j3d/TextureCubeMapRetained.java b/src/classes/share/javax/media/j3d/TextureCubeMapRetained.java
index 7fa84e3..dd85def 100644
--- a/src/classes/share/javax/media/j3d/TextureCubeMapRetained.java
+++ b/src/classes/share/javax/media/j3d/TextureCubeMapRetained.java
@@ -305,15 +305,12 @@ class TextureCubeMapRetained extends TextureRetained {
int width, int height,
int boundaryWidth, int imageDataType,
Object imageData) {
-
- boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures &
- Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0);
Pipeline.getPipeline().updateTextureCubeMapImage(cv.ctx,
face, numLevels, level,
textureFormat, imageFormat,
width, height,
- boundaryWidth, imageDataType, imageData, useAutoMipMap);
+ boundaryWidth, imageDataType, imageData, useAutoMipMapGeneration(cv));
}
// This is just a wrapper of the native method.
@@ -324,16 +321,13 @@ class TextureCubeMapRetained extends TextureRetained {
int imgXOffset, int imgYOffset,
int tilew, int width, int height,
int imageDataType, Object imageData) {
-
- boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures &
- Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0);
Pipeline.getPipeline().updateTextureCubeMapSubImage(cv.ctx,
face, level, xoffset, yoffset,
textureFormat, imageFormat,
imgXOffset, imgYOffset,
tilew, width, height,
- imageDataType, imageData, useAutoMipMap);
+ imageDataType, imageData, useAutoMipMapGeneration(cv));
}
}
diff --git a/src/classes/share/javax/media/j3d/TextureRetained.java b/src/classes/share/javax/media/j3d/TextureRetained.java
index 95dd1f6..ccdcd07 100644
--- a/src/classes/share/javax/media/j3d/TextureRetained.java
+++ b/src/classes/share/javax/media/j3d/TextureRetained.java
@@ -76,9 +76,7 @@ abstract class TextureRetained extends NodeComponentRetained {
// 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.
- boolean useAutoMipMapGeneration = false;
+ private int maxMipMapLevels = 0;
int numFaces = 1; // For CubeMap, it is 6
int baseLevel = 0;
@@ -1180,8 +1178,8 @@ abstract class TextureRetained extends NodeComponentRetained {
// update sharpen texture function if applicable
- if ((magFilter >= Texture.LINEAR_SHARPEN) &&
- (magFilter <= Texture.LINEAR_SHARPEN_ALPHA)) {
+ if ((magnificationFilter >= Texture.LINEAR_SHARPEN) &&
+ (magnificationFilter <= Texture.LINEAR_SHARPEN_ALPHA)) {
if ((cv.textureExtendedFeatures & Canvas3D.TEXTURE_SHARPEN) != 0 ) {
@@ -1197,8 +1195,8 @@ abstract class TextureRetained extends NodeComponentRetained {
magnificationFilter = Texture.BASE_LEVEL_LINEAR;
}
- } else if ((magFilter >= Texture2D.LINEAR_DETAIL) &&
- (magFilter <= Texture2D.LINEAR_DETAIL_ALPHA)) {
+ } else if ((magnificationFilter >= Texture2D.LINEAR_DETAIL) &&
+ (magnificationFilter <= Texture2D.LINEAR_DETAIL_ALPHA)) {
if ((cv.textureExtendedFeatures & Canvas3D.TEXTURE_DETAIL) == 0) {
// detail texture is not supported by the underlying
@@ -1208,7 +1206,7 @@ abstract class TextureRetained extends NodeComponentRetained {
}
}
- if (minFilter == Texture.FILTER4 || magFilter == Texture.FILTER4) {
+ if (minificationFilter == Texture.FILTER4 || magnificationFilter == Texture.FILTER4) {
boolean noFilter4 = false;
@@ -1233,23 +1231,23 @@ abstract class TextureRetained extends NodeComponentRetained {
}
if (noFilter4) {
- if (minFilter == Texture.FILTER4) {
+ if (minificationFilter == Texture.FILTER4) {
minificationFilter = Texture.BASE_LEVEL_LINEAR;
}
- if (magFilter == Texture.FILTER4) {
+ if (magnificationFilter == Texture.FILTER4) {
magnificationFilter = Texture.BASE_LEVEL_LINEAR;
}
}
}
// Fallback to BASE mode if hardware mipmap generation is not supported.
- if (useAutoMipMapGeneration && ((cv.textureExtendedFeatures &
+ if ((mipmapMode == Texture.BASE_LEVEL) && ((cv.textureExtendedFeatures &
Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) == 0)) {
- if (minFilter == Texture.NICEST ||
- minFilter == Texture.MULTI_LEVEL_LINEAR) {
+ if (minificationFilter == Texture.NICEST ||
+ minificationFilter == Texture.MULTI_LEVEL_LINEAR) {
minificationFilter = Texture.BASE_LEVEL_LINEAR;
- } else if (minFilter == Texture.MULTI_LEVEL_POINT) {
+ } else if (minificationFilter == Texture.MULTI_LEVEL_POINT) {
minificationFilter = Texture.BASE_LEVEL_POINT;
}
}
@@ -1283,14 +1281,11 @@ abstract class TextureRetained extends NodeComponentRetained {
int boundaryWidth,
int imageDataType, Object data) {
- boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures &
- Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0);
-
Pipeline.getPipeline().updateTexture2DImage(cv.ctx,
numLevels, level,
textureFormat, imageFormat,
width, height, boundaryWidth,
- imageDataType, data, useAutoMipMap);
+ imageDataType, data, useAutoMipMapGeneration(cv));
}
// Wrapper around the native call for 2D textures; overridden for
@@ -1302,16 +1297,13 @@ abstract class TextureRetained extends NodeComponentRetained {
int imgXOffset, int imgYOffset,
int tilew, int width, int height,
int imageDataType, Object data) {
-
- boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures &
- Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0);
Pipeline.getPipeline().updateTexture2DSubImage(cv.ctx,
level, xoffset, yoffset,
textureFormat, imageFormat,
imgXOffset, imgYOffset,
tilew, width, height,
- imageDataType, data, useAutoMipMap);
+ imageDataType, data, useAutoMipMapGeneration(cv));
}
@@ -1980,14 +1972,6 @@ abstract class TextureRetained extends NodeComponentRetained {
mirrorTexture.anisotropicFilterMode = anisotropicFilterMode;
mirrorTexture.anisotropicFilterDegree = anisotropicFilterDegree;
- // implicit mipmap generation
- if (mipmapMode == Texture.BASE_LEVEL &&
- (minFilter == Texture.NICEST ||
- minFilter == Texture.MULTI_LEVEL_POINT ||
- minFilter == Texture.MULTI_LEVEL_LINEAR)) {
- mirrorTexture.useAutoMipMapGeneration = true;
- }
-
mirrorTexture.maxLevels = maxLevels;
if (images != null) {
@@ -2004,7 +1988,19 @@ abstract class TextureRetained extends NodeComponentRetained {
}
}
-
+ boolean useAutoMipMapGeneration(Canvas3D cv) {
+ if (mipmapMode == Texture.BASE_LEVEL &&
+ (minFilter == Texture.NICEST ||
+ minFilter == Texture.MULTI_LEVEL_POINT ||
+ minFilter == Texture.MULTI_LEVEL_LINEAR) &&
+ ((cv.textureExtendedFeatures &
+ Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0)) {
+ return true;
+ }
+
+ return false;
+ }
+
/**
* Go through the image update info list
* and remove those that are already done