summaryrefslogtreecommitdiff
path: root/src/base/bitmap.hh
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2015-05-23 13:37:03 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2015-05-23 13:37:03 +0100
commitdb5c9a5f9028fd87a74e1750068511bd311435ae (patch)
treed2d2125ce8f717355187c767599945ad354470e9 /src/base/bitmap.hh
parent1985d28ef905753423b3ee407c8bf4ee9165302b (diff)
downloadgem5-db5c9a5f9028fd87a74e1750068511bd311435ae.tar.xz
base: Redesign internal frame buffer handling
Currently, frame buffer handling in gem5 is quite ad hoc. In practice, we pass around naked pointers to raw pixel data and expect consumers to convert frame buffers using the (broken) VideoConverter. This changeset completely redesigns the way we handle frame buffers internally. In summary, it fixes several color conversion bugs, adds support for more color formats (e.g., big endian), and makes the code base easier to follow. In the new world, gem5 always represents pixel data using the Pixel struct when pixels need to be passed between different classes (e.g., a display controller and the VNC server). Producers of entire frames (e.g., display controllers) should use the FrameBuffer class to represent a frame. Frame producers are expected to create one instance of the FrameBuffer class in their constructors and register it with its consumers once. Consumers are expected to check the dimensions of the frame buffer when they consume it. Conversion between the external representation and the internal representation is supported for all common "true color" RGB formats of up to 32-bit color depth. The external pixel representation is expected to be between 1 and 4 bytes in either big endian or little endian. Color channels are assumed to be contiguous ranges of bits within each pixel word. The external pixel value is scaled to an 8-bit internal representation using a floating multiplication to map it to the entire 8-bit range.
Diffstat (limited to 'src/base/bitmap.hh')
-rw-r--r--src/base/bitmap.hh51
1 files changed, 20 insertions, 31 deletions
diff --git a/src/base/bitmap.hh b/src/base/bitmap.hh
index b06aff10f..0797a26a7 100644
--- a/src/base/bitmap.hh
+++ b/src/base/bitmap.hh
@@ -45,7 +45,7 @@
#include <ostream>
#include "base/compiler.hh"
-#include "base/vnc/convert.hh"
+#include "base/framebuffer.hh"
/**
* @file Declaration of a class that writes a frame buffer to a bitmap
@@ -59,38 +59,17 @@ class Bitmap
/**
* Create a bitmap that takes data in a given mode & size and
* outputs to an ostream.
- *
- * @param mode the type of data that is being provided
- * @param h the hight of the image
- * @param w the width of the image
- * @param d the data for the image in mode
*/
- Bitmap(VideoConvert::Mode mode, uint16_t w, uint16_t h, uint8_t *d);
+ Bitmap(const FrameBuffer *fb);
~Bitmap();
/**
- * Provide the converter with the data that should be output. It
- * will be converted into rgb8888 and written when write() is
- * called.
- *
- * @param d the data
- */
- void rawData(uint8_t* d) { data = d; }
-
- /**
* Write the frame buffer data into the provided ostream
*
* @param bmp stream to write to
*/
- void write(std::ostream *bmp) const;
-
- /**
- * Gets a hash over the bitmap for quick comparisons to other bitmaps.
- *
- * @return hash of the bitmap
- */
- uint64_t getHash() const { return vc.getHash(data); }
+ void write(std::ostream &bmp) const;
private:
@@ -121,16 +100,26 @@ class Bitmap
InfoHeaderV1 info;
} M5_ATTR_PACKED;
- typedef uint32_t PixelType;
+ struct BmpPixel32 {
+ BmpPixel32 &operator=(const Pixel &rhs) {
+ red = rhs.red;
+ green = rhs.green;
+ blue = rhs.blue;
+ padding = 0;
+
+ return *this;
+ }
+ uint8_t blue;
+ uint8_t green;
+ uint8_t red;
+ uint8_t padding;
+ } M5_ATTR_PACKED;
- const CompleteV1Header getCompleteHeader() const;
+ typedef BmpPixel32 PixelType;
- const uint16_t height;
- const uint16_t width;
- const CompleteV1Header header;
- uint8_t *data;
+ const CompleteV1Header getCompleteHeader() const;
- VideoConvert vc;
+ const FrameBuffer &fb;
};
#endif // __BASE_BITMAP_HH__