diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-03 06:30:53 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-03 06:30:53 (GMT) |
commit | 966613212de269421944a5df355f54c5a6b36c17 (patch) | |
tree | c03f711c29571ce3ce4d8c0f23215d57d3458d2a /src/plugins | |
parent | 69ab0cd2b51a86fe27c92c7c18390f6791939b53 (diff) | |
parent | 891221a3f0c952817eb7891b9243827edda61085 (diff) | |
download | Qt-966613212de269421944a5df355f54c5a6b36c17.zip Qt-966613212de269421944a5df355f54c5a6b36c17.tar.gz Qt-966613212de269421944a5df355f54c5a6b36c17.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
Fix Malayalam Rendering - 'Ra' is PreBase
Update .def files for QtGui and QtOpenVG
Use 32bit textures for alpha textures after all.
One more fix for dithering.
Doc: Fixing typo
Fix QTBUG-14640:oci performance problem with qlonglong
32bit => 16bit conversion has 4byte-aligned output.
Fix gcc bug in qReallocAligned
Prevented threading related crash in OpenGL module.
Fix possible crash in QStaticText and QDeclarativeTextLayout
Fix QTBUG-14132 oracle (xe) stored procedures with bind variables get errors
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/graphicssystems/meego/dithering.cpp | 53 | ||||
-rw-r--r-- | src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp | 5 |
2 files changed, 44 insertions, 14 deletions
diff --git a/src/plugins/graphicssystems/meego/dithering.cpp b/src/plugins/graphicssystems/meego/dithering.cpp index b50826c..122c51e 100644 --- a/src/plugins/graphicssystems/meego/dithering.cpp +++ b/src/plugins/graphicssystems/meego/dithering.cpp @@ -68,7 +68,7 @@ // Writes(ads) a new value to the diffusion accumulator. accumulator is a short. // x, y is a position in the accumulation buffer. y can be 0 or 1 -- we operate on two lines at time. -#define ACCUMULATE(accumulator, x, y, width, v) if (x < width && x > 0) accumulator[(y * width) + x] += v +#define ACCUMULATE(accumulator, x, y, width, v) if (x < width && x >= 0) accumulator[(y * width) + x] += v // Clamps a value to be in 0..255 range. #define CLAMP_256(v) if (v > 255) v = 255; if (v < 0) v = 0; @@ -76,8 +76,13 @@ // Converts incoming RGB32 (QImage::Format_RGB32) to RGB565. Returns the newly allocated data. unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int height, int stride) { + // Output line stride. Alligned to 4 bytes. + int alignedWidth = width; + if (alignedWidth % 2 > 0) + alignedWidth++; + // Will store output - unsigned short *out = (unsigned short *) malloc(width * height * 2); + unsigned short *out = (unsigned short *) malloc(alignedWidth * height * 2); // Lookup tables for the 8bit => 6bit and 8bit => 5bit conversion unsigned char lookup_8bit_to_5bit[256]; @@ -105,18 +110,18 @@ unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int h // Produce the conversion lookup tables. for (i = 0; i < 256; i++) { lookup_8bit_to_5bit[i] = round(i / 8.0); - if (lookup_8bit_to_5bit[i] > 31) - lookup_8bit_to_5bit[i] -= 1; // Before bitshifts: (i * 8) - (... * 8 * 8) lookup_8bit_to_5bit_diff[i] = (i << 3) - (lookup_8bit_to_5bit[i] << 6); + if (lookup_8bit_to_5bit[i] > 31) + lookup_8bit_to_5bit[i] -= 1; lookup_8bit_to_6bit[i] = round(i / 4.0); - if (lookup_8bit_to_6bit[i] > 63) - lookup_8bit_to_6bit[i] -= 1; // Before bitshifts: (i * 8) - (... * 4 * 8) lookup_8bit_to_6bit_diff[i] = (i << 3) - (lookup_8bit_to_6bit[i] << 5); + if (lookup_8bit_to_6bit[i] > 63) + lookup_8bit_to_6bit[i] -= 1; } // Clear the accumulators @@ -174,7 +179,7 @@ unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int h } // Write the newly produced pixel - PUT_565(out, x, y, width, component[2], component[1], component[0]); + PUT_565(out, x, y, alignedWidth, component[2], component[1], component[0]); } } @@ -183,10 +188,16 @@ unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int h // Converts incoming RGBA32 (QImage::Format_ARGB32_Premultiplied) to RGB565. Returns the newly allocated data. // This function is similar (yet different) to the _565 variant but it makes sense to duplicate it here for simplicity. +// The output has each scan line aligned to 4 bytes (as expected by GL by default). unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, int height, int stride) { + // Output line stride. Alligned to 4 bytes. + int alignedWidth = width; + if (alignedWidth % 2 > 0) + alignedWidth++; + // Will store output - unsigned short *out = (unsigned short *) malloc(width * height * 2); + unsigned short *out = (unsigned short *) malloc(alignedWidth * 2 * height); // Lookup tables for the 8bit => 4bit conversion unsigned char lookup_8bit_to_4bit[256]; @@ -210,11 +221,11 @@ unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, in // Produce the conversion lookup tables. for (i = 0; i < 256; i++) { lookup_8bit_to_4bit[i] = round(i / 16.0); - if (lookup_8bit_to_4bit[i] > 15) - lookup_8bit_to_4bit[i] -= 1; - // Before bitshifts: (i * 8) - (... * 16 * 8) lookup_8bit_to_4bit_diff[i] = (i << 3) - (lookup_8bit_to_4bit[i] << 7); + + if (lookup_8bit_to_4bit[i] > 15) + lookup_8bit_to_4bit[i] = 15; } // Clear the accumulators @@ -269,9 +280,27 @@ unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, in } // Write the newly produced pixel - PUT_4444(out, x, y, width, component[0], component[1], component[2], component[3]); + PUT_4444(out, x, y, alignedWidth, component[0], component[1], component[2], component[3]); } } return out; } + +unsigned char* convertBGRA32_to_RGBA32(const unsigned char *in, int width, int height, int stride) +{ + unsigned char *out = (unsigned char *) malloc(stride * height); + + // For each line... + for (int y = 0; y < height; y++) { + // For each column + for (int x = 0; x < width; x++) { + out[(stride * y) + (x * 4) + 0] = in[(stride * y) + (x * 4) + 2]; + out[(stride * y) + (x * 4) + 1] = in[(stride * y) + (x * 4) + 1]; + out[(stride * y) + (x * 4) + 2] = in[(stride * y) + (x * 4) + 0]; + out[(stride * y) + (x * 4) + 3] = in[(stride * y) + (x * 4) + 3]; + } + } + + return out; +}
\ No newline at end of file diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp index 02a4273..eb63692 100644 --- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp @@ -51,6 +51,7 @@ // from dithering.cpp extern unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int height, int stride); extern unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, int height, int stride); +extern unsigned char* convertBGRA32_to_RGBA32(const unsigned char *in, int width, int height, int stride); static EGLint preserved_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; @@ -146,8 +147,8 @@ Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image) glGenTextures(1, &textureId); glBindTexture(GL_TEXTURE_2D, textureId); if (image.hasAlphaChannel() && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()) { - void *converted = convertARGB32_to_RGBA4444(image.bits(), image.width(), image.height(), image.bytesPerLine()); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, converted); + void *converted = convertBGRA32_to_RGBA32(image.bits(), image.width(), image.height(), image.bytesPerLine()); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, converted); free(converted); } else { void *converted = convertRGB32_to_RGB565(image.bits(), image.width(), image.height(), image.bytesPerLine()); |