Java Code Examples for java.nio.IntBuffer#limit()
The following examples show how to use
java.nio.IntBuffer#limit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ByteBufferViews.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "intViewProvider") public void testIntGet(String desc, IntFunction<ByteBuffer> fbb, Function<ByteBuffer, IntBuffer> fbi) { ByteBuffer bb = allocate(fbb); IntBuffer vb = fbi.apply(bb); int o = bb.position(); for (int i = 0; i < vb.limit(); i++) { int fromBytes = getIntFromBytes(bb, o + i * 4); int fromMethodView = bb.getInt(o + i * 4); assertValues(i, fromBytes, fromMethodView, bb); int fromBufferView = vb.get(i); assertValues(i, fromMethodView, fromBufferView, bb, vb); } for (int i = 0; i < vb.limit(); i++) { int v = getIntFromBytes(bb, o + i * 4); int a = bb.getInt(); assertValues(i, v, a, bb); int b = vb.get(); assertValues(i, a, b, bb, vb); } }
Example 2
Source File: BufferUtils.java From Ultraino with MIT License | 6 votes |
public static IntBuffer ensureLargeEnough(IntBuffer buffer, int required) { if (buffer != null) { buffer.limit(buffer.capacity()); } if (buffer == null || (buffer.remaining() < required)) { int position = (buffer != null ? buffer.position() : 0); IntBuffer newVerts = createIntBuffer(position + required); if (buffer != null) { buffer.flip(); newVerts.put(buffer); newVerts.position(position); } buffer = newVerts; } return buffer; }
Example 3
Source File: LwjglALC.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void alcGetInteger(int param, IntBuffer buffer, int size) { if (buffer.position() != 0) throw new AssertionError(); if (buffer.limit() != size) throw new AssertionError(); ALCcontext context = ALC10.alcGetCurrentContext(); ALCdevice device = ALC10.alcGetContextsDevice(context); ALC10.alcGetInteger(device, param, buffer); }
Example 4
Source File: AbstractPerfDataBufferPrologue.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Return an IntBuffer that accesses the minor version number. * This is used to create a Monitor object for this value. * * @return IntBuffer - a ByteBuffer that accesses the minor version number * in the instrumentation buffer header. */ public IntBuffer minorVersionBuffer() { int[] holder = new int[1]; holder[0] = getMinorVersion(); IntBuffer ib = IntBuffer.wrap(holder); ib.limit(1); return ib; }
Example 5
Source File: AbstractPerfDataBufferPrologue.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Return an IntBuffer that accesses the minor version number. * This is used to create a Monitor object for this value. * * @return IntBuffer - a ByteBuffer that accesses the minor version number * in the instrumentation buffer header. */ public IntBuffer minorVersionBuffer() { int[] holder = new int[1]; holder[0] = getMinorVersion(); IntBuffer ib = IntBuffer.wrap(holder); ib.limit(1); return ib; }
Example 6
Source File: JTranscBufferTools.java From jtransc with Apache License 2.0 | 5 votes |
static public int[] toIntArray(ByteBuffer buffer) { IntBuffer intBuffer = buffer.asIntBuffer(); int[] out = new int[intBuffer.limit()]; for (int n = 0; n < out.length; n++) { out[n] = intBuffer.get(n); } return out; }
Example 7
Source File: BufferUtils.java From aion-germany with GNU General Public License v3.0 | 5 votes |
/** * Create a new int[] array and populate it with the given IntBuffer's contents. * * @param buff * the IntBuffer to read from * @return a new int array populated from the IntBuffer */ public static int[] getIntArray(IntBuffer buff) { if (buff == null) { return null; } buff.clear(); int[] inds = new int[buff.limit()]; for (int x = 0; x < inds.length; x++) { inds[x] = buff.get(); } return inds; }
Example 8
Source File: GlyphMapping.java From ttt with BSD 2-Clause "Simplified" License | 5 votes |
private static int[] getGlyphs(GlyphSequence gs) { IntBuffer gb = gs.getGlyphs(); gb.rewind(); int[] glyphs = new int[gb.limit() - gb.position()]; for (int i = 0; gb.position() < gb.limit(); ) { glyphs[i++] = gb.get(); } return glyphs; }
Example 9
Source File: Homoglyph.java From ph-commons with Apache License 2.0 | 5 votes |
public CodePoints (@Nonnull final String sText) { m_sText = sText; final IntBuffer aBuf = IntBuffer.allocate (sText.length ()); StringHelper.iterateCodePoints (sText, aBuf::put); aBuf.flip (); m_aCodepoints = new int [aBuf.limit ()]; aBuf.get (m_aCodepoints); }
Example 10
Source File: AbstractPerfDataBufferPrologue.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Return an IntBuffer that accesses the major version number. * This is used to create a Monitor object for this value. * * @return IntBuffer - a ByteBuffer that accesses the major version number * in the instrumentation buffer header. */ public IntBuffer majorVersionBuffer() { int[] holder = new int[1]; holder[0] = getMajorVersion(); IntBuffer ib = IntBuffer.wrap(holder); ib.limit(1); return ib; }
Example 11
Source File: DOMOutputCapsule.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void write(IntBuffer value, String name, IntBuffer defVal) throws IOException { if (value == null) { return; } if (value.equals(defVal)) { return; } Element el = appendElement(name); el.setAttribute("size", String.valueOf(value.limit())); StringBuilder buf = new StringBuilder(); int pos = value.position(); value.rewind(); int ctr = 0; while (value.hasRemaining()) { ctr++; buf.append(value.get()); buf.append(" "); } if (ctr != value.limit()) { throw new IOException("'" + name + "' buffer contention resulted in write data consistency. " + ctr + " values written when should have written " + value.limit()); } if (buf.length() > 0) { //remove last space buf.setLength(buf.length() - 1); } value.position(pos); el.setAttribute(dataAttributeName, buf.toString()); currentElement = (Element) el.getParentNode(); }
Example 12
Source File: AbstractPerfDataBufferPrologue.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Return an IntBuffer that accesses the minor version number. * This is used to create a Monitor object for this value. * * @return IntBuffer - a ByteBuffer that accesses the minor version number * in the instrumentation buffer header. */ public IntBuffer minorVersionBuffer() { int[] holder = new int[1]; holder[0] = getMinorVersion(); IntBuffer ib = IntBuffer.wrap(holder); ib.limit(1); return ib; }
Example 13
Source File: AbstractPerfDataBufferPrologue.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Return an IntBuffer that accesses the major version number. * This is used to create a Monitor object for this value. * * @return IntBuffer - a ByteBuffer that accesses the major version number * in the instrumentation buffer header. */ public IntBuffer majorVersionBuffer() { int[] holder = new int[1]; holder[0] = getMajorVersion(); IntBuffer ib = IntBuffer.wrap(holder); ib.limit(1); return ib; }
Example 14
Source File: IntNioDataBuffer.java From java with Apache License 2.0 | 5 votes |
@Override public IntDataBuffer slice(long index, long size) { Validator.sliceArgs(this, index, size); IntBuffer sliceBuf = buf.duplicate(); sliceBuf.position((int)index); sliceBuf.limit((int)index + (int)size); return new IntNioDataBuffer(sliceBuf.slice()); }
Example 15
Source File: IosGL.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
private static int getLimitBytes(IntBuffer buffer) { checkLimit(buffer); return buffer.limit() * 4; }
Example 16
Source File: LwjglEFX.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void alGenFilters(int numFilters, IntBuffer buffers) { if (buffers.position() != 0) throw new AssertionError(); if (buffers.limit() != numFilters) throw new AssertionError(); EFX10.alGenFilters(buffers); }
Example 17
Source File: AndroidGL.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
private static int getLimitBytes(IntBuffer buffer) { checkLimit(buffer); return buffer.limit() * 4; }
Example 18
Source File: LwjglTextureUtils.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static int createTexture(BufferedImage imageData, TextureFilter filterMode) { imageData = convertToGlFormat(imageData); IntBuffer buff = BufferUtils.createIntBuffer(16); buff.limit(1); GL11.glGenTextures(buff); int textureId = buff.get(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); if (filterMode == TextureFilter.NEAREST) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); } GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); ByteBuffer scratch = ByteBuffer.allocateDirect(4*imageData.getWidth()*imageData.getHeight()); Raster raster = imageData.getRaster(); byte data[] = (byte[])raster.getDataElements(0, 0, imageData.getWidth(), imageData.getHeight(), null); scratch.clear(); scratch.put(data); scratch.rewind(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, // Mip level & Internal format imageData.getWidth(), imageData.getHeight(), 0, // width, height, border GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, // pixel data format scratch); // pixel data GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, imageData.getWidth(), imageData.getHeight(), GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, // format, type scratch); return textureId; }
Example 19
Source File: LwjglAL.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void alDeleteSources(final int numSources, final IntBuffer sources) { if (sources.position() != 0) throw new AssertionError(); if (sources.limit() != numSources) throw new AssertionError(); AL10.alDeleteSources(sources); }
Example 20
Source File: BufferUtils.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 3 votes |
/** * Create a new IntBuffer of an appropriate size to hold the specified * number of ints only if the given buffer if not already the right size. * * @param buf * the buffer to first check and rewind * @param size * number of ints that need to be held by the newly created * buffer * @return the requested new IntBuffer */ public static IntBuffer createIntBuffer(IntBuffer buf, int size) { if (buf != null && buf.limit() == size) { buf.rewind(); return buf; } buf = createIntBuffer(size); return buf; }