X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=android%2Fproject%2Fxscreensaver%2Fsrc%2Forg%2Fjwz%2Fxscreensaver%2FBufferFactory.java;fp=android%2Fproject%2Fxscreensaver%2Fsrc%2Forg%2Fjwz%2Fxscreensaver%2FBufferFactory.java;h=0000000000000000000000000000000000000000;hp=228928fa076be7f3b6634e4d0ad5b057d65177f6;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hpb=88cfe534a698a0562e81345957a50714af1453bc diff --git a/android/project/xscreensaver/src/org/jwz/xscreensaver/BufferFactory.java b/android/project/xscreensaver/src/org/jwz/xscreensaver/BufferFactory.java deleted file mode 100644 index 228928fa..00000000 --- a/android/project/xscreensaver/src/org/jwz/xscreensaver/BufferFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.jwz.xscreensaver; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.FloatBuffer; -import java.nio.ShortBuffer; - -/** - * A utility class to create buffers. - * - * All public methods are static. The Singleton pattern was avoided to avoid concerns about - * threading and the Android life cycle. If needed, It can be implemented later given some research. - */ -public class BufferFactory { - // This class cannot and should not be instantiated - private BufferFactory() {} - - // We use Buffer.allocateDirect() to get memory outside of - // the normal, garbage collected heap. I think this is done - // because the buffer is subject to native I/O. - // See http://download.oracle.com/javase/1.4.2/docs/api/java/nio/ByteBuffer.html#direct - - /** - * Creates a buffer of floats using memory outside the normal, garbage collected heap - * - * @param capacity The number of primitives to create in the buffer. - */ - public static FloatBuffer createFloatBuffer(int capacity) { - // 4 is the number of bytes in a float - ByteBuffer vbb = ByteBuffer.allocateDirect(capacity * 4); - vbb.order(ByteOrder.nativeOrder()); - return vbb.asFloatBuffer(); - } - - /** - * Creates a buffer of shorts using memory outside the normal, garbage collected heap - * - * @param capacity The number of primitives to create in the buffer. - */ - public static ShortBuffer createShortBuffer(int capacity) { - // 2 is the number of bytes in a short - ByteBuffer vbb = ByteBuffer.allocateDirect(capacity * 2); - vbb.order(ByteOrder.nativeOrder()); - return vbb.asShortBuffer(); - } -}