From: Caspian Rychlik-P. <ci...@us...> - 2002-08-20 09:29:56
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl In directory usw-pr-cvs1:/tmp/cvs-serv23898/src/java/org/lwjgl Modified Files: Math.java Log Message: Ready for native code Index: Math.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/Math.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/Math.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Math.java 19 Aug 2002 11:29:42 -0000 1.4 +++ Math.java 20 Aug 2002 09:29:50 -0000 1.5 @@ -46,7 +46,7 @@ public final class Math { static { - System.loadLibrary(Sys.LIBRARY_NAME); + System.loadLibrary(Sys.getLibraryName()); } /** Floating point version of pi */ @@ -136,43 +136,17 @@ protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } }; /** * A matrix operation is direct if the source and destination addresses * are the same, and the strides are the same. */ - private final MatrixOpClassification MATRIXOP_DIRECT = new MatrixOpClassification() { - protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } - protected MatrixOpClassification safe() { return this; } - protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( - int sourceAddress, - int sourceStride, - int numElements, - int sourceWidth, - int sourceHeight, - boolean transposeSource, - int destAddress, - int destStride, - boolean transposeDest) - { - } - }; - - - /** - * A matrix operation is offset if source > destination, and the - * strides are the same - */ - private final MatrixOpClassification MATRIXOP_OFFSET = new MatrixOpClassification() { + private final class MatrixOpDirect extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return this; } protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return this; } - void execute( + native void execute( int sourceAddress, int sourceStride, int numElements, @@ -181,22 +155,19 @@ boolean transposeSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; - + private final MatrixOpDirect MATRIXOP_DIRECT = new MatrixOpDirect(); /** * A matrix operation is safe if the source and destination do not * overlap in any way */ - private final MatrixOpClassification MATRIXOP_SAFE = new MatrixOpClassification() { + private final class MatrixOpSafe extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( + native void execute( int sourceAddress, int sourceStride, int numElements, @@ -205,10 +176,9 @@ boolean transposeSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; + private final MatrixOpSafe MATRIXOP_SAFE = new MatrixOpSafe(); }; public static final MatrixOpCopy MATRIXOP_COPY = new MatrixOpCopy(); @@ -230,43 +200,17 @@ protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } }; /** * A matrix operation is direct if the source and destination addresses * are the same, and the strides are the same. */ - private final MatrixOpClassification MATRIXOP_DIRECT = new MatrixOpClassification() { - protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } - protected MatrixOpClassification safe() { return this; } - protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( - int sourceAddress, - int sourceStride, - int numElements, - int sourceWidth, - int sourceHeight, - boolean transposeSource, - int destAddress, - int destStride, - boolean transposeDest) - { - } - }; - - - /** - * A matrix operation is offset if source > destination, and the - * strides are the same - */ - private final MatrixOpClassification MATRIXOP_OFFSET = new MatrixOpClassification() { + private final class MatrixOpDirect extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return this; } protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return this; } - void execute( + native void execute( int sourceAddress, int sourceStride, int numElements, @@ -275,22 +219,19 @@ boolean transposeSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; - + private final MatrixOpDirect MATRIXOP_DIRECT = new MatrixOpDirect(); /** * A matrix operation is safe if the source and destination do not * overlap in any way */ - private final MatrixOpClassification MATRIXOP_SAFE = new MatrixOpClassification() { + private final class MatrixOpSafe extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( + native void execute( int sourceAddress, int sourceStride, int numElements, @@ -299,10 +240,9 @@ boolean transposeSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; + private final MatrixOpSafe MATRIXOP_SAFE = new MatrixOpSafe(); }; public static final MatrixOpNegate MATRIXOP_NEGATE = new MatrixOpNegate(); @@ -324,43 +264,17 @@ protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } }; /** * A matrix operation is direct if the source and destination addresses * are the same, and the strides are the same. */ - private final MatrixOpClassification MATRIXOP_DIRECT = new MatrixOpClassification() { - protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } - protected MatrixOpClassification safe() { return this; } - protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( - int sourceAddress, - int sourceStride, - int numElements, - int sourceWidth, - int sourceHeight, - boolean transposeSource, - int destAddress, - int destStride, - boolean transposeDest) - { - } - }; - - - /** - * A matrix operation is offset if source > destination, and the - * strides are the same - */ - private final MatrixOpClassification MATRIXOP_OFFSET = new MatrixOpClassification() { + private final class MatrixOpDirect extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return this; } protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return this; } - void execute( + native void execute( int sourceAddress, int sourceStride, int numElements, @@ -369,22 +283,19 @@ boolean transposeSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; - + private final MatrixOpDirect MATRIXOP_DIRECT = new MatrixOpDirect(); /** * A matrix operation is safe if the source and destination do not * overlap in any way */ - private final MatrixOpClassification MATRIXOP_SAFE = new MatrixOpClassification() { + private final class MatrixOpSafe extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( + native void execute( int sourceAddress, int sourceStride, int numElements, @@ -393,10 +304,9 @@ boolean transposeSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; + private final MatrixOpSafe MATRIXOP_SAFE = new MatrixOpSafe(); }; public static final MatrixOpNormalise MATRIXOP_NORMALISE = new MatrixOpNormalise(); @@ -418,43 +328,17 @@ protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } }; /** * A matrix operation is direct if the source and destination addresses * are the same, and the strides are the same. */ - private final MatrixOpClassification MATRIXOP_DIRECT = new MatrixOpClassification() { - protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } - protected MatrixOpClassification safe() { return this; } - protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( - int sourceAddress, - int sourceStride, - int numElements, - int sourceWidth, - int sourceHeight, - boolean transposeSource, - int destAddress, - int destStride, - boolean transposeDest) - { - } - }; - - - /** - * A matrix operation is offset if source > destination, and the - * strides are the same - */ - private final MatrixOpClassification MATRIXOP_OFFSET = new MatrixOpClassification() { + private final class MatrixOpDirect extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return this; } protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return this; } - void execute( + native void execute( int sourceAddress, int sourceStride, int numElements, @@ -463,22 +347,19 @@ boolean transposeSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; - + private final MatrixOpDirect MATRIXOP_DIRECT = new MatrixOpDirect(); /** * A matrix operation is safe if the source and destination do not * overlap in any way */ - private final MatrixOpClassification MATRIXOP_SAFE = new MatrixOpClassification() { + private final class MatrixOpSafe extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( + native void execute( int sourceAddress, int sourceStride, int numElements, @@ -487,10 +368,9 @@ boolean transposeSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; + private final MatrixOpSafe MATRIXOP_SAFE = new MatrixOpSafe(); }; public static final MatrixOpInvert MATRIXOP_INVERT = new MatrixOpInvert(); @@ -562,49 +442,17 @@ protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } }; /** * A matrix operation is direct if the source and destination addresses * are the same, and the strides are the same. */ - private final MatrixOpClassification MATRIXOP_DIRECT = new MatrixOpClassification() { - protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } - protected MatrixOpClassification safe() { return this; } - protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( - int leftSourceAddress, - int leftSourceStride, - int leftElements, - int leftSourceWidth, - int leftSourceHeight, - boolean transposeLeftSource, - int rightSourceAddress, - int rightSourceStride, - int rightElements, - int rightSourceWidth, - int rightSourceHeight, - boolean transposeRightSource, - int destAddress, - int destStride, - boolean transposeDest) - { - } - }; - - - /** - * A matrix operation is offset if source > destination, and the - * strides are the same - */ - private final MatrixOpClassification MATRIXOP_OFFSET = new MatrixOpClassification() { + private final class MatrixOpDirect extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return this; } protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return this; } - void execute( + native void execute( int leftSourceAddress, int leftSourceStride, int leftElements, @@ -619,22 +467,20 @@ boolean transposeRightSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; + private final MatrixOpDirect MATRIXOP_DIRECT = new MatrixOpDirect(); /** * A matrix operation is safe if the source and destination do not * overlap in any way */ - private final MatrixOpClassification MATRIXOP_SAFE = new MatrixOpClassification() { + private final class MatrixOpSafe extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( + native void execute( int leftSourceAddress, int leftSourceStride, int leftElements, @@ -649,10 +495,9 @@ boolean transposeRightSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; + private final MatrixOpSafe MATRIXOP_SAFE = new MatrixOpSafe(); }; public static final MatrixOpMultiply MATRIXOP_MULTIPLY = new MatrixOpMultiply(); @@ -694,49 +539,17 @@ protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } }; /** * A matrix operation is direct if the source and destination addresses * are the same, and the strides are the same. */ - private final MatrixOpClassification MATRIXOP_DIRECT = new MatrixOpClassification() { - protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } - protected MatrixOpClassification safe() { return this; } - protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( - int leftSourceAddress, - int leftSourceStride, - int leftElements, - int leftSourceWidth, - int leftSourceHeight, - boolean transposeLeftSource, - int rightSourceAddress, - int rightSourceStride, - int rightElements, - int rightSourceWidth, - int rightSourceHeight, - boolean transposeRightSource, - int destAddress, - int destStride, - boolean transposeDest) - { - } - }; - - - /** - * A matrix operation is offset if source > destination, and the - * strides are the same - */ - private final MatrixOpClassification MATRIXOP_OFFSET = new MatrixOpClassification() { + private final class MatrixOpDirect extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return this; } protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return this; } - void execute( + native void execute( int leftSourceAddress, int leftSourceStride, int leftElements, @@ -751,22 +564,20 @@ boolean transposeRightSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; + private final MatrixOpDirect MATRIXOP_DIRECT = new MatrixOpDirect(); /** * A matrix operation is safe if the source and destination do not * overlap in any way */ - private final MatrixOpClassification MATRIXOP_SAFE = new MatrixOpClassification() { + private final class MatrixOpSafe extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - void execute( + native void execute( int leftSourceAddress, int leftSourceStride, int leftElements, @@ -781,10 +592,9 @@ boolean transposeRightSource, int destAddress, int destStride, - boolean transposeDest) - { - } + boolean transposeDest); }; + private final MatrixOpSafe MATRIXOP_SAFE = new MatrixOpSafe(); }; public static final MatrixOpAdd MATRIXOP_ADD = new MatrixOpAdd(); @@ -826,46 +636,16 @@ protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } }; /** * A matrix operation is direct if the source and destination addresses * are the same, and the strides are the same. */ - private final MatrixOpClassification MATRIXOP_DIRECT = new MatrixOpClassification() { - protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } - protected MatrixOpClassification safe() { return this; } - protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } - native void execute( - int leftSourceAddress, - int leftSourceStride, - int leftElements, - int leftSourceWidth, - int leftSourceHeight, - boolean transposeLeftSource, - int rightSourceAddress, - int rightSourceStride, - int rightElements, - int rightSourceWidth, - int rightSourceHeight, - boolean transposeRightSource, - int destAddress, - int destStride, - boolean transposeDest); - }; - - - /** - * A matrix operation is offset if source > destination, and the - * strides are the same - */ - private final MatrixOpClassification MATRIXOP_OFFSET = new MatrixOpClassification() { + private final class MatrixOpDirect extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return this; } protected MatrixOpClassification direct() { return this; } - protected MatrixOpClassification offset() { return this; } native void execute( int leftSourceAddress, int leftSourceStride, @@ -883,17 +663,17 @@ int destStride, boolean transposeDest); }; + private final MatrixOpDirect MATRIXOP_DIRECT = new MatrixOpDirect(); /** * A matrix operation is safe if the source and destination do not * overlap in any way */ - private final MatrixOpClassification MATRIXOP_SAFE = new MatrixOpClassification() { + private final class MatrixOpSafe extends MatrixOpClassification { protected MatrixOpClassification unsafe() { return MATRIXOP_UNSAFE; } protected MatrixOpClassification safe() { return MATRIXOP_SAFE; } protected MatrixOpClassification direct() { return MATRIXOP_DIRECT; } - protected MatrixOpClassification offset() { return MATRIXOP_OFFSET; } native void execute( int leftSourceAddress, int leftSourceStride, @@ -911,6 +691,7 @@ int destStride, boolean transposeDest); }; + private final MatrixOpSafe MATRIXOP_SAFE = new MatrixOpSafe(); }; public static final MatrixOpSubtract MATRIXOP_SUBTRACT = new MatrixOpSubtract(); @@ -998,8 +779,6 @@ abstract MatrixOpClassification unsafe(); abstract MatrixOpClassification safe(); abstract MatrixOpClassification direct(); - abstract MatrixOpClassification offset(); - /** * Execute a unary matrix operation. * The default implementation does nothing. @@ -1055,7 +834,7 @@ if (destAddress > sourceAddress || sourceStride != destStride) return unsafe(); else if (destAddress < sourceAddress) - return offset(); + return safe(); else return direct(); |