Change fillRect() to take a buffer instead of a pixel
There has been some confusion if fillRect() should accept a buffer
or a pixel. This can cause misrendering if your data is not in the
native endian order. A buffer makes more sense here though, and
is what most of the callers are already assuming, so change the
API to follow that.
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx
index b03af1a..89addab 100644
--- a/common/rfb/PixelBuffer.cxx
+++ b/common/rfb/PixelBuffer.cxx
@@ -96,7 +96,7 @@
{
}
-void ModifiablePixelBuffer::fillRect(const Rect& r, Pixel pix)
+void ModifiablePixelBuffer::fillRect(const Rect& r, const void* pix)
{
int stride;
U8 *buf;
@@ -113,20 +113,18 @@
if (b == 1) {
while (h--) {
- memset(buf, pix, w);
+ memset(buf, *(const U8*)pix, w);
buf += stride * b;
}
} else {
- U8 pixbuf[4], *start;
+ U8 *start;
int w1;
start = buf;
- format.bufferFromPixel(pixbuf, pix);
-
w1 = w;
while (w1--) {
- memcpy(buf, pixbuf, b);
+ memcpy(buf, pix, b);
buf += b;
}
buf += (stride - w) * b;
@@ -309,9 +307,11 @@
}
void ModifiablePixelBuffer::fillRect(const PixelFormat& pf, const Rect &dest,
- Pixel pix)
+ const void* pix)
{
- fillRect(dest, format.pixelFromPixel(pf, pix));
+ rdr::U8 buf[4];
+ format.bufferFromBuffer(buf, pf, (const rdr::U8*)pix, 1);
+ fillRect(dest, buf);
}
void ModifiablePixelBuffer::imageRect(const PixelFormat& pf, const Rect &dest,