aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer/Viewport.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-07-09 16:44:11 +0200
committerPierre Ossman <ossman@cendio.se>2014-07-14 16:03:41 +0200
commit0c9bd4b0ba28f5aab8b1f3e2eb8d83e01915e2b8 (patch)
tree500f61ee230d30fa1f8e955214c698e86b69e2f4 /vncviewer/Viewport.cxx
parent126e56420e47d72cc950d03976ee57d1efda436e (diff)
downloadtigervnc-0c9bd4b0ba28f5aab8b1f3e2eb8d83e01915e2b8.tar.gz
tigervnc-0c9bd4b0ba28f5aab8b1f3e2eb8d83e01915e2b8.zip
Use PixelBuffer objects as the interface for encoders and decoders
This avoid a lot of unnecessary middle men. This also pushes the responsibility for pixel format conversion into the encoders and decoders. The new bufferFromBuffer() is used for direct conversion, rather than PixelTransformer/TransImageGetter.
Diffstat (limited to 'vncviewer/Viewport.cxx')
-rw-r--r--vncviewer/Viewport.cxx114
1 files changed, 8 insertions, 106 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 70964b76..cd8b1bc3 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -27,7 +27,6 @@
#include <rfb/CMsgWriter.h>
#include <rfb/LogWriter.h>
-#include <rfb/PixelTransformer.h>
// FLTK can pull in the X11 headers on some systems
#ifndef XK_VoidSymbol
@@ -84,7 +83,7 @@ enum { ID_EXIT, ID_FULLSCREEN, ID_RESIZE,
ID_REFRESH, ID_OPTIONS, ID_INFO, ID_ABOUT, ID_DISMISS };
Viewport::Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_)
- : Fl_Widget(0, 0, w, h), cc(cc_), frameBuffer(NULL), pixelTrans(NULL),
+ : Fl_Widget(0, 0, w, h), cc(cc_), frameBuffer(NULL),
lastPointerPos(0, 0), lastButtonMask(0),
cursor(NULL), menuCtrlKey(false), menuAltKey(false)
{
@@ -101,8 +100,6 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_)
frameBuffer = createFramebuffer(w, h);
assert(frameBuffer);
- setServerPF(serverPF);
-
contextMenu = new Fl_Menu_Button(0, 0, 0, 0);
// Setting box type to FL_NO_BOX prevents it from trying to draw the
// button component (which we don't want)
@@ -130,7 +127,6 @@ Viewport::~Viewport()
{
// Unregister all timeouts in case they get a change tro trigger
// again later when this object is already gone.
- Fl::remove_timeout(handleUpdateTimeout, this);
Fl::remove_timeout(handlePointerTimeout, this);
#ifdef HAVE_FLTK_CLIPBOARD
@@ -141,9 +137,6 @@ Viewport::~Viewport()
delete frameBuffer;
- if (pixelTrans)
- delete pixelTrans;
-
if (cursor) {
if (!cursor->alloc_array)
delete [] cursor->array;
@@ -155,40 +148,6 @@ Viewport::~Viewport()
}
-void Viewport::setServerPF(const rfb::PixelFormat& pf)
-{
- if (pixelTrans)
- delete pixelTrans;
- pixelTrans = NULL;
-
- if (pf.equal(getPreferredPF()))
- return;
-
- pixelTrans = new PixelTransformer();
-
- // FIXME: This is an ugly (temporary) hack to get around a corner
- // case during startup. The conversion routines cannot handle
- // non-native source formats, and we can sometimes get that
- // as the initial format. We will switch to a better format
- // before getting any updates, but we need something for now.
- // Our old client used something completely bogus and just
- // hoped nothing would ever go wrong. We try to at least match
- // the pixel size so that we don't get any memory access issues
- // should a stray update appear.
- static rdr::U32 endianTest = 1;
- static bool nativeBigEndian = *(rdr::U8*)(&endianTest) != 1;
- if ((pf.bpp > 8) && (pf.bigEndian != nativeBigEndian)) {
- PixelFormat fake_pf(pf.bpp, pf.depth, nativeBigEndian, pf.trueColour,
- pf.redMax, pf.greenMax, pf.blueMax,
- pf.redShift, pf.greenShift, pf.blueShift);
- pixelTrans->init(fake_pf, getPreferredPF());
- return;
- }
-
- pixelTrans->init(pf, getPreferredPF());
-}
-
-
const rfb::PixelFormat &Viewport::getPreferredPF()
{
return frameBuffer->getPF();
@@ -197,65 +156,21 @@ const rfb::PixelFormat &Viewport::getPreferredPF()
// Copy the areas of the framebuffer that have been changed (damaged)
// to the displayed window.
+// FIXME: Make sure this gets called on slow updates
void Viewport::updateWindow()
{
Rect r;
- Fl::remove_timeout(handleUpdateTimeout, this);
-
- r = damage.get_bounding_rect();
- Fl_Widget::damage(FL_DAMAGE_USER1, r.tl.x + x(), r.tl.y + y(), r.width(), r.height());
-
- damage.clear();
-}
-
-void Viewport::fillRect(const rfb::Rect& r, rfb::Pixel pix) {
- if (pixelTrans) {
- rfb::Pixel pix2;
- pixelTrans->translatePixels(&pix, &pix2, 1);
- pix = pix2;
- }
-
- frameBuffer->fillRect(r, pix);
- damageRect(r);
+ r = frameBuffer->getDamage();
+ damage(FL_DAMAGE_USER1, r.tl.x + x(), r.tl.y + y(), r.width(), r.height());
}
-void Viewport::imageRect(const rfb::Rect& r, void* pixels) {
- if (pixelTrans) {
- rdr::U8* buffer;
- int stride;
- buffer = frameBuffer->getBufferRW(r, &stride);
- pixelTrans->translateRect(pixels, r.width(),
- rfb::Rect(0, 0, r.width(), r.height()),
- buffer, stride, rfb::Point(0, 0));
- frameBuffer->commitBufferRW(r);
- } else {
- frameBuffer->imageRect(r, pixels);
- }
- damageRect(r);
-}
-
-void Viewport::copyRect(const rfb::Rect& r, int srcX, int srcY) {
- frameBuffer->copyRect(r, rfb::Point(r.tl.x-srcX, r.tl.y-srcY));
- damageRect(r);
-}
-
-rdr::U8* Viewport::getBufferRW(const rfb::Rect& r, int* stride) {
- return frameBuffer->getBufferRW(r, stride);
-}
-
-void Viewport::commitBufferRW(const rfb::Rect& r) {
- frameBuffer->commitBufferRW(r);
- damageRect(r);
+rfb::ModifiablePixelBuffer* Viewport::getFramebuffer(void)
+{
+ return frameBuffer;
}
-void Viewport::damageRect(const rfb::Rect& r) {
- damage.assign_union(rfb::Region(r));
- if (!Fl::has_timeout(handleUpdateTimeout, this))
- Fl::add_timeout(0.500, handleUpdateTimeout, this);
-};
-
#ifdef HAVE_FLTK_CURSOR
static const char * dotcursor_xpm[] = {
"5 5 2 1",
@@ -303,10 +218,7 @@ void Viewport::setCursor(int width, int height, const Point& hotspot,
const PixelFormat *pf;
- if (pixelTrans)
- pf = &pixelTrans->getInPF();
- else
- pf = &frameBuffer->getPF();
+ pf = &cc->cp.pf();
i = (U8*)data;
o = buffer;
@@ -530,16 +442,6 @@ PlatformPixelBuffer* Viewport::createFramebuffer(int w, int h)
}
-void Viewport::handleUpdateTimeout(void *data)
-{
- Viewport *self = (Viewport *)data;
-
- assert(self);
-
- self->updateWindow();
-}
-
-
void Viewport::handleClipboardChange(int source, void *data)
{
Viewport *self = (Viewport *)data;