aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2015-02-06 13:51:35 +0100
committerPierre Ossman <ossman@cendio.se>2015-02-27 09:19:20 +0100
commiteb2e24db7b4fc645aa10602d78b1bc6a38ed2543 (patch)
treed8fdda5a95edf80bfb16f6f3e2cb64238cd25cec
parent1fefeafa642dbd76d9c9cd85c5b23c422bb09876 (diff)
downloadtigervnc-eb2e24db7b4fc645aa10602d78b1bc6a38ed2543.tar.gz
tigervnc-eb2e24db7b4fc645aa10602d78b1bc6a38ed2543.zip
Optimise fillRect()
It had regressed in performance compared to 1.3. This brings it back up to the same speed. (cherry picked from commit a43a3f4e0e1ae9faa389a91ad9a38db4af4c54c8)
-rw-r--r--common/rfb/PixelBuffer.cxx32
1 files changed, 26 insertions, 6 deletions
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx
index b1359c2e..b03af1af 100644
--- a/common/rfb/PixelBuffer.cxx
+++ b/common/rfb/PixelBuffer.cxx
@@ -99,23 +99,43 @@ ModifiablePixelBuffer::~ModifiablePixelBuffer()
void ModifiablePixelBuffer::fillRect(const Rect& r, Pixel pix)
{
int stride;
- U8 *buf, pixbuf[4];
+ U8 *buf;
int w, h, b;
- buf = getBufferRW(r, &stride);
w = r.width();
h = r.height();
b = format.bpp/8;
- format.bufferFromPixel(pixbuf, pix);
+ if (h == 0)
+ return;
+
+ buf = getBufferRW(r, &stride);
- while (h--) {
- int w_ = w;
- while (w_--) {
+ if (b == 1) {
+ while (h--) {
+ memset(buf, pix, w);
+ buf += stride * b;
+ }
+ } else {
+ U8 pixbuf[4], *start;
+ int w1;
+
+ start = buf;
+
+ format.bufferFromPixel(pixbuf, pix);
+
+ w1 = w;
+ while (w1--) {
memcpy(buf, pixbuf, b);
buf += b;
}
buf += (stride - w) * b;
+ h--;
+
+ while (h--) {
+ memcpy(buf, start, w * b);
+ buf += stride * b;
+ }
}
commitBufferRW(r);