From de53d193c86a02a3cdc46c5c8758192d957d1c67 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 8 Jul 2014 22:10:03 +0200 Subject: Findbugs: Misc minor issues (see below) - remove duplicate code in branch - Use Type.valueOf(primitive) - Don't use array.toString() directly - remove dead code --- .../jogamp/opengl/glu/mipmap/ExtractSByte.java | 4 +-- .../classes/jogamp/opengl/glu/mipmap/Mipmap.java | 30 ++++++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/glu/mipmap') diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java index e9b021413..76c34330f 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java @@ -58,9 +58,7 @@ public class ExtractSByte implements ExtractPrimitive { @Override public double extract( final boolean isSwap, final ByteBuffer sbyte ) { - final byte b = sbyte.get(); - assert( b <= 127 ); - return( b ); + return sbyte.get(); // <= 127 } @Override diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java index fba6a231a..9ff6bd637 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java @@ -661,8 +661,6 @@ public class Mipmap { public static int gluBuild2DMipmapLevels( final GL gl, final int target, final int internalFormat, final int width, final int height, final int format, final int type, final int userLevel, final int baseLevel, final int maxLevel, final Object data ) { - int dataPos = 0; - int level, levels; final int rc = checkMipmapArgs( internalFormat, format, type ); @@ -686,14 +684,14 @@ public class Mipmap { } //PointerWrapper pointer = PointerWrapperFactory.getPointerWrapper( data ); - ByteBuffer buffer = null; + final ByteBuffer buffer; if( data instanceof ByteBuffer ) { buffer = (ByteBuffer)data; - dataPos = buffer.position(); } else if( data instanceof byte[] ) { - final byte[] array = (byte[])data; - buffer = ByteBuffer.allocateDirect(array.length); - buffer.put(array); + final byte[] array = (byte[])data; + buffer = ByteBuffer.allocateDirect(array.length); + buffer.put(array); + buffer.flip(); } else if( data instanceof short[] ) { final short[] array = (short[])data; buffer = ByteBuffer.allocateDirect( array.length * 2 ); @@ -709,8 +707,11 @@ public class Mipmap { buffer = ByteBuffer.allocateDirect( array.length * 4 ); final FloatBuffer fb = buffer.asFloatBuffer(); fb.put( array ); + } else { + throw new IllegalArgumentException("Unhandled data type: "+data.getClass().getName()); } + final int dataPos = buffer.position(); try { return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat, width, height, width, height, format, type, userLevel, baseLevel, @@ -723,8 +724,6 @@ public class Mipmap { public static int gluBuild2DMipmaps( final GL gl, final int target, final int internalFormat, final int width, final int height, final int format, final int type, final Object data ) { - int dataPos = 0; - final int[] widthPowerOf2 = new int[1]; final int[] heightPowerOf2 = new int[1]; int level, levels; @@ -748,14 +747,14 @@ public class Mipmap { } //PointerWrapper pointer = PointerWrapperFactory.getPointerWrapper( data ); - ByteBuffer buffer = null; + final ByteBuffer buffer; if( data instanceof ByteBuffer ) { buffer = (ByteBuffer)data; - dataPos = buffer.position(); } else if( data instanceof byte[] ) { - final byte[] array = (byte[])data; - buffer = ByteBuffer.allocateDirect(array.length); - buffer.put(array); + final byte[] array = (byte[])data; + buffer = ByteBuffer.allocateDirect(array.length); + buffer.put(array); + buffer.flip(); } else if( data instanceof short[] ) { final short[] array = (short[])data; buffer = ByteBuffer.allocateDirect( array.length * 2 ); @@ -771,8 +770,11 @@ public class Mipmap { buffer = ByteBuffer.allocateDirect( array.length * 4 ); final FloatBuffer fb = buffer.asFloatBuffer(); fb.put( array ); + } else { + throw new IllegalArgumentException("Unhandled data type: "+data.getClass().getName()); } + final int dataPos = buffer.position(); try { return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat, width, height, widthPowerOf2[0], heightPowerOf2[0], format, type, 0, -- cgit v1.2.3