APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.glass.ui.monocle

pack-priv Class FramebufferY8

extends Framebuffer
Class Inheritance
Imports
com.sun.javafx.logging.PlatformLogger, com.sun.javafx.util.Logging, java.io.IOException, java.nio.Buffer, .ByteBuffer, .ByteOrder, .IntBuffer, .ShortBuffer, java.nio.channels.WritableByteChannel, java.text.MessageFormat

Provides a buffer for composing JavaFX scenes. This class is given a 32-bit composition buffer that is either the Linux frame buffer itself or an off-screen byte buffer. It can write the contents of this buffer to a target channel, or copy them to a buffer, in one of three pixel formats: 32-bit ARGB32 color, 16-bit RGB565 color, or 8-bit Y8 grayscale.

Field Summary

Modifier and TypeField and Description
private final ByteBuffer
private final int
private static final int
BITS_TO_BYTES

The arithmetic right shift value to convert a bit depth to a byte depth.

private final int
private final int
private ByteBuffer
private Buffer
private final PlatformLogger
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
FramebufferY8(ByteBuffer
the 32-bit composition buffer
bb
,
int
the width of the composition buffer in pixels
width
,
int
the height of the composition buffer in pixels
height
,
int
the color depth of the target channel or buffer in bits per pixel
depth
,
boolean
true to clear the composition buffer on the first upload of each frame unless that upload already overwrites the entire buffer; otherwise false
clear
)

Creates a new FramebufferY8 with the given 32-bit composition buffer and target color depth.

Method Summary

Modifier and TypeMethod and Description
private void
copyNextPixel(IntBuffer
the source integer buffer in ARGB32 format
source
,
ByteBuffer
the target byte buffer in Y8 format
target
)

Copies the next 32-bit ARGB32 pixel to a byte buffer with 8-bit Y8 pixels.

private void
copyNextPixel(IntBuffer
the source integer buffer in ARGB32 format
source
,
ShortBuffer
the target short buffer in RGB565 format
target
)

Copies the next 32-bit ARGB32 pixel to a short buffer with 16-bit RGB565 pixels.

pack-priv void
copyToBuffer(ByteBuffer
the output buffer
out
)

Overrides com.sun.glass.ui.monocle.Framebuffer.copyToBuffer.

Copies the contents of the composition buffer to the output buffer, converting the pixel format as necessary.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

pack-priv void
write(WritableByteChannel
the output channel
out
)

Overrides com.sun.glass.ui.monocle.Framebuffer.write.

Writes the contents of the composition buffer to the output channel, converting the pixel format as necessary.

Inherited from com.sun.glass.ui.monocle.Framebuffer:
clearBufferContentscomposePixelsgetBufferhasReceivedDataresetsetStartAddress

Field Detail

bbback to summary
private final ByteBuffer bb

Hides com.sun.glass.ui.monocle.Framebuffer.bb.

bitDepthback to summary
private final int bitDepth
BITS_TO_BYTESback to summary
private static final int BITS_TO_BYTES

The arithmetic right shift value to convert a bit depth to a byte depth.

byteDepthback to summary
private final int byteDepth

Hides com.sun.glass.ui.monocle.Framebuffer.byteDepth.

heightback to summary
private final int height

Hides com.sun.glass.ui.monocle.Framebuffer.height.

lineByteBufferback to summary
private ByteBuffer lineByteBuffer

Hides com.sun.glass.ui.monocle.Framebuffer.lineByteBuffer.

linePixelBufferback to summary
private Buffer linePixelBuffer

Hides com.sun.glass.ui.monocle.Framebuffer.linePixelBuffer.

loggerback to summary
private final PlatformLogger logger
widthback to summary
private final int width

Hides com.sun.glass.ui.monocle.Framebuffer.width.

Constructor Detail

FramebufferY8back to summary
pack-priv FramebufferY8(ByteBuffer bb, int width, int height, int depth, boolean clear)

Creates a new FramebufferY8 with the given 32-bit composition buffer and target color depth.

Parameters
bb:ByteBuffer

the 32-bit composition buffer

width:int

the width of the composition buffer in pixels

height:int

the height of the composition buffer in pixels

depth:int

the color depth of the target channel or buffer in bits per pixel

clear:boolean

true to clear the composition buffer on the first upload of each frame unless that upload already overwrites the entire buffer; otherwise false

Method Detail

copyNextPixelback to summary
private void copyNextPixel(IntBuffer source, ByteBuffer target)

Copies the next 32-bit ARGB32 pixel to a byte buffer with 8-bit Y8 pixels. Luma Y' can be calculated from gamma-corrected R'G'B' using the following coefficients. This method uses the coefficients from Rec. 709, which defines the same primaries and white point as the sRGB color space.

Simple average:  Y' = (R' + G' + B') / 3
Rec. 601 (SDTV): Y' = 0.299  * R' + 0.587  * G' + 0.114  * B'
Rec. 709 (HDTV): Y' = 0.2126 * R' + 0.7152 * G' + 0.0722 * B'
Rec. 2100 (HDR): Y' = 0.2627 * R' + 0.6780 * G' + 0.0593 * B'

Implementation Note

Java rounds toward zero when converting a float to an int. The calculation of luma could be rounded to the nearest integer by adding 0.5 before the type conversion, but the extra operation seems unnecessary for a display with only 16 levels of gray.

Parameters
source:IntBuffer

the source integer buffer in ARGB32 format

target:ByteBuffer

the target byte buffer in Y8 format

copyNextPixelback to summary
private void copyNextPixel(IntBuffer source, ShortBuffer target)

Copies the next 32-bit ARGB32 pixel to a short buffer with 16-bit RGB565 pixels. This method truncates the low-order bits of each color component.

Parameters
source:IntBuffer

the source integer buffer in ARGB32 format

target:ShortBuffer

the target short buffer in RGB565 format

copyToBufferback to summary
pack-priv void copyToBuffer(ByteBuffer out)

Overrides com.sun.glass.ui.monocle.Framebuffer.copyToBuffer.

Copies the contents of the composition buffer to the output buffer, converting the pixel format as necessary.

Parameters
out:ByteBuffer

the output buffer

Annotations
@Override
Exceptions
IllegalArgumentException:
if the buffer has an unsupported color depth
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
writeback to summary
pack-priv void write(WritableByteChannel out) throws IOException

Overrides com.sun.glass.ui.monocle.Framebuffer.write.

Writes the contents of the composition buffer to the output channel, converting the pixel format as necessary.

Parameters
out:WritableByteChannel

the output channel

Annotations
@Override
Exceptions
IOException:
if an error occurs writing to the channel
IllegalArgumentException:
if the channel has an unsupported color depth