From b56dbaf5b3247bd8e87e4e856ad845593755c10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 28 Sep 2011 15:22:56 +0200 Subject: Fixed broken window surface flush when depth is 24 and bpp is not 32. Some X servers use a compact representation of 24 depth visuals. In that case we can't use the shared memory or XPutImage paths, as Qt's RGB32 does not match the internal memory layout. Also fixed QPixmap::fromImage() to work in this case to prevent the red and blue channels from being swapped. Task-number: QTBUG-21754 Reviewed-by: Alberto Mardegan --- src/gui/image/qnativeimage.cpp | 12 ++++++------ src/gui/image/qpixmap_x11.cpp | 18 +++++++++++++----- src/gui/kernel/qapplication_x11.cpp | 6 ++++++ src/gui/kernel/qt_x11_p.h | 2 ++ src/gui/painting/qwindowsurface_raster.cpp | 5 +++-- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index aebcbaf..e1382dd 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/image/qnativeimage.cpp @@ -153,7 +153,12 @@ QImage::Format QNativeImage::systemFormat() QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /* isTextBuffer */, QWidget *widget) : xshmimg(0), xshmpm(0) { - if (!X11->use_mitshm) { + QX11Info info = widget->x11Info(); + + int dd = info.depth(); + Visual *vis = (Visual*) info.visual(); + + if (!X11->use_mitshm || format != QImage::Format_RGB16 && X11->bppForDepth.value(dd) != 32) { image = QImage(width, height, format); // follow good coding practice and set xshminfo attributes, though values not used in this case xshminfo.readOnly = true; @@ -163,11 +168,6 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /* return; } - QX11Info info = widget->x11Info(); - - int dd = info.depth(); - Visual *vis = (Visual*) info.visual(); - xshmimg = XShmCreateImage(X11->display, vis, dd, ZPixmap, 0, &xshminfo, width, height); if (!xshmimg) { qWarning("QNativeImage: Unable to create shared XImage."); diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index 77c2a2a..0e1401c 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -897,12 +897,20 @@ void QX11PixmapData::fromImage(const QImage &img, } ) break; - case BPP24_888: // 24 bit MSB + case BPP24_888: CYCLE( - for (int x=0; xdefaultScreen = DefaultScreen(X11->display); X11->screenCount = ScreenCount(X11->display); + int formatCount = 0; + XPixmapFormatValues *values = XListPixmapFormats(X11->display, &formatCount); + for (int i = 0; i < formatCount; ++i) + X11->bppForDepth[values[i].depth] = values[i].bits_per_pixel; + XFree(values); + X11->screens = new QX11InfoData[X11->screenCount]; X11->argbVisuals = new Visual *[X11->screenCount]; X11->argbColormaps = new Colormap[X11->screenCount]; diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h index 72acaf3..fe4a631 100644 --- a/src/gui/kernel/qt_x11_p.h +++ b/src/gui/kernel/qt_x11_p.h @@ -54,6 +54,7 @@ // #include "QtGui/qwindowdefs.h" +#include "QtCore/qhash.h" #include "QtCore/qlist.h" #include "QtCore/qvariant.h" @@ -467,6 +468,7 @@ struct QX11Data Colormap *argbColormaps; int screenCount; int defaultScreen; + QHash bppForDepth; Time time; Time userTime; diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index 15ff044..2a25bff 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -254,8 +254,9 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi } else #endif { + int depth = widget->x11Info().depth(); const QImage &src = d->image->image; - if (src.format() != QImage::Format_RGB32 || widget->x11Info().depth() < 24) { + if (src.format() != QImage::Format_RGB32 || depth < 24 || X11->bppForDepth.value(depth) != 32) { Q_ASSERT(src.depth() >= 16); const QImage sub_src(src.scanLine(br.y()) + br.x() * (uint(src.depth()) / 8), br.width(), br.height(), src.bytesPerLine(), src.format()); @@ -267,7 +268,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi } else { // qpaintengine_x11.cpp extern void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image, Drawable hd, GC gc, Display *dpy, Visual *visual, int depth); - qt_x11_drawImage(br, wpos, src, widget->handle(), d_ptr->gc, X11->display, (Visual *)widget->x11Info().visual(), widget->x11Info().depth()); + qt_x11_drawImage(br, wpos, src, widget->handle(), d_ptr->gc, X11->display, (Visual *)widget->x11Info().visual(), depth); } } -- cgit v0.12 From 18943d3203a794f3f3173be6ec51c15db83db9e1 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 7 Oct 2011 13:56:35 +0200 Subject: omit unassigned (and too recent codepoints) from the text Normalization process > handle any code points that were not defined in the earlier version > as if they were unassigned: such code points will not decompose or compose, > and their Canonical_Combining_Class value will be zero. see http://www.unicode.org/reports/tr15/#Guaranteeing_Process_Stability for details we should respect that the QChar::Unicode_Unassigned == 0 and thus less than any other QChar::UnicodeVersion value Merge-request: 952 Reviewed-by: Jiang Jiang --- src/corelib/tools/qchar.cpp | 18 +++++++++++++----- src/corelib/tools/qstring.cpp | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 9db7d1a..b296129 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -1481,7 +1481,8 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion ucs4 = QChar::surrogateToUcs4(high, ucs4); } } - if (QChar::unicodeVersion(ucs4) > version) + QChar::UnicodeVersion v = QChar::unicodeVersion(ucs4); + if (v == QChar::Unicode_Unassigned || v > version) continue; int length; int tag; @@ -1541,7 +1542,7 @@ static ushort ligatureHelper(ushort u1, ushort u2) return 0; } -static void composeHelper(QString *str, int from) +static void composeHelper(QString *str, QChar::UnicodeVersion version, int from) { QString &s = *str; @@ -1561,7 +1562,14 @@ static void composeHelper(QString *str, int from) ++pos; } } - int combining = QChar::combiningClass(uc); + const QUnicodeTables::Properties *p = qGetProp(uc); + if (p->unicodeVersion == QChar::Unicode_Unassigned || p->unicodeVersion > version) { + starter = -1; // to prevent starter == pos - 1 + lastCombining = 0; + ++pos; + continue; + } + int combining = p->combiningClass; if (starter == pos - 1 || combining > lastCombining) { // allowed to form ligature with S QChar ligature = ligatureHelper(s.at(starter).unicode(), uc); @@ -1608,7 +1616,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in ushort c2 = 0; { const QUnicodeTables::Properties *p = qGetProp(u2); - if ((QChar::UnicodeVersion)p->unicodeVersion <= version) + if (p->unicodeVersion != QChar::Unicode_Unassigned && p->unicodeVersion <= version) c2 = p->combiningClass; } if (c2 == 0) { @@ -1619,7 +1627,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in ushort c1 = 0; { const QUnicodeTables::Properties *p = qGetProp(u1); - if ((QChar::UnicodeVersion)p->unicodeVersion <= version) + if (p->unicodeVersion != QChar::Unicode_Unassigned && p->unicodeVersion <= version) c1 = p->combiningClass; } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index f5efe55..934b6ad 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6367,7 +6367,7 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar:: if (mode == QString::NormalizationForm_D || mode == QString::NormalizationForm_KD) return; - composeHelper(data, from); + composeHelper(data, version, from); } -- cgit v0.12 From 355bef74a30e5178ae361e6e1873d37b455d8dcb Mon Sep 17 00:00:00 2001 From: aavit Date: Mon, 10 Oct 2011 14:22:17 +0200 Subject: Fixes: libpng symbols exported from QtGui.dll on Windows The upgrade of the bundled libpng to version 1.5 had the side effect of causing the png functions to be exported from the QtGUi DLL when built with the MS Visual C++ compiler. Task-number: QTBUG-21455 Reviewed-by: Kim --- src/3rdparty/libpng/pngconf.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/3rdparty/libpng/pngconf.h b/src/3rdparty/libpng/pngconf.h index 2a41a29..b02f2a0 100644 --- a/src/3rdparty/libpng/pngconf.h +++ b/src/3rdparty/libpng/pngconf.h @@ -286,6 +286,11 @@ # endif # endif +/* Avoid exporting libpng symbols from Qt DLL on Windows */ +# if defined (_MSC_VER) && defined(PNG_IMPEXP) +# undef PNG_IMPEXP +# endif + # ifndef PNG_IMPEXP # define PNG_IMPEXP # endif -- cgit v0.12