APIdia Launch Partner
Top Description Fields Constructors Methods
sun.java2d.pipe

public final Class RenderBuffer

extends Object
Class Inheritance
Imports
java.lang.foreign.Arena, .MemorySegment, .ValueLayout

The RenderBuffer class is a simplified, high-performance class used for buffering rendering operations in a single-threaded rendering environment. Its functionality is similar to the ByteBuffer and related NIO classes. However, the methods in this class perform little to no alignment or bounds checks for performance reasons. Therefore, it is the caller's responsibility to ensure that all put() calls are properly aligned and within bounds: - int and float values must be aligned on 4-byte boundaries - long and double values must be aligned on 8-byte boundaries Failure to do so will result in exceptions from the FFM API, or worse. This class only includes the bare minimum of methods to support single-threaded rendering. For example, there is no put(double[]) method because we currently have no need for such a method in the STR classes.

Field Summary

Modifier and TypeField and Description
private static final int
COPY_FROM_ARRAY_THRESHOLD

Measurements show that using the copy API from a segment backed by a heap array gets reliably faster than individual puts around a length of 10.

private int
private final MemorySegment
private static final int
SIZEOF_BYTE

These constants represent the size of various data types (in bytes).

private static final int
private static final int
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
private
RenderBuffer(int numBytes)

Method Summary

Modifier and TypeMethod and Description
public static RenderBuffer
allocate(int numBytes)

Allocates a fresh buffer using the machine endianness.

public final int
capacity()

The behavior (and names) of the following methods are nearly identical to their counterparts in the various NIO Buffer classes.

public final void
public final long
getAddress()

Returns the base address of the underlying memory buffer.

public final int
public final void
position(int bytePos)

public RenderBuffer
put(byte[] x)

public RenderBuffer
put(byte[] x, int offset, int length)

public RenderBuffer
put(short[] x)

public RenderBuffer
put(short[] x, int offset, int length)

public RenderBuffer
put(int[] x)

public RenderBuffer
put(int[] x, int offset, int length)

public RenderBuffer
put(float[] x)

public RenderBuffer
put(float[] x, int offset, int length)

public RenderBuffer
put(long[] x)

public RenderBuffer
put(long[] x, int offset, int length)

public final RenderBuffer
putByte(byte x)

putByte() methods...

public final RenderBuffer
putDouble(double x)

putDouble() method(s)...

public final RenderBuffer
putFloat(float x)

putFloat() methods...

public final RenderBuffer
putInt(int pos, int x)

putInt() methods...

public final RenderBuffer
putInt(int x)

public final RenderBuffer
putLong(long x)

putLong() methods...

public final RenderBuffer
putShort(short x)

putShort() methods...

public final int
public final RenderBuffer
skip(int numBytes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COPY_FROM_ARRAY_THRESHOLDback to summary
private static final int COPY_FROM_ARRAY_THRESHOLD

Measurements show that using the copy API from a segment backed by a heap array gets reliably faster than individual puts around a length of 10. However the time is miniscule in the context of what it is used for and much more than adequate, so no problem expected if this changes over time.

curOffsetback to summary
private int curOffset
segmentback to summary
private final MemorySegment segment
SIZEOF_BYTEback to summary
private static final int SIZEOF_BYTE

These constants represent the size of various data types (in bytes).

SIZEOF_DOUBLEback to summary
private static final int SIZEOF_DOUBLE
SIZEOF_FLOATback to summary
private static final int SIZEOF_FLOAT
SIZEOF_INTback to summary
private static final int SIZEOF_INT
SIZEOF_LONGback to summary
private static final int SIZEOF_LONG
SIZEOF_SHORTback to summary
private static final int SIZEOF_SHORT

Constructor Detail

RenderBufferback to summary
private RenderBuffer(int numBytes)

Method Detail

allocateback to summary
public static RenderBuffer allocate(int numBytes)

Allocates a fresh buffer using the machine endianness.

capacityback to summary
public final int capacity()

The behavior (and names) of the following methods are nearly identical to their counterparts in the various NIO Buffer classes.

clearback to summary
public final void clear()
getAddressback to summary
public final long getAddress()

Returns the base address of the underlying memory buffer.

positionback to summary
public final int position()
positionback to summary
public final void position(int bytePos)
putback to summary
public RenderBuffer put(byte[] x)
putback to summary
public RenderBuffer put(byte[] x, int offset, int length)
putback to summary
public RenderBuffer put(short[] x)
putback to summary
public RenderBuffer put(short[] x, int offset, int length)
putback to summary
public RenderBuffer put(int[] x)
putback to summary
public RenderBuffer put(int[] x, int offset, int length)
putback to summary
public RenderBuffer put(float[] x)
putback to summary
public RenderBuffer put(float[] x, int offset, int length)
putback to summary
public RenderBuffer put(long[] x)
putback to summary
public RenderBuffer put(long[] x, int offset, int length)
putByteback to summary
public final RenderBuffer putByte(byte x)

putByte() methods...

putDoubleback to summary
public final RenderBuffer putDouble(double x)

putDouble() method(s)...

putFloatback to summary
public final RenderBuffer putFloat(float x)

putFloat() methods...

putIntback to summary
public final RenderBuffer putInt(int pos, int x)

putInt() methods...

putIntback to summary
public final RenderBuffer putInt(int x)
putLongback to summary
public final RenderBuffer putLong(long x)

putLong() methods...

putShortback to summary
public final RenderBuffer putShort(short x)

putShort() methods...

remainingback to summary
public final int remaining()
skipback to summary
public final RenderBuffer skip(int numBytes)