diff options
author | Pierre Ossman <ossman@cendio.se> | 2014-01-07 15:28:45 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2014-01-07 15:28:45 +0000 |
commit | 1ed4d50a95654df453f6d1adf042786bbcc75591 (patch) | |
tree | 4aeb7873cd92bb9c70abaa1cb2d0530d6e9e2477 | |
parent | 857bed00f6ed1dea8a629b7b7d0129b26d485094 (diff) | |
download | tigervnc-1ed4d50a95654df453f6d1adf042786bbcc75591.tar.gz tigervnc-1ed4d50a95654df453f6d1adf042786bbcc75591.zip |
Make sure the fill function pointer gets updated if the
managed pixel buffer changes format. Also add a bit more
protection for switching pixel format as the base classes
aren't really designed for that. Fixes a crash with the
mouse pointer in WinVNC.
Based on work done by Daniel Wyatt (dewyatt).
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5152 3789f03b-4d11-0410-bbf8-ca57d06f2519
-rw-r--r-- | common/rfb/PixelBuffer.cxx | 22 | ||||
-rw-r--r-- | common/rfb/PixelBuffer.h | 7 |
2 files changed, 24 insertions, 5 deletions
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx index 106b42bc..60957a25 100644 --- a/common/rfb/PixelBuffer.cxx +++ b/common/rfb/PixelBuffer.cxx @@ -133,6 +133,22 @@ FullFramePixelBuffer::FullFramePixelBuffer(const PixelFormat& pf, int w, int h, rdr::U8* data_, ColourMap* cm) : PixelBuffer(pf, w, h, cm), data(data_) { + // Called again to configure the fill function + setPF(pf); +} + +FullFramePixelBuffer::FullFramePixelBuffer() : data(0) {} + +FullFramePixelBuffer::~FullFramePixelBuffer() {} + + +void FullFramePixelBuffer::setPF(const PixelFormat &pf) { + // We have this as a separate method for ManagedPixelBuffer's + // sake. Direct users of FullFramePixelBuffer aren't allowed + // to call it. + + PixelBuffer::setPF(pf); + switch(pf.bpp) { case 8: fillRectFn = fillRect8; @@ -148,10 +164,6 @@ FullFramePixelBuffer::FullFramePixelBuffer(const PixelFormat& pf, int w, int h, } } -FullFramePixelBuffer::FullFramePixelBuffer() : data(0) {} - -FullFramePixelBuffer::~FullFramePixelBuffer() {} - int FullFramePixelBuffer::getStride() const { return width(); } @@ -334,7 +346,7 @@ ManagedPixelBuffer::~ManagedPixelBuffer() { void ManagedPixelBuffer::setPF(const PixelFormat &pf) { - format = pf; checkDataSize(); + FullFramePixelBuffer::setPF(pf); checkDataSize(); }; void ManagedPixelBuffer::setSize(int w, int h) { diff --git a/common/rfb/PixelBuffer.h b/common/rfb/PixelBuffer.h index d721fa29..e870622e 100644 --- a/common/rfb/PixelBuffer.h +++ b/common/rfb/PixelBuffer.h @@ -44,7 +44,10 @@ namespace rfb { // // Set/get pixel format & colourmap + protected: + // Only for subclasses that support changing parameters virtual void setPF(const PixelFormat &pf); + public: virtual const PixelFormat &getPF() const; virtual ColourMap* getColourMap() const; @@ -103,6 +106,10 @@ namespace rfb { rdr::U8* data_, ColourMap* cm); virtual ~FullFramePixelBuffer(); + protected: + virtual void setPF(const PixelFormat &pf); + + public: // - Get the number of pixels per row in the actual pixel buffer data area // This may in some cases NOT be the same as width(). virtual int getStride() const; |