APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.prism.impl

public Class QueuedPixelSource

extends Object
implements PixelSource
Class Inheritance
All Implemented Interfaces
com.sun.prism.PixelSource
Imports
com.sun.glass.ui.Application, .Pixels, com.sun.prism.PixelSource, java.lang.ref.WeakReference, java.nio.IntBuffer, java.util.ArrayList, .List

Base concrete implementation of the 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.

Field Summary

Modifier and TypeField and Description
private volatile Pixels
private volatile Pixels
private final List<WeakReference<Pixels>>
private final boolean

Constructor Summary

AccessConstructor and Description
public
QueuedPixelSource(boolean useDirectBuffers)

Method Summary

Modifier and TypeMethod and Description
public synchronized void
doneWithPixels(Pixels used)

Implements com.sun.prism.PixelSource.doneWithPixels.

Indicates that the specified non-null Pixels object which was obtained from getLatestPixels() is done being processed and can be reused for future pixel deliveries if needed.

public synchronized void
enqueuePixels(Pixels
the Pixels object to be enqueued
pixels
)

Place the indicated Pixels object into the enqueued state, replacing any other objects that are currently enqueued but not yet being used by the consumer.

public synchronized Pixels
getLatestPixels()

Implements com.sun.prism.PixelSource.getLatestPixels.

Gets the next "latest" set of Pixels to be processed or displayed.

public synchronized Pixels

Returns:

an unused Pixels object
getUnusedPixels
(int
the 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.sun.prism.PixelSource.skipLatestPixels.

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
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beingConsumedback to summary
private volatile Pixels beingConsumed
enqueuedback to summary
private volatile Pixels enqueued
savedback to summary
private final List<WeakReference<Pixels>> saved
useDirectBuffersback to summary
private final boolean useDirectBuffers

Constructor Detail

QueuedPixelSourceback to summary
public QueuedPixelSource(boolean useDirectBuffers)

Method Detail

doneWithPixelsback to summary
public synchronized void doneWithPixels(Pixels used)

Implements com.sun.prism.PixelSource.doneWithPixels.

Doc from com.sun.prism.PixelSource.doneWithPixels.

Indicates that the specified non-null Pixels object which was obtained from getLatestPixels() is done being processed and can be reused for future pixel deliveries if needed. This method should be called by the consumer if and only if the call to getLatestPixels() returned a non-null object.

Annotations
@Override
enqueuePixelsback to summary
public synchronized void enqueuePixels(Pixels pixels)

Place the indicated Pixels object into the enqueued state, replacing any other objects that are currently enqueued but not yet being used by the consumer.

Parameters
pixels:Pixels

the Pixels object to be enqueued

getLatestPixelsback to summary
public synchronized Pixels getLatestPixels()

Implements com.sun.prism.PixelSource.getLatestPixels.

Doc from com.sun.prism.PixelSource.getLatestPixels.

Gets the next "latest" set of Pixels to be processed or displayed. This method is called by the consumer of Pixels objects. The return value may be null if the delivery request was obsoleted or superceded while in transit between the threads. The caller should call doneWithPixels() if and only if the return value was non-null.

Annotations
@Override
getUnusedPixelsback 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) Pixels object. Or it may be a brand new object.

Parameters
w:int

the width of the desired Pixels object

h:int

the height of the desired Pixels object

scalex:float

the horizontal scale of the desired Pixels object

scaley:float

the vertical scale of the desired Pixels object

Returns:Pixels

an unused Pixels object

skipLatestPixelsback to summary
public synchronized void skipLatestPixels()

Implements com.sun.prism.PixelSource.skipLatestPixels.

Doc from com.sun.prism.PixelSource.skipLatestPixels.

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 doneWithPixels(getLatestPixels()).

Annotations
@Override
usesSameBufferback to summary
private boolean usesSameBuffer(Pixels p1, Pixels p2)