From 8c183dc88d4ba0c14e29433294a6885f29ffc36c Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Thu, 28 Oct 2010 11:35:53 +0200 Subject: Use QVarLengthArray to store accumulator data. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 2499 Reviewed-by: Samuel Rødal --- src/plugins/graphicssystems/meego/dithering.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/graphicssystems/meego/dithering.cpp b/src/plugins/graphicssystems/meego/dithering.cpp index ba6b99b..b50826c 100644 --- a/src/plugins/graphicssystems/meego/dithering.cpp +++ b/src/plugins/graphicssystems/meego/dithering.cpp @@ -54,6 +54,7 @@ #include #include #include +#include // Gets a component (red = 1, green = 2...) from a RGBA data structure. // data is unsigned char. stride is the number of bytes per line. @@ -95,7 +96,11 @@ unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int h int x, y, c; // Pixel we're processing. c is component number (0, 1, 2 for r, b, b) short component[3]; // Stores the new components (r, g, b) for pixel produced during conversion short diff; // The difference between the converted value and the original one. To be accumulated. - short accumulator[3][width * 2]; // Three acumulators for r, g, b. Each accumulator is two lines. + QVarLengthArray accumulatorData(3 * width * 2); // Data for three acumulators for r, g, b. Each accumulator is two lines. + short *accumulator[3]; // Helper for accessing the accumulator on a per-channel basis more easily. + accumulator[0] = accumulatorData.data(); + accumulator[1] = accumulatorData.data() + width; + accumulator[2] = accumulatorData.data() + (width * 2); // Produce the conversion lookup tables. for (i = 0; i < 256; i++) { @@ -195,7 +200,12 @@ unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, in int x, y, c; // Pixel we're processing. c is component number (0, 1, 2, 3 for r, b, b, a) short component[4]; // Stores the new components (r, g, b, a) for pixel produced during conversion short diff; // The difference between the converted value and the original one. To be accumulated. - short accumulator[4][width * 2]; // Four acumulators for r, g, b, a. Each accumulator is two lines. + QVarLengthArray accumulatorData(4 * width * 2); // Data for three acumulators for r, g, b. Each accumulator is two lines. + short *accumulator[4]; // Helper for accessing the accumulator on a per-channel basis more easily. + accumulator[0] = accumulatorData.data(); + accumulator[1] = accumulatorData.data() + width; + accumulator[2] = accumulatorData.data() + (width * 2); + accumulator[3] = accumulatorData.data() + (width * 3); // Produce the conversion lookup tables. for (i = 0; i < 256; i++) { -- cgit v0.12