summaryrefslogtreecommitdiff
path: root/src/base/vnc/vncinput.cc
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/vnc/vncinput.cc
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/vnc/vncinput.cc')
-rw-r--r--src/base/vnc/vncinput.cc62
1 files changed, 35 insertions, 27 deletions
diff --git a/src/base/vnc/vncinput.cc b/src/base/vnc/vncinput.cc
index 071804583..017fc3876 100644
--- a/src/base/vnc/vncinput.cc
+++ b/src/base/vnc/vncinput.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 ARM Limited
+ * Copyright (c) 2010, 2015 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -53,9 +53,10 @@ using namespace std;
VncInput::VncInput(const Params *p)
: SimObject(p), keyboard(NULL), mouse(NULL),
- vc(NULL), fbPtr(NULL), videoMode(VideoConvert::UnknownMode),
- _videoWidth(1), _videoHeight(1), captureEnabled(p->frame_capture),
- captureCurrentFrame(0), captureLastHash(0), captureBitmap(0)
+ fb(&FrameBuffer::dummy),
+ _videoWidth(fb->width()), _videoHeight(fb->height()),
+ captureEnabled(p->frame_capture),
+ captureCurrentFrame(0), captureLastHash(0)
{
if (captureEnabled) {
// remove existing frame output directory if it exists, then create a
@@ -68,33 +69,40 @@ VncInput::VncInput(const Params *p)
}
void
-VncInput::setFrameBufferParams(VideoConvert::Mode mode, uint16_t width,
- uint16_t height)
+VncInput::setFrameBuffer(const FrameBuffer *rfb)
{
- DPRINTF(VNC, "Updating video params: mode: %d width: %d height: %d\n", mode,
- width, height);
+ if (!rfb)
+ panic("Trying to VNC frame buffer to NULL!");
- if (mode != videoMode || width != videoWidth() || height != videoHeight()) {
- videoMode = mode;
- _videoWidth = width;
- _videoHeight = height;
+ fb = rfb;
+
+ // create bitmap of the frame with new attributes
+ if (captureEnabled)
+ captureBitmap.reset(new Bitmap(rfb));
+
+ // Setting a new frame buffer means that we need to send an update
+ // to the client. Mark the internal buffers as dirty to do so.
+ setDirty();
+}
- if (vc)
- delete vc;
+void
+VncInput::setDirty()
+{
+ const unsigned width(fb->width());
+ const unsigned height(fb->height());
- vc = new VideoConvert(mode, VideoConvert::rgb8888, videoWidth(),
- videoHeight());
+ if (_videoWidth != width || _videoHeight != height) {
+ DPRINTF(VNC, "Updating video params: width: %d height: %d\n",
+ width, height);
- if (captureEnabled) {
- // create bitmap of the frame with new attributes
- if (captureBitmap)
- delete captureBitmap;
+ _videoWidth = width;
+ _videoHeight = height;
- assert(fbPtr);
- captureBitmap = new Bitmap(videoMode, width, height, fbPtr);
- assert(captureBitmap);
- }
+ frameBufferResized();
}
+
+ if (captureEnabled)
+ captureFrameBuffer();
}
void
@@ -103,7 +111,7 @@ VncInput::captureFrameBuffer()
assert(captureBitmap);
// skip identical frames
- uint64_t new_hash = captureBitmap->getHash();
+ uint64_t new_hash = fb->getHash();
if (captureLastHash == new_hash)
return;
captureLastHash = new_hash;
@@ -116,8 +124,8 @@ VncInput::captureFrameBuffer()
// create the compressed framebuffer file
ostream *fb_out = simout.create(captureOutputDirectory + frameFilename,
- true);
- captureBitmap->write(fb_out);
+ true);
+ captureBitmap->write(*fb_out);
simout.close(fb_out);
++captureCurrentFrame;