Split decoders into a read and decode step

We need to split these steps up in preparation for multi-core
support. Reading needs to be done in a serial manner, whilst
decoding can be done in parallel.

This also involved a rather large cleanup of the Tight decoder.
diff --git a/common/rfb/RawDecoder.cxx b/common/rfb/RawDecoder.cxx
index 292c343..e349bda 100644
--- a/common/rfb/RawDecoder.cxx
+++ b/common/rfb/RawDecoder.cxx
@@ -15,7 +15,10 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  */
-#include <rdr/InStream.h>
+
+#include <assert.h>
+
+#include <rdr/OutStream.h>
 #include <rfb/ConnParams.h>
 #include <rfb/PixelBuffer.h>
 #include <rfb/RawDecoder.h>
@@ -31,36 +34,15 @@
 }
 
 void RawDecoder::readRect(const Rect& r, rdr::InStream* is,
-                          const ConnParams& cp, ModifiablePixelBuffer* pb)
+                          const ConnParams& cp, rdr::OutStream* os)
 {
-  const PixelFormat& pf = cp.pf();
+  os->copyBytes(is, r.area() * cp.pf().bpp/8);
+}
 
-  rdr::U8 imageBuf[16384];
-  const int maxPixels = sizeof(imageBuf) / (pf.bpp/8);
-
-  int x = r.tl.x;
-  int y = r.tl.y;
-  int w = r.width();
-  int h = r.height();
-
-  while (h > 0) {
-    int dx;
-
-    dx = 0;
-    while (dx < w) {
-      int dw;
-
-      dw = maxPixels;
-      if (dx + dw > w)
-        dw = w - dx;
-
-      is->readBytes(imageBuf, dw * pf.bpp/8);
-      pb->imageRect(pf, Rect(x+dx, y, x+dx+dw, y+1), imageBuf);
-
-      dx += dw;
-    }
-
-    y++;
-    h--;
-  }
+void RawDecoder::decodeRect(const Rect& r, const void* buffer,
+                            size_t buflen, const ConnParams& cp,
+                            ModifiablePixelBuffer* pb)
+{
+  assert(buflen >= (size_t)r.area() * cp.pf().bpp/8);
+  pb->imageRect(cp.pf(), r, buffer);
 }