Refine search
private static byte[] floatArrayToByteArray(float[] input) { final ByteBuffer buffer = ByteBuffer.allocate(Float.BYTES * input.length); buffer.asFloatBuffer().put(input); return buffer.array(); }
/** Allocates a FloatBuffer with the given data. */ public static FloatBuffer createBuffer(float[] data) { ByteBuffer bb = ByteBuffer.allocateDirect(data.length * C.BYTES_PER_FLOAT); bb.order(ByteOrder.nativeOrder()); FloatBuffer buffer = bb.asFloatBuffer(); buffer.put(data); buffer.position(0); return buffer; }
@Override public byte[] getCacheKey() { byte[] fieldNameBytes = StringUtils.toUtf8(fieldName); ByteBuffer buf = ByteBuffer .allocate(1 + fieldNameBytes.length + Float.BYTES * breaks.length) .put(AggregatorUtil.HIST_CACHE_TYPE_ID) .put(fieldNameBytes) .put((byte) 0xFF); buf.asFloatBuffer().put(breaks); return buf.array(); }
private static FloatBuffer nativeFloatBuffer(float... array) { FloatBuffer buffer = ByteBuffer.allocateDirect(array.length * 4).order( ByteOrder.nativeOrder()).asFloatBuffer(); buffer.put(array); buffer.flip(); return buffer; }
@Override public byte[] getCacheKey() { ByteBuffer minCoordsBuffer = ByteBuffer.allocate(minCoords.length * Float.BYTES); minCoordsBuffer.asFloatBuffer().put(minCoords); final byte[] minCoordsCacheKey = minCoordsBuffer.array(); ByteBuffer maxCoordsBuffer = ByteBuffer.allocate(maxCoords.length * Float.BYTES); maxCoordsBuffer.asFloatBuffer().put(maxCoords); final byte[] maxCoordsCacheKey = maxCoordsBuffer.array(); final ByteBuffer cacheKey = ByteBuffer .allocate(1 + minCoordsCacheKey.length + maxCoordsCacheKey.length + Integer.BYTES) .put(minCoordsCacheKey) .put(maxCoordsCacheKey) .putInt(limit) .put(CACHE_TYPE_ID); return cacheKey.array(); } }
private FloatBuffer alocateBuffer(FloatBuffer buffer, float[] data) { if (buffer == null) { buffer = ByteBuffer .allocateDirect(data.length * Geometry3D.FLOAT_SIZE_BYTES * 4) .order(ByteOrder.nativeOrder()).asFloatBuffer(); buffer.put(data); buffer.position(0); } else { buffer.put(data); } return buffer; }
@Override public byte[] getCacheKey() { final ByteBuffer minCoordsBuffer = ByteBuffer.allocate(coords.length * Float.BYTES); minCoordsBuffer.asFloatBuffer().put(coords); final byte[] minCoordsCacheKey = minCoordsBuffer.array(); final ByteBuffer cacheKey = ByteBuffer .allocate(1 + minCoordsCacheKey.length + Integer.BYTES + Float.BYTES) .put(minCoordsCacheKey) .putFloat(radius) .putInt(getLimit()) .put(CACHE_TYPE_ID); return cacheKey.array(); } }
@Override public byte[] getCacheKey() { ByteBuffer abscissaBuffer = ByteBuffer.allocate(abscissa.length * Float.BYTES); abscissaBuffer.asFloatBuffer().put(abscissa); final byte[] abscissaCacheKey = abscissaBuffer.array(); ByteBuffer ordinateBuffer = ByteBuffer.allocate(ordinate.length * Float.BYTES); ordinateBuffer.asFloatBuffer().put(ordinate); final byte[] ordinateCacheKey = ordinateBuffer.array(); final ByteBuffer cacheKey = ByteBuffer .allocate(1 + abscissaCacheKey.length + ordinateCacheKey.length + Integer.BYTES) .put(abscissaCacheKey) .put(ordinateCacheKey) .putInt(getLimit()) .put(CACHE_TYPE_ID); return cacheKey.array(); } }
public void setColors(float[] colors, boolean override) { final BufferInfo colorInfo = mBuffers.get(COLOR_BUFFER_KEY); if (colorInfo.buffer == null || override == true) { colorInfo.buffer = ByteBuffer .allocateDirect(colors.length * FLOAT_SIZE_BYTES) .order(ByteOrder.nativeOrder()).asFloatBuffer(); ((FloatBuffer) colorInfo.buffer).put(colors); colorInfo.buffer.position(0); } else { ((FloatBuffer) colorInfo.buffer).put(colors); colorInfo.buffer.position(0); } }
/** * Writes the dense representation of this ApproximateHistogram object to the given byte-buffer * * Requires 16 + 12 * size bytes of storage * * @param buf ByteBuffer to write the ApproximateHistogram to */ public void toBytesDense(ByteBuffer buf) { buf.putInt(size); buf.putInt(binCount); buf.asFloatBuffer().put(positions); buf.position(buf.position() + Float.BYTES * positions.length); buf.asLongBuffer().put(bins); buf.position(buf.position() + Long.BYTES * bins.length); buf.putFloat(min); buf.putFloat(max); }
public GPUImageRenderer(final GPUImageFilter filter) { this.filter = filter; runOnDraw = new LinkedList<>(); runOnDrawEnd = new LinkedList<>(); glCubeBuffer = ByteBuffer.allocateDirect(CUBE.length * 4) .order(ByteOrder.nativeOrder()) .asFloatBuffer(); glCubeBuffer.put(CUBE).position(0); glTextureBuffer = ByteBuffer.allocateDirect(TEXTURE_NO_ROTATION.length * 4) .order(ByteOrder.nativeOrder()) .asFloatBuffer(); setRotation(Rotation.NORMAL, false, false); }
public void setTextureCoords(float[] textureCoords, boolean override) { if (textureCoords == null) { return; } final BufferInfo textureInfo = mBuffers.get(TEXTURE_BUFFER_KEY); if (textureInfo.buffer == null || override == true) { textureInfo.buffer = ByteBuffer .allocateDirect(textureCoords.length * FLOAT_SIZE_BYTES) .order(ByteOrder.nativeOrder()).asFloatBuffer(); ((FloatBuffer) textureInfo.buffer).put(textureCoords); textureInfo.buffer.position(0); } else { ((FloatBuffer) textureInfo.buffer).put(textureCoords); } mHasTextureCoordinates = true; }
public GSYVideoGLViewSimpleRender() { mTriangleVertices = ByteBuffer .allocateDirect( mTriangleVerticesData.length * FLOAT_SIZE_BYTES) .order(ByteOrder.nativeOrder()).asFloatBuffer(); mTriangleVertices.put(mTriangleVerticesData).position(0); Matrix.setIdentityM(mSTMatrix, 0); Matrix.setIdentityM(mMVPMatrix, 0); }
private void init() { mTriangleVertices = ByteBuffer .allocateDirect( mTriangleVerticesData.length * FLOAT_SIZE_BYTES) .order(ByteOrder.nativeOrder()).asFloatBuffer(); mTriangleVertices.put(mTriangleVerticesData).position(0); Matrix.setIdentityM(mSTMatrix, 0); Matrix.setIdentityM(mMVPMatrix, 0); }
public static FloatBuffer createSquareVtx() { final float vtx[] = { // XYZ, UV -1f, 1f, 0f, 0f, 1f, -1f, -1f, 0f, 0f, 0f, 1f, 1f, 0f, 1f, 1f, 1f, -1f, 0f, 1f, 0f, }; ByteBuffer bb = ByteBuffer.allocateDirect(4 * vtx.length); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(vtx); fb.position(0); return fb; }
public static FloatBuffer createVertexBuffer() { final float vtx[] = { // XYZ -1f, 1f, 0f, -1f, -1f, 0f, 1f, 1f, 0f, 1f, -1f, 0f, }; ByteBuffer bb = ByteBuffer.allocateDirect(4 * vtx.length); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(vtx); fb.position(0); return fb; }
public static FloatBuffer createTexCoordBuffer() { final float vtx[] = { // UV 0f, 1f, 0f, 0f, 1f, 1f, 1f, 0f, }; ByteBuffer bb = ByteBuffer.allocateDirect(4 * vtx.length); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(vtx); fb.position(0); return fb; }
public void setNormals(float[] normals, boolean override) { if (normals == null) { return; } final BufferInfo normalInfo = mBuffers.get(NORMAL_BUFFER_KEY); if (normalInfo.buffer == null || override == true) { normalInfo.buffer = ByteBuffer.allocateDirect(normals.length * FLOAT_SIZE_BYTES) .order(ByteOrder.nativeOrder()).asFloatBuffer(); ((FloatBuffer) normalInfo.buffer).put(normals); normalInfo.buffer.position(0); } else { normalInfo.buffer.position(0); ((FloatBuffer) normalInfo.buffer).put(normals); normalInfo.buffer.position(0); } mHasNormals = true; }
public void setRotation(final Rotation rotation, final boolean flipHorizontal, final boolean flipVertical) { float[] buffer = TextureRotationUtil.getRotation(rotation, flipHorizontal, flipVertical); ByteBuffer bBuffer = ByteBuffer.allocateDirect(32).order(ByteOrder.nativeOrder()); FloatBuffer fBuffer = bBuffer.asFloatBuffer(); fBuffer.put(buffer); fBuffer.flip(); texture2CoordinatesBuffer = bBuffer; } }
public void setVertices(float[] vertices, boolean override) { final BufferInfo vertexInfo = mBuffers.get(VERTEX_BUFFER_KEY); if (vertexInfo.buffer == null || override == true) { if (vertexInfo.buffer != null) { vertexInfo.buffer.clear(); } vertexInfo.buffer = ByteBuffer .allocateDirect(vertices.length * FLOAT_SIZE_BYTES) .order(ByteOrder.nativeOrder()).asFloatBuffer(); ((FloatBuffer) vertexInfo.buffer).put(vertices); vertexInfo.buffer.position(0); mNumVertices = vertices.length / 3; } else { ((FloatBuffer) vertexInfo.buffer).put(vertices); } }