From bf79f6850941c57c630f546e0093fe32ef743b3e Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 19 Aug 2011 16:08:09 +0000 Subject: [PATCH] Do register reduction to re-normalize the performance at the low level git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4643 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/PixelFormat.cxx | 27 +++++++++++++++++++-------- common/rfb/tightEncode.h | 11 +++++++---- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/common/rfb/PixelFormat.cxx b/common/rfb/PixelFormat.cxx index 013cceb2..b51adab2 100644 --- a/common/rfb/PixelFormat.cxx +++ b/common/rfb/PixelFormat.cxx @@ -315,27 +315,38 @@ void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, bindex = blueShift/8; } - for(rowptr = (rdr::U8 *)src; rowptr < &src[pitch * h]; rowptr += pitch) { - for(colptr = rowptr; colptr < &rowptr[w * 4]; colptr += 4) { - *(dst++) = colptr[rindex]; - *(dst++) = colptr[gindex]; - *(dst++) = colptr[bindex]; + int srcPad = pitch - w * 4; + while (h > 0) { + rdr::U8 *srcEndOfRow = (rdr::U8 *)src + w * 4; + while (src < srcEndOfRow) { + *(dst++) = src[rindex]; + *(dst++) = src[gindex]; + *(dst++) = src[bindex]; + src += 4; } + src += srcPad; + h--; } } else { // Generic code Pixel p; rdr::U8 r, g, b; + int pixelSize = bpp/8; - for(rowptr = (rdr::U8 *)src; rowptr < &src[pitch * h]; rowptr += pitch) { - for(colptr = rowptr; colptr < &rowptr[w * bpp/8]; colptr += bpp/8) { - p = pixelFromBuffer(colptr); + int srcPad = pitch - w * pixelSize; + while (h > 0) { + rdr::U8 *srcEndOfRow = (rdr::U8 *)src + w * pixelSize; + while (src < srcEndOfRow) { + p = pixelFromBuffer(src); rgbFromPixel(p, cm, &r, &g, &b); *(dst++) = r; *(dst++) = g; *(dst++) = b; + src += pixelSize; } + src += srcPad; + h--; } } } diff --git a/common/rfb/tightEncode.h b/common/rfb/tightEncode.h index e8d3ef44..407c9d69 100644 --- a/common/rfb/tightEncode.h +++ b/common/rfb/tightEncode.h @@ -647,12 +647,15 @@ bool CHECK_SOLID_TILE(Rect& r, rdr::U32 *colorPtr, bool needSameColor) if (needSameColor && (rdr::U32)colorValue != *colorPtr) return false; - for (dy = 0; dy < h; dy++) { - for (dx = 0; dx < w; dx++) { - if (colorValue != buf[dx]) + int bufPad = stride - w; + while (h > 0) { + PIXEL_T *bufEndOfRow = buf + w; + while (buf < bufEndOfRow) { + if (colorValue != *(buf++)) return false; } - buf += stride; + buf += bufPad; + h--; } *colorPtr = (rdr::U32)colorValue; -- 2.39.5