40 #ifndef __BASE_FRAMEBUFFER_HH__
41 #define __BASE_FRAMEBUFFER_HH__
63 Pixel(uint8_t _red, uint8_t _green, uint8_t _blue)
75 return lhs.
red == rhs.
red &&
109 return round(((word >> offset) &
mask) *
factor);
132 unsigned ro,
unsigned go,
unsigned bo,
133 unsigned rw,
unsigned gw,
unsigned bw,
173 uint32_t
readWord(
const uint8_t *
p)
const;
180 void writeWord(uint8_t *
p, uint32_t word)
const;
226 inline std::ostream &
272 void resize(
unsigned width,
unsigned height);
380 #endif // __BASE_FRAMEBUFFER_HH__
uint32_t fromPixel(uint8_t ch) const
Convert an 8-bit representation of a color into an external format.
Pixel toPixel(uint32_t word) const
Get the Pixel representation of a color word.
const Pixel & pixel(unsigned x, unsigned y) const
Get a pixel from an (x, y) coordinate.
Pixel toPixel(const uint8_t *rfb) const
Get a Pixel representation by reading a word from memory.
static const FrameBuffer dummy
Static "dummy" frame buffer.
Internal gem5 representation of a frame buffer.
Channel ch_g
Green channel conversion helper.
void resize(unsigned width, unsigned height)
Resize the frame buffer.
uint32_t readWord(const uint8_t *p) const
Read a word of a given length and endianness from memory.
unsigned length
Bytes per pixel when stored in memory (including padding)
float factor
Scaling factor when converting to the full range of an 8-bit color channel.
void copyIn(const uint8_t *fb, const PixelConverter &conv)
Fill the frame buffer with pixel data from an external buffer of the same width and height as this fr...
void copyOut(uint8_t *fb, const PixelConverter &conv) const
Store the contents of this frame buffer in an external buffer of the same width and height as this fr...
unsigned _width
Width in pixels.
void clear()
Fill the frame buffer with black pixels.
FrameBuffer()
Create an empty (0x0) frame buffer.
std::vector< Pixel > pixels
Frame buffer backing store.
Channel ch_b
Blue channel conversion helper.
unsigned mask
Bit mask (after shifting)
Channel(unsigned offset, unsigned width)
static const PixelConverter rgb565_be
Predefined 16-bit RGB565 (red in least significant bits, big endian) conversion helper.
Pixel(uint8_t _red, uint8_t _green, uint8_t _blue)
unsigned depth
Number of bits used to represent one pixel value (excluding padding).
PixelConverter(unsigned length, unsigned ro, unsigned go, unsigned bo, unsigned rw, unsigned gw, unsigned bw, ByteOrder byte_order=LittleEndianByteOrder)
unsigned offset
Offset in bits.
ByteOrder byte_order
Byte order when stored to memory.
std::string csprintf(const char *format, const Args &...args)
unsigned height() const
Frame buffer height in pixels.
void copyOut(std::vector< uint8_t > &fb, const PixelConverter &conv) const
Store the contents of this frame buffer in an external buffer of the same width and height as this fr...
static const PixelConverter rgba8888_le
Predefined 32-bit RGB (red in least significant bits, 8 bits/channel, little endian) conversion helpe...
Channel ch_r
Red channel conversion helper.
Pixel & pixel(unsigned x, unsigned y)
Get a pixel from an (x, y) coordinate.
std::ostream & operator<<(std::ostream &os, const Pixel &pxl)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void fromPixel(uint8_t *rfb, const Pixel &pixel) const
Convert a pixel into a color word and store the resulting word in memory.
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint8_t toPixel(uint32_t word) const
Get the value of a single color channel represented as an 8-bit number.
Basic support for object serialization.
void copyIn(const std::vector< uint8_t > &fb, const PixelConverter &conv)
Fill the frame buffer with pixel data from an external buffer of the same width and height as this fr...
static const PixelConverter rgb565_le
Predefined 16-bit RGB565 (red in least significant bits, little endian) conversion helper...
std::ostream CheckpointOut
unsigned width() const
Frame buffer width in pixels.
Color channel conversion and scaling helper class.
uint64_t getHash() const
Create a hash of the image that can be used for quick comparisons.
void fill(const Pixel &pixel)
Fill the frame buffer with a single pixel value.
Configurable RGB pixel converter.
Internal gem5 representation of a Pixel.
unsigned _height
Height in pixels.
void writeWord(uint8_t *p, uint32_t word) const
Write a word of a given length and endianness to memory.
void serialize(CheckpointOut &cp) const override
Serialize an object.
bool to_number(const std::string &value, Pixel &retval)
static const PixelConverter rgba8888_be
Predefined 32-bit RGB (red in least significant bits, 8 bits/channel, big endian) conversion helper...
uint32_t fromPixel(const Pixel &pixel) const
Convert a Pixel into a color word.
unsigned area() const
Total number of pixels in frame buffer.
bool operator==(const Pixel &lhs, const Pixel &rhs)