From: Pierre Ossman Date: Thu, 9 Oct 2014 14:47:45 +0000 (+0200) Subject: Use constants for the test buffer dimensions X-Git-Tag: v1.3.90~23^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=387bf9b3866989e0bb736ef83e2f4510db4132f6;p=tigervnc.git Use constants for the test buffer dimensions --- diff --git a/tests/conv.cxx b/tests/conv.cxx index 22c86c4e..b4d1f014 100644 --- a/tests/conv.cxx +++ b/tests/conv.cxx @@ -26,6 +26,12 @@ static const rdr::U8 pixelRed = 0xf1; static const rdr::U8 pixelGreen = 0xc3; static const rdr::U8 pixelBlue = 0x97; +static const int fbWidth = 40; +static const int fbHeight = 30; +static const int fbArea = fbWidth * fbHeight; +// Maximum bpp, plus some room for unaligned fudging +static const int fbMalloc = (fbArea * 4) + 4; + typedef bool (*testfn) (const rfb::PixelFormat&, const rfb::PixelFormat&); struct TestEntry { @@ -117,27 +123,27 @@ static bool testBuffer(const rfb::PixelFormat &dstpf, const rfb::PixelFormat &srcpf) { int i, unaligned; - rdr::U8 bufIn[1024 + 1], bufOut[1024 + 1]; + rdr::U8 bufIn[fbMalloc], bufOut[fbMalloc]; // Once aligned, and once unaligned for (unaligned = 0;unaligned < 2;unaligned++) { - for (i = 0;i < 1024/4;i++) + for (i = 0;i < fbArea;i++) makePixel(srcpf, bufIn + unaligned + i*srcpf.bpp/8); memset(bufOut, 0, sizeof(bufOut)); dstpf.bufferFromBuffer(bufOut + unaligned, srcpf, - bufIn + unaligned, 1024/4); + bufIn + unaligned, fbArea); - for (i = 0;i < 1024/4;i++) { + for (i = 0;i < fbArea;i++) { if (!verifyPixel(dstpf, srcpf, bufOut + unaligned + i*dstpf.bpp/8)) return false; } memset(bufOut, 0, sizeof(bufOut)); dstpf.bufferFromBuffer(bufOut + unaligned, srcpf, bufIn + unaligned, - 1024/4/10, 10, 1024/4/10, 1024/4/10); + fbWidth, fbHeight, fbWidth, fbWidth); - for (i = 0;i < 1024/4/10*10;i++) { + for (i = 0;i < fbArea;i++) { if (!verifyPixel(dstpf, srcpf, bufOut + unaligned + i*dstpf.bpp/8)) return false; } @@ -150,33 +156,33 @@ static bool testRGB(const rfb::PixelFormat &dstpf, const rfb::PixelFormat &srcpf) { int i, unaligned; - rdr::U8 bufIn[1024 + 1], bufRGB[1024 + 1], bufOut[1024 + 1]; + rdr::U8 bufIn[fbMalloc], bufRGB[fbMalloc], bufOut[fbMalloc]; // Once aligned, and once unaligned for (unaligned = 0;unaligned < 2;unaligned++) { - for (i = 0;i < 1024/4;i++) + for (i = 0;i < fbArea;i++) makePixel(srcpf, bufIn + unaligned + i*srcpf.bpp/8); memset(bufRGB, 0, sizeof(bufRGB)); - srcpf.rgbFromBuffer(bufRGB + unaligned, bufIn + unaligned, 1024/4); + srcpf.rgbFromBuffer(bufRGB + unaligned, bufIn + unaligned, fbArea); memset(bufOut, 0, sizeof(bufOut)); - dstpf.bufferFromRGB(bufOut + unaligned, bufRGB + unaligned, 1024/4); + dstpf.bufferFromRGB(bufOut + unaligned, bufRGB + unaligned, fbArea); - for (i = 0;i < 1024/4;i++) { + for (i = 0;i < fbArea;i++) { if (!verifyPixel(dstpf, srcpf, bufOut + unaligned + i*dstpf.bpp/8)) return false; } memset(bufRGB, 0, sizeof(bufRGB)); srcpf.rgbFromBuffer(bufRGB + unaligned, bufIn + unaligned, - 1024/4/10, 1024/4/10, 10); + fbWidth, fbWidth, fbHeight); memset(bufOut, 0, sizeof(bufOut)); dstpf.bufferFromRGB(bufOut + unaligned, bufRGB + unaligned, - 1024/4/10, 1024/4/10, 10); + fbWidth, fbWidth, fbHeight); - for (i = 0;i < 1024/4/10*10;i++) { + for (i = 0;i < fbArea;i++) { if (!verifyPixel(dstpf, srcpf, bufOut + unaligned + i*dstpf.bpp/8)) return false; }