From 4d493ac36bd5d763d2af3243e799bbaef3679594 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 17 Oct 2009 13:44:12 -0700 Subject: All tracker are aggregated in the GLContext now and used within the GL*Impl. New GLStateTracker: - Tracking client/server states - Currently supports PixelStorei - Prologued in glPixelStorei and glGetIntegerv, the latter will return the tracked state if available and not call the GL method. Impacts performance and ES1 compatibility (supports ALIGNMENT). Fixed 'imageSizeInBytes' calculation: - skipPixels and skipRows is a static one time offset --- .../jogl/gl-impl-CustomJavaCode-desktop.java | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'make/config/jogl/gl-impl-CustomJavaCode-desktop.java') diff --git a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java index 0d01aaec4..bd4659b88 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java @@ -3,7 +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 w, int h, int d, + int width, int height, int depth, int dimensions, boolean pack) { int rowLength = 0; @@ -45,14 +45,16 @@ private int imageSizeInBytes(int bytesPerElement, } } // Try to deal somewhat correctly with potentially invalid values - rowLength = Math.max(0, rowLength); + height = Math.max(0, height); 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(rowLength, w + skipPixels); + + rowLength = Math.max(Math.max(0, rowLength), width); // > 0 && >= width int rowLengthInBytes = rowLength * bytesPerElement; + if (alignment > 1) { int modulus = rowLengthInBytes % alignment; if (modulus > 0) { @@ -60,15 +62,19 @@ private int imageSizeInBytes(int bytesPerElement, } } - int size = 0; - if (dimensions == 1) { - return (w + skipPixels) * bytesPerElement; - } else { - int size2D = ((skipRows + h - 1) * rowLengthInBytes) + (w + skipPixels) * bytesPerElement; - if (dimensions == 2) { - return size2D; - } - int imageSizeInBytes = imageHeight * rowLength; - return ((skipImages + d - 1) * imageSizeInBytes) + size2D; + /** + * skipPixels and skipRows is a static one time offset + * + * rowlenght is the actual repeating offset + * from line-start to the next line-start. + */ + int size = height * rowLengthInBytes; // height == 1 for 1D + if(dimensions==3) { + size *= (skipImages + depth); } + + int skipOffset = skipPixels * bytesPerElement + + skipRows * rowLengthInBytes; + + return size + skipOffset; } -- cgit v1.2.3