aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConstantin Kaplinsky <const@tightvnc.com>2008-05-30 11:02:04 +0000
committerConstantin Kaplinsky <const@tightvnc.com>2008-05-30 11:02:04 +0000
commit2c019834000c25f005a1a042c5c544d0190269c2 (patch)
treec953495dea5b30c0f21c7b853d0a34c9099db0f7
parent82f7b015eaca970f18d1666c972c95bf674e175e (diff)
downloadtigervnc-2c019834000c25f005a1a042c5c544d0190269c2.tar.gz
tigervnc-2c019834000c25f005a1a042c5c544d0190269c2.zip
Code refactoring - PollingManager's constructor is given an XPixelBuffer*
instead of an Image*. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2567 3789f03b-4d11-0410-bbf8-ca57d06f2519
-rw-r--r--unix/x0vncserver/PollingManager.cxx22
-rw-r--r--unix/x0vncserver/PollingManager.h3
-rw-r--r--unix/x0vncserver/XPixelBuffer.cxx2
-rw-r--r--unix/x0vncserver/XPixelBuffer.h8
-rw-r--r--unix/x0vncserver/x0vncserver.cxx17
5 files changed, 28 insertions, 24 deletions
diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx
index bcc9547c..71b5d660 100644
--- a/unix/x0vncserver/PollingManager.cxx
+++ b/unix/x0vncserver/PollingManager.cxx
@@ -43,27 +43,25 @@ const int PollingManager::m_pollingOrder[32] = {
//
// Constructor.
//
-// Note that dpy and image should remain valid during the object
+// Note that dpy and buffer should remain valid during the object
// lifetime, while factory is used only in the constructor itself.
//
-// FIXME: Pass XPixelBuffer* instead of Image*.
-//
-PollingManager::PollingManager(Display *dpy, Image *image,
+PollingManager::PollingManager(Display *dpy, XPixelBuffer *buffer,
ImageFactory *factory,
int offsetLeft, int offsetTop)
: m_dpy(dpy),
m_server(0),
- m_image(image),
- m_bytesPerPixel(image->xim->bits_per_pixel / 8),
+ m_image(buffer->getImage()),
+ m_bytesPerPixel(buffer->getPF().bpp / 8),
m_offsetLeft(offsetLeft),
m_offsetTop(offsetTop),
- m_width(image->xim->width),
- m_height(image->xim->height),
- m_widthTiles((image->xim->width + 31) / 32),
- m_heightTiles((image->xim->height + 31) / 32),
- m_numTiles(((image->xim->width + 31) / 32) *
- ((image->xim->height + 31) / 32)),
+ m_width(buffer->width()),
+ m_height(buffer->height()),
+ m_widthTiles((buffer->width() + 31) / 32),
+ m_heightTiles((buffer->height() + 31) / 32),
+ m_numTiles(((buffer->width() + 31) / 32) *
+ ((buffer->height() + 31) / 32)),
m_pollingStep(0)
{
// Get initial screen image.
diff --git a/unix/x0vncserver/PollingManager.h b/unix/x0vncserver/PollingManager.h
index cedac1a3..015b3ca6 100644
--- a/unix/x0vncserver/PollingManager.h
+++ b/unix/x0vncserver/PollingManager.h
@@ -27,6 +27,7 @@
#include <rfb/VNCServer.h>
#include <x0vncserver/Image.h>
+#include <x0vncserver/XPixelBuffer.h>
#ifdef DEBUG
#include <x0vncserver/TimeMillis.h>
@@ -38,7 +39,7 @@ class PollingManager {
public:
- PollingManager(Display *dpy, Image *image, ImageFactory *factory,
+ PollingManager(Display *dpy, XPixelBuffer *buffer, ImageFactory *factory,
int offsetLeft = 0, int offsetTop = 0);
virtual ~PollingManager();
diff --git a/unix/x0vncserver/XPixelBuffer.cxx b/unix/x0vncserver/XPixelBuffer.cxx
index 29470073..78ac5588 100644
--- a/unix/x0vncserver/XPixelBuffer.cxx
+++ b/unix/x0vncserver/XPixelBuffer.cxx
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007 Constantin Kaplinsky. All Rights Reserved.
+/* Copyright (C) 2007-2008 Constantin Kaplinsky. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/unix/x0vncserver/XPixelBuffer.h b/unix/x0vncserver/XPixelBuffer.h
index 010763bb..2f84245e 100644
--- a/unix/x0vncserver/XPixelBuffer.h
+++ b/unix/x0vncserver/XPixelBuffer.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007 Constantin Kaplinsky. All Rights Reserved.
+/* Copyright (C) 2007-2008 Constantin Kaplinsky. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,6 +40,12 @@ public:
const PixelFormat& pf, ColourMap* cm);
virtual ~XPixelBuffer();
+ // We allow public access to the underlying Image object.
+ // The image is heavily used by the PollingManager.
+ // TODO: Allow read-only (const Image *) access only.
+ // Or better do not allow public access at all.
+ virtual Image *getImage() const { return m_image; }
+
virtual int getStride() const { return m_stride; }
// Override PixelBuffer's function.
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx
index ab939846..8489290a 100644
--- a/unix/x0vncserver/x0vncserver.cxx
+++ b/unix/x0vncserver/x0vncserver.cxx
@@ -1,5 +1,5 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
- * Copyright (C) 2004-2006 Constantin Kaplinsky. All Rights Reserved.
+ * Copyright (C) 2004-2008 Constantin Kaplinsky. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -180,13 +180,6 @@ public:
image = factory.newImage(dpy, geometry->width(), geometry->height());
vlog.info("Allocated %s", image->classDesc());
- // Create polling manager object. It will track screen changes and
- // keep pixels of the `image' object up to date.
- pollmgr = new PollingManager(dpy, image, &factory,
- geometry->offsetLeft(),
- geometry->offsetTop());
- pollmgr->setVNCServer(vs);
-
pf.bpp = image->xim->bits_per_pixel;
pf.depth = image->xim->depth;
pf.bigEndian = (image->xim->byte_order == MSBFirst);
@@ -205,6 +198,12 @@ public:
server = vs;
server->setPixelBuffer(pb);
+ // Create polling manager object for detection of pixel changes.
+ pollmgr = new PollingManager(dpy, pb, &factory,
+ geometry->offsetLeft(),
+ geometry->offsetTop());
+ pollmgr->setVNCServer(vs);
+
running = true;
}
@@ -286,7 +285,7 @@ protected:
Display* dpy;
Geometry* geometry;
PixelFormat pf;
- PixelBuffer* pb;
+ XPixelBuffer* pb;
VNCServer* server;
Image* image;
PollingManager* pollmgr;