gem5  v20.1.0.0
Classes | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
PixelConverter Class Reference

Configurable RGB pixel converter. More...

#include <pixel.hh>

Classes

struct  Channel
 Color channel conversion and scaling helper class. More...
 

Public Member Functions

 PixelConverter (unsigned length, unsigned ro, unsigned go, unsigned bo, unsigned rw, unsigned gw, unsigned bw, ByteOrder byte_order=ByteOrder::little)
 
Pixel toPixel (uint32_t word) const
 Get the Pixel representation of a color word. More...
 
Pixel toPixel (const uint8_t *rfb) const
 Get a Pixel representation by reading a word from memory. More...
 
uint32_t fromPixel (const Pixel &pixel) const
 Convert a Pixel into a color word. More...
 
void fromPixel (uint8_t *rfb, const Pixel &pixel) const
 Convert a pixel into a color word and store the resulting word in memory. More...
 
uint32_t readWord (const uint8_t *p) const
 Read a word of a given length and endianness from memory. More...
 
void writeWord (uint8_t *p, uint32_t word) const
 Write a word of a given length and endianness to memory. More...
 

Public Attributes

unsigned length
 Bytes per pixel when stored in memory (including padding) More...
 
unsigned depth
 Number of bits used to represent one pixel value (excluding padding). More...
 
ByteOrder byte_order
 Byte order when stored to memory. More...
 
Channel ch_r
 Red channel conversion helper. More...
 
Channel ch_g
 Green channel conversion helper. More...
 
Channel ch_b
 Blue channel conversion helper. More...
 

Static Public Attributes

static const PixelConverter rgba8888_le
 Predefined 32-bit RGB (red in least significant bits, 8 bits/channel, little endian) conversion helper. More...
 
static const PixelConverter rgb565_le
 Predefined 16-bit RGB565 (red in least significant bits, little endian) conversion helper. More...
 
static const PixelConverter rgba8888_be
 Predefined 32-bit RGB (red in least significant bits, 8 bits/channel, big endian) conversion helper. More...
 
static const PixelConverter rgb565_be
 Predefined 16-bit RGB565 (red in least significant bits, big endian) conversion helper. More...
 

Detailed Description

Configurable RGB pixel converter.

This class converts between external RGB representations and gem5's internal Pixel representation. The class assumes that pixels are stored in a word of configurable length (up to 32 bits). Individual pixels are assumed to be represented by contiguous bit ranges in the word (i.e., it is possible to shift and mask out a contiguous bit range for each pixel).

Definition at line 87 of file pixel.hh.

Constructor & Destructor Documentation

◆ PixelConverter()

PixelConverter::PixelConverter ( unsigned  length,
unsigned  ro,
unsigned  go,
unsigned  bo,
unsigned  rw,
unsigned  gw,
unsigned  bw,
ByteOrder  byte_order = ByteOrder::little 
)

Definition at line 51 of file pixel.cc.

References length.

Member Function Documentation

◆ fromPixel() [1/2]

uint32_t PixelConverter::fromPixel ( const Pixel pixel) const
inline

Convert a Pixel into a color word.

Definition at line 145 of file pixel.hh.

References Pixel::blue, ch_b, ch_g, ch_r, PixelConverter::Channel::fromPixel(), Pixel::green, and Pixel::red.

Referenced by FrameBuffer::copyOut(), fromPixel(), VncServer::sendFrameBufferUpdate(), and TEST().

◆ fromPixel() [2/2]

void PixelConverter::fromPixel ( uint8_t *  rfb,
const Pixel pixel 
) const
inline

Convert a pixel into a color word and store the resulting word in memory.

Definition at line 155 of file pixel.hh.

References fromPixel(), and writeWord().

◆ readWord()

uint32_t PixelConverter::readWord ( const uint8_t *  p) const

Read a word of a given length and endianness from memory.

The number of bytes read from memory is determined by the length of a color word. Note that some of the bytes may be padding.

Parameters
pPointer to the first byte in the word.
Returns
Word in host endianness.

Definition at line 73 of file pixel.cc.

References byte_order, ArmISA::i, length, and MipsISA::p.

Referenced by toPixel().

◆ toPixel() [1/2]

Pixel PixelConverter::toPixel ( const uint8_t *  rfb) const
inline

Get a Pixel representation by reading a word from memory.

Definition at line 140 of file pixel.hh.

References readWord(), and toPixel().

◆ toPixel() [2/2]

Pixel PixelConverter::toPixel ( uint32_t  word) const
inline

Get the Pixel representation of a color word.

Definition at line 133 of file pixel.hh.

References ch_b, ch_g, ch_r, and PixelConverter::Channel::toPixel().

Referenced by FrameBuffer::copyIn(), HDLcd::pxlNext(), to_number(), and toPixel().

◆ writeWord()

void PixelConverter::writeWord ( uint8_t *  p,
uint32_t  word 
) const

Write a word of a given length and endianness to memory.

Parameters
pPointer to the first byte in memory.
wordWord to store (host endianness).

Definition at line 89 of file pixel.cc.

References byte_order, ArmISA::i, length, and MipsISA::p.

Referenced by fromPixel().

Member Data Documentation

◆ byte_order

ByteOrder PixelConverter::byte_order

Byte order when stored to memory.

Definition at line 187 of file pixel.hh.

Referenced by readWord(), VncServer::VncServer(), and writeWord().

◆ ch_b

Channel PixelConverter::ch_b

Blue channel conversion helper.

Definition at line 194 of file pixel.hh.

Referenced by fromPixel(), toPixel(), and VncServer::VncServer().

◆ ch_g

Channel PixelConverter::ch_g

Green channel conversion helper.

Definition at line 192 of file pixel.hh.

Referenced by fromPixel(), toPixel(), and VncServer::VncServer().

◆ ch_r

Channel PixelConverter::ch_r

Red channel conversion helper.

Definition at line 190 of file pixel.hh.

Referenced by fromPixel(), toPixel(), and VncServer::VncServer().

◆ depth

unsigned PixelConverter::depth

Number of bits used to represent one pixel value (excluding padding).

This could be less than length * 8 if the pixel value is padded.

Definition at line 185 of file pixel.hh.

Referenced by VncServer::VncServer().

◆ length

unsigned PixelConverter::length

Bytes per pixel when stored in memory (including padding)

Definition at line 179 of file pixel.hh.

Referenced by FrameBuffer::copyIn(), FrameBuffer::copyOut(), PixelConverter(), HDLcd::pxlNext(), readWord(), VncServer::sendFrameBufferUpdate(), VncServer::VncServer(), and writeWord().

◆ rgb565_be

const PixelConverter PixelConverter::rgb565_be
static

Predefined 16-bit RGB565 (red in least significant bits, big endian) conversion helper.

Definition at line 208 of file pixel.hh.

◆ rgb565_le

const PixelConverter PixelConverter::rgb565_le
static

Predefined 16-bit RGB565 (red in least significant bits, little endian) conversion helper.

Definition at line 201 of file pixel.hh.

Referenced by TEST().

◆ rgba8888_be

const PixelConverter PixelConverter::rgba8888_be
static

Predefined 32-bit RGB (red in least significant bits, 8 bits/channel, big endian) conversion helper.

Definition at line 205 of file pixel.hh.

Referenced by TEST().

◆ rgba8888_le

const PixelConverter PixelConverter::rgba8888_le
static

Predefined 32-bit RGB (red in least significant bits, 8 bits/channel, little endian) conversion helper.

Definition at line 198 of file pixel.hh.

Referenced by operator<<(), TEST(), and to_number().


The documentation for this class was generated from the following files:

Generated on Wed Sep 30 2020 14:02:29 for gem5 by doxygen 1.8.17