diff options
author | Pierre Ossman <ossman@cendio.se> | 2014-02-13 10:38:48 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2014-07-09 16:31:05 +0200 |
commit | 9da47f879e4d913d39cf346702647c802fb452a3 (patch) | |
tree | ec2af9d0b376b21f6c1b1a5cb6c30091f3222845 | |
parent | acc387c1eb5d93640fae45459b9f7c321d7f9eef (diff) | |
download | tigervnc-9da47f879e4d913d39cf346702647c802fb452a3.tar.gz tigervnc-9da47f879e4d913d39cf346702647c802fb452a3.zip |
Add convenience functions to ModifiablePixelBuffer
Allows you to modify the buffer with data in a
different pixel format.
-rw-r--r-- | common/rfb/PixelBuffer.cxx | 22 | ||||
-rw-r--r-- | common/rfb/PixelBuffer.h | 7 |
2 files changed, 29 insertions, 0 deletions
diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx index 187150d9..ed74a874 100644 --- a/common/rfb/PixelBuffer.cxx +++ b/common/rfb/PixelBuffer.cxx @@ -268,6 +268,28 @@ void ModifiablePixelBuffer::copyRect(const Rect &rect, commitBufferRW(drect); } +void ModifiablePixelBuffer::fillRect(const PixelFormat& pf, const Rect &dest, + Pixel pix) +{ + fillRect(dest, format.pixelFromPixel(pf, pix)); +} + +void ModifiablePixelBuffer::imageRect(const PixelFormat& pf, const Rect &dest, + const void* pixels, int stride) +{ + rdr::U8* dstBuffer; + int dstStride; + + if (stride == 0) + stride = dest.width(); + + dstBuffer = getBufferRW(dest, &dstStride); + format.bufferFromBuffer(dstBuffer, pf, (const rdr::U8*)pixels, + dest.width(), dest.height(), + dstStride, stride); + commitBufferRW(dest); +} + // -=- Simple pixel buffer with a continuous block of memory FullFramePixelBuffer::FullFramePixelBuffer(const PixelFormat& pf, int w, int h, diff --git a/common/rfb/PixelBuffer.h b/common/rfb/PixelBuffer.h index e2cc3e92..7060a014 100644 --- a/common/rfb/PixelBuffer.h +++ b/common/rfb/PixelBuffer.h @@ -137,6 +137,13 @@ namespace rfb { // pixel is the Pixel value to be used where mask_ is set void maskRect(const Rect& r, Pixel pixel, const void* mask_); + // Render in a specific format + // Does the exact same thing as the above methods, but the given + // pixel values are defined by the given PixelFormat. + void fillRect(const PixelFormat& pf, const Rect &dest, Pixel pix); + void imageRect(const PixelFormat& pf, const Rect &dest, + const void* pixels, int stride=0); + protected: ModifiablePixelBuffer(); }; |