summaryrefslogtreecommitdiffstats
path: root/src/plugins/graphicssystems
diff options
context:
space:
mode:
authorMichael Dominic K <mdk@codethink.co.uk>2010-10-28 09:35:53 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2010-10-28 09:36:41 (GMT)
commit8c183dc88d4ba0c14e29433294a6885f29ffc36c (patch)
treecbc9627330290a46ed3a0fe8374f28b4b7cfbf62 /src/plugins/graphicssystems
parent96beb59dc7fb303debbbf06beb192158ab3476c2 (diff)
downloadQt-8c183dc88d4ba0c14e29433294a6885f29ffc36c.zip
Qt-8c183dc88d4ba0c14e29433294a6885f29ffc36c.tar.gz
Qt-8c183dc88d4ba0c14e29433294a6885f29ffc36c.tar.bz2
Use QVarLengthArray to store accumulator data.
Merge-request: 2499 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/plugins/graphicssystems')
-rw-r--r--src/plugins/graphicssystems/meego/dithering.cpp14
1 files 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 <stdio.h>
#include <stdlib.h>
#include <math.h>
+#include <QVarLengthArray>
// 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 <short> 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 <short> 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++) {