java.lang.Object | |
↳ | sun.java2d.pipe.RenderQueue |
![]() |
The RenderQueue class encapsulates a RenderBuffer on which rendering operations are enqueued. Note that the RenderQueue lock must be acquired before performing any operations on the queue (e.g. enqueuing an operation or flushing the queue). A sample usage scenario follows: public void drawSomething(...) { rq.lock(); try { ctx.validate(...); rq.ensureCapacity(4); rq.getBuffer().putInt(DRAW_SOMETHING); ... } finally { rq.unlock(); } } If you are enqueuing an operation that involves 8-byte parameters (i.e. long or double values), it is imperative that you ensure proper alignment of the underlying RenderBuffer. This can be accomplished simply by providing an offset to the first 8-byte parameter in your operation to the ensureCapacityAndAlignment() method. For example: public void drawStuff(...) { rq.lock(); try { RenderBuffer buf = rq.getBuffer(); ctx.validate(...); // 28 total bytes in the operation, 12 bytes to the first long rq.ensureCapacityAndAlignment(28, 12); buf.putInt(DRAW_STUFF); buf.putInt(x).putInt(y); buf.putLong(addr1); buf.putLong(addr2); } finally { rq.unlock(); } }
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
buf | The underlying buffer for this queue. | ||||||||||
refSet | A Set containing hard references to Objects that must stay alive until the queue has been completely flushed. |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds the given Object to the set of hard references, which will
prevent that Object from being disposed until the queue has been
flushed completely.
| |||||||||||
Inserts a 4-byte NOOP token when necessary to ensure that all 8-byte
parameters for the following operation are added to the underlying
buffer with an 8-byte memory alignment.
| |||||||||||
Ensures that there will be enough room on the underlying buffer
for the following operation.
| |||||||||||
Convenience method that is equivalent to calling ensureCapacity()
followed by ensureAlignment().
| |||||||||||
Immediately processes each operation currently pending on the buffer,
and then invokes the provided task.
| |||||||||||
Updates the current position of the underlying buffer, and then
flushes the queue immediately.
| |||||||||||
Immediately processes each operation currently pending on the buffer.
| |||||||||||
Returns the encapsulated RenderBuffer object.
| |||||||||||
Locks the queue for read/write access.
| |||||||||||
Attempts to lock the queue.
| |||||||||||
Unlocks the queue.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
A Set containing hard references to Objects that must stay alive until the queue has been completely flushed.
Adds the given Object to the set of hard references, which will prevent that Object from being disposed until the queue has been flushed completely. This is useful in cases where some enqueued data could become invalid if the reference Object were garbage collected before the queue could be processed. (For example, keeping a hard reference to a FontStrike will prevent any enqueued glyph images associated with that strike from becoming invalid before the queue is flushed.) The reference set will be cleared immediately after the queue is flushed each time.
Inserts a 4-byte NOOP token when necessary to ensure that all 8-byte parameters for the following operation are added to the underlying buffer with an 8-byte memory alignment.
first8ByteValueOffset | offset (in bytes) from the current position to the first 8-byte value used in the following operation |
---|
Ensures that there will be enough room on the underlying buffer for the following operation. If the operation will not fit given the remaining space, the buffer will be flushed immediately, leaving an empty buffer for the impending operation.
opsize | size (in bytes) of the following operation |
---|
Convenience method that is equivalent to calling ensureCapacity() followed by ensureAlignment(). The ensureCapacity() call allows for an extra 4 bytes of space in case the ensureAlignment() method needs to insert a NOOP token on the buffer.
opsize | size (in bytes) of the following operation |
---|---|
first8ByteValueOffset | offset (in bytes) from the current position to the first 8-byte value used in the following operation |
Immediately processes each operation currently pending on the buffer, and then invokes the provided task. This method will block until the entire buffer has been flushed and the provided task has been executed. The queue lock must be acquired before calling this method.
Updates the current position of the underlying buffer, and then flushes the queue immediately. This method is useful when native code has added data to the queue and needs to flush immediately.
Immediately processes each operation currently pending on the buffer. This method will block until the entire buffer has been flushed. The queue lock must be acquired before calling this method.
Locks the queue for read/write access.
Attempts to lock the queue. If successful, this method returns true,
indicating that the caller is responsible for calling
unlock
; otherwise this method returns false.
Unlocks the queue.