summaryrefslogtreecommitdiffstats
path: root/make/config/jogl/gl-impl-CustomJavaCode-desktop.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-10-18 07:42:54 -0700
committerSven Gothel <[email protected]>2009-10-18 07:53:05 -0700
commite4b0e57b9fe28296fcd8d9eb372242c33643886b (patch)
treef1d2c72b1dc17674c9a7dc14049960ef65c3d350 /make/config/jogl/gl-impl-CustomJavaCode-desktop.java
parent4d493ac36bd5d763d2af3243e799bbaef3679594 (diff)
New iteration of check 'imageSizeInBytes':
Premises: See http://www.glprogramming.com/red/chapter08.html "If the rectangle in memory is larger than the subrectangle that's being drawn or read, you need to specify the actual length (measured in pixels) of the larger rectangle with *ROW_LENGTH. " This equals ROW_LENGTH == SubPicture-Width + 'Dirt', ie the offset to go from one line to the next. "You also need to specify the number of rows and pixels to skip before starting to copy the data for the subrectangle. These numbers are set using the parameters *SKIP_ROWS and *SKIP_PIXELS, as shown in Figure 8-9. By default, both parameters are 0, so you start at the lower-left corner." This equals to a one time offset _before_ you start copy the data, ie with your DMA engine, using ROW_LENGTH and HEIGHT only. Compared to Mesa3D's implementation (proof): http://cgit.freedesktop.org/mesa/mesa/tree/src/glx/x11/pixelstore.c Line 78 - 200 PixelStore State Tracker: Store the values in the PixelStore structure. http://cgit.freedesktop.org/mesa/mesa/tree/src/glx/x11/pixel.c Line 82 - 155 Line 210: Start position is set one time using SKIP_* values the same way we do. Line 228: Jump to the first pixel in the newxt row, just using ROW_LENGTH Line 230: Jump to the first pixel in the next 'image' just using imageSize, rowsPerImage = IMAGE_HEIGHT>0?IMAGE_HEIGHT:height; groupsPerRow = ROW_LENGTH>0?ROW_LENGTH:width; groupSize = elementSize * components; rowSize = groupsPerRow * groupSize; imageSize = rowSize * rowsPerImage; changes: Removed redundand 'dimension' parameted, which is derived from depth and height, 1D == depth:1 height:1 2D == depth:1 height>1 nD == depth>1 height>1 Safe fail depth to >= 1 Safe fail height to >= 1D Take either the ROW_LENGTH / IMAGE_HEIGHT PixelStore value if > 0, or the given width / height.
Diffstat (limited to 'make/config/jogl/gl-impl-CustomJavaCode-desktop.java')
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-desktop.java42
1 files changed, 22 insertions, 20 deletions
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java
index bd4659b88..fb06aa4ae 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java
@@ -3,9 +3,7 @@ private int[] imageSizeTemp = new int[1];
/** Helper for more precise computation of number of bytes that will
be touched by a pixel pack or unpack operation. */
private int imageSizeInBytes(int bytesPerElement,
- int width, int height, int depth,
- int dimensions,
- boolean pack) {
+ int width, int height, int depth, boolean pack) {
int rowLength = 0;
int skipRows = 0;
int skipPixels = 0;
@@ -22,7 +20,7 @@ private int imageSizeInBytes(int bytesPerElement,
skipPixels = imageSizeTemp[0];
glGetIntegerv(GL_PACK_ALIGNMENT, imageSizeTemp, 0);
alignment = imageSizeTemp[0];
- if (dimensions > 2) {
+ if (depth > 1) {
glGetIntegerv(GL_PACK_IMAGE_HEIGHT, imageSizeTemp, 0);
imageHeight = imageSizeTemp[0];
glGetIntegerv(GL_PACK_SKIP_IMAGES, imageSizeTemp, 0);
@@ -37,7 +35,7 @@ private int imageSizeInBytes(int bytesPerElement,
skipPixels = imageSizeTemp[0];
glGetIntegerv(GL_UNPACK_ALIGNMENT, imageSizeTemp, 0);
alignment = imageSizeTemp[0];
- if (dimensions > 2) {
+ if (depth > 1) {
glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, imageSizeTemp, 0);
imageHeight = imageSizeTemp[0];
glGetIntegerv(GL_UNPACK_SKIP_IMAGES, imageSizeTemp, 0);
@@ -45,36 +43,40 @@ private int imageSizeInBytes(int bytesPerElement,
}
}
// Try to deal somewhat correctly with potentially invalid values
- height = Math.max(0, height);
+ width = Math.max(0, width );
+ height = Math.max(1, height); // min 1D
+ depth = Math.max(1, depth ); // min 1 * imageSize
skipRows = Math.max(0, skipRows);
skipPixels = Math.max(0, skipPixels);
alignment = Math.max(1, alignment);
- imageHeight = Math.max(0, imageHeight);
skipImages = Math.max(0, skipImages);
- rowLength = Math.max(Math.max(0, rowLength), width); // > 0 && >= width
+ imageHeight = ( imageHeight > 0 ) ? imageHeight : height;
+ rowLength = ( rowLength > 0 ) ? rowLength : width;
+
int rowLengthInBytes = rowLength * bytesPerElement;
if (alignment > 1) {
- int modulus = rowLengthInBytes % alignment;
- if (modulus > 0) {
- rowLengthInBytes += alignment - modulus;
+ int padding = rowLengthInBytes % alignment;
+ if (padding > 0) {
+ rowLengthInBytes += alignment - padding;
}
}
/**
- * skipPixels and skipRows is a static one time offset
+ * skipPixels and skipRows is a static one time offset.
+ *
+ * skipImages and depth are in multiples of image size.
*
* rowlenght is the actual repeating offset
- * from line-start to the next line-start.
+ * to go from line n to line n+1 at the same x-axis position.
*/
- int size = height * rowLengthInBytes; // height == 1 for 1D
- if(dimensions==3) {
- size *= (skipImages + depth);
- }
+ int imageSize = imageHeight * rowLengthInBytes;
- int skipOffset = skipPixels * bytesPerElement +
- skipRows * rowLengthInBytes;
+ int skipOffset = skipImages * imageSize +
+ skipRows * rowLengthInBytes +
+ skipPixels * bytesPerElement;
- return size + skipOffset;
+ return skipOffset + imageSize * depth;
}
+