Search in sources :

Example 91 with ShortBuffer

use of java.nio.ShortBuffer in project ffx by mjschnie.

the class Signed16BitIntegerMatrixBuf_1 method sendItems.

// Hidden operations.
/**
 * {@inheritDoc}
 *
 * Send as many items as possible from this buffer to the given byte buffer.
 * <P>
 * The <TT>sendItems()</TT> method must not block the calling thread; if it
 * does, all message I/O in MP will be blocked.
 */
protected int sendItems(int i, ByteBuffer buffer) {
    ShortBuffer shortbuffer = buffer.asShortBuffer();
    int n = 0;
    int r = i2r(i);
    int row = r + myLowerRow;
    int c = i2c(i);
    int col = c + myLowerCol;
    int ncols = Math.min(myColCount - c, shortbuffer.remaining());
    while (r < myRowCount && ncols > 0) {
        int[] myMatrix_row = myMatrix[row];
        while (c < ncols) {
            shortbuffer.put((short) myMatrix_row[col]);
            ++c;
            ++col;
        }
        n += ncols;
        ++r;
        ++row;
        c = 0;
        col = myLowerCol;
        ncols = Math.min(myColCount, shortbuffer.remaining());
    }
    buffer.position(buffer.position() + 2 * n);
    return n;
}
Also used : ShortBuffer(java.nio.ShortBuffer)

Example 92 with ShortBuffer

use of java.nio.ShortBuffer in project ffx by mjschnie.

the class Unsigned16BitIntegerMatrixBuf_1 method receiveItems.

/**
 * {@inheritDoc}
 *
 * Receive as many items as possible from the given byte buffer to this
 * buffer.
 * <P>
 * The <TT>receiveItems()</TT> method must not block the calling thread; if
 * it does, all message I/O in MP will be blocked.
 */
protected int receiveItems(int i, int num, ByteBuffer buffer) {
    ShortBuffer shortbuffer = buffer.asShortBuffer();
    num = Math.min(num, shortbuffer.remaining());
    int n = 0;
    int r = i2r(i);
    int row = r + myLowerRow;
    int c = i2c(i);
    int col = c + myLowerCol;
    int ncols = Math.min(myColCount - c, num);
    while (r < myRowCount && ncols > 0) {
        int[] myMatrix_row = myMatrix[row];
        for (c = 0; c < ncols; ++c) {
            myMatrix_row[col] = shortbuffer.get() & 0xFFFF;
            ++col;
        }
        num -= ncols;
        n += ncols;
        ++r;
        ++row;
        col = myLowerCol;
        ncols = Math.min(myColCount, num);
    }
    buffer.position(buffer.position() + 2 * n);
    return n;
}
Also used : ShortBuffer(java.nio.ShortBuffer)

Example 93 with ShortBuffer

use of java.nio.ShortBuffer in project ffx by mjschnie.

the class Unsigned16BitIntegerMatrixBuf_1 method sendItems.

// Hidden operations.
/**
 * {@inheritDoc}
 *
 * Send as many items as possible from this buffer to the given byte buffer.
 * <P>
 * The <TT>sendItems()</TT> method must not block the calling thread; if it
 * does, all message I/O in MP will be blocked.
 */
protected int sendItems(int i, ByteBuffer buffer) {
    ShortBuffer shortbuffer = buffer.asShortBuffer();
    int n = 0;
    int r = i2r(i);
    int row = r + myLowerRow;
    int c = i2c(i);
    int col = c + myLowerCol;
    int ncols = Math.min(myColCount - c, shortbuffer.remaining());
    while (r < myRowCount && ncols > 0) {
        int[] myMatrix_row = myMatrix[row];
        while (c < ncols) {
            shortbuffer.put((short) myMatrix_row[col]);
            ++c;
            ++col;
        }
        n += ncols;
        ++r;
        ++row;
        c = 0;
        col = myLowerCol;
        ncols = Math.min(myColCount, shortbuffer.remaining());
    }
    buffer.position(buffer.position() + 2 * n);
    return n;
}
Also used : ShortBuffer(java.nio.ShortBuffer)

Example 94 with ShortBuffer

use of java.nio.ShortBuffer in project ffx by mjschnie.

the class ShortArrayBuf_1 method sendItems.

// Hidden operations.
/**
 * {@inheritDoc}
 *
 * Send as many items as possible from this buffer to the given byte buffer.
 * <P>
 * The <TT>sendItems()</TT> method must not block the calling thread; if it
 * does, all message I/O in MP will be blocked.
 */
protected int sendItems(int i, ByteBuffer buffer) {
    ShortBuffer shortbuffer = buffer.asShortBuffer();
    int n = Math.min(myLength - i, shortbuffer.remaining());
    shortbuffer.put(myArray, myArrayOffset + i, n);
    buffer.position(buffer.position() + 2 * n);
    return n;
}
Also used : ShortBuffer(java.nio.ShortBuffer)

Example 95 with ShortBuffer

use of java.nio.ShortBuffer in project ffx by mjschnie.

the class ShortMatrixBuf_1 method sendItems.

// Hidden operations.
/**
 * {@inheritDoc}
 *
 * Send as many items as possible from this buffer to the given byte buffer.
 * <P>
 * The <TT>sendItems()</TT> method must not block the calling thread; if it
 * does, all message I/O in MP will be blocked.
 */
protected int sendItems(int i, ByteBuffer buffer) {
    ShortBuffer shortbuffer = buffer.asShortBuffer();
    int n = 0;
    int r = i2r(i);
    int row = r + myLowerRow;
    int c = i2c(i);
    int col = c + myLowerCol;
    int ncols = Math.min(myColCount - c, shortbuffer.remaining());
    while (r < myRowCount && ncols > 0) {
        shortbuffer.put(myMatrix[row], col, ncols);
        n += ncols;
        ++r;
        ++row;
        c = 0;
        col = myLowerCol;
        ncols = Math.min(myColCount, shortbuffer.remaining());
    }
    buffer.position(buffer.position() + 2 * n);
    return n;
}
Also used : ShortBuffer(java.nio.ShortBuffer)

Aggregations

ShortBuffer (java.nio.ShortBuffer)227 ByteBuffer (java.nio.ByteBuffer)78 FloatBuffer (java.nio.FloatBuffer)54 IntBuffer (java.nio.IntBuffer)45 DoubleBuffer (java.nio.DoubleBuffer)23 LongBuffer (java.nio.LongBuffer)16 Test (org.junit.Test)14 Buffer (java.nio.Buffer)11 BufferOverflowException (java.nio.BufferOverflowException)11 CharBuffer (java.nio.CharBuffer)11 VertexBuffer (com.jme3.scene.VertexBuffer)8 BufferUnderflowException (java.nio.BufferUnderflowException)7 BytePointer (org.bytedeco.javacpp.BytePointer)7 IndexBuffer (com.jme3.scene.mesh.IndexBuffer)6 IOException (java.io.IOException)5 Vector3f (com.jme3.math.Vector3f)4 ArrayList (java.util.ArrayList)4 Bitmap (android.graphics.Bitmap)3 Mesh (com.jme3.scene.Mesh)3 InvalidMarkException (java.nio.InvalidMarkException)3