From 8a85c49dcbf1b15bc633a14ffef293ca6b7753bf Mon Sep 17 00:00:00 2001 From: Constantin Kaplinsky Date: Wed, 4 Jun 2008 05:36:40 +0000 Subject: Code refactoring: PollingManager should not know anything about XPixelBuffer. This commit partially reverts the changes from r2567. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2575 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- unix/x0vncserver/PollingManager.cxx | 20 ++++++++++---------- unix/x0vncserver/PollingManager.h | 3 +-- unix/x0vncserver/XPixelBuffer.h | 7 ++----- unix/x0vncserver/x0vncserver.cxx | 2 +- 4 files changed, 14 insertions(+), 18 deletions(-) (limited to 'unix') diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx index 27f10285..99518833 100644 --- a/unix/x0vncserver/PollingManager.cxx +++ b/unix/x0vncserver/PollingManager.cxx @@ -43,24 +43,24 @@ const int PollingManager::m_pollingOrder[32] = { // // Constructor. // -// Note that dpy and buffer should remain valid during the object +// Note that dpy and image should remain valid during the object // lifetime, while factory is used only in the constructor itself. // -PollingManager::PollingManager(Display *dpy, XPixelBuffer *buffer, +PollingManager::PollingManager(Display *dpy, const Image *image, ImageFactory *factory, int offsetLeft, int offsetTop) : m_dpy(dpy), - m_image(buffer->getImage()), - m_bytesPerPixel(buffer->getPF().bpp / 8), + m_image(image), + m_bytesPerPixel(image->xim->bits_per_pixel / 8), m_offsetLeft(offsetLeft), m_offsetTop(offsetTop), - 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_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_pollingStep(0) { // Create additional images used in polling algorithm, warn if diff --git a/unix/x0vncserver/PollingManager.h b/unix/x0vncserver/PollingManager.h index 587e347b..779e88b8 100644 --- a/unix/x0vncserver/PollingManager.h +++ b/unix/x0vncserver/PollingManager.h @@ -27,7 +27,6 @@ #include #include -#include #ifdef DEBUG #include @@ -39,7 +38,7 @@ class PollingManager { public: - PollingManager(Display *dpy, XPixelBuffer *buffer, ImageFactory *factory, + PollingManager(Display *dpy, const Image *image, ImageFactory *factory, int offsetLeft = 0, int offsetTop = 0); virtual ~PollingManager(); diff --git a/unix/x0vncserver/XPixelBuffer.h b/unix/x0vncserver/XPixelBuffer.h index 25a3d844..3632f804 100644 --- a/unix/x0vncserver/XPixelBuffer.h +++ b/unix/x0vncserver/XPixelBuffer.h @@ -39,11 +39,8 @@ public: const Rect &rect, 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; } + // Provide access to the underlying Image object. + virtual const Image *getImage() const { return m_image; } // Override PixelBuffer::getStride(). virtual int getStride() const { return m_stride; } diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx index 2d387618..b63e9379 100644 --- a/unix/x0vncserver/x0vncserver.cxx +++ b/unix/x0vncserver/x0vncserver.cxx @@ -187,7 +187,7 @@ public: server->setPixelBuffer(pb); // Create polling manager object for detection of pixel changes. - pollmgr = new PollingManager(dpy, pb, &factory, + pollmgr = new PollingManager(dpy, pb->getImage(), &factory, geometry->offsetLeft(), geometry->offsetTop()); running = true; -- cgit v1.2.3