@Override public double get(int index) { return buffer.get(buffer.position() + index); }
/** Returns a string representing the state of this double buffer. * * @return A string representing the state of this double buffer. * @since Android 1.0 */ public String toString () { StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()); sb.append(", status: capacity="); //$NON-NLS-1$ sb.append(capacity()); sb.append(" position="); //$NON-NLS-1$ sb.append(position()); sb.append(" limit="); //$NON-NLS-1$ sb.append(limit()); return sb.toString(); } }
/** Returns a string representing the state of this double buffer. * * @return A string representing the state of this double buffer. * @since Android 1.0 */ public String toString () { StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()); sb.append(", status: capacity="); //$NON-NLS-1$ sb.append(capacity()); sb.append(" position="); //$NON-NLS-1$ sb.append(position()); sb.append(" limit="); //$NON-NLS-1$ sb.append(limit()); return sb.toString(); } }
public double[] getA8d( ) { _arys++; int len = getInt(); if( len == -1 ) return null; double[] buf = MemoryManager.malloc8d(len); int sofar = 0; while( sofar < len ) { DoubleBuffer as = _bb.asDoubleBuffer(); int more = Math.min(as.remaining(), len - sofar); as.get(buf, sofar, more); sofar += more; _bb.position(_bb.position() + as.position()*8); if( sofar < len ) getSp(Math.min(_bb.capacity()-7, (len-sofar)*8)); } return buf; } public byte[][] getAA1( ) {
public void setJoints(SkeletonJoint[] joints) { if(joints == null) return; mJoints = joints; if (mBoneMatrices == null) { mBoneMatrices = ByteBuffer .allocateDirect(joints.length * DOUBLE_SIZE_BYTES * 16) .order(ByteOrder.nativeOrder()).asDoubleBuffer(); } else mBoneMatrices.clear(); mBoneMatrices.put(uBoneMatrix); mBoneMatrices.position(0); mBoneMatricesBufferInfo.buffer = mBoneMatrices; mGeometry.addBuffer(mBoneMatricesBufferInfo, BufferType.FLOAT_BUFFER, GLES20.GL_ARRAY_BUFFER); }
public AutoBuffer putA8d( double[] ary ) { _arys++; if( ary == null ) return putInt(-1); putInt(ary.length); int sofar = 0; while( sofar < ary.length ) { DoubleBuffer sb = _bb.asDoubleBuffer(); int len = Math.min(ary.length - sofar, sb.remaining()); sb.put(ary, sofar, len); sofar += len; _bb.position(_bb.position() + sb.position()*8); if( sofar < ary.length ) sendPartial(); } return this; }
@Override public DoubleBuffer asNioDouble() { if (offset() >= Integer.MAX_VALUE) throw new IllegalStateException("Index out of bounds " + offset()); if (offset() == 0) { return wrappedBuffer().asDoubleBuffer(); } else { return (DoubleBuffer) wrappedBuffer().asDoubleBuffer().position((int) (offset())); } }
@Override public void setArg(int index, double d) { DoubleBuffer buf = Utils.tempBuffers[0].b16d; buf.position(0); buf.limit(1); buf.put(0, d); int ret = cl.clSetKernelArg(kernel, index, 8, buf); Utils.checkError(ret, "clSetKernelArg"); }
@Override public void setArg(int index, double d) { DoubleBuffer buf = Utils.tempBuffers[0].b16d; buf.position(0); buf.limit(1); buf.put(0, d); int ret = CL10.clSetKernelArg(kernel, index, buf); Utils.checkError(ret, "clSetKernelArg"); }
/** * Creates the actual Buffer objects. */ public void createBuffers() { for (BufferInfo info : mBuffers) { if (info.buffer != null) { if (info.buffer instanceof FloatBuffer) { ((FloatBuffer) info.buffer).compact().position(0); } else if (info.buffer instanceof IntBuffer) { ((IntBuffer) info.buffer).compact().position(0); } else if (info.buffer instanceof ShortBuffer) { ((ShortBuffer) info.buffer).compact().position(0); } else if (info.buffer instanceof ByteBuffer) { ((ByteBuffer) info.buffer).compact().position(0); } else if (info.buffer instanceof DoubleBuffer) { ((DoubleBuffer) info.buffer).compact().position(0); } else if (info.buffer instanceof LongBuffer) { ((LongBuffer) info.buffer).compact().position(0); } else if (info.buffer instanceof CharBuffer) { ((CharBuffer) info.buffer).compact().position(0); } } createBuffer(info); } GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); mHaveCreatedBuffers = true; }
/** * For direct buffers, calls {@link Pointer#Pointer(Buffer)}, while for buffers * backed with an array, allocates enough memory for the array and copies it. * * @param buffer the Buffer to reference or copy * @see #put(double[]) */ public DoublePointer(DoubleBuffer buffer) { super(buffer); if (buffer != null && !buffer.isDirect() && buffer.hasArray()) { double[] array = buffer.array(); allocateArray(array.length - buffer.arrayOffset()); put(array, buffer.arrayOffset(), array.length - buffer.arrayOffset()); position(buffer.position()); limit(buffer.limit()); } } /**
/** * @param buffer * @param numPoints */ private CoordinateSequence readCoordinates( final ByteBuffer buffer, final int numPoints, final int dimensions) { CoordinateSequence cs = JTS.createCS(geometryFactory.getCoordinateSequenceFactory(), numPoints, dimensions); DoubleBuffer dbuffer = buffer.asDoubleBuffer(); double[] ordinates = new double[numPoints * 2]; dbuffer.get(ordinates); for (int t = 0; t < numPoints; t++) { cs.setOrdinate(t, 0, ordinates[t * 2]); cs.setOrdinate(t, 1, ordinates[t * 2 + 1]); } if (dimensions > 2) { // z dbuffer.position(dbuffer.position() + 2); dbuffer.get(ordinates, 0, numPoints); for (int t = 0; t < numPoints; t++) { cs.setOrdinate(t, 2, ordinates[t]); } } return cs; }
public Object read(ByteBuffer buffer, ShapeType type, boolean flatGeometry) { if (type == ShapeType.NULL) { return createNull(); } // read bounding box (not needed) buffer.position(buffer.position() + 4 * 8); int numpoints = buffer.getInt(); int dimensions = shapeType == shapeType.MULTIPOINTZ && !flatGeometry ? 3 : 2; CoordinateSequence cs = JTS.createCS(geometryFactory.getCoordinateSequenceFactory(), numpoints, dimensions); DoubleBuffer dbuffer = buffer.asDoubleBuffer(); double[] ordinates = new double[numpoints * 2]; dbuffer.get(ordinates); for (int t = 0; t < numpoints; t++) { cs.setOrdinate(t, 0, ordinates[t * 2]); cs.setOrdinate(t, 1, ordinates[t * 2 + 1]); } if (dimensions > 2) { dbuffer.position(dbuffer.position() + 2); dbuffer.get(ordinates, 0, numpoints); for (int t = 0; t < numpoints; t++) { cs.setOrdinate(t, 2, ordinates[t]); // z } } return geometryFactory.createMultiPoint(cs); }
return; mBoneMatrices.clear(); mBoneMatrices.position(0);
@Override public double get(int index) { final int bufferNum = index / sizePer; final int bufferIndex = index % sizePer; if (bufferNum != currIndex) { loadBuffer(bufferNum); } return doubleBuffer.get(doubleBuffer.position() + bufferIndex); }
@Override public AVector subVector(int offset, int length) { checkRange(offset,length); if (length==0) return Vector0.INSTANCE; if (length==this.length) return this; buffer.position(offset); buffer.limit(offset+length); DoubleBuffer newBuffer=buffer.slice(); buffer.clear(); return wrap(newBuffer,length); }
@Override protected void checkDirectBufferInvariants(final MatrixDirect4x4DType mk) { Assert.assertEquals(0L, (long) mk.getDirectDoubleBuffer().position()); } }
@Override protected void checkDirectBufferInvariantsGeneric( final PMatrixDirect3x3DType<T0, T1> m) { Assert.assertEquals(0L, (long) m.getDirectDoubleBuffer().position()); } }