aboutsummaryrefslogtreecommitdiffstats
path: root/tests/perf/decperf.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2020-02-27 12:43:05 +0100
committerPierre Ossman <ossman@cendio.se>2020-02-27 12:43:05 +0100
commit954ad21da2092a257df60e42c9b1774fed40ac66 (patch)
tree777fc9e7006eea55c93b1c8b2c00ccd81a65db67 /tests/perf/decperf.cxx
parent2b45fb39504b72147984a18e880e0cd6acce98ce (diff)
downloadtigervnc-954ad21da2092a257df60e42c9b1774fed40ac66.tar.gz
tigervnc-954ad21da2092a257df60e42c9b1774fed40ac66.zip
Provide dummy output for dummy client connections
The CConnection base class wants to be able to write things these days, so we need to provide it a place to do so.
Diffstat (limited to 'tests/perf/decperf.cxx')
-rw-r--r--tests/perf/decperf.cxx49
1 files changed, 48 insertions, 1 deletions
diff --git a/tests/perf/decperf.cxx b/tests/perf/decperf.cxx
index df5214f2..a6a50899 100644
--- a/tests/perf/decperf.cxx
+++ b/tests/perf/decperf.cxx
@@ -31,9 +31,11 @@
#include <rdr/Exception.h>
#include <rdr/FileInStream.h>
+#include <rdr/OutStream.h>
#include <rfb/CConnection.h>
#include <rfb/CMsgReader.h>
+#include <rfb/CMsgWriter.h>
#include <rfb/PixelBuffer.h>
#include <rfb/PixelFormat.h>
@@ -42,6 +44,20 @@
// FIXME: Files are always in this format
static const rfb::PixelFormat filePF(32, 24, false, true, 255, 255, 255, 0, 8, 16);
+class DummyOutStream : public rdr::OutStream {
+public:
+ DummyOutStream();
+
+ virtual size_t length();
+ virtual void flush();
+
+private:
+ virtual size_t overrun(size_t itemSize, size_t nItems);
+
+ int offset;
+ rdr::U8 buf[131072];
+};
+
class CConn : public rfb::CConnection {
public:
CConn(const char *filename);
@@ -61,24 +77,55 @@ public:
protected:
rdr::FileInStream *in;
+ DummyOutStream *out;
};
+DummyOutStream::DummyOutStream()
+{
+ offset = 0;
+ ptr = buf;
+ end = buf + sizeof(buf);
+}
+
+size_t DummyOutStream::length()
+{
+ flush();
+ return offset;
+}
+
+void DummyOutStream::flush()
+{
+ offset += ptr - buf;
+ ptr = buf;
+}
+
+size_t DummyOutStream::overrun(size_t itemSize, size_t nItems)
+{
+ flush();
+ if (itemSize * nItems > (size_t)(end - ptr))
+ nItems = (end - ptr) / itemSize;
+ return nItems;
+}
+
CConn::CConn(const char *filename)
{
cpuTime = 0.0;
in = new rdr::FileInStream(filename);
- setStreams(in, NULL);
+ out = new DummyOutStream;
+ setStreams(in, out);
// Need to skip the initial handshake
setState(RFBSTATE_INITIALISATION);
// That also means that the reader and writer weren't setup
setReader(new rfb::CMsgReader(this, in));
+ setWriter(new rfb::CMsgWriter(&server, out));
}
CConn::~CConn()
{
delete in;
+ delete out;
}
void CConn::initDone()