diff options
author | Pierre Ossman <ossman@cendio.se> | 2014-01-30 16:59:14 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2014-07-07 14:50:29 +0200 |
commit | 5c1a1536db0bd3f59e8c9ed0fd8a0a0fb8108ef2 (patch) | |
tree | cc8aa2c9e63a39bd6bde16b550321b747a7d1d8d /common | |
parent | 1b350ed9127e43863157a7a4453405fdf0cbb617 (diff) | |
download | tigervnc-5c1a1536db0bd3f59e8c9ed0fd8a0a0fb8108ef2.tar.gz tigervnc-5c1a1536db0bd3f59e8c9ed0fd8a0a0fb8108ef2.zip |
We don't need a fillRect() that is this optimised
Keep things simple instead and allows us to remove the extra setPF()
methods.
Diffstat (limited to 'common')
-rw-r--r-- | common/rfb/PixelBuffer.cxx | 98 | ||||
-rw-r--r-- | common/rfb/PixelBuffer.h | 4 |
2 files changed, 19 insertions, 83 deletions
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx index 7f4c3440..ace0934d 100644 --- a/common/rfb/PixelBuffer.cxx +++ b/common/rfb/PixelBuffer.cxx @@ -60,63 +60,10 @@ PixelBuffer::getImage(void* imageBuf, const Rect& r, int outStride) { } -static void fillRect8(U8 *buf, int stride, const Rect& r, Pixel pix) -{ - U8* ptr = buf; - int w = r.width(), h = r.height(); - - while (h > 0) { - memset(ptr, pix, w); - ptr += stride; - h--; - } -} - -static void fillRect16(U8 *buf, int stride, const Rect& r, Pixel pix) -{ - U16* ptr = (U16 *)buf; - int w = r.width(), h = r.height(), wBytes = w * 2; - - while (w > 0) { - *ptr++ = pix; w--; - } - h--; - - ptr = (U16 *)buf; - - while (h > 0) { - U16 *oldptr = ptr; - memcpy(ptr += stride, oldptr, wBytes); - h--; - } -} - -static void fillRect32(U8 *buf, int stride, const Rect& r, Pixel pix) -{ - U32* ptr = (U32 *)buf; - int w = r.width(), h = r.height(), wBytes = w * 4; - - while (w > 0) { - *ptr++ = pix; w--; - } - h--; - - ptr = (U32 *)buf; - - while (h > 0) { - U32 *oldptr = ptr; - memcpy(ptr += stride, oldptr, wBytes); - h--; - } -} - - FullFramePixelBuffer::FullFramePixelBuffer(const PixelFormat& pf, int w, int h, rdr::U8* data_) : PixelBuffer(pf, w, h), data(data_) { - // Called again to configure the fill function - setPF(pf); } FullFramePixelBuffer::FullFramePixelBuffer() : data(0) {} @@ -124,29 +71,6 @@ 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; - break; - case 16: - fillRectFn = fillRect16; - break; - case 32: - fillRectFn = fillRect32; - break; - default: - throw Exception("rfb::FullFramePixelBuffer - Unsupported pixel format"); - } -} - - int FullFramePixelBuffer::getStride() const { return width(); } rdr::U8* FullFramePixelBuffer::getBufferRW(const Rect& r, int* stride) @@ -158,8 +82,24 @@ rdr::U8* FullFramePixelBuffer::getBufferRW(const Rect& r, int* stride) void FullFramePixelBuffer::fillRect(const Rect& r, Pixel pix) { int stride; - U8 *buf = getBufferRW(r, &stride); - fillRectFn(buf, stride, r, pix); + U8 *buf, pixbuf[4]; + int w, h, b; + + buf = getBufferRW(r, &stride); + w = r.width(); + h = r.height(); + b = format.bpp/8; + + format.bufferFromPixel(pixbuf, pix); + + while (h--) { + int w_ = w; + while (w_--) { + memcpy(buf, pixbuf, b); + buf += b; + } + buf += (stride - w) * b; + } } void FullFramePixelBuffer::imageRect(const Rect& r, const void* pixels, int srcStride) { @@ -327,7 +267,7 @@ ManagedPixelBuffer::~ManagedPixelBuffer() { void ManagedPixelBuffer::setPF(const PixelFormat &pf) { - FullFramePixelBuffer::setPF(pf); checkDataSize(); + format = pf; checkDataSize(); }; void ManagedPixelBuffer::setSize(int w, int h) { diff --git a/common/rfb/PixelBuffer.h b/common/rfb/PixelBuffer.h index ad30cf22..bff28021 100644 --- a/common/rfb/PixelBuffer.h +++ b/common/rfb/PixelBuffer.h @@ -83,8 +83,6 @@ namespace rfb { virtual void grabRegion(const Region& region) {} protected: - // Only for subclasses that support changing parameters - void setPF(const PixelFormat &pf) { format = pf; } PixelBuffer(); PixelFormat format; int width_, height_; @@ -136,9 +134,7 @@ namespace rfb { rdr::U8* data; protected: - void setPF(const PixelFormat &pf); FullFramePixelBuffer(); - void (*fillRectFn)(rdr::U8 *, int, const Rect&, Pixel); }; // -=- Managed pixel buffer class |