summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-09-29 22:37:09 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-09-29 22:37:09 (GMT)
commit3fa715ef374d9f9064abb421fae6534f745ea9f8 (patch)
tree4256d33f0c8e81df96716f84dee3acb8a7820cef
parent8c3bf71e6fcbcfb21b9574e25cfdb00614a0c68d (diff)
downloadQt-3fa715ef374d9f9064abb421fae6534f745ea9f8.zip
Qt-3fa715ef374d9f9064abb421fae6534f745ea9f8.tar.gz
Qt-3fa715ef374d9f9064abb421fae6534f745ea9f8.tar.bz2
Make QPF's implementation of alphaMapForGlyph() consistent.
The QPF implementation of alphaMapForGlyph() was returning color values of RGBA = (a, a, a, 255) instead of (0, 0, 0, a), which was inconsistent with all the other font engines. This inconsistency caused some QPF-specific workarounds in the OpenGL and OpenVG paint engines. This change removes the workarounds and makes QPF generate the right colors from the start. Paint engines that ignore the color table or which don't use the alphaMapForGlyph() function (e.g. raster) are not affected. Reviewed-by: Paul
-rw-r--r--src/gui/text/qfontengine_qpf.cpp4
-rw-r--r--src/gui/text/qfontengine_qws.cpp4
-rw-r--r--src/opengl/qpaintengine_opengl.cpp16
-rw-r--r--src/openvg/qpaintengine_vg.cpp14
4 files changed, 5 insertions, 33 deletions
diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp
index 996e471..ef3f2ae 100644
--- a/src/gui/text/qfontengine_qpf.cpp
+++ b/src/gui/text/qfontengine_qpf.cpp
@@ -628,13 +628,13 @@ QImage QFontEngineQPF::alphaMapForGlyph(glyph_t g)
{
const Glyph *glyph = findGlyph(g);
if (!glyph)
- QImage();
+ return QImage();
const uchar *bits = ((const uchar *) glyph) + sizeof(Glyph);
QImage image(glyph->width, glyph->height, QImage::Format_Indexed8);
for (int j=0; j<256; ++j)
- image.setColor(j, 0xff000000 | j | (j<<8) | (j<<16));
+ image.setColor(j, qRgba(0, 0, 0, j));
for (int i=0; i<glyph->height; ++i) {
memcpy(image.scanLine(i), bits, glyph->bytesPerLine);
diff --git a/src/gui/text/qfontengine_qws.cpp b/src/gui/text/qfontengine_qws.cpp
index 888e1be..de8028c 100644
--- a/src/gui/text/qfontengine_qws.cpp
+++ b/src/gui/text/qfontengine_qws.cpp
@@ -528,10 +528,12 @@ QImage QFontEngineQPF1::alphaMapForGlyph(glyph_t g)
QImage image;
if (mono) {
image = QImage((glyph->metrics->width+7)&~7, glyph->metrics->height, QImage::Format_Mono);
+ image.setColor(0, qRgba(0, 0, 0, 0));
+ image.setColor(1, qRgba(0, 0, 0, 255));
} else {
image = QImage(glyph->metrics->width, glyph->metrics->height, QImage::Format_Indexed8);
for (int j=0; j<256; ++j)
- image.setColor(j, 0xff000000 | j | (j<<8) | (j<<16));
+ image.setColor(j, qRgba(0, 0, 0, j));
}
for (int i=0; i<glyph->metrics->height; ++i) {
memcpy(image.scanLine(i), bits, glyph->metrics->linestep);
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index bd3883a..a904064 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -4791,22 +4791,6 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, const QTextItemInt &ti,
}
QImage glyph_im(ti.fontEngine->alphaMapForGlyph(glyphs[i]));
-
- // The QPF implementation of alphaMapForGlyph() uses the color
- // RGBA = (value, value, value, 255) instead of the color
- // RGBA = (0, 0, 0, value) that the other font engines use.
- // We modify the image colors to rectify this situation.
- QFontEngine::Type type = ti.fontEngine->type();
- if (type == QFontEngine::QPF1 || type == QFontEngine::QPF2) {
- if (glyph_im.format() == QImage::Format_Indexed8) {
- for (int i = 0; i < 256; ++i)
- glyph_im.setColor(i, qRgba(0, 0, 0, i));
- } else if (glyph_im.format() == QImage::Format_Mono) {
- glyph_im.setColor(0, qRgba(0, 0, 0, 0));
- glyph_im.setColor(1, qRgba(0, 0, 0, 255));
- }
- }
-
glyph_im = glyph_im.convertToFormat(QImage::Format_Indexed8);
glyph_width = glyph_im.width();
Q_ASSERT(glyph_width >= 0);
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 3558c28..b129164 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -3023,20 +3023,6 @@ void QVGFontGlyphCache::cacheGlyphs
VGImage vgImage = VG_INVALID_HANDLE;
metrics = ti.fontEngine->boundingBox(glyph);
if (!scaledImage.isNull()) { // Not a space character
- // The QPF implementation of alphaMapForGlyph() uses the color
- // RGBA = (value, value, value, 255) instead of the color
- // RGBA = (0, 0, 0, value) that the other font engines use.
- // We modify the image colors to rectify this situation.
- QFontEngine::Type type = ti.fontEngine->type();
- if (type == QFontEngine::QPF1 || type == QFontEngine::QPF2) {
- if (scaledImage.format() == QImage::Format_Indexed8) {
- for (int i = 0; i < 256; ++i)
- scaledImage.setColor(i, qRgba(0, 0, 0, i));
- } else if (scaledImage.format() == QImage::Format_Mono) {
- scaledImage.setColor(0, qRgba(0, 0, 0, 0));
- scaledImage.setColor(1, qRgba(0, 0, 0, 255));
- }
- }
if (scaledImage.format() == QImage::Format_Indexed8) {
vgImage = vgCreateImage(VG_A_8, scaledImage.width(), scaledImage.height(), VG_IMAGE_QUALITY_FASTER);
vgImageSubData(vgImage, scaledImage.bits(), scaledImage.bytesPerLine(), VG_A_8, 0, 0, scaledImage.width(), scaledImage.height());