diff options
Diffstat (limited to 'src')
55 files changed, 629 insertions, 369 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp index 1e717cb..abe15c8 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp @@ -241,7 +241,7 @@ NEVER_INLINE CollectorBlock* Heap::allocateBlock() #elif PLATFORM(WINCE) void* address = VirtualAlloc(NULL, BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); #elif PLATFORM(WIN_OS) -#if COMPILER(MINGW) +#if COMPILER(MINGW) && !PLATFORM(X86_64) void* address = __mingw_aligned_malloc(BLOCK_SIZE, BLOCK_SIZE); #else void* address = _aligned_malloc(BLOCK_SIZE, BLOCK_SIZE); @@ -327,7 +327,7 @@ NEVER_INLINE void Heap::freeBlock(CollectorBlock* block) #elif PLATFORM(WINCE) VirtualFree(block, 0, MEM_RELEASE); #elif PLATFORM(WIN_OS) -#if COMPILER(MINGW) +#if COMPILER(MINGW) && !PLATFORM(X86_64) __mingw_aligned_free(block); #else _aligned_free(block); @@ -617,7 +617,7 @@ static inline void* currentThreadStackBase() MOV pTib, EAX } return static_cast<void*>(pTib->StackBase); -#elif PLATFORM(WIN_OS) && PLATFORM(X86_64) && COMPILER(MSVC) +#elif PLATFORM(WIN_OS) && PLATFORM(X86_64) && (COMPILER(MSVC) ||COMPILER(GCC)) PNT_TIB64 pTib = reinterpret_cast<PNT_TIB64>(NtCurrentTeb()); return reinterpret_cast<void*>(pTib->StackBase); #elif PLATFORM(WIN_OS) && PLATFORM(X86) && COMPILER(GCC) diff --git a/src/3rdparty/libpng/png.h b/src/3rdparty/libpng/png.h index 14e3416..5ea2b0d 100644 --- a/src/3rdparty/libpng/png.h +++ b/src/3rdparty/libpng/png.h @@ -386,7 +386,7 @@ #include "zlib.h" #endif -#ifdef AIX +#ifdef _AIX #define jmpbuf __jmpbuf #endif diff --git a/src/3rdparty/libpng/pngconf.h b/src/3rdparty/libpng/pngconf.h index 5d202db..1f8bef8 100644 --- a/src/3rdparty/libpng/pngconf.h +++ b/src/3rdparty/libpng/pngconf.h @@ -1379,7 +1379,7 @@ typedef char FAR * FAR * FAR * png_charppp; /* memory model/platform independent fns */ #ifndef PNG_ABORT -# ifdef _WINDOWS_ +# if defined(_WINDOWS_) || defined(_WIN32_WCE) # define PNG_ABORT() ExitProcess(0) # else # define PNG_ABORT() abort() diff --git a/src/3rdparty/libpng/pngpriv.h b/src/3rdparty/libpng/pngpriv.h index 13c2b3f..87a4ba6 100644 --- a/src/3rdparty/libpng/pngpriv.h +++ b/src/3rdparty/libpng/pngpriv.h @@ -74,7 +74,9 @@ #if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \ defined(_WIN32) || defined(__WIN32__) -# include <windows.h> /* defines _WINDOWS_ macro */ +# if !defined(__SYMBIAN32__) +# include <windows.h> /* defines _WINDOWS_ macro */ +# endif /* I have no idea why is this necessary... */ # ifdef _MSC_VER # include <malloc.h> diff --git a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp index 79fc51e..5c87fe6 100644 --- a/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp +++ b/src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp @@ -368,7 +368,7 @@ static inline void handleElementNamespaces(Element* newElement, const QXmlStream for (int i = 0; i < ns.count(); ++i) { const QXmlStreamNamespaceDeclaration &decl = ns[i]; String namespaceURI = decl.namespaceUri(); - String namespaceQName = decl.prefix().isEmpty() ? String("xmlns") : String("xmlns:") + decl.prefix(); + String namespaceQName = decl.prefix().isEmpty() ? String("xmlns") : String("xmlns:") + String(decl.prefix()); newElement->setAttributeNS("http://www.w3.org/2000/xmlns/", namespaceQName, namespaceURI, ec); if (ec) // exception setting attributes return; diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp index 7a1bfd5..5fbc876 100644 --- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp +++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp @@ -179,7 +179,7 @@ void InspectorClientQt::populateSetting(const String& key, InspectorController:: return; } - QString settingKey(settingStoragePrefix + key); + QString settingKey(settingStoragePrefix + QString(key)); QString storedValueType = qsettings.value(settingKey + settingStorageTypeSuffix).toString(); QVariant storedValue = qsettings.value(settingKey); storedValue.convert(QVariant::nameToType(storedValueType.toAscii().data())); @@ -196,7 +196,7 @@ void InspectorClientQt::storeSetting(const String& key, const InspectorControlle } QVariant valueToStore = settingToVariant(setting); - QString settingKey(settingStoragePrefix + key); + QString settingKey(settingStoragePrefix + QString(key)); qsettings.setValue(settingKey, valueToStore); qsettings.setValue(settingKey + settingStorageTypeSuffix, QVariant::typeToName(valueToStore.type())); } diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp index 02a29d9..7692749 100644 --- a/src/activeqt/container/qaxbase.cpp +++ b/src/activeqt/container/qaxbase.cpp @@ -1353,11 +1353,9 @@ bool QAxBase::initializeFromFile(IUnknown** ptr) // There seams to be a naming problem in mingw headers -#ifdef Q_CC_GNU -#ifndef COAUTHIDENTITY +#if defined(Q_CC_GNU) && !defined(COAUTHIDENTITY) && !defined(__MINGW64_VERSION_MAJOR) #define COAUTHIDENTITY AUTH_IDENTITY #endif -#endif /*! diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index 9149320..7d2dde7 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -77,25 +77,21 @@ // #define QAX_SUPPORT_BORDERSPACE // missing interface from win32api -#if defined(Q_CC_GNU) -# if !defined(IOleInPlaceObjectWindowless) -# undef INTERFACE -# define INTERFACE IOleInPlaceObjectWindowless - DECLARE_INTERFACE_(IOleInPlaceObjectWindowless,IOleInPlaceObject) - { - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(GetWindow)(THIS_ HWND*) PURE; - STDMETHOD(ContextSensitiveHelp)(THIS_ BOOL) PURE; - STDMETHOD(InPlaceDeactivate)(THIS) PURE; - STDMETHOD(UIDeactivate)(THIS) PURE; - STDMETHOD(SetObjectRects)(THIS_ LPCRECT,LPCRECT) PURE; - STDMETHOD(ReactivateAndUndo)(THIS) PURE; - STDMETHOD(OnWindowMessage)(THIS_ UINT, WPARAM, LPARAM, LRESULT*) PURE; - STDMETHOD(GetDropTarget)(THIS_ IDropTarget**) PURE; - }; -# endif +#if defined(Q_CC_GNU) && !defined(__MINGW64_VERSION_MAJOR) + DECLARE_INTERFACE_(IOleInPlaceObjectWindowless,IOleInPlaceObject) + { + STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + STDMETHOD(GetWindow)(THIS_ HWND*) PURE; + STDMETHOD(ContextSensitiveHelp)(THIS_ BOOL) PURE; + STDMETHOD(InPlaceDeactivate)(THIS) PURE; + STDMETHOD(UIDeactivate)(THIS) PURE; + STDMETHOD(SetObjectRects)(THIS_ LPCRECT,LPCRECT) PURE; + STDMETHOD(ReactivateAndUndo)(THIS) PURE; + STDMETHOD(OnWindowMessage)(THIS_ UINT, WPARAM, LPARAM, LRESULT*) PURE; + STDMETHOD(GetDropTarget)(THIS_ IDropTarget**) PURE; + }; #endif #include "../shared/qaxtypes.h" diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index 5fa0aad..ce71490 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -1536,7 +1536,7 @@ HWND QAxServerBase::create(HWND hWndParent, RECT& rcPos) HINSTANCE hInst = (HINSTANCE)qAxInstance; EnterCriticalSection(&createWindowSection); QString cn(QLatin1String("QAxControl")); - cn += QString::number((int)ActiveXProc); + cn += QString::number((quintptr)ActiveXProc); if (!atom) { WNDCLASS wcTemp; wcTemp.style = CS_DBLCLKS; @@ -1599,10 +1599,10 @@ HMENU QAxServerBase::createPopup(QMenu *popup, HMENU oldMenu) ushort itemId; if (flags & MF_POPUP) { itemId = static_cast<ushort>( - reinterpret_cast<ulong>(createPopup(action->menu())) + reinterpret_cast<quintptr>(createPopup(action->menu())) ); } else { - itemId = static_cast<ushort>(reinterpret_cast<ulong>(action)); + itemId = static_cast<ushort>(reinterpret_cast<quintptr>(action)); actionMap.remove(itemId); actionMap.insert(itemId, action); } @@ -1646,10 +1646,10 @@ void QAxServerBase::createMenu(QMenuBar *menuBar) ushort itemId; if (flags & MF_POPUP) { itemId = static_cast<ushort>( - reinterpret_cast<ulong>(createPopup(action->menu())) + reinterpret_cast<quintptr>(createPopup(action->menu())) ); } else { - itemId = static_cast<ushort>(reinterpret_cast<ulong>(action)); + itemId = static_cast<ushort>(reinterpret_cast<quintptr>(action)); actionMap.insert(itemId, action); } AppendMenu(hmenuShared, flags, itemId, (const wchar_t *)action->text().utf16()); diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index a9ea44a..d5041c9 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -439,7 +439,7 @@ QLibraryInfo::location(LibraryLocation loc) QCFType<CFURLRef> urlRef = CFBundleCopyBundleURL(bundleRef); if (urlRef) { QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle); - return QDir::cleanPath(path + QLatin1String("/Contents/") + ret); + return QDir::cleanPath(QString(path) + QLatin1String("/Contents/") + ret); } } #endif diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 076cc33..0290fb8 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -6348,7 +6348,7 @@ QUrl QUrl::fromUserInput(const QString &userInput) return QUrl::fromLocalFile(trimmedString); QUrl url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode); - QUrl urlPrepended = QUrl::fromEncoded((QLatin1String("http://") + trimmedString).toUtf8(), QUrl::TolerantMode); + QUrl urlPrepended = QUrl::fromEncoded("http://" + trimmedString.toUtf8(), QUrl::TolerantMode); // Check the most common case of a valid url with scheme and host // We check if the port would be valid by adding the scheme to handle the case host:port diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 5990f86..566626d 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -1021,14 +1021,14 @@ QString decodeMSG(const MSG& msg) LPWINDOWPOS winPos = (LPWINDOWPOS)lParam; if (!winPos) break; - QString hwndAfter = valueCheck((uint)winPos->hwndInsertAfter, - FLAG_STRING((uint)HWND_BOTTOM, "HWND_BOTTOM"), - FLAG_STRING((int)HWND_NOTOPMOST, "HWND_NOTOPMOST"), - FLAG_STRING((uint)HWND_TOP, "HWND_TOP"), - FLAG_STRING((int)HWND_TOPMOST, "HWND_TOPMOST"), + QString hwndAfter = valueCheck(quint64(winPos->hwndInsertAfter), + FLAG_STRING((quintptr)HWND_BOTTOM, "HWND_BOTTOM"), + FLAG_STRING((quintptr)HWND_NOTOPMOST, "HWND_NOTOPMOST"), + FLAG_STRING((quintptr)HWND_TOP, "HWND_TOP"), + FLAG_STRING((quintptr)HWND_TOPMOST, "HWND_TOPMOST"), FLAG_STRING()); if (hwndAfter.size() == 0) - hwndAfter = QString::number((uint)winPos->hwndInsertAfter, 16); + hwndAfter = QString::number((quintptr)winPos->hwndInsertAfter, 16); QString flags = flagCheck(winPos->flags, FLGSTR(SWP_DRAWFRAME), FLGSTR(SWP_FRAMECHANGED), diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index ec50ac8..43df13a 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -41,6 +41,7 @@ #include "qplatformdefs.h" #include "qmutex.h" +#include <qdebug.h> #ifndef QT_NO_THREAD #include "qatomic.h" @@ -159,8 +160,7 @@ void QMutex::lock() if (!isLocked) { #ifndef QT_NO_DEBUG if (d->owner == self) - qWarning("QMutex::lock: Deadlock detected in thread %ld", - long(d->owner)); + qWarning() << "QMutex::lock: Deadlock detected in thread" << d->owner; #endif // didn't get the lock, wait for it @@ -197,8 +197,7 @@ void QMutex::lock() if (!isLocked) { #ifndef QT_NO_DEBUG if (d->owner == self) - qWarning("QMutex::lock: Deadlock detected in thread %ld", - long(d->owner)); + qWarning() << "QMutex::lock: Deadlock detected in thread" << d->owner; #endif // didn't get the lock, wait for it diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index b4bfcaf..84bc154 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -465,7 +465,7 @@ static QString winToQtFormat(const QString &sys_fmt) if (text == QLatin1String("'")) result += QLatin1String("''"); else - result += QLatin1Char('\'') + text + QLatin1Char('\''); + result += QString(QLatin1Char('\'') + text + QLatin1Char('\'')); continue; } @@ -681,8 +681,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const case DateTimeFormatLong: case DateTimeFormatShort: - return query(type == DateTimeFormatLong ? DateFormatLong : DateFormatShort).toString() - + QLatin1Char(' ') + query(type == DateTimeFormatLong ? TimeFormatLong : TimeFormatShort).toString(); + return QString(query(type == DateTimeFormatLong ? DateFormatLong : DateFormatShort).toString() + + QLatin1Char(' ') + query(type == DateTimeFormatLong ? TimeFormatLong : TimeFormatShort).toString()); case DayNameLong: case DayNameShort: return winDayName(in.toInt(), (type == DayNameShort)); @@ -698,8 +698,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const case DateTimeToStringShort: case DateTimeToStringLong: { const QDateTime dt = in.toDateTime(); - return winDateToString(dt.date(), type == DateTimeToStringShort ? DATE_SHORTDATE : DATE_LONGDATE) - + QLatin1Char(' ') + winTimeToString(dt.time()); } + return QString(winDateToString(dt.date(), type == DateTimeToStringShort ? DATE_SHORTDATE : DATE_LONGDATE) + + QLatin1Char(' ') + winTimeToString(dt.time())); } case ZeroDigit: locale_info = LOCALE_SNATIVEDIGITS; diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index b1a7caa..58e3ba8 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -841,7 +841,7 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const return symbianTimeFormat(); case DateTimeFormatLong: case DateTimeFormatShort: - return symbianDateFormat( (type == DateTimeFormatShort) ) + QLatin1Char(' ') + symbianTimeFormat(); + return QString(symbianDateFormat( (type == DateTimeFormatShort) ) + QLatin1Char(' ') + symbianTimeFormat()); case DateToStringShort: case DateToStringLong: return symbianDateToString(in.toDate(), (type == DateToStringShort) ); @@ -851,8 +851,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const case DateTimeToStringShort: case DateTimeToStringLong: { const QDateTime dt = in.toDateTime(); - return symbianDateToString(dt.date(), (type == DateTimeToStringShort) ) - + QLatin1Char(' ') + symbianTimeToString(dt.time()); + return QString(symbianDateToString(dt.date(), (type == DateTimeToStringShort) ) + + QLatin1Char(' ') + symbianTimeToString(dt.time())); } case MeasurementSystem: return static_cast<int>(symbianMeasurementSystem()); diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 8de3c7d..a59c0bd 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -73,6 +73,16 @@ typedef std::basic_string<wchar_t> QStdWString; #error qstring.h must be included before any header file that defines truncate #endif +#if defined(Q_CC_GNU) && (__GNUC__ == 4 && __GNUC_MINOR__ == 0) +//There is a bug in GCC 4.0 that tries to instantiate template of annonymous enum +# ifdef QT_USE_FAST_OPERATOR_PLUS +# undef QT_USE_FAST_OPERATOR_PLUS +# endif +# ifdef QT_USE_FAST_CONCATENATION +# undef QT_USE_FAST_CONCATENATION +# endif +#endif + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 74661c2..0c3ba06 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -100,14 +100,18 @@ public: operator QString() const { - QString s(QConcatenable< QStringBuilder<A, B> >::size(*this), - Qt::Uninitialized); + const uint size = QConcatenable< QStringBuilder<A, B> >::size(*this); + QString s(size, Qt::Uninitialized); QChar *d = s.data(); + const QChar * const start = d; QConcatenable< QStringBuilder<A, B> >::appendTo(*this, d); - // this resize is necessary since we allocate a bit too much - // when dealing with variable sized 8-bit encodings - s.resize(d - s.data()); + + if (!QConcatenable< QStringBuilder<A, B> >::ExactSize && int(size) != d - start) { + // this resize is necessary since we allocate a bit too much + // when dealing with variable sized 8-bit encodings + s.resize(d - start); + } return s; } QByteArray toLatin1() const { return QString(*this).toLatin1(); } @@ -116,10 +120,24 @@ public: const B &b; }; +template <> +class QStringBuilder <QString, QString> +{ + public: + QStringBuilder(const QString &a_, const QString &b_) : a(a_), b(b_) {} + + operator QString() const + { QString r(a); r += b; return r; } + QByteArray toLatin1() const { return QString(*this).toLatin1(); } + + const QString &a; + const QString &b; +}; template <> struct QConcatenable<char> : private QAbstractConcatenable { typedef char type; + enum { ExactSize = true }; static int size(const char) { return 1; } static inline void appendTo(const char c, QChar *&out) { @@ -130,6 +148,7 @@ template <> struct QConcatenable<char> : private QAbstractConcatenable template <> struct QConcatenable<QLatin1Char> { typedef QLatin1Char type; + enum { ExactSize = true }; static int size(const QLatin1Char) { return 1; } static inline void appendTo(const QLatin1Char c, QChar *&out) { @@ -140,6 +159,7 @@ template <> struct QConcatenable<QLatin1Char> template <> struct QConcatenable<QChar> { typedef QChar type; + enum { ExactSize = true }; static int size(const QChar) { return 1; } static inline void appendTo(const QChar c, QChar *&out) { @@ -150,6 +170,7 @@ template <> struct QConcatenable<QChar> template <> struct QConcatenable<QCharRef> { typedef QCharRef type; + enum { ExactSize = true }; static int size(const QCharRef &) { return 1; } static inline void appendTo(const QCharRef &c, QChar *&out) { @@ -160,6 +181,7 @@ template <> struct QConcatenable<QCharRef> template <> struct QConcatenable<QLatin1String> { typedef QLatin1String type; + enum { ExactSize = true }; static int size(const QLatin1String &a) { return qstrlen(a.latin1()); } static inline void appendTo(const QLatin1String &a, QChar *&out) { @@ -172,6 +194,7 @@ template <> struct QConcatenable<QLatin1String> template <> struct QConcatenable<QLatin1Literal> { typedef QLatin1Literal type; + enum { ExactSize = true }; static int size(const QLatin1Literal &a) { return a.size(); } static inline void appendTo(const QLatin1Literal &a, QChar *&out) { @@ -183,6 +206,7 @@ template <> struct QConcatenable<QLatin1Literal> template <> struct QConcatenable<QString> { typedef QString type; + enum { ExactSize = true }; static int size(const QString &a) { return a.size(); } static inline void appendTo(const QString &a, QChar *&out) { @@ -195,6 +219,7 @@ template <> struct QConcatenable<QString> template <> struct QConcatenable<QStringRef> { typedef QStringRef type; + enum { ExactSize = true }; static int size(const QStringRef &a) { return a.size(); } static inline void appendTo(QStringRef a, QChar *&out) { @@ -208,6 +233,7 @@ template <> struct QConcatenable<QStringRef> template <int N> struct QConcatenable<char[N]> : private QAbstractConcatenable { typedef char type[N]; + enum { ExactSize = false }; static int size(const char[N]) { return N - 1; @@ -221,6 +247,7 @@ template <int N> struct QConcatenable<char[N]> : private QAbstractConcatenable template <int N> struct QConcatenable<const char[N]> : private QAbstractConcatenable { typedef const char type[N]; + enum { ExactSize = false }; static int size(const char[N]) { return N - 1; } static inline void appendTo(const char a[N], QChar *&out) { @@ -231,6 +258,7 @@ template <int N> struct QConcatenable<const char[N]> : private QAbstractConcaten template <> struct QConcatenable<const char *> : private QAbstractConcatenable { typedef char const *type; + enum { ExactSize = false }; static int size(const char *a) { return qstrlen(a); } static inline void appendTo(const char *a, QChar *&out) { @@ -241,6 +269,7 @@ template <> struct QConcatenable<const char *> : private QAbstractConcatenable template <> struct QConcatenable<QByteArray> : private QAbstractConcatenable { typedef QByteArray type; + enum { ExactSize = false }; static int size(const QByteArray &ba) { return qstrnlen(ba.constData(), ba.size()); } static inline void appendTo(const QByteArray &ba, QChar *&out) { @@ -253,6 +282,7 @@ template <typename A, typename B> struct QConcatenable< QStringBuilder<A, B> > { typedef QStringBuilder<A, B> type; + enum { ExactSize = QConcatenable<A>::ExactSize && QConcatenable<B>::ExactSize }; static int size(const type &p) { return QConcatenable<A>::size(p.a) + QConcatenable<B>::size(p.b); diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp index 14c7c71..3f4521e 100644 --- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp @@ -1205,7 +1205,7 @@ void QmlGraphicsParticlesPainter::paint(QPainter *p, const QStyleOptionGraphicsI const int myX = x() + parentItem()->x(); const int myY = y() + parentItem()->y(); - QVarLengthArray<QDrawPixmaps::Data, 256> pixmapData; + QVarLengthArray<QPainter::Fragment, 256> pixmapData; pixmapData.resize(d->particles.count()); const QRectF sourceRect = d->image.rect(); @@ -1213,16 +1213,20 @@ void QmlGraphicsParticlesPainter::paint(QPainter *p, const QStyleOptionGraphicsI qreal halfPHeight = sourceRect.height()/2.; for (int i = 0; i < d->particles.count(); ++i) { const QmlGraphicsParticle &particle = d->particles.at(i); - pixmapData[i].point = QPointF(particle.x - myX + halfPWidth, particle.y - myY + halfPHeight); + pixmapData[i].x = particle.x - myX + halfPWidth; + pixmapData[i].y = particle.y - myY + halfPHeight; pixmapData[i].opacity = particle.opacity; //these never change pixmapData[i].rotation = 0; pixmapData[i].scaleX = 1; pixmapData[i].scaleY = 1; - pixmapData[i].source = sourceRect; + pixmapData[i].sourceLeft = sourceRect.left(); + pixmapData[i].sourceTop = sourceRect.top(); + pixmapData[i].width = sourceRect.width(); + pixmapData[i].height = sourceRect.height(); } - qDrawPixmaps(p, pixmapData.data(), d->particles.count(), d->image); + p->drawPixmapFragments(pixmapData.data(), d->particles.count(), d->image); } void QmlGraphicsParticles::componentComplete() diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index b3ca3b5..2c92364 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -156,8 +156,8 @@ public: needSortChildren(0), allChildrenDirty(0), fullUpdatePending(0), - flags(0), dirtyChildrenBoundingRect(1), + flags(0), paintedViewBoundingRectsNeedRepaint(0), dirtySceneTransform(1), geometryChanged(1), @@ -474,11 +474,11 @@ public: quint32 inSetPosHelper : 1; quint32 needSortChildren : 1; quint32 allChildrenDirty : 1; + quint32 fullUpdatePending : 1; + quint32 dirtyChildrenBoundingRect : 1; // Packed 32 bits - quint32 fullUpdatePending : 1; quint32 flags : 17; - quint32 dirtyChildrenBoundingRect : 1; quint32 paintedViewBoundingRectsNeedRepaint : 1; quint32 dirtySceneTransform : 1; quint32 geometryChanged : 1; @@ -492,10 +492,10 @@ public: quint32 sceneTransformTranslateOnly : 1; quint32 notifyBoundingRectChanged : 1; quint32 notifyInvalidated : 1; - - // New 32 bits quint32 mouseSetsFocus : 1; quint32 explicitActivate : 1; + + // New 32 bits quint32 wantsActive : 1; quint32 holesInSiblingIndex : 1; quint32 sequentialOrdering : 1; @@ -503,6 +503,7 @@ public: quint32 scenePosDescendants : 1; quint32 pendingPolish : 1; quint32 mayHaveChildWithGraphicsEffect : 1; + quint32 padding : 25; // Optional stacking order int globalStackingOrder; diff --git a/src/gui/image/qpaintengine_pic.cpp b/src/gui/image/qpaintengine_pic.cpp index 1aeb524..029154b 100644 --- a/src/gui/image/qpaintengine_pic.cpp +++ b/src/gui/image/qpaintengine_pic.cpp @@ -486,8 +486,11 @@ void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti) qDebug() << " -> drawTextItem():" << p << ti.text(); #endif + const QTextItemInt &si = static_cast<const QTextItemInt &>(ti); + if (si.chars == 0) + QPaintEngine::drawTextItem(p, ti); // Draw as path + if (d->pic_d->formatMajor >= 9) { - const QTextItemInt &si = static_cast<const QTextItemInt &>(ti); int pos; SERIALIZE_CMD(QPicturePrivate::PdcDrawTextItem); QFont fnt = ti.font(); diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index 1c26e51..5128b64 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -2221,7 +2221,8 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e) return; } case QHeaderViewPrivate::MoveSection: { - if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance()) { + if (qAbs(pos - d->firstPos) >= QApplication::startDragDistance() + || !d->sectionIndicator->isHidden()) { int indicatorCenter = (d->orientation == Qt::Horizontal ? d->sectionIndicator->width() : d->sectionIndicator->height()) / 2; @@ -2233,12 +2234,6 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e) return; d->target = d->logicalIndex(visual); d->updateSectionIndicator(d->section, pos); - } else { - int visual = visualIndexAt(d->firstPos); - if (visual == -1) - return; - d->target = d->logicalIndex(visual); - d->updateSectionIndicator(d->section, d->firstPos); } return; } diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index e73013c..c63a07b 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -563,7 +563,7 @@ QVector<QPair<int, QVector<int > > > QSortFilterProxyModelPrivate::proxy_interva int proxy_item = 0; int source_items_index = 0; QVector<int> source_items_in_interval; - bool compare = (orient == Qt::Vertical && source_sort_column >= 0); + bool compare = (orient == Qt::Vertical && source_sort_column >= 0 && dynamic_sortfilter); while (source_items_index < source_items.size()) { source_items_in_interval.clear(); int first_new_source_item = source_items.at(source_items_index); @@ -1244,7 +1244,7 @@ void QSortFilterProxyModelPrivate::_q_sourceRowsInserted( const QModelIndex &source_parent, int start, int end) { source_items_inserted(source_parent, start, end, Qt::Vertical); - if (update_source_sort_column()) //previous call to update_source_sort_column may fail if the model has no column. + if (update_source_sort_column() && dynamic_sortfilter) //previous call to update_source_sort_column may fail if the model has no column. sort(); // now it should succeed so we need to make sure to sort again } @@ -1281,8 +1281,8 @@ void QSortFilterProxyModelPrivate::_q_sourceColumnsInserted( if (source_parent.isValid()) return; //we sort according to the root column only if (source_sort_column == -1) { - //we update the source_sort_column depending on the prox_sort_column - if (update_source_sort_column()) + //we update the source_sort_column depending on the proxy_sort_column + if (update_source_sort_column() && dynamic_sortfilter) sort(); } else { if (start <= source_sort_column) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 706d2a8..37168eb 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -3770,10 +3770,15 @@ void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent, if (previousSibiling != -1 && after && model->rowCount(parent) == start) viewItems[previousSibiling].hasMoreSiblings = false; - - updateChildCount(parentItem, -removedCount); - if (parentItem != -1 && viewItems.at(parentItem).total == 0) - viewItems[parentItem].hasChildren = false; //every children have been removed; + if (parentItem != -1) { + if (viewItems.at(parentItem).expanded) { + updateChildCount(parentItem, -removedCount); + if (viewItems.at(parentItem).total == 0) + viewItems[parentItem].hasChildren = false; //every children have been removed; + } else if (viewItems[parentItem].hasChildren && !hasVisibleChildren(parent)) { + viewItems[parentItem].hasChildren = false; + } + } if (after) { q->updateGeometries(); viewport->update(); diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index c6e192b..3c2c743 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -2221,30 +2221,60 @@ void qt_init(QApplicationPrivate *priv, int, int format; unsigned long length, after; uchar *data = 0; + int rc; + + do { + if (!qgetenv("KDE_FULL_SESSION").isEmpty()) { + X11->desktopEnvironment = DE_KDE; + X11->desktopVersion = qgetenv("KDE_SESSION_VERSION").toInt(); + break; + } + + if (qgetenv("DESKTOP_SESSION") == "gnome") { + X11->desktopEnvironment = DE_GNOME; + break; + } + + // GNOME_DESKTOP_SESSION_ID is deprecated for some reason, but still check it + if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty()) { + X11->desktopEnvironment = DE_GNOME; + break; + } + + rc = XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_DT_SAVE_MODE), + 0, 2, False, XA_STRING, &type, &format, &length, + &after, &data); + if (rc == Success && length) { + if (!strcmp(reinterpret_cast<char *>(data), "xfce4")) { + // Pretend that xfce4 is gnome, as it uses the same libraries. + // The detection above is stolen from xdg-open. + X11->desktopEnvironment = DE_GNOME; + break; + } + + // We got the property but it wasn't xfce4. Free data before it gets overwritten. + XFree(data); + data = 0; + } + + rc = XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING), + 0, 1, False, AnyPropertyType, &type, &format, &length, + &after, &data); + if (rc == Success && length) { + // DTWM is running, meaning most likely CDE is running... + X11->desktopEnvironment = DE_CDE; + break; + } + + rc = XGetWindowProperty(X11->display, QX11Info::appRootWindow(), + ATOM(_SGI_DESKS_MANAGER), 0, 1, False, XA_WINDOW, + &type, &format, &length, &after, &data); + if (rc == Success && length) { + X11->desktopEnvironment = DE_4DWM; + break; + } + } while(0); - if (!qgetenv("KDE_FULL_SESSION").isEmpty()) { - X11->desktopEnvironment = DE_KDE; - X11->desktopVersion = qgetenv("KDE_SESSION_VERSION").toInt(); - } else if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty() // Deprecated for some reason. - || qgetenv("DESKTOP_SESSION") == "gnome") { // De-facto-standardized by GNOME. - X11->desktopEnvironment = DE_GNOME; - } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_DT_SAVE_MODE), - 0, 2, False, XA_STRING, &type, &format, &length, - &after, &data) == Success - && !strcmp(reinterpret_cast<char *>(data), "xfce4")) { - // Pretend that xfce4 is gnome, as it uses the same libraries. - // The detection above is stolen from xdg-open. - X11->desktopEnvironment = DE_GNOME; - } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING), - 0, 1, False, AnyPropertyType, &type, &format, &length, - &after, &data) == Success && length) { - // DTWM is running, meaning most likely CDE is running... - X11->desktopEnvironment = DE_CDE; - } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_SGI_DESKS_MANAGER), - 0, 1, False, XA_WINDOW, &type, &format, &length, &after, &data) == Success - && length) { - X11->desktopEnvironment = DE_4DWM; - } if (data) XFree((char *)data); diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 4977042..6a16403 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -467,8 +467,9 @@ extern "C" { if (QApplicationPrivate::graphicsSystem() != 0) { if (QWidgetBackingStore *bs = qwidgetprivate->maybeBackingStore()) { // Drawing is handled on the window level - // See qcocoasharedwindowmethods_mac_p. - return; + // See qcocoasharedwindowmethods_mac_p.h + if (!qwidget->testAttribute(Qt::WA_PaintOnScreen)) + return; } } CGContextRef cg = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; diff --git a/src/gui/kernel/qkeymapper_win.cpp b/src/gui/kernel/qkeymapper_win.cpp index 578f32a..e555c5c 100644 --- a/src/gui/kernel/qkeymapper_win.cpp +++ b/src/gui/kernel/qkeymapper_win.cpp @@ -619,7 +619,7 @@ void QKeyMapperPrivate::clearMappings() /* MAKELCID()'s first argument is a WORD, and GetKeyboardLayout() * returns a DWORD. */ - LCID newLCID = MAKELCID((DWORD)GetKeyboardLayout(0), SORT_DEFAULT); + LCID newLCID = MAKELCID((quintptr)GetKeyboardLayout(0), SORT_DEFAULT); // keyboardInputLocale = qt_localeFromLCID(newLCID); bool bidi = false; diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index c37e49a..891f4c2 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -3701,7 +3701,7 @@ template <> Q_STATIC_TEMPLATE_SPECIALIZATION inline quint32 alpha_4(const qargb8555 *src) { - Q_ASSERT((long(src) & 0x3) == 0); + Q_ASSERT((quintptr(src) & 0x3) == 0); const quint8 *src8 = reinterpret_cast<const quint8*>(src); return src8[0] << 24 | src8[3] << 16 | src8[6] << 8 | src8[9]; } @@ -4027,8 +4027,8 @@ template <> inline void interpolate_pixel_4(qargb8565 *dest, const qargb8565 *src, quint32 alpha) { - Q_ASSERT((long(dest) & 0x3) == 0); - Q_ASSERT((long(src) & 0x3) == 0); + Q_ASSERT((quintptr(dest) & 0x3) == 0); + Q_ASSERT((quintptr(src) & 0x3) == 0); const quint32 a = eff_alpha_4(alpha, dest); const quint32 ia = eff_ialpha_4(alpha, dest); @@ -4123,8 +4123,8 @@ template <> inline void interpolate_pixel_4(qargb8555 *dest, const qargb8555 *src, quint32 alpha) { - Q_ASSERT((long(dest) & 0x3) == 0); - Q_ASSERT((long(src) & 0x3) == 0); + Q_ASSERT((quintptr(dest) & 0x3) == 0); + Q_ASSERT((quintptr(src) & 0x3) == 0); const quint32 a = eff_alpha_4(alpha, dest); @@ -4219,8 +4219,8 @@ template <> inline void interpolate_pixel_4(qrgb888 *dest, const qrgb888 *src, quint32 alpha) { - Q_ASSERT((long(dest) & 0x3) == 0); - Q_ASSERT((long(src) & 0x3) == 0); + Q_ASSERT((quintptr(dest) & 0x3) == 0); + Q_ASSERT((quintptr(src) & 0x3) == 0); const quint32 a = eff_alpha_4(alpha, dest); const quint32 ia = eff_ialpha_4(alpha, dest); @@ -4292,8 +4292,8 @@ template <class DST, class SRC> inline void interpolate_pixel_4(DST *dest, quint8 a, const SRC *src, quint8 b) { - Q_ASSERT((long(dest) & 0x3) == 0); - Q_ASSERT((long(src) & 0x3) == 0); + Q_ASSERT((quintptr(dest) & 0x3) == 0); + Q_ASSERT((quintptr(src) & 0x3) == 0); dest[0] = dest[0].byte_mul(a) + DST(src[0]).byte_mul(b); dest[1] = dest[1].byte_mul(a) + DST(src[1]).byte_mul(b); @@ -4304,8 +4304,8 @@ inline void interpolate_pixel_4(DST *dest, quint8 a, template <class DST, class SRC> inline void blend_sourceOver_4(DST *dest, const SRC *src) { - Q_ASSERT((long(dest) & 0x3) == 0); - Q_ASSERT((long(src) & 0x3) == 0); + Q_ASSERT((quintptr(dest) & 0x3) == 0); + Q_ASSERT((quintptr(src) & 0x3) == 0); const quint32 a = alpha_4(src); if (a == 0xffffffff) { @@ -4320,8 +4320,8 @@ inline void blend_sourceOver_4(DST *dest, const SRC *src) template <> inline void blend_sourceOver_4(qargb8565 *dest, const qargb8565 *src) { - Q_ASSERT((long(dest) & 0x3) == 0); - Q_ASSERT((long(src) & 0x3) == 0); + Q_ASSERT((quintptr(dest) & 0x3) == 0); + Q_ASSERT((quintptr(src) & 0x3) == 0); const quint32 a = alpha_4(src); if (a == 0xffffffff) { @@ -4334,8 +4334,8 @@ inline void blend_sourceOver_4(qargb8565 *dest, const qargb8565 *src) template <> inline void blend_sourceOver_4(qargb8555 *dest, const qargb8555 *src) { - Q_ASSERT((long(dest) & 0x3) == 0); - Q_ASSERT((long(src) & 0x3) == 0); + Q_ASSERT((quintptr(dest) & 0x3) == 0); + Q_ASSERT((quintptr(src) & 0x3) == 0); const quint32 a = alpha_4(src); if (a == 0xffffffff) { @@ -4348,8 +4348,8 @@ inline void blend_sourceOver_4(qargb8555 *dest, const qargb8555 *src) template <> inline void blend_sourceOver_4(qargb6666 *dest, const qargb6666 *src) { - Q_ASSERT((long(dest) & 0x3) == 0); - Q_ASSERT((long(src) & 0x3) == 0); + Q_ASSERT((quintptr(dest) & 0x3) == 0); + Q_ASSERT((quintptr(src) & 0x3) == 0); const quint32 a = alpha_4(src); if (a == 0xffffffff) { diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index df4d9c5..f5b17ea 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -1640,7 +1640,7 @@ inline void qt_memconvert(qrgb666 *dest, const quint32 *src, int count) return; } - const int align = (long(dest) & 3); + const int align = (quintptr(dest) & 3); switch (align) { case 1: *dest++ = qrgb666(*src++); --count; case 2: *dest++ = qrgb666(*src++); --count; diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp index 5619a2e..d76c709 100644 --- a/src/gui/painting/qdrawutil.cpp +++ b/src/gui/painting/qdrawutil.cpp @@ -1081,7 +1081,7 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs, according to the \a margins structure. */ -typedef QVarLengthArray<QDrawPixmaps::Data, 16> QDrawPixmapsDataArray; +typedef QVarLengthArray<QPainter::Fragment, 16> QPixmapFragmentsArray; /*! \since 4.6 @@ -1102,12 +1102,12 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins, const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints) { - QDrawPixmaps::Data d; + QPainter::Fragment d; d.opacity = 1.0; d.rotation = 0.0; - QDrawPixmapsDataArray opaqueData; - QDrawPixmapsDataArray translucentData; + QPixmapFragmentsArray opaqueData; + QPixmapFragmentsArray translucentData; // source center const int sourceCenterTop = sourceRect.top() + sourceMargins.top(); @@ -1182,44 +1182,56 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin // corners if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left - d.point.setX(0.5 * (xTarget[1] + xTarget[0])); - d.point.setY(0.5 * (yTarget[1] + yTarget[0])); - d.source = QRectF(sourceRect.left(), sourceRect.top(), sourceMargins.left(), sourceMargins.top()); - d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.source.width(); - d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.source.height(); + d.x = (0.5 * (xTarget[1] + xTarget[0])); + d.y = (0.5 * (yTarget[1] + yTarget[0])); + d.sourceLeft = sourceRect.left(); + d.sourceTop = sourceRect.top(); + d.width = sourceMargins.left(); + d.height = sourceMargins.top(); + d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width; + d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height; if (hints & QDrawBorderPixmap::OpaqueTopLeft) opaqueData.append(d); else translucentData.append(d); } if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right - d.point.setX(0.5 * (xTarget[columns] + xTarget[columns - 1])); - d.point.setY(0.5 * (yTarget[1] + yTarget[0])); - d.source = QRectF(sourceCenterRight, sourceRect.top(), sourceMargins.right(), sourceMargins.top()); - d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.source.width(); - d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.source.height(); + d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1])); + d.y = (0.5 * (yTarget[1] + yTarget[0])); + d.sourceLeft = sourceCenterRight; + d.sourceTop = sourceRect.top(); + d.width = sourceMargins.right(); + d.height = sourceMargins.top(); + d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width; + d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height; if (hints & QDrawBorderPixmap::OpaqueTopRight) opaqueData.append(d); else translucentData.append(d); } if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left - d.point.setX(0.5 * (xTarget[1] + xTarget[0])); - d.point.setY(0.5 * (yTarget[rows] + yTarget[rows - 1])); - d.source = QRectF(sourceRect.left(), sourceCenterBottom, sourceMargins.left(), sourceMargins.bottom()); - d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.source.width(); - d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.source.height(); + d.x = (0.5 * (xTarget[1] + xTarget[0])); + d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1])); + d.sourceLeft = sourceRect.left(); + d.sourceTop = sourceCenterBottom; + d.width = sourceMargins.left(); + d.height = sourceMargins.bottom(); + d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width; + d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height; if (hints & QDrawBorderPixmap::OpaqueBottomLeft) opaqueData.append(d); else translucentData.append(d); } if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right - d.point.setX(0.5 * (xTarget[columns] + xTarget[columns - 1])); - d.point.setY(0.5 * (yTarget[rows] + yTarget[rows - 1])); - d.source = QRectF(sourceCenterRight, sourceCenterBottom, sourceMargins.right(), sourceMargins.bottom()); - d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.source.width(); - d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.source.height(); + d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1])); + d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1])); + d.sourceLeft = sourceCenterRight; + d.sourceTop = sourceCenterBottom; + d.width = sourceMargins.right(); + d.height = sourceMargins.bottom(); + d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width; + d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height; if (hints & QDrawBorderPixmap::OpaqueBottomRight) opaqueData.append(d); else @@ -1229,151 +1241,107 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin // horizontal edges if (targetCenterWidth > 0 && sourceCenterWidth > 0) { if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top - QDrawPixmapsDataArray &data = hints & QDrawBorderPixmap::OpaqueTop ? opaqueData : translucentData; - d.source = QRectF(sourceCenterLeft, sourceRect.top(), sourceCenterWidth, sourceMargins.top()); - d.point.setY(0.5 * (yTarget[1] + yTarget[0])); - d.scaleX = dx / d.source.width(); - d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.source.height(); + QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueTop ? opaqueData : translucentData; + d.sourceLeft = sourceCenterLeft; + d.sourceTop = sourceRect.top(); + d.width = sourceCenterWidth; + d.height = sourceMargins.top(); + d.y = (0.5 * (yTarget[1] + yTarget[0])); + d.scaleX = dx / d.width; + d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height; for (int i = 1; i < columns - 1; ++i) { - d.point.setX(0.5 * (xTarget[i + 1] + xTarget[i])); + d.x = (0.5 * (xTarget[i + 1] + xTarget[i])); data.append(d); } if (rules.horizontal == Qt::RepeatTile) - data[data.size() - 1].source.setWidth((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX); + data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX); } if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom - QDrawPixmapsDataArray &data = hints & QDrawBorderPixmap::OpaqueBottom ? opaqueData : translucentData; - d.source = QRectF(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom());; - d.point.setY(0.5 * (yTarget[rows] + yTarget[rows - 1])); - d.scaleX = dx / d.source.width(); - d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.source.height(); + QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueBottom ? opaqueData : translucentData; + d.sourceLeft = sourceCenterLeft; + d.sourceTop = sourceCenterBottom; + d.width = sourceCenterWidth; + d.height = sourceMargins.bottom(); + d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1])); + d.scaleX = dx / d.width; + d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height; for (int i = 1; i < columns - 1; ++i) { - d.point.setX(0.5 * (xTarget[i + 1] + xTarget[i])); + d.x = (0.5 * (xTarget[i + 1] + xTarget[i])); data.append(d); } if (rules.horizontal == Qt::RepeatTile) - data[data.size() - 1].source.setWidth((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX); + data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX); } } // vertical edges if (targetCenterHeight > 0 && sourceCenterHeight > 0) { if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left - QDrawPixmapsDataArray &data = hints & QDrawBorderPixmap::OpaqueLeft ? opaqueData : translucentData; - d.source = QRectF(sourceRect.left(), sourceCenterTop, sourceMargins.left(), sourceCenterHeight); - d.point.setX(0.5 * (xTarget[1] + xTarget[0])); - d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.source.width(); - d.scaleY = dy / d.source.height(); + QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueLeft ? opaqueData : translucentData; + d.sourceLeft = sourceRect.left(); + d.sourceTop = sourceCenterTop; + d.width = sourceMargins.left(); + d.height = sourceCenterHeight; + d.x = (0.5 * (xTarget[1] + xTarget[0])); + d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width; + d.scaleY = dy / d.height; for (int i = 1; i < rows - 1; ++i) { - d.point.setY(0.5 * (yTarget[i + 1] + yTarget[i])); + d.y = (0.5 * (yTarget[i + 1] + yTarget[i])); data.append(d); } if (rules.vertical == Qt::RepeatTile) - data[data.size() - 1].source.setHeight((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY); + data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY); } if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right - QDrawPixmapsDataArray &data = hints & QDrawBorderPixmap::OpaqueRight ? opaqueData : translucentData; - d.source = QRectF(sourceCenterRight, sourceCenterTop, sourceMargins.right(), sourceCenterHeight); - d.point.setX(0.5 * (xTarget[columns] + xTarget[columns - 1])); - d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.source.width(); - d.scaleY = dy / d.source.height(); + QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueRight ? opaqueData : translucentData; + d.sourceLeft = sourceCenterRight; + d.sourceTop = sourceCenterTop; + d.width = sourceMargins.right(); + d.height = sourceCenterHeight; + d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1])); + d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width; + d.scaleY = dy / d.height; for (int i = 1; i < rows - 1; ++i) { - d.point.setY(0.5 * (yTarget[i + 1] + yTarget[i])); + d.y = (0.5 * (yTarget[i + 1] + yTarget[i])); data.append(d); } if (rules.vertical == Qt::RepeatTile) - data[data.size() - 1].source.setHeight((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY); + data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY); } } // center if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) { - QDrawPixmapsDataArray &data = hints & QDrawBorderPixmap::OpaqueCenter ? opaqueData : translucentData; - d.source = QRectF(sourceCenterLeft, sourceCenterTop, sourceCenterWidth, sourceCenterHeight); - d.scaleX = dx / d.source.width(); - d.scaleY = dy / d.source.height(); + QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueCenter ? opaqueData : translucentData; + d.sourceLeft = sourceCenterLeft; + d.sourceTop = sourceCenterTop; + d.width = sourceCenterWidth; + d.height = sourceCenterHeight; + d.scaleX = dx / d.width; + d.scaleY = dy / d.height; qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX; qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY; for (int j = 1; j < rows - 1; ++j) { - d.point.setY(0.5 * (yTarget[j + 1] + yTarget[j])); + d.y = (0.5 * (yTarget[j + 1] + yTarget[j])); for (int i = 1; i < columns - 1; ++i) { - d.point.setX(0.5 * (xTarget[i + 1] + xTarget[i])); + d.x = (0.5 * (xTarget[i + 1] + xTarget[i])); data.append(d); } if (rules.horizontal == Qt::RepeatTile) - data[data.size() - 1].source.setWidth(repeatWidth); + data[data.size() - 1].width = repeatWidth; } if (rules.vertical == Qt::RepeatTile) { for (int i = 1; i < columns - 1; ++i) - data[data.size() - i].source.setHeight(repeatHeight); + data[data.size() - i].height = repeatHeight; } } if (opaqueData.size()) - qDrawPixmaps(painter, opaqueData.data(), opaqueData.size(), pixmap, QDrawPixmaps::OpaqueHint); + painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint); if (translucentData.size()) - qDrawPixmaps(painter, translucentData.data(), translucentData.size(), pixmap); -} - -/*! - \class QDrawPixmaps::Data - \since 4.6 - \internal - - This structure is used with the qDrawPixmaps() function. - - QPointF point: Specifies the center of the target rectangle. - QRectF source: Specifies the source rectangle in the pixmap passed into the qDrawPixmaps() call. - qreal scaleX: Specifies the horizontal scale of the target rectangle. - qreal scaleY: Specifies the vertical scale of the target rectangle. - qreal rotation: Specifies the rotation of the target rectangle in degrees. - The target rectangle is rotated after scaling. - qreal opacity: Specifies the opacity of the rectangle. -*/ - -/*! - \enum QDrawPixmaps::DrawingHint - \internal -*/ - -/*! - \internal - \since 4.6 - - This function is used to draw \a pixmap, or a sub-rectangle of \a pixmap, at multiple positions - with different scale, rotation and opacity on \a painter. \a drawingData is an array of \a - dataCount elements specifying the parameters used to draw each pixmap instance. - This can be used for example to implement a particle system. -*/ -void qDrawPixmaps(QPainter *painter, const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints) -{ - QPaintEngine *engine = painter->paintEngine(); - if (!engine) - return; - - if (engine->isExtended()) { - static_cast<QPaintEngineEx *>(engine)->drawPixmaps(drawingData, dataCount, pixmap, hints); - } else { - qreal oldOpacity = painter->opacity(); - QTransform oldTransform = painter->transform(); - - for (int i = 0; i < dataCount; ++i) { - QTransform transform = oldTransform; - transform.translate(drawingData[i].point.x(), drawingData[i].point.y()); - transform.rotate(drawingData[i].rotation); - painter->setOpacity(oldOpacity * drawingData[i].opacity); - painter->setTransform(transform); - - qreal w = drawingData[i].scaleX * drawingData[i].source.width(); - qreal h = drawingData[i].scaleY * drawingData[i].source.height(); - painter->drawPixmap(QRectF(-0.5 * w, -0.5 * h, w, h), pixmap, drawingData[i].source); - } - - painter->setOpacity(oldOpacity); - painter->setTransform(oldTransform); - } + painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap); } QT_END_NAMESPACE diff --git a/src/gui/painting/qdrawutil.h b/src/gui/painting/qdrawutil.h index 2801b2f..31e352f 100644 --- a/src/gui/painting/qdrawutil.h +++ b/src/gui/painting/qdrawutil.h @@ -188,31 +188,6 @@ inline void qDrawBorderPixmap(QPainter *painter, qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins); } -// For internal use only. -namespace QDrawPixmaps -{ - struct Data - { - QPointF point; - QRectF source; - qreal scaleX; - qreal scaleY; - qreal rotation; - qreal opacity; - }; - - enum DrawingHint - { - OpaqueHint = 0x01 - }; - - Q_DECLARE_FLAGS(DrawingHints, DrawingHint) -} - -// This function is private and may change without notice. Do not use outside Qt!!! -Q_GUI_EXPORT void qDrawPixmaps(QPainter *painter, const QDrawPixmaps::Data *drawingData, - int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints = 0); - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 4f2fffa..98762f0 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -893,7 +893,7 @@ void QPaintEngineEx::drawPoints(const QPoint *points, int pointCount) for (int i=0; i<count; ++i) { pts[++oset] = points[i].x(); pts[++oset] = points[i].y(); - pts[++oset] = points[i].x() + 1/63; + pts[++oset] = points[i].x() + 1/63.; pts[++oset] = points[i].y(); } QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::LinesHint); @@ -970,23 +970,26 @@ void QPaintEngineEx::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, con fill(path, brush); } -void QPaintEngineEx::drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints /*hints*/) +void QPaintEngineEx::drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount, + const QPixmap &pixmap, QPainter::FragmentHints /*hints*/) { qreal oldOpacity = state()->opacity; QTransform oldTransform = state()->matrix; - for (int i = 0; i < dataCount; ++i) { + for (int i = 0; i < fragmentCount; ++i) { QTransform transform = oldTransform; - transform.translate(drawingData[i].point.x(), drawingData[i].point.y()); - transform.rotate(drawingData[i].rotation); - state()->opacity = oldOpacity * drawingData[i].opacity; + transform.translate(fragments[i].x, fragments[i].y); + transform.rotate(fragments[i].rotation); + state()->opacity = oldOpacity * fragments[i].opacity; state()->matrix = transform; opacityChanged(); transformChanged(); - qreal w = drawingData[i].scaleX * drawingData[i].source.width(); - qreal h = drawingData[i].scaleY * drawingData[i].source.height(); - drawPixmap(QRectF(-0.5 * w, -0.5 * h, w, h), pixmap, drawingData[i].source); + qreal w = fragments[i].scaleX * fragments[i].width; + qreal h = fragments[i].scaleY * fragments[i].height; + QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop, + fragments[i].width, fragments[i].height); + drawPixmap(QRectF(-0.5 * w, -0.5 * h, w, h), pixmap, sourceRect); } state()->opacity = oldOpacity; diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h index 90c4f9f..2401b94 100644 --- a/src/gui/painting/qpaintengineex_p.h +++ b/src/gui/painting/qpaintengineex_p.h @@ -197,7 +197,7 @@ public: virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s); - virtual void drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QFlags<QDrawPixmaps::DrawingHint> hints); + virtual void drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount, const QPixmap &pixmap, QFlags<QPainter::FragmentHint> hints); virtual void updateState(const QPaintEngineState &state); diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 4f532c0..dc96c17 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5700,6 +5700,61 @@ void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QR d->engine->drawImage(QRectF(x, y, w, h), image, QRectF(sx, sy, sw, sh), flags); } + +void qt_draw_glyphs(QPainter *painter, const quint32 *glyphArray, const QPointF *positionArray, + int glyphCount) +{ + QPainterPrivate *painter_d = QPainterPrivate::get(painter); + painter_d->drawGlyphs(glyphArray, positionArray, glyphCount); +} + +void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *positionArray, + int glyphCount) +{ + updateState(state); + + QFontEngine *fontEngine = state->font.d->engineForScript(QUnicodeTables::Common); + + QVarLengthArray<QFixedPoint, 128> positions; + for (int i=0; i<glyphCount; ++i) { + QFixedPoint fp = QFixedPoint::fromPointF(positionArray[i]); + positions.append(fp); + } + + if (extended != 0) { + QStaticTextItem staticTextItem; + staticTextItem.color = state->pen.color(); + staticTextItem.font = state->font; + staticTextItem.fontEngine = fontEngine; + staticTextItem.numGlyphs = glyphCount; + staticTextItem.glyphs = reinterpret_cast<glyph_t *>(const_cast<glyph_t *>(glyphArray)); + staticTextItem.glyphPositions = positions.data(); + + extended->drawStaticTextItem(&staticTextItem); + } else { + QTextItemInt textItem; + textItem.f = &state->font; + textItem.fontEngine = fontEngine; + + QVarLengthArray<QFixed, 128> advances(glyphCount); + QVarLengthArray<QGlyphJustification, 128> glyphJustifications(glyphCount); + QVarLengthArray<HB_GlyphAttributes, 128> glyphAttributes(glyphCount); + qMemSet(glyphAttributes.data(), 0, glyphAttributes.size() * sizeof(HB_GlyphAttributes)); + qMemSet(advances.data(), 0, advances.size() * sizeof(QFixed)); + qMemSet(glyphJustifications.data(), 0, glyphJustifications.size() * sizeof(QGlyphJustification)); + + textItem.glyphs.numGlyphs = glyphCount; + textItem.glyphs.glyphs = reinterpret_cast<HB_Glyph *>(const_cast<quint32 *>(glyphArray)); + textItem.glyphs.offsets = positions.data(); + textItem.glyphs.advances_x = advances.data(); + textItem.glyphs.advances_y = advances.data(); + textItem.glyphs.justifications = glyphJustifications.data(); + textItem.glyphs.attributes = glyphAttributes.data(); + + engine->drawTextItem(QPointF(0, 0), textItem); + } +} + /*! \fn void QPainter::drawStaticText(const QPoint &position, const QStaticText &staticText) @@ -8847,6 +8902,160 @@ QTransform QPainter::combinedTransform() const return d->state->worldMatrix * d->viewTransform(); } +/*! + \since 4.7 + + This function is used to draw \a pixmap, or a sub-rectangle of \a pixmap, + at multiple positions with different scale, rotation and opacity. \a + fragments is an array of \a fragmentCount elements specifying the + parameters used to draw each pixmap fragment. The \a hints + parameter can be used to pass in drawing hints. + + This function is potentially faster than multiple calls to drawPixmap(), + since the backend can optimize state changes. + + \sa QPainter::Fragment, QPainter::FragmentHint +*/ + +void QPainter::drawPixmapFragments(const Fragment *fragments, int fragmentCount, + const QPixmap &pixmap, FragmentHints hints) +{ + Q_D(QPainter); + + if (!d->engine) + return; + + if (d->engine->isExtended()) { + d->extended->drawPixmapFragments(fragments, fragmentCount, pixmap, hints); + } else { + qreal oldOpacity = opacity(); + QTransform oldTransform = transform(); + + for (int i = 0; i < fragmentCount; ++i) { + QTransform transform = oldTransform; + transform.translate(fragments[i].x, fragments[i].y); + transform.rotate(fragments[i].rotation); + setOpacity(oldOpacity * fragments[i].opacity); + setTransform(transform); + + qreal w = fragments[i].scaleX * fragments[i].width; + qreal h = fragments[i].scaleY * fragments[i].height; + QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop, + fragments[i].width, fragments[i].height); + drawPixmap(QRectF(-0.5 * w, -0.5 * h, w, h), pixmap, sourceRect); + } + + setOpacity(oldOpacity); + setTransform(oldTransform); + } +} + +/*! + \since 4.7 + \class QPainter::Fragment + + \brief This class is used in conjunction with the + QPainter::drawPixmapFragments() function to specify how a pixmap, or + sub-rect of a pixmap, is drawn. + + The \a sourceLeft, \a sourceTop, \a width and \a height variables are used + as a source rectangle within the pixmap passed into the + QPainter::drawPixmapFragments() function. The variables \a x, \a y, \a + width and \a height are used to calculate the target rectangle that is + drawn. \a x and \a y denotes the center of the target rectangle. The \a + width and \a heigth in the target rectangle is scaled by the \a scaleX and + \a scaleY values. The resulting target rectangle is then rotated \a + rotation degrees around the \a x, \a y center point. + + \sa QPainter::drawPixmapFragments() +*/ + +/*! + \since 4.7 + + This is a convenience function that returns a QPainter::Fragment that is + initialized with the \a pos, \a sourceRect, \a scaleX, \a scaleY, \a + rotation, \a opacity parameters. +*/ + +QPainter::Fragment QPainter::Fragment::create(const QPointF &pos, const QRectF &sourceRect, + qreal scaleX, qreal scaleY, qreal rotation, + qreal opacity) +{ + Fragment fragment = {pos.x(), pos.y(), sourceRect.x(), sourceRect.y(), sourceRect.width(), + sourceRect.height(), scaleX, scaleY, rotation, opacity}; + return fragment; +} + +/*! + \variable QPainter::Fragment::x + \brief the x coordinate of center point in the target rectangle. +*/ + +/*! + \variable QPainter::Fragment::y + \brief the y coordinate of the center point in the target rectangle. +*/ + +/*! + \variable QPainter::Fragment::sourceLeft + \brief the left coordinate of the source rectangle. +*/ + +/*! + \variable QPainter::Fragment::sourceTop + \brief the top coordinate of the source rectangle. +*/ + +/*! + \variable QPainter::Fragment::width + + \brief the width of the source rectangle and is used to calculate the width + of the target rectangle. +*/ + +/*! + \variable QPainter::Fragment::height + + \brief the height of the source rectangle and is used to calculate the + height of the target rectangle. +*/ + +/*! + \variable QPainter::Fragment::scaleX + \brief the horizontal scale of the target rectangle. +*/ + +/*! + \variable QPainter::Fragment::scaleY + \brief the vertical scale of the target rectangle. +*/ + +/*! + \variable QPainter::Fragment::rotation + + \brief the rotation of the target rectangle in degrees. The target + rectangle is rotated after it has been scaled. +*/ + +/*! + \variable QPainter::Fragment::opacity + + \brief the opacity of the target rectangle, where 0.0 is fully transparent + and 1.0 is fully opaque. +*/ + +/*! + \since 4.7 + + \enum QPainter::FragmentHint + + \value OpaqueHint Indicates that the pixmap fragments to be drawn are + opaque. Opaque fragments are potentially faster to draw. + + \sa QPainter::drawPixmapFragments(), QPainter::Fragment +*/ + void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation) { p->draw_helper(path, operation); diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index e9fd532..bcb0b50 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -99,6 +99,29 @@ public: Q_DECLARE_FLAGS(RenderHints, RenderHint) + class Fragment { + public: + qreal x; + qreal y; + qreal sourceLeft; + qreal sourceTop; + qreal width; + qreal height; + qreal scaleX; + qreal scaleY; + qreal rotation; + qreal opacity; + static Fragment Q_GUI_EXPORT create(const QPointF &pos, const QRectF &sourceRect, + qreal scaleX = 1, qreal scaleY = 1, + qreal rotation = 0, qreal opacity = 1); + }; + + enum FragmentHint { + OpaqueHint = 0x01 + }; + + Q_DECLARE_FLAGS(FragmentHints, FragmentHint) + QPainter(); explicit QPainter(QPaintDevice *); ~QPainter(); @@ -352,6 +375,9 @@ public: inline void drawPixmap(const QRect &r, const QPixmap &pm); inline void drawPixmap(int x, int y, int w, int h, const QPixmap &pm); + void drawPixmapFragments(const Fragment *fragments, int fragmentCount, + const QPixmap &pixmap, FragmentHints hints = 0); + void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags = Qt::AutoColor); inline void drawImage(const QRect &targetRect, const QImage &image, const QRect &sourceRect, diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h index 02a91aa..9362dbe 100644 --- a/src/gui/painting/qpainter_p.h +++ b/src/gui/painting/qpainter_p.h @@ -228,6 +228,7 @@ public: void draw_helper(const QPainterPath &path, DrawOperation operation = StrokeAndFillDraw); void drawStretchedGradient(const QPainterPath &path, DrawOperation operation); void drawOpaqueBackground(const QPainterPath &path, DrawOperation operation); + void drawGlyphs(const quint32 *glyphArray, const QPointF *positionArray, int glyphCount); void updateMatrix(); void updateInvMatrix(); @@ -238,6 +239,11 @@ public: void checkEmulation(); + static QPainterPrivate *get(QPainter *painter) + { + return painter->d_ptr.data(); + } + QTransform viewTransform() const; static bool attachPainterPrivate(QPainter *q, QPaintDevice *pdev); void detachPainterPrivate(QPainter *q); @@ -252,6 +258,8 @@ public: }; Q_GUI_EXPORT void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation); +Q_GUI_EXPORT void qt_draw_glyphs(QPainter *painter, const quint32 *glyphArray, + const QPointF *positionArray, int glyphCount); QString qt_generate_brush_key(const QBrush &brush); diff --git a/src/gui/painting/qprintengine_win.cpp b/src/gui/painting/qprintengine_win.cpp index d029b1e..ea9dc5d 100644 --- a/src/gui/painting/qprintengine_win.cpp +++ b/src/gui/painting/qprintengine_win.cpp @@ -368,7 +368,8 @@ void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem } // We only want to convert the glyphs to text if the entire string is compatible with ASCII - bool convertToText = true; + // and if we actually have access to the chars. + bool convertToText = ti.chars != 0; for (int i=0; i < ti.num_chars; ++i) { if (ti.chars[i].unicode() >= 0x80) { convertToText = false; diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 40ee31d..116b03e 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -3760,7 +3760,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QPalette np = tab->palette; np.setColor(QPalette::WindowText, QColor(255, 255, 255, 75)); QRect nr = subElementRect(SE_TabBarTabText, opt, w); - nr.moveTop(+1); + nr.moveTop(-1); int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextHideMnemonic; proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled, tab->text, QPalette::WindowText); diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index a2fff70..5adf237 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -291,6 +291,7 @@ private: friend class QFontMetricsF; friend class QFontInfo; friend class QPainter; + friend class QPainterPrivate; friend class QPSPrintEngineFont; friend class QApplication; friend class QWidget; diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index c000457..e5975d2 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -587,8 +587,9 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &t) { QImage i = alphaMapForGlyph(glyph); if (t.type() > QTransform::TxTranslate) - i = i.transformed(t); + i = i.transformed(t).convertToFormat(QImage::Format_Indexed8); Q_ASSERT(i.depth() <= 8); // To verify that transformed didn't change the format... + return i; } @@ -597,11 +598,14 @@ QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, int /* margin */, const Q QImage alphaMask = alphaMapForGlyph(glyph, t); QImage rgbMask(alphaMask.width(), alphaMask.height(), QImage::Format_RGB32); + QVector<QRgb> colorTable = alphaMask.colorTable(); for (int y=0; y<alphaMask.height(); ++y) { uint *dst = (uint *) rgbMask.scanLine(y); uchar *src = (uchar *) alphaMask.scanLine(y); - for (int x=0; x<alphaMask.width(); ++x) - dst[x] = qRgb(src[x], src[x], src[x]); + for (int x=0; x<alphaMask.width(); ++x) { + int val = qAlpha(colorTable.at(src[x])); + dst[x] = qRgb(val, val, val); + } } return rgbMask; diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index 1a815d3..55e93bd 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -208,7 +208,7 @@ void QFontEngineWin::getCMap() unitsPerEm = otm->otmEMSquare; x_height = (int)otm->otmsXHeight; loadKerningPairs(designToDevice); - _faceId.filename = QString::fromWCharArray((wchar_t *)((char *)otm + (int)otm->otmpFullName)).toLatin1(); + _faceId.filename = QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFullName)).toLatin1(); lineWidth = otm->otmsUnderscoreSize; fsType = otm->otmfsType; free(otm); @@ -1006,8 +1006,8 @@ QFontEngine::Properties QFontEngineWin::properties() const Properties p; p.emSquare = unitsPerEm; p.italicAngle = otm->otmItalicAngle; - p.postscriptName = QString::fromWCharArray((wchar_t *)((char *)otm + (int)otm->otmpFamilyName)).toLatin1(); - p.postscriptName += QString::fromWCharArray((wchar_t *)((char *)otm + (int)otm->otmpStyleName)).toLatin1(); + p.postscriptName = QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpFamilyName)).toLatin1(); + p.postscriptName += QString::fromWCharArray((wchar_t *)((char *)otm + (quintptr)otm->otmpStyleName)).toLatin1(); #ifndef QT_NO_PRINTER p.postscriptName = QPdf::stripSpecialCharacters(p.postscriptName); #endif diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index a7138b9..8fe4c47 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -350,15 +350,13 @@ QStaticTextPrivate::QStaticTextPrivate() : items(0), itemCount(0), glyphPool(0), positionPool(0), needsClipRect(false), useBackendOptimizations(false), textFormat(Qt::AutoText) { - ref = 1; } QStaticTextPrivate::QStaticTextPrivate(const QStaticTextPrivate &other) : text(other.text), font(other.font), maximumSize(other.maximumSize), matrix(other.matrix), items(0), itemCount(0), glyphPool(0), positionPool(0), needsClipRect(false), - useBackendOptimizations(false), textFormat(other.textFormat) + useBackendOptimizations(other.useBackendOptimizations), textFormat(other.textFormat) { - ref = 1; } QStaticTextPrivate::~QStaticTextPrivate() diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index ea464d5..25ad5d7 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1309,7 +1309,6 @@ void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem) ? QFontEngineGlyphCache::Type(textItem->fontEngine->glyphFormat) : d->glyphCacheType; - // ### What about huge fonts? These are not passed through cache in drawTextItem(). d->drawCachedGlyphs(glyphType, textItem, true); } @@ -1642,21 +1641,23 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp s->matrix = old; } -void QGL2PaintEngineEx::drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints) +void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::FragmentHints hints) { Q_D(QGL2PaintEngineEx); // Use fallback for extended composition modes. if (state()->composition_mode > QPainter::CompositionMode_Plus) { - QPaintEngineEx::drawPixmaps(drawingData, dataCount, pixmap, hints); + QPaintEngineEx::drawPixmapFragments(fragments, fragmentCount, pixmap, hints); return; } ensureActive(); - d->drawPixmaps(drawingData, dataCount, pixmap, hints); + d->drawPixmapFragments(fragments, fragmentCount, pixmap, hints); } -void QGL2PaintEngineExPrivate::drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints) +void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::Fragment *fragments, + int fragmentCount, const QPixmap &pixmap, + QPainter::FragmentHints hints) { GLfloat dx = 1.0f / pixmap.size().width(); GLfloat dy = 1.0f / pixmap.size().height(); @@ -1677,28 +1678,29 @@ void QGL2PaintEngineExPrivate::drawPixmaps(const QDrawPixmaps::Data *drawingData bool allOpaque = true; - for (int i = 0; i < dataCount; ++i) { + for (int i = 0; i < fragmentCount; ++i) { qreal s = 0; qreal c = 1; - if (drawingData[i].rotation != 0) { - s = qFastSin(drawingData[i].rotation * Q_PI / 180); - c = qFastCos(drawingData[i].rotation * Q_PI / 180); + if (fragments[i].rotation != 0) { + s = qFastSin(fragments[i].rotation * Q_PI / 180); + c = qFastCos(fragments[i].rotation * Q_PI / 180); } - qreal right = 0.5 * drawingData[i].scaleX * drawingData[i].source.width(); - qreal bottom = 0.5 * drawingData[i].scaleY * drawingData[i].source.height(); + qreal right = 0.5 * fragments[i].scaleX * fragments[i].width; + qreal bottom = 0.5 * fragments[i].scaleY * fragments[i].height; QGLPoint bottomRight(right * c - bottom * s, right * s + bottom * c); QGLPoint bottomLeft(-right * c - bottom * s, -right * s + bottom * c); - vertexCoordinateArray.lineToArray(bottomRight.x + drawingData[i].point.x(), bottomRight.y + drawingData[i].point.y()); - vertexCoordinateArray.lineToArray(-bottomLeft.x + drawingData[i].point.x(), -bottomLeft.y + drawingData[i].point.y()); - vertexCoordinateArray.lineToArray(-bottomRight.x + drawingData[i].point.x(), -bottomRight.y + drawingData[i].point.y()); - vertexCoordinateArray.lineToArray(-bottomRight.x + drawingData[i].point.x(), -bottomRight.y + drawingData[i].point.y()); - vertexCoordinateArray.lineToArray(bottomLeft.x + drawingData[i].point.x(), bottomLeft.y + drawingData[i].point.y()); - vertexCoordinateArray.lineToArray(bottomRight.x + drawingData[i].point.x(), bottomRight.y + drawingData[i].point.y()); + vertexCoordinateArray.lineToArray(bottomRight.x + fragments[i].x, bottomRight.y + fragments[i].y); + vertexCoordinateArray.lineToArray(-bottomLeft.x + fragments[i].x, -bottomLeft.y + fragments[i].y); + vertexCoordinateArray.lineToArray(-bottomRight.x + fragments[i].x, -bottomRight.y + fragments[i].y); + vertexCoordinateArray.lineToArray(-bottomRight.x + fragments[i].x, -bottomRight.y + fragments[i].y); + vertexCoordinateArray.lineToArray(bottomLeft.x + fragments[i].x, bottomLeft.y + fragments[i].y); + vertexCoordinateArray.lineToArray(bottomRight.x + fragments[i].x, bottomRight.y + fragments[i].y); - QGLRect src(drawingData[i].source.left() * dx, drawingData[i].source.top() * dy, - drawingData[i].source.right() * dx, drawingData[i].source.bottom() * dy); + QGLRect src(fragments[i].sourceLeft * dx, fragments[i].sourceTop * dy, + (fragments[i].sourceLeft + fragments[i].width) * dx, + (fragments[i].sourceTop + fragments[i].height) * dy); textureCoordinateArray.lineToArray(src.right, src.bottom); textureCoordinateArray.lineToArray(src.right, src.top); @@ -1707,7 +1709,7 @@ void QGL2PaintEngineExPrivate::drawPixmaps(const QDrawPixmaps::Data *drawingData textureCoordinateArray.lineToArray(src.left, src.bottom); textureCoordinateArray.lineToArray(src.right, src.bottom); - qreal opacity = drawingData[i].opacity * q->state()->opacity; + qreal opacity = fragments[i].opacity * q->state()->opacity; opacityArray << opacity << opacity << opacity << opacity << opacity << opacity; allOpaque &= (opacity >= 0.99f); } @@ -1720,21 +1722,22 @@ void QGL2PaintEngineExPrivate::drawPixmaps(const QDrawPixmaps::Data *drawingData if (texture->options & QGLContext::InvertedYBindOption) { // Flip texture y-coordinate. QGLPoint *data = textureCoordinateArray.data(); - for (int i = 0; i < 6 * dataCount; ++i) + for (int i = 0; i < 6 * fragmentCount; ++i) data[i].y = 1 - data[i].y; } transferMode(ImageArrayDrawingMode); bool isBitmap = pixmap.isQBitmap(); - bool isOpaque = !isBitmap && (!pixmap.hasAlphaChannel() || (hints & QDrawPixmaps::OpaqueHint)) && allOpaque; + bool isOpaque = !isBitmap && (!pixmap.hasAlphaChannel() || (hints & QPainter::OpaqueHint)) && allOpaque; updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, q->state()->renderHints & QPainter::SmoothPixmapTransform, texture->id); // Setup for texture drawing currentBrush = noBrush; - shaderManager->setSrcPixelType(isBitmap ? QGLEngineShaderManager::PatternSrc : QGLEngineShaderManager::ImageSrc); + shaderManager->setSrcPixelType(isBitmap ? QGLEngineShaderManager::PatternSrc + : QGLEngineShaderManager::ImageSrc); if (prepareForDraw(isOpaque)) shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT); @@ -1743,7 +1746,7 @@ void QGL2PaintEngineExPrivate::drawPixmaps(const QDrawPixmaps::Data *drawingData shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); } - glDrawArrays(GL_TRIANGLES, 0, 6 * dataCount); + glDrawArrays(GL_TRIANGLES, 0, 6 * fragmentCount); } bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index d4932be..5d3608b 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -125,7 +125,7 @@ public: virtual void drawTexture(const QRectF &r, GLuint textureId, const QSize &size, const QRectF &sr); virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); - virtual void drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints); + virtual void drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::FragmentHints hints); virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags = Qt::AutoColor); virtual void drawTextItem(const QPointF &p, const QTextItem &textItem); @@ -196,7 +196,7 @@ public: void fill(const QVectorPath &path); void stroke(const QVectorPath &path, const QPen &pen); void drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false); - void drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints); + void drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::FragmentHints hints); void drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType, QStaticTextItem *staticTextItem, bool includeMatrixInCache); diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 62f0293..bc9f0c9 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -93,7 +93,7 @@ public: VGFont font; VGfloat scaleX; VGfloat scaleY; - + uint cachedGlyphsMask[256 / 32]; QSet<glyph_t> cachedGlyphs; }; @@ -3035,9 +3035,8 @@ void QVGPaintEngine::drawTiledPixmap // (i.e. no opacity), no rotation or scaling, and drawing the full // pixmap rather than parts of the pixmap. Even having just one of // these conditions will improve performance. -void QVGPaintEngine::drawPixmaps - (const QDrawPixmaps::Data *drawingData, int dataCount, - const QPixmap &pixmap, QFlags<QDrawPixmaps::DrawingHint> hints) +void QVGPaintEngine::drawPixmapFragments(const QPainter::Fragment *drawingData, int dataCount, + const QPixmap &pixmap, QFlags<QPainter::FragmentHint> hints) { #if !defined(QT_SHIVAVG) Q_D(QVGPaintEngine); @@ -3048,7 +3047,7 @@ void QVGPaintEngine::drawPixmaps if (!pd) return; // null QPixmap if (pd->classId() != QPixmapData::OpenVGClass || !d->simpleTransform) { - QPaintEngineEx::drawPixmaps(drawingData, dataCount, pixmap, hints); + QPaintEngineEx::drawPixmapFragments(drawingData, dataCount, pixmap, hints); return; } @@ -3072,7 +3071,7 @@ void QVGPaintEngine::drawPixmaps QVarLengthArray<QRect> cachedSources; // Select the opacity paint object. - if ((hints & QDrawPixmaps::OpaqueHint) != 0 && d->opacity == 1.0f) { + if ((hints & QPainter::OpaqueHint) != 0 && d->opacity == 1.0f) { d->setImageMode(VG_DRAW_IMAGE_NORMAL); } else { hints = 0; @@ -3084,12 +3083,13 @@ void QVGPaintEngine::drawPixmaps for (int i = 0; i < dataCount; ++i) { QTransform transform(d->imageTransform); - transform.translate(drawingData[i].point.x(), drawingData[i].point.y()); + transform.translate(drawingData[i].x, drawingData[i].y); transform.rotate(drawingData[i].rotation); VGImage child; QSize imageSize = vgpd->size(); - QRectF sr = drawingData[i].source; + QRectF sr(drawingData[i].sourceLeft, drawingData[i].sourceTop, + drawingData[i].width, drawingData[i].height); if (sr.topLeft().isNull() && sr.size() == imageSize) { child = vgImg; } else { @@ -3118,7 +3118,7 @@ void QVGPaintEngine::drawPixmaps transform.scale(scaleX, scaleY); d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform); - if ((hints & QDrawPixmaps::OpaqueHint) == 0) { + if ((hints & QPainter::OpaqueHint) == 0) { qreal opacity = d->opacity * drawingData[i].opacity; if (opacity != 1.0f) { if (d->paintOpacity != opacity) { @@ -3144,7 +3144,7 @@ void QVGPaintEngine::drawPixmaps for (int i = 0; i < cachedImages.size(); ++i) vgDestroyImage(cachedImages[i]); #else - QPaintEngineEx::drawPixmaps(drawingData, dataCount, pixmap, hints); + QPaintEngineEx::drawPixmapFragments(drawingData, dataCount, pixmap, hints); #endif } @@ -3274,7 +3274,7 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) QPaintEngineEx::drawTextItem(p, textItem); return; } - + // Get the glyphs and positions associated with the text item. QVarLengthArray<QFixedPoint> positions; QVarLengthArray<glyph_t> glyphs; @@ -3284,7 +3284,7 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) (ti.glyphs, matrix, ti.flags, glyphs, positions); if (!drawCachedGlyphs(glyphs.size(), glyphs.data(), ti.font(), ti.fontEngine, p)) - QPaintEngineEx::drawTextItem(p, textItem); + QPaintEngineEx::drawTextItem(p, textItem); #else // OpenGL 1.0 does not have support for VGFont and glyphs, // so fall back to the default Qt path stroking algorithm. @@ -3312,7 +3312,7 @@ void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) glyphCache = new QVGFontGlyphCache(); if (glyphCache->font == VG_INVALID_HANDLE) { qWarning("QVGPaintEngine::drawTextItem: OpenVG fonts are not supported by the OpenVG engine"); - delete glyphCache; + delete glyphCache; return false; } glyphCache->setScaleFromText(font, fontEngine); diff --git a/src/openvg/qpaintengine_vg_p.h b/src/openvg/qpaintengine_vg_p.h index 3f73fed..1203af5 100644 --- a/src/openvg/qpaintengine_vg_p.h +++ b/src/openvg/qpaintengine_vg_p.h @@ -137,7 +137,7 @@ public: void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s); - void drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QFlags<QDrawPixmaps::DrawingHint> hints); + void drawPixmapFragments(const QPainter::Fragment *drawingData, int dataCount, const QPixmap &pixmap, QFlags<QPainter::FragmentHint> hints); void drawTextItem(const QPointF &p, const QTextItem &textItem); void drawStaticTextItem(QStaticTextItem *staticTextItem); diff --git a/src/plugins/mediaservices/gstreamer/gstreamer.pro b/src/plugins/mediaservices/gstreamer/gstreamer.pro index db0ee4e..22e3c16 100644 --- a/src/plugins/mediaservices/gstreamer/gstreamer.pro +++ b/src/plugins/mediaservices/gstreamer/gstreamer.pro @@ -8,16 +8,8 @@ unix:contains(QT_CONFIG, alsa) { LIBS += -lasound } -LIBS += -lXv - -CONFIG += link_pkgconfig - -PKGCONFIG += \ - gstreamer-0.10 \ - gstreamer-base-0.10 \ - gstreamer-interfaces-0.10 \ - gstreamer-audio-0.10 \ - gstreamer-video-0.10 +QMAKE_CXXFLAGS += $$QT_CFLAGS_GSTREAMER +LIBS += -lXv $$QT_LIBS_GSTREAMER -lgstinterfaces-0.10 -lgstvideo-0.10 -lgstbase-0.10 -lgstaudio-0.10 # Input HEADERS += \ diff --git a/src/plugins/mediaservices/mediaservices.pro b/src/plugins/mediaservices/mediaservices.pro index 0cef605..d84b276 100644 --- a/src/plugins/mediaservices/mediaservices.pro +++ b/src/plugins/mediaservices/mediaservices.pro @@ -5,16 +5,7 @@ contains(QT_CONFIG, mediaservice) { mac: SUBDIRS += qt7 - unix:!mac:!symbian { - TMP_GST_LIBS = \ - gstreamer-0.10 >= 0.10.19 \ - gstreamer-base-0.10 >= 0.10.19 \ - gstreamer-interfaces-0.10 >= 0.10.19 \ - gstreamer-audio-0.10 >= 0.10.19 \ - gstreamer-video-0.10 >= 0.10.19 - - system(pkg-config --exists \'$${TMP_GST_LIBS}\' --print-errors): { - SUBDIRS += gstreamer - } + unix:!mac:!symbian:contains(QT_CONFIG, xvideo):contains(QT_CONFIG, gstreamer) { + SUBDIRS += gstreamer } } diff --git a/src/qbase.pri b/src/qbase.pri index ef5d9e5..835ed0e 100644 --- a/src/qbase.pri +++ b/src/qbase.pri @@ -157,6 +157,7 @@ contains(QT_PRODUCT, OpenSource.*):DEFINES *= QT_OPENSOURCE DEFINES *= QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARNINGS contains(QT_CONFIG, qt3support):DEFINES *= QT3_SUPPORT DEFINES *= QT_MOC_COMPAT #we don't need warnings from calling moc code in our generated code +DEFINES *= QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION TARGET = $$qtLibraryTarget($$TARGET$$QT_LIBINFIX) #do this towards the end diff --git a/src/qt3support/text/q3richtext.cpp b/src/qt3support/text/q3richtext.cpp index 21383bd..8614076 100644 --- a/src/qt3support/text/q3richtext.cpp +++ b/src/qt3support/text/q3richtext.cpp @@ -6667,7 +6667,7 @@ Q3TextImage::Q3TextImage(Q3TextDocument *p, const QMap<QString, QString> &attr, imageName = attr[QLatin1String("source")]; if (!imageName.isEmpty()) { - imgId = QString::fromLatin1("%1,%2,%3,%4").arg(imageName).arg(width).arg(height).arg((ulong)&factory); + imgId = QString::fromLatin1("%1,%2,%3,%4").arg(imageName).arg(width).arg(height).arg((quintptr)&factory); if (!pixmap_map) pixmap_map = new QMap<QString, QPixmapInt>; if (pixmap_map->contains(imgId)) { diff --git a/src/qt3support/text/q3textedit.cpp b/src/qt3support/text/q3textedit.cpp index 7f51bea..d4f75ed 100644 --- a/src/qt3support/text/q3textedit.cpp +++ b/src/qt3support/text/q3textedit.cpp @@ -6238,7 +6238,7 @@ void Q3TextEdit::optimParseTags(QString * line, int lineNo, int indexOffset) } else { tmp = tagStack.isEmpty() ? 0 : tagStack.pop(); if (!tmp) { - if (((QLatin1Char('/') + cur->tag) == tag->tag) || + if ((QString(QLatin1Char('/') + cur->tag) == tag->tag) || (tag->tag == QLatin1String("/font") && cur->tag.left(4) == QLatin1String("font"))) { // set up the left and parent of this tag tag->leftTag = cur; diff --git a/src/qt3support/text/q3textstream.cpp b/src/qt3support/text/q3textstream.cpp index 41aab4d..8c86c7c 100644 --- a/src/qt3support/text/q3textstream.cpp +++ b/src/qt3support/text/q3textstream.cpp @@ -2084,7 +2084,7 @@ Q3TextStream &Q3TextStream::operator<<( void *ptr ) setf( hex, basefield ); setf( showbase ); unsetf( uppercase ); - output_int( I_LONG | I_UNSIGNED, (ulong)ptr, FALSE ); + output_int( I_LONG | I_UNSIGNED, (quintptr)ptr, FALSE ); flags( f ); return *this; } diff --git a/src/qt3support/tools/q3gcache.cpp b/src/qt3support/tools/q3gcache.cpp index a31f827..ada8330 100644 --- a/src/qt3support/tools/q3gcache.cpp +++ b/src/qt3support/tools/q3gcache.cpp @@ -226,7 +226,7 @@ public: bool remove_ascii(Q3CacheItem *item) { return Q3GDict::remove_ascii((const char *)item->key,item); } bool remove_int(Q3CacheItem *item) - { return Q3GDict::remove_int((long)item->key,item);} + { return Q3GDict::remove_int((quintptr)item->key,item);} void statistics() { Q3GDict::statistics(); } @@ -426,7 +426,7 @@ bool Q3GCache::insert_other(const char *key, Q3PtrCollection::Item data, if (keytype == AsciiKey) dict->insert_ascii(key, ci); else - dict->insert_int((long)key, ci); + dict->insert_int((quintptr)key, ci); tCost += cost; return true; } @@ -486,7 +486,7 @@ Q3PtrCollection::Item Q3GCache::take_other(const char *key) if (keytype == AsciiKey) ci = dict->take_ascii(key); else - ci = dict->take_int((long)key); + ci = dict->take_int((quintptr)key); Item d; if (ci) { d = ci->data; @@ -563,7 +563,7 @@ Q3PtrCollection::Item Q3GCache::find_string(const QString &key, bool ref) const Q3PtrCollection::Item Q3GCache::find_other(const char *key, bool ref) const { Q3CacheItem *ci = keytype == AsciiKey ? dict->find_ascii(key) - : dict->find_int((long)key); + : dict->find_int((quintptr)key); #if defined(QT_DEBUG) lruList->finds++; #endif @@ -811,7 +811,7 @@ const char *Q3GCacheIterator::getKeyAscii() const long Q3GCacheIterator::getKeyInt() const { Q3CacheItem *item = it->current(); - return item ? (long)item->key : 0; + return item ? (quintptr)item->key : 0; } /*! diff --git a/src/qt3support/tools/q3gdict.cpp b/src/qt3support/tools/q3gdict.cpp index a968407..e8144fe 100644 --- a/src/qt3support/tools/q3gdict.cpp +++ b/src/qt3support/tools/q3gdict.cpp @@ -437,7 +437,7 @@ Q3PtrCollection::Item Q3GDict::look_int(long key, Q3PtrCollection::Item d, int o Q3PtrCollection::Item Q3GDict::look_ptr(void *key, Q3PtrCollection::Item d, int op) { Q3PtrBucket *n; - int index = (int)((ulong)key % vlen); // simple hash + int index = (int)((quintptr)key % vlen); // simple hash if (op == op_find) { // find for (n=(Q3PtrBucket*)vec[index]; n; n=(Q3PtrBucket*)n->getNext()) { @@ -650,7 +650,7 @@ Q3PtrBucket *Q3GDict::unlink_ptr(void *key, Q3PtrCollection::Item d) return 0; Q3PtrBucket *n; Q3PtrBucket *prev = 0; - int index = (int)((ulong)key % vlen); + int index = (int)((quintptr)key % vlen); for (n=(Q3PtrBucket *)vec[index]; n; n=(Q3PtrBucket *)n->getNext()) { bool found = (n->getKey() == key); if (found && d) diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp index b5c85e6..de2be89 100644 --- a/src/sql/drivers/oci/qsql_oci.cpp +++ b/src/sql/drivers/oci/qsql_oci.cpp @@ -56,6 +56,12 @@ #include <qvector.h> #include <qdebug.h> +// This is needed for oracle oci when compiling with mingw-w64 headers +#if defined(__MINGW64_VERSION_MAJOR) && defined(_WIN64) +#define _int64 __int64 +#endif + + #include <oci.h> #ifdef max #undef max diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index fab3ab3..9f7d267 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE #define ODBC_CHECK_DRIVER // newer platform SDKs use SQLLEN instead of SQLINTEGER -#if defined(WIN32) && (_MSC_VER < 1300) +#if defined(WIN32) && (_MSC_VER < 1300) && !defined(__MINGW64_VERSION_MAJOR) # define QSQLLEN SQLINTEGER # define QSQLULEN SQLUINTEGER #else |