From b266561b0c6e97fe0669fb25719503aa608237ce Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 30 Jan 2014 09:51:39 +0100 Subject: [PATCH] Avoid code duplication for the linear pixel format conversion methods --- common/rfb/PixelFormat.cxx | 81 +------------------------------------- 1 file changed, 2 insertions(+), 79 deletions(-) diff --git a/common/rfb/PixelFormat.cxx b/common/rfb/PixelFormat.cxx index 6a5fc96d..b11f8836 100644 --- a/common/rfb/PixelFormat.cxx +++ b/common/rfb/PixelFormat.cxx @@ -135,48 +135,7 @@ bool PixelFormat::isLittleEndian(void) const void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, int pixels, ColourMap* cm) const { - if (is888()) { - // Optimised common case - rdr::U8 *r, *g, *b, *x; - - if (bigEndian) { - r = dst + (24 - redShift)/8; - g = dst + (24 - greenShift)/8; - b = dst + (24 - blueShift)/8; - x = dst + (24 - (48 - redShift - greenShift - blueShift))/8; - } else { - r = dst + redShift/8; - g = dst + greenShift/8; - b = dst + blueShift/8; - x = dst + (48 - redShift - greenShift - blueShift)/8; - } - - while (pixels--) { - *r = *(src++); - *g = *(src++); - *b = *(src++); - *x = 0; - r += 4; - g += 4; - b += 4; - x += 4; - } - } else { - // Generic code - Pixel p; - rdr::U8 r, g, b; - - while (pixels--) { - r = *(src++); - g = *(src++); - b = *(src++); - - p = pixelFromRGB(r, g, b, cm); - - bufferFromPixel(dst, p); - dst += bpp/8; - } - } + bufferFromRGB(dst, src, pixels, pixels, 1, cm); } void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src, @@ -254,43 +213,7 @@ void PixelFormat::rgbFromPixel(Pixel p, ColourMap* cm, Colour* rgb) const void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, int pixels, ColourMap* cm) const { - if (is888()) { - // Optimised common case - const rdr::U8 *r, *g, *b; - - if (bigEndian) { - r = src + (24 - redShift)/8; - g = src + (24 - greenShift)/8; - b = src + (24 - blueShift)/8; - } else { - r = src + redShift/8; - g = src + greenShift/8; - b = src + blueShift/8; - } - - while (pixels--) { - *(dst++) = *r; - *(dst++) = *g; - *(dst++) = *b; - r += 4; - g += 4; - b += 4; - } - } else { - // Generic code - Pixel p; - rdr::U8 r, g, b; - - while (pixels--) { - p = pixelFromBuffer(src); - src += bpp/8; - - rgbFromPixel(p, cm, &r, &g, &b); - *(dst++) = r; - *(dst++) = g; - *(dst++) = b; - } - } + rgbFromBuffer(dst, src, pixels, pixels, 1, cm); } -- 2.39.5