PixelSource interface which
manages Pixels objects in the state of being consumed (uploaded
to the screen usually), in flight in the queue of upload requests, and
idle waiting to be reused for temporary storage for future uploads.
All Pixels objects currently saved for reuse will all be the
same dimensions and scale which are tracked by calling the
validate() method.
At most we will need 3 sets of pixels:
One may be "in use", a hard reference stored in beingConsumed
Another may be "in the queue", hard ref stored in enqueued
A third may be needed to prepare new pixels while those two are in
transit.
If the third is filled with pixels and enqueued while the previously
mentioned two are still in their stages of use, then it will replace
the second object as the "enqueued" reference and the previously
enqueued object will then become itself the "third unused" reference.
If everything happens in lock step we will often have only one
set of pixels. If the consumer/displayer gets slightly or occasionally
behind we might end up with two sets of pixels in play. Only when things
get really bad with multiple deliveries enqueued during the processing
of a single earlier delivery will we end up with three sets of
Pixels objects in play.
| Modifier and Type | Field and Description |
|---|---|
| private volatile Pixels | |
| private volatile Pixels | |
| private final List | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | doneWithPixels(Pixels used)
Implements com. Indicates that the specified non-null |
| public synchronized void | enqueuePixels(Pixels
the pixels)Pixels object to be enqueuedPlace the indicated |
| public synchronized Pixels | getLatestPixels()
Implements com. Gets the next "latest" set of |
| public synchronized Pixels | Returns: an unusedPixels objectthe width of the desired Pixels object w, int the height of the desired Pixels object h, float the horizontal scale of the desired Pixels object scalex, float the vertical scale of the desired Pixels object scaley)Return an unused Pixels with the indicated dimensions and scale. |
| public synchronized void | skipLatestPixels()
Implements com. A one step method for skipping a pixel delivery object in the case where the consumer is not ready to process any pixels. |
| private boolean |
| beingConsumed | back to summary |
|---|---|
| private volatile Pixels beingConsumed | |
| enqueued | back to summary |
|---|---|
| private volatile Pixels enqueued | |
| saved | back to summary |
|---|---|
| private final List<WeakReference<Pixels>> saved | |
| useDirectBuffers | back to summary |
|---|---|
| private final boolean useDirectBuffers | |
| QueuedPixelSource | back to summary |
|---|---|
| public QueuedPixelSource(boolean useDirectBuffers) | |
| doneWithPixels | back to summary |
|---|---|
| public synchronized void doneWithPixels(Pixels used) Implements com. Doc from com. Indicates that the specified non-null
| |
| enqueuePixels | back to summary |
|---|---|
| public synchronized void enqueuePixels(Pixels pixels) Place the indicated
| |
| getLatestPixels | back to summary |
|---|---|
| public synchronized Pixels getLatestPixels() Implements com. Doc from com. Gets the next "latest" set of
| |
| getUnusedPixels | back to summary |
|---|---|
| public synchronized Pixels getUnusedPixels(int w, int h, float scalex, float scaley) Return an unused Pixels with the indicated dimensions and scale.
The returned object may either be saved from a previous use, but
currently not being consumed or in the queue.
Or it may be an object that reuses a buffer from a previously
used (but not active)
| |
| skipLatestPixels | back to summary |
|---|---|
| public synchronized void skipLatestPixels() Implements com. Doc from com. A one step method for skipping a pixel delivery object in the case
where the consumer is not ready to process any pixels.
Examples of cases where this method is used is when deliveries are
received for closed, iconified, or disposed windows.
This call is equivalent to
| |
| usesSameBuffer | back to summary |
|---|---|
| private boolean usesSameBuffer(Pixels p1, Pixels p2) | |