]> source.dussan.org Git - tigervnc.git/commitdiff
Fixed the problem with framebuffer data not always aligned properly.
authorConstantin Kaplinsky <const@tightvnc.com>
Tue, 23 May 2006 06:33:03 +0000 (06:33 +0000)
committerConstantin Kaplinsky <const@tightvnc.com>
Tue, 23 May 2006 06:33:03 +0000 (06:33 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@578 3789f03b-4d11-0410-bbf8-ca57d06f2519

x0vncserver/x0vncserver.cxx

index d3423830d59f074a6785658ffb8d5b3f152abf99..80483bf89f0d58aeff1977e5126979e325badf21 100644 (file)
@@ -131,6 +131,27 @@ private:
 };
 
 
+//
+// XPixelBuffer is a modification of FullFramePixelBuffer that does
+// not always return buffer width in getStride().
+//
+
+class XPixelBuffer : public FullFramePixelBuffer
+{
+public:
+  XPixelBuffer(const PixelFormat& pf, int width, int height,
+               rdr::U8* data_, ColourMap* cm, int stride_) :
+    FullFramePixelBuffer(pf, width, height, data_, cm), stride(stride_)
+  {
+  }
+
+  virtual int getStride() const { return stride; }
+
+protected:
+  int stride;
+};
+
+
 class XDesktop : public SDesktop, public ColourMap
 {
 public:
@@ -195,8 +216,12 @@ public:
     pf.greenMax   = image->xim->green_mask >> pf.greenShift;
     pf.blueMax    = image->xim->blue_mask  >> pf.blueShift;
 
-    pb = new FullFramePixelBuffer(pf, geometry->width(), geometry->height(),
-                                  (rdr::U8*)image->xim->data, this);
+    // Calculate the number of pixels in a row, with padding included.
+    int stride = image->xim->bytes_per_line * 8 / image->xim->bits_per_pixel;
+
+    // Provide pixel buffer to the server object.
+    pb = new XPixelBuffer(pf, geometry->width(), geometry->height(),
+                          (rdr::U8*)image->xim->data, this, stride);
     server = vs;
     server->setPixelBuffer(pb);