diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-17 15:36:59 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-17 15:36:59 (GMT) |
commit | 54b20c491f7e182f6b98f65b7e9e8e68286d6109 (patch) | |
tree | 7f17d6b2540ea226eb7d8d1b830f31f1a032316a /src | |
parent | dcb2678f39345b66c5303e74c156654a8d13fe83 (diff) | |
parent | 17a0a50a101fc9863d0dffd0dcb887ba68a99622 (diff) | |
download | Qt-54b20c491f7e182f6b98f65b7e9e8e68286d6109.zip Qt-54b20c491f7e182f6b98f65b7e9e8e68286d6109.tar.gz Qt-54b20c491f7e182f6b98f65b7e9e8e68286d6109.tar.bz2 |
Merge branch '4.6' into qt-master-from-4.6
Conflicts:
mkspecs/common/symbian/symbian.conf
src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
tools/assistant/tools/assistant/helpviewer.cpp
Diffstat (limited to 'src')
56 files changed, 746 insertions, 298 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 1c607a6..ca5e658 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -80,6 +80,7 @@ #endif // QT_NO_CODECS #include "qlocale.h" #include "qmutex.h" +#include "qhash.h" #include <stdlib.h> #include <ctype.h> @@ -172,6 +173,7 @@ static QTextCodec *createForMib(int mib) } static QList<QTextCodec*> *all = 0; +static int clearCaches = 0; // flags specifying if caches should be invalided: 0x1 codecForName, 0x2 codecForMib #ifdef Q_DEBUG_TEXTCODEC static bool destroying_is_ok = false; #endif @@ -935,6 +937,7 @@ QTextCodec::~QTextCodec() QMutexLocker locker(textCodecsMutex()); #endif all->removeAll(this); + clearCaches = 0x1 | 0x2; } } @@ -961,17 +964,33 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name) #endif setup(); + static QHash <QByteArray, QTextCodec *> cache; + if (clearCaches & 0x1) { + cache.clear(); + clearCaches &= ~0x1; + } + QTextCodec *codec = cache.value(name); + if (codec) + return codec; + for (int i = 0; i < all->size(); ++i) { QTextCodec *cursor = all->at(i); - if (nameMatch(cursor->name(), name)) + if (nameMatch(cursor->name(), name)) { + cache.insert(name, cursor); return cursor; + } QList<QByteArray> aliases = cursor->aliases(); for (int y = 0; y < aliases.size(); ++y) - if (nameMatch(aliases.at(y), name)) + if (nameMatch(aliases.at(y), name)) { + cache.insert(name, cursor); return cursor; + } } - return createForName(name); + codec = createForName(name); + if (codec) + cache.insert(name, codec); + return codec; } @@ -986,19 +1005,34 @@ QTextCodec* QTextCodec::codecForMib(int mib) #endif setup(); - // Qt 3 used 1000 (mib for UCS2) as its identifier for the utf16 codec. Map - // this correctly for compatibility. - if (mib == 1000) - mib = 1015; + static QHash <int, QTextCodec *> cache; + if (clearCaches & 0x2) { + cache.clear(); + clearCaches &= ~0x2; + } + QTextCodec *codec = cache.value(mib); + if (codec) + return codec; QList<QTextCodec*>::ConstIterator i; for (int i = 0; i < all->size(); ++i) { QTextCodec *cursor = all->at(i); - if (cursor->mibEnum() == mib) + if (cursor->mibEnum() == mib) { + cache.insert(mib, cursor); return cursor; + } } - return createForMib(mib); + codec = createForMib(mib); + + // Qt 3 used 1000 (mib for UCS2) as its identifier for the utf16 codec. Map + // this correctly for compatibility. + if (!codec && mib == 1000) + return codecForMib(1015); + + if (codec) + cache.insert(mib, codec); + return codec; } /*! diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h index 5012b42..e00d7b4 100644 --- a/src/corelib/codecs/qtextcodec.h +++ b/src/corelib/codecs/qtextcodec.h @@ -174,8 +174,10 @@ private: friend class QXmlStreamWriter; friend class QXmlStreamWriterPrivate; +#if defined Q_XMLSTREAM_RENAME_SYMBOLS friend class QCoreXmlStreamWriter; friend class QCoreXmlStreamWriterPrivate; +#endif }; class Q_CORE_EXPORT QTextDecoder { diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 9a15bf1..efee610 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -35,4 +35,20 @@ symbian: { # Workaroud for problems with paging this dll MMP_RULES -= PAGED MMP_RULES *= UNPAGED + + # Partial upgrade SIS file + vendorinfo = \ + "&EN" \ + "; Localised Vendor name" \ + "%{\"Nokia, Qt\"}" \ + " " \ + "; Unique Vendor name" \ + ":\"Nokia, Qt\"" \ + " " + pu_header = "; Partial upgrade package for testing QtCore changes without reinstalling everything" \ + "$${LITERAL_HASH}{\"Qt corelib\"}, (0x2001E61C), $${QT_MAJOR_VERSION},$${QT_MINOR_VERSION},$${QT_PATCH_VERSION}, TYPE=PU" + partial_upgrade.pkg_prerules = pu_header vendorinfo + partial_upgrade.sources = qtcore.dll + partial_upgrade.path = c:/sys/bin + DEPLOYMENT = partial_upgrade $$DEPLOYMENT } diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index 7c1887e..fc35bfa 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -157,6 +157,13 @@ QT_BEGIN_NAMESPACE data, followed by the data. Note that any encoding/decoding of the data (apart from the length quint32) must be done by you. + \section1 Reading and writing Qt collection classes + + The Qt collection classes can also be serialized to a QDataStream. + These include QList, QLinkedList, QVector, QSet, QHash, and QMap. + These classes have have stream operators declared as non-member of + the class. + \target Serializing Qt Classes \section1 Reading and writing other Qt classes. diff --git a/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/src/corelib/io/qfilesystemwatcher_kqueue.cpp index 8396481..99c165e 100644 --- a/src/corelib/io/qfilesystemwatcher_kqueue.cpp +++ b/src/corelib/io/qfilesystemwatcher_kqueue.cpp @@ -260,12 +260,22 @@ void QKqueueFileSystemWatcherEngine::run() DEBUG() << "QKqueueFileSystemWatcherEngine: processing kevent" << kev.ident << kev.filter; if (fd == kqpipe[0]) { - char c; - if (read(kqpipe[0], &c, 1) != 1) { + // read all pending data from the pipe + QByteArray ba; + ba.resize(kev.data); + if (read(kqpipe[0], ba.data(), ba.size()) != ba.size()) { perror("QKqueueFileSystemWatcherEngine: error reading from pipe"); return; } - switch (c) { + // read the command from the buffer (but break and return on 'q') + char cmd = 0; + for (int i = 0; i < ba.size(); ++i) { + cmd = ba.constData()[i]; + if (cmd == 'q') + break; + } + // handle the command + switch (cmd) { case 'q': DEBUG() << "QKqueueFileSystemWatcherEngine: thread received 'q', exiting..."; return; @@ -273,7 +283,7 @@ void QKqueueFileSystemWatcherEngine::run() DEBUG() << "QKqueueFileSystemWatcherEngine: thread received '@', continuing..."; break; default: - DEBUG() << "QKqueueFileSystemWatcherEngine: thread received unknow message" << c; + DEBUG() << "QKqueueFileSystemWatcherEngine: thread received unknow message" << cmd; break; } } else { diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index eb99f27..d8b1c03 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1479,7 +1479,7 @@ QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions() const { //### what to do with permissions if we don't use NTFS // for now just add all permissions and what about exe missions ?? - // also qt_ntfs_permission_lookup is now not set by defualt ... should it ? + // also qt_ntfs_permission_lookup is now not set by default ... should it ? ret |= QAbstractFileEngine::ReadOtherPerm | QAbstractFileEngine::ReadGroupPerm | QAbstractFileEngine::ReadOwnerPerm | QAbstractFileEngine::ReadUserPerm | QAbstractFileEngine::WriteUserPerm | QAbstractFileEngine::WriteOwnerPerm diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 7c8fb3d..818b7cf 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -68,6 +68,14 @@ extern uint qGlobalPostedEventsCount(); # define QS_RAWINPUT 0x0400 #endif +#ifndef WM_TOUCH +# define WM_TOUCH 0x0240 +#endif +#ifndef WM_GESTURE +# define WM_GESTURE 0x0119 +# define WM_GESTURENOTIFY 0x011A +#endif + enum { WM_QT_SOCKETNOTIFIER = WM_USER, WM_QT_SENDPOSTEDEVENTS = WM_USER + 1, @@ -729,6 +737,9 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) && msg.message <= WM_MOUSELAST) || msg.message == WM_MOUSEWHEEL || msg.message == WM_MOUSEHWHEEL + || msg.message == WM_TOUCH + || msg.message == WM_GESTURE + || msg.message == WM_GESTURENOTIFY || msg.message == WM_CLOSE)) { // queue user input events for later processing haveMessage = false; diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 1f7fdb2..aa5603d 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -221,22 +221,29 @@ void QContiguousCache<T>::setCapacity(int asize) x.d->alloc = asize; x.d->count = qMin(d->count, asize); x.d->offset = d->offset + d->count - x.d->count; - x.d->start = x.d->offset % x.d->alloc; - T *dest = x.p->array + (x.d->start + x.d->count-1) % x.d->alloc; - T *src = p->array + (d->start + d->count-1) % d->alloc; + if(asize) + x.d->start = x.d->offset % x.d->alloc; + else + x.d->start = 0; + int oldcount = x.d->count; - while (oldcount--) { - if (QTypeInfo<T>::isComplex) { - new (dest) T(*src); - } else { - *dest = *src; + if(oldcount) + { + T *dest = x.p->array + (x.d->start + x.d->count-1) % x.d->alloc; + T *src = p->array + (d->start + d->count-1) % d->alloc; + while (oldcount--) { + if (QTypeInfo<T>::isComplex) { + new (dest) T(*src); + } else { + *dest = *src; + } + if (dest == x.p->array) + dest = x.p->array + x.d->alloc; + dest--; + if (src == p->array) + src = p->array + d->alloc; + src--; } - if (dest == x.p->array) - dest = x.p->array + x.d->alloc; - dest--; - if (src == p->array) - src = p->array + d->alloc; - src--; } /* free old */ free(p); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 44abf7b..6cb4924 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1937,7 +1937,7 @@ int QDBusConnectionPrivate::sendWithReplyAsync(const QDBusMessage &message, QObj QDBusPendingCallPrivate *pcall = sendWithReplyAsync(message, timeout); Q_ASSERT(pcall); - // has it already finished (dispatched locally)? + // has it already finished with success (dispatched locally)? if (pcall->replyMessage.type() == QDBusMessage::ReplyMessage) { pcall->setReplyCallback(receiver, returnMethod); processFinishedCall(pcall); @@ -1945,33 +1945,24 @@ int QDBusConnectionPrivate::sendWithReplyAsync(const QDBusMessage &message, QObj return 1; } + // either it hasn't finished or it has finished with error + if (errorMethod) { + pcall->watcherHelper = new QDBusPendingCallWatcherHelper; + connect(pcall->watcherHelper, SIGNAL(error(QDBusError,QDBusMessage)), receiver, errorMethod, + Qt::QueuedConnection); + pcall->watcherHelper->moveToThread(thread()); + } + // has it already finished and is an error reply message? if (pcall->replyMessage.type() == QDBusMessage::ErrorMessage) { - if (errorMethod) { - pcall->watcherHelper = new QDBusPendingCallWatcherHelper; - connect(pcall->watcherHelper, SIGNAL(error(QDBusError,QDBusMessage)), receiver, errorMethod); - pcall->watcherHelper->moveToThread(thread()); - } processFinishedCall(pcall); delete pcall; return 1; } - // has it already finished with error? - if (pcall->replyMessage.type() != QDBusMessage::InvalidMessage) { - delete pcall; - return 0; - } - pcall->autoDelete = true; pcall->ref.ref(); - pcall->setReplyCallback(receiver, returnMethod); - if (errorMethod) { - pcall->watcherHelper = new QDBusPendingCallWatcherHelper; - connect(pcall->watcherHelper, SIGNAL(error(QDBusError,QDBusMessage)), receiver, errorMethod); - pcall->watcherHelper->moveToThread(thread()); - } return 1; } diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 10ef5ea..7d1d03d 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -699,12 +699,17 @@ void QGraphicsColorizeEffect::draw(QPainter *painter) if (sourceIsPixmap()) { // No point in drawing in device coordinates (pixmap will be scaled anyways). const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad); - d->filter->draw(painter, offset, pixmap); + if (!pixmap.isNull()) + d->filter->draw(painter, offset, pixmap); + return; } // Draw pixmap in deviceCoordinates to avoid pixmap scaling. const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset); + if (pixmap.isNull()) + return; + QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); @@ -858,9 +863,11 @@ void QGraphicsBlurEffect::draw(QPainter *painter) if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) mode = NoPad; - // Draw pixmap in device coordinates to avoid pixmap scaling. QPoint offset; QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, mode); + if (pixmap.isNull()) + return; + d->filter->draw(painter, offset, pixmap); } @@ -1047,6 +1054,9 @@ void QGraphicsDropShadowEffect::draw(QPainter *painter) // Draw pixmap in device coordinates to avoid pixmap scaling. QPoint offset; const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode); + if (pixmap.isNull()) + return; + QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index ae3d6c3..4d447cb 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -54,9 +54,10 @@ QT_BEGIN_NAMESPACE static QEglContext * volatile currentGLContext = 0; static QEglContext * volatile currentVGContext = 0; +EGLDisplay QEglContext::dpy = EGL_NO_DISPLAY; + QEglContext::QEglContext() : apiType(QEgl::OpenGL) - , dpy(EGL_NO_DISPLAY) , ctx(EGL_NO_CONTEXT) , cfg(0) , currentSurface(EGL_NO_SURFACE) @@ -68,7 +69,7 @@ QEglContext::QEglContext() QEglContext::~QEglContext() { - destroy(); + destroyContext(); if (currentGLContext == this) currentGLContext = 0; @@ -86,14 +87,6 @@ bool QEglContext::isCurrent() const return current; } -// Open the EGL display associated with "device". -bool QEglContext::openDisplay(QPaintDevice *device) -{ - if (dpy == EGL_NO_DISPLAY) - dpy = defaultDisplay(device); - return (dpy != EGL_NO_DISPLAY); -} - // Choose a configuration that matches "properties". bool QEglContext::chooseConfig (const QEglProperties& properties, QEgl::PixelFormatMatch match) @@ -102,7 +95,7 @@ bool QEglContext::chooseConfig do { // Get the number of matching configurations for this set of properties. EGLint matching = 0; - if (!eglChooseConfig(dpy, props.properties(), 0, 0, &matching) || !matching) + if (!eglChooseConfig(display(), props.properties(), 0, 0, &matching) || !matching) continue; // If we want the best pixel format, then return the first @@ -179,7 +172,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties if (shareContext && shareContext->ctx == EGL_NO_CONTEXT) shareContext = 0; if (shareContext) { - ctx = eglCreateContext(dpy, cfg, shareContext->ctx, contextProps.properties()); + ctx = eglCreateContext(display(), cfg, shareContext->ctx, contextProps.properties()); if (ctx == EGL_NO_CONTEXT) { qWarning() << "QEglContext::createContext(): Could not share context:" << errorString(eglGetError()); shareContext = 0; @@ -209,7 +202,7 @@ void QEglContext::destroySurface(EGLSurface surface) } // Destroy the context. Note: this does not destroy the surface. -void QEglContext::destroy() +void QEglContext::destroyContext() { if (ctx != EGL_NO_CONTEXT && ownsContext) eglDestroyContext(dpy, ctx); @@ -248,7 +241,7 @@ bool QEglContext::makeCurrent(EGLSurface surface) eglBindAPI(EGL_OPENVG_API); #endif - bool ok = eglMakeCurrent(dpy, surface, surface, ctx); + bool ok = eglMakeCurrent(display(), surface, surface, ctx); if (!ok) qWarning() << "QEglContext::makeCurrent():" << errorString(eglGetError()); return ok; @@ -277,7 +270,7 @@ bool QEglContext::doneCurrent() eglBindAPI(EGL_OPENVG_API); #endif - bool ok = eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + bool ok = eglMakeCurrent(display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (!ok) qWarning() << "QEglContext::doneCurrent():" << errorString(eglGetError()); return ok; @@ -299,7 +292,7 @@ bool QEglContext::swapBuffers(EGLSurface surface) if(ctx == EGL_NO_CONTEXT) return false; - bool ok = eglSwapBuffers(dpy, surface); + bool ok = eglSwapBuffers(display(), surface); if (!ok) qWarning() << "QEglContext::swapBuffers():" << errorString(eglGetError()); return ok; @@ -338,7 +331,7 @@ void QEglContext::waitClient() // Query the value of a configuration attribute. bool QEglContext::configAttrib(int name, EGLint *value) const { - return eglGetConfigAttrib(dpy, cfg, name, value); + return eglGetConfigAttrib(display(), cfg, name, value); } // Retrieve all of the properties on "cfg". If zero, return @@ -357,27 +350,38 @@ QEglProperties QEglContext::configProperties(EGLConfig cfg) const return props; } -// Initialize and return the default display. -EGLDisplay QEglContext::defaultDisplay(QPaintDevice *device) +EGLDisplay QEglContext::display() { - static EGLDisplay dpy = EGL_NO_DISPLAY; - if (dpy == EGL_NO_DISPLAY) { - dpy = getDisplay(device); + static bool openedDisplay = false; + + if (!openedDisplay) { + dpy = eglGetDisplay(nativeDisplay()); + openedDisplay = true; + if (dpy == EGL_NO_DISPLAY) { + qWarning("QEglContext::display(): Falling back to EGL_DEFAULT_DISPLAY"); + dpy = eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); + } if (dpy == EGL_NO_DISPLAY) { - qWarning() << "QEglContext::defaultDisplay(): Cannot open EGL display"; + qWarning("QEglContext::display(): Can't even open the default display"); return EGL_NO_DISPLAY; } + if (!eglInitialize(dpy, NULL, NULL)) { - qWarning() << "QEglContext::defaultDisplay(): Cannot initialize EGL display:" << errorString(eglGetError()); + qWarning() << "QEglContext::display(): Cannot initialize EGL display:" << errorString(eglGetError()); return EGL_NO_DISPLAY; } -#ifdef EGL_OPENGL_ES_API - eglBindAPI(EGL_OPENGL_ES_API); -#endif } + return dpy; } +#if !defined(Q_WS_X11) && !defined(Q_WS_WINCE) // WinCE & X11 implement this properly +EGLNativeDisplayType QEglContext::nativeDisplay() +{ + return EGL_DEFAULT_DISPLAY; +} +#endif + // Return the error string associated with a specific code. QString QEglContext::errorString(EGLint code) { @@ -410,7 +414,7 @@ void QEglContext::dumpAllConfigs() { QEglProperties props; EGLint count = 0; - if (!eglGetConfigs(dpy, 0, 0, &count) || count < 1) + if (!eglGetConfigs(display(), 0, 0, &count) || count < 1) return; EGLConfig *configs = new EGLConfig [count]; eglGetConfigs(dpy, configs, count, &count); @@ -423,7 +427,7 @@ void QEglContext::dumpAllConfigs() QString QEglContext::extensions() { - const char* exts = eglQueryString(QEglContext::defaultDisplay(0), EGL_EXTENSIONS); + const char* exts = eglQueryString(QEglContext::display(), EGL_EXTENSIONS); return QString(QLatin1String(exts)); } @@ -431,7 +435,7 @@ bool QEglContext::hasExtension(const char* extensionName) { QList<QByteArray> extensions = QByteArray(reinterpret_cast<const char *> - (eglQueryString(QEglContext::defaultDisplay(0), EGL_EXTENSIONS))).split(' '); + (eglQueryString(QEglContext::display(), EGL_EXTENSIONS))).split(' '); return extensions.contains(extensionName); } diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index a7de9c8..87ed818 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -86,14 +86,12 @@ public: QEgl::API api() const { return apiType; } void setApi(QEgl::API api) { apiType = api; } - bool openDisplay(QPaintDevice *device); bool chooseConfig(const QEglProperties& properties, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat); bool createContext(QEglContext *shareContext = 0, const QEglProperties *properties = 0); + void destroyContext(); EGLSurface createSurface(QPaintDevice *device, const QEglProperties *properties = 0); void destroySurface(EGLSurface surface); - void destroy(); - bool makeCurrent(EGLSurface surface); bool doneCurrent(); bool lazyDoneCurrent(); @@ -108,7 +106,7 @@ public: static EGLint error() { return eglGetError(); } static QString errorString(EGLint code); - EGLDisplay display() const { return dpy; } + static EGLDisplay display(); EGLContext context() const { return ctx; } void setContext(EGLContext context) { ctx = context; ownsContext = false;} @@ -118,8 +116,6 @@ public: QEglProperties configProperties(EGLConfig cfg = 0) const; - static EGLDisplay defaultDisplay(QPaintDevice *device); - void dumpAllConfigs(); static QString extensions(); @@ -127,7 +123,6 @@ public: private: QEgl::API apiType; - EGLDisplay dpy; EGLContext ctx; EGLConfig cfg; EGLSurface currentSurface; @@ -135,7 +130,8 @@ private: bool ownsContext; bool sharing; - static EGLDisplay getDisplay(QPaintDevice *device); + static EGLDisplay dpy; + static EGLNativeDisplayType nativeDisplay(); static QEglContext *currentContext(QEgl::API api); static void setCurrentContext(QEgl::API api, QEglContext *context); diff --git a/src/gui/egl/qegl_qws.cpp b/src/gui/egl/qegl_qws.cpp index e999e0b..2a61beb 100644 --- a/src/gui/egl/qegl_qws.cpp +++ b/src/gui/egl/qegl_qws.cpp @@ -64,12 +64,6 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties return EGL_NO_SURFACE; } -EGLDisplay QEglContext::getDisplay(QPaintDevice *device) -{ - Q_UNUSED(device); - return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); -} - static QScreen *screenForDevice(QPaintDevice *device) { QScreen *screen = qt_screen; diff --git a/src/gui/egl/qegl_symbian.cpp b/src/gui/egl/qegl_symbian.cpp index 44ecd19..b1c9408 100644 --- a/src/gui/egl/qegl_symbian.cpp +++ b/src/gui/egl/qegl_symbian.cpp @@ -86,14 +86,6 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties return surf; } -EGLDisplay QEglContext::getDisplay(QPaintDevice *device) -{ - EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (dpy == EGL_NO_DISPLAY) - qWarning("QEglContext::defaultDisplay(): Falling back to EGL_DEFAULT_DISPLAY"); - return dpy; -} - // Set pixel format and other properties based on a paint device. void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev) { diff --git a/src/gui/egl/qegl_wince.cpp b/src/gui/egl/qegl_wince.cpp index 026a7b1..c9c9773 100644 --- a/src/gui/egl/qegl_wince.cpp +++ b/src/gui/egl/qegl_wince.cpp @@ -87,20 +87,15 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties return surf; } -EGLDisplay QEglContext::getDisplay(QPaintDevice *device) +EGLNativeDisplayType QEglContext::nativeDisplay() { - EGLDisplay dpy = 0; HWND win = (static_cast<QWidget*>(device))->winId(); HDC myDc = GetDC(win); if (!myDc) { - qWarning("QEglContext::defaultDisplay(): WinCE display is not open"); + qWarning("QEglContext::nativeDisplay(): WinCE display is not open"); + return EGL_DEFAULT_DISPLAY; } - dpy = eglGetDisplay(EGLNativeDisplayType(myDc)); - if (dpy == EGL_NO_DISPLAY) { - qWarning("QEglContext::defaultDisplay(): Falling back to EGL_DEFAULT_DISPLAY"); - dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - } - return dpy; + return EGLNativeDisplayType(myDc); } // Set pixel format and other properties based on a paint device. diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index 2cf4e33..634ff13 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -93,15 +93,14 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties return surf; } -EGLDisplay QEglContext::getDisplay(QPaintDevice *device) +EGLNativeDisplayType QEglContext::nativeDisplay() { - Q_UNUSED(device); Display *xdpy = QX11Info::display(); if (!xdpy) { qWarning("QEglContext::getDisplay(): X11 display is not open"); - return EGL_NO_DISPLAY; + return EGLNativeDisplayType(EGL_DEFAULT_DISPLAY); } - return eglGetDisplay(EGLNativeDisplayType(xdpy)); + return EGLNativeDisplayType(xdpy); } static int countBits(unsigned long mask) diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp index 2915fb9..236ec37 100644 --- a/src/gui/egl/qeglproperties.cpp +++ b/src/gui/egl/qeglproperties.cpp @@ -60,7 +60,7 @@ QEglProperties::QEglProperties(EGLConfig cfg) props.append(EGL_NONE); for (int name = 0x3020; name <= 0x304F; ++name) { EGLint value; - if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::defaultDisplay(0), cfg, name, &value)) + if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::display(), cfg, name, &value)) setValue(name, value); } eglGetError(); // Clear the error state. @@ -273,12 +273,12 @@ static void addTag(QString& str, const QString& tag) void QEglProperties::dumpAllConfigs() { EGLint count = 0; - eglGetConfigs(QEglContext::defaultDisplay(0), 0, 0, &count); + eglGetConfigs(QEglContext::display(), 0, 0, &count); if (count < 1) return; EGLConfig *configs = new EGLConfig [count]; - eglGetConfigs(QEglContext::defaultDisplay(0), configs, count, &count); + eglGetConfigs(QEglContext::display(), configs, count, &count); for (EGLint index = 0; index < count; ++index) qWarning() << QEglProperties(configs[index]).toString(); delete [] configs; diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 63b0ec7..dd0c047 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -357,19 +357,22 @@ default, child items are stacked on top of the parent item. But setting this flag, the child will be stacked behind it. This flag is useful for drop shadow effects and for decoration objects that follow the parent - item's geometry without drawing on top of it. + item's geometry without drawing on top of it. This flag was introduced + in Qt 4.5. \value ItemUsesExtendedStyleOption The item makes use of either - \l{QStyleOptionGraphicsItem::}{exposedRect} or - \l{QStyleOptionGraphicsItem::}{matrix} in QStyleOptionGraphicsItem. By default, - the \l{QStyleOptionGraphicsItem::}{exposedRect} is initialized to the item's - boundingRect() and the \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. - You can enable this flag for the style options to be set up with more - fine-grained values. - Note that QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag + \l{QStyleOptionGraphicsItem::} {exposedRect} or + \l{QStyleOptionGraphicsItem::} {matrix} in + QStyleOptionGraphicsItem. By default, the + \l{QStyleOptionGraphicsItem::} {exposedRect} is initialized to the + item's boundingRect() and the + \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. You can + enable this flag for the style options to be set up with more + fine-grained values. Note that + QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag and always initialized to 1. Use - QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need a higher - value. + QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need + a higher value. This flag was introduced in Qt 4.6. \value ItemHasNoContents The item does not paint anything (i.e., calling paint() on the item has no effect). You should set this flag on items that @@ -387,9 +390,10 @@ used for Asian languages. This flag was introduced in Qt 4.6. - \value ItemNegativeZStacksBehindParent The item automatically stacks behind - it's parent if it's z-value is negative. This flag enables setZValue() to - toggle ItemStacksBehindParent. + \value ItemNegativeZStacksBehindParent The item automatically + stacks behind it's parent if it's z-value is negative. This flag + enables setZValue() to toggle ItemStacksBehindParent. This flag + was introduced in Qt 4.6. \value ItemIsPanel The item is a panel. A panel provides activation and contained focus handling. Only one panel can be active at a time (see diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 9a36d46..d1ec7a5 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5134,6 +5134,8 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool } /*! + \obsolete + Paints the given \a items using the provided \a painter, after the background has been drawn, and before the foreground has been drawn. All painting is done in \e scene coordinates. Before @@ -5156,7 +5158,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool \snippet doc/src/snippets/graphicssceneadditemsnippet.cpp 0 - \obsolete Since Qt 4.6, this function is not called anymore unless + Since Qt 4.6, this function is not called anymore unless the QGraphicsView::IndirectPainting flag is given as an Optimization flag. @@ -5712,8 +5714,15 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent) item->d_ptr->acceptedTouchBeginEvent = true; bool res = sendTouchBeginEvent(item, &touchEvent) && touchEvent.isAccepted(); - if (!res) + if (!res) { + // forget about these touch points, we didn't handle them + for (int i = 0; i < touchEvent.touchPoints().count(); ++i) { + const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().at(i); + itemForTouchPointId.remove(touchPoint.id()); + sceneCurrentTouchPoints.remove(touchPoint.id()); + } ignoreSceneTouchEvent = false; + } break; } default: @@ -5904,13 +5913,21 @@ void QGraphicsScenePrivate::getGestureTargets(const QSet<QGesture *> &gestures, QList<QGraphicsItem *> items = itemsAtPosition(screenPos, QPointF(), viewport); QList<QGraphicsObject *> result; for (int j = 0; j < items.size(); ++j) { - QGraphicsObject *item = items.at(j)->toGraphicsObject(); - if (!item) - continue; - QGraphicsItemPrivate *d = item->QGraphicsItem::d_func(); - if (d->gestureContext.contains(gestureType)) { - result.append(item); + QGraphicsItem *item = items.at(j); + + // Check if the item is blocked by a modal panel and use it as + // a target instead of this item. + (void) item->isBlockedByModalPanel(&item); + + if (QGraphicsObject *itemobj = item->toGraphicsObject()) { + QGraphicsItemPrivate *d = item->d_func(); + if (d->gestureContext.contains(gestureType)) { + result.append(itemobj); + } } + // Don't propagate through panels. + if (item->isPanel()) + break; } DEBUG() << "QGraphicsScenePrivate::getGestureTargets:" << gesture << result; diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 8ad3bac..d46f3b4 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -51,8 +51,27 @@ contains(DEFINES,QT_EVAL):include($$QT_SOURCE_TREE/src/corelib/eval.pri) QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist DEFINES += Q_INTERNAL_QAPP_SRC -symbian:TARGET.UID3=0x2001B2DD +symbian: { + TARGET.UID3=0x2001B2DD + + # ro-section in gui can exceed default allocated space, so move rw-section a little further + QMAKE_LFLAGS.ARMCC += --rw-base 0x800000 + QMAKE_LFLAGS.GCCE += -Tdata 0xC00000 + + # Partial upgrade SIS file + vendorinfo = \ + "&EN" \ + "; Localised Vendor name" \ + "%{\"Nokia, Qt\"}" \ + " " \ + "; Unique Vendor name" \ + ":\"Nokia, Qt\"" \ + " " + pu_header = "; Partial upgrade package for testing QtGui changes without reinstalling everything" \ + "$${LITERAL_HASH}{\"Qt gui\"}, (0x2001E61C), $${QT_MAJOR_VERSION},$${QT_MINOR_VERSION},$${QT_PATCH_VERSION}, TYPE=PU" + partial_upgrade.pkg_prerules = pu_header vendorinfo + partial_upgrade.sources = qtgui.dll + partial_upgrade.path = c:/sys/bin + DEPLOYMENT = partial_upgrade $$DEPLOYMENT +} -# ro-section in gui can exceed default allocated space, so more rw-section little further -symbian-sbsv2: QMAKE_LFLAGS.ARMCC += --rw-base 0x800000 -symbian: QMAKE_LFLAGS.GCCE += -Tdata 0xC00000 diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp index ace4bb6..517fcb0 100644 --- a/src/gui/image/qimagepixmapcleanuphooks.cpp +++ b/src/gui/image/qimagepixmapcleanuphooks.cpp @@ -122,19 +122,32 @@ void QImagePixmapCleanupHooks::executeImageHooks(qint64 key) qt_image_cleanup_hook_64(key); } -void QImagePixmapCleanupHooks::enableCleanupHooks(const QPixmap &pixmap) -{ - enableCleanupHooks(const_cast<QPixmap &>(pixmap).data_ptr().data()); -} void QImagePixmapCleanupHooks::enableCleanupHooks(QPixmapData *pixmapData) { pixmapData->is_cached = true; } +void QImagePixmapCleanupHooks::enableCleanupHooks(const QPixmap &pixmap) +{ + enableCleanupHooks(const_cast<QPixmap &>(pixmap).data_ptr().data()); +} + void QImagePixmapCleanupHooks::enableCleanupHooks(const QImage &image) { const_cast<QImage &>(image).data_ptr()->is_cached = true; } +bool QImagePixmapCleanupHooks::isImageCached(const QImage &image) +{ + return const_cast<QImage &>(image).data_ptr()->is_cached; +} + +bool QImagePixmapCleanupHooks::isPixmapCached(const QPixmap &pixmap) +{ + return const_cast<QPixmap&>(pixmap).data_ptr().data()->is_cached; +} + + + QT_END_NAMESPACE diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h index 88dd3a6..eae11f4 100644 --- a/src/gui/image/qimagepixmapcleanuphooks_p.h +++ b/src/gui/image/qimagepixmapcleanuphooks_p.h @@ -72,6 +72,9 @@ public: static void enableCleanupHooks(const QPixmap &pixmap); static void enableCleanupHooks(QPixmapData *pixmapData); + static bool isImageCached(const QImage &image); + static bool isPixmapCached(const QPixmap &pixmap); + // Gets called when a pixmap data is about to be modified: void addPixmapDataModificationHook(_qt_pixmap_cleanup_hook_pmd); diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 7cafbd0..ae62f06 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1690,10 +1690,9 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) \o The hasAlphaChannel() returns true if the pixmap has a format that - respects the alpha channel, otherwise returns false, while the - hasAlpha() function returns true if the pixmap has an alpha - channel \e or a mask (otherwise false). The mask() function returns - the mask as a QBitmap object, which can be set using setMask(). + respects the alpha channel, otherwise returns false. The hasAlpha(), + setMask() and mask() functions are legacy and should not be used. + They are potentially very slow. The createHeuristicMask() function creates and returns a 1-bpp heuristic mask (i.e. a QBitmap) for this pixmap. It works by @@ -1780,6 +1779,8 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) Returns true if this pixmap has an alpha channel, \e or has a mask, otherwise returns false. + \warning This is potentially an expensive operation. + \sa hasAlphaChannel(), mask() */ bool QPixmap::hasAlpha() const diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index c7d042d..9b035cb 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -497,6 +497,14 @@ static bool IsMouseOrKeyEvent( NSEvent* event ) case NSOtherMouseDown: case NSOtherMouseUp: case NSOtherMouseDragged: +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + case NSEventTypeGesture: // touch events + case NSEventTypeMagnify: + case NSEventTypeSwipe: + case NSEventTypeRotate: + case NSEventTypeBeginGesture: + case NSEventTypeEndGesture: +#endif result = true; break; diff --git a/src/gui/painting/qcups.cpp b/src/gui/painting/qcups.cpp index 7903762..ac41692 100644 --- a/src/gui/painting/qcups.cpp +++ b/src/gui/painting/qcups.cpp @@ -342,7 +342,9 @@ bool QCUPSSupport::printerHasPPD(const char *printerName) { if (!isAvailable()) return false; - return _cupsGetPPD(printerName) != 0; + const char *ppdFile = _cupsGetPPD(printerName); + unlink(ppdFile); + return (ppdFile != 0); } QString QCUPSSupport::unicodeString(const char *s) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 7a3da20..070491d 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -8092,20 +8092,43 @@ void qInitDrawhelperAsm() qDrawHelper[QImage::Format_ARGB32_Premultiplied].blendColor = qt_blend_color_argb_sse3dnow; } #endif // 3DNOW - extern void qt_blend_rgb32_on_rgb32_sse(uchar *destPixels, int dbpl, - const uchar *srcPixels, int sbpl, - int w, int h, - int const_alpha); - extern void qt_blend_argb32_on_argb32_sse(uchar *destPixels, int dbpl, - const uchar *srcPixels, int sbpl, - int w, int h, - int const_alpha); - qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; - qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; - qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; - qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; - } + +#ifdef QT_HAVE_SSE2 + if (features & SSE2) { + extern void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + extern void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + + + qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; + qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2; + qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; + qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2; + } else +#endif + { + extern void qt_blend_rgb32_on_rgb32_sse(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + extern void qt_blend_argb32_on_argb32_sse(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + + + qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; + qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse; + qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; + qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse; + } +} #endif // SSE #ifdef QT_HAVE_IWMMXT diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp index dd6fa1b..6ac64d3 100644 --- a/src/gui/painting/qdrawhelper_sse2.cpp +++ b/src/gui/painting/qdrawhelper_sse2.cpp @@ -57,6 +57,217 @@ QT_BEGIN_NAMESPACE +/* + * Multiply the components of pixelVector by alphaChannel + * Each 32bits components of alphaChannel must be in the form 0x00AA00AA + * colorMask must have 0x00ff00ff on each 32 bits component + * half must have the value 128 (0x80) for each 32 bits compnent + */ +#define BYTE_MUL_SSE2(result, pixelVector, alphaChannel, colorMask, half) \ +{ \ + /* 1. separate the colors in 2 vectors so each color is on 16 bits \ + (in order to be multiplied by the alpha \ + each 32 bit of dstVectorAG are in the form 0x00AA00GG \ + each 32 bit of dstVectorRB are in the form 0x00RR00BB */\ + __m128i pixelVectorAG = _mm_srli_epi16(pixelVector, 8); \ + __m128i pixelVectorRB = _mm_and_si128(pixelVector, colorMask); \ + \ + /* 2. multiply the vectors by the alpha channel */\ + pixelVectorAG = _mm_mullo_epi16(pixelVectorAG, alphaChannel); \ + pixelVectorRB = _mm_mullo_epi16(pixelVectorRB, alphaChannel); \ + \ + /* 3. devide by 255, that's the tricky part. \ + we do it like for BYTE_MUL(), with bit shift: X/255 ~= (X + X/256 + rounding)/256 */ \ + /** so first (X + X/256 + rounding) */\ + pixelVectorRB = _mm_add_epi16(pixelVectorRB, _mm_srli_epi16(pixelVectorRB, 8)); \ + pixelVectorRB = _mm_add_epi16(pixelVectorRB, half); \ + pixelVectorAG = _mm_add_epi16(pixelVectorAG, _mm_srli_epi16(pixelVectorAG, 8)); \ + pixelVectorAG = _mm_add_epi16(pixelVectorAG, half); \ + \ + /** second devide by 256 */\ + pixelVectorRB = _mm_srli_epi16(pixelVectorRB, 8); \ + /** for AG, we could >> 8 to divide followed by << 8 to put the \ + bytes in the correct position. By masking instead, we execute \ + only one instruction */\ + pixelVectorAG = _mm_andnot_si128(colorMask, pixelVectorAG); \ + \ + /* 4. combine the 2 pairs of colors */ \ + result = _mm_or_si128(pixelVectorAG, pixelVectorRB); \ +} + +/* + * Each 32bits components of alphaChannel must be in the form 0x00AA00AA + * oneMinusAlphaChannel must be 255 - alpha for each 32 bits component + * colorMask must have 0x00ff00ff on each 32 bits component + * half must have the value 128 (0x80) for each 32 bits compnent + */ +#define INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, alphaChannel, oneMinusAlphaChannel, colorMask, half) { \ + /* interpolate AG */\ + __m128i srcVectorAG = _mm_srli_epi16(srcVector, 8); \ + __m128i dstVectorAG = _mm_srli_epi16(dstVector, 8); \ + __m128i srcVectorAGalpha = _mm_mullo_epi16(srcVectorAG, alphaChannel); \ + __m128i dstVectorAGoneMinusAlphalpha = _mm_mullo_epi16(dstVectorAG, oneMinusAlphaChannel); \ + __m128i finalAG = _mm_add_epi16(srcVectorAGalpha, dstVectorAGoneMinusAlphalpha); \ + finalAG = _mm_add_epi16(finalAG, _mm_srli_epi16(finalAG, 8)); \ + finalAG = _mm_add_epi16(finalAG, half); \ + finalAG = _mm_andnot_si128(colorMask, finalAG); \ + \ + /* interpolate RB */\ + __m128i srcVectorRB = _mm_and_si128(srcVector, colorMask); \ + __m128i dstVectorRB = _mm_and_si128(dstVector, colorMask); \ + __m128i srcVectorRBalpha = _mm_mullo_epi16(srcVectorRB, alphaChannel); \ + __m128i dstVectorRBoneMinusAlphalpha = _mm_mullo_epi16(dstVectorRB, oneMinusAlphaChannel); \ + __m128i finalRB = _mm_add_epi16(srcVectorRBalpha, dstVectorRBoneMinusAlphalpha); \ + finalRB = _mm_add_epi16(finalRB, _mm_srli_epi16(finalRB, 8)); \ + finalRB = _mm_add_epi16(finalRB, half); \ + finalRB = _mm_srli_epi16(finalRB, 8); \ + \ + /* combine */\ + result = _mm_or_si128(finalAG, finalRB); \ +} + +void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha) +{ + const quint32 *src = (const quint32 *) srcPixels; + quint32 *dst = (uint *) destPixels; + if (const_alpha == 256) { + const __m128i alphaMask = _mm_set1_epi32(0xff000000); + const __m128i nullVector = _mm_set1_epi32(0); + const __m128i half = _mm_set1_epi16(0x80); + const __m128i one = _mm_set1_epi16(0xff); + const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); + for (int y = 0; y < h; ++y) { + int x = 0; + for (; x < w-3; x += 4) { + const __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]); + const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); + if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) { + // all opaque + _mm_storeu_si128((__m128i *)&dst[x], srcVector); + } else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) != 0xffff) { + // not fully transparent + // result = s + d * (1-alpha) + + // extract the alpha channel on 2 x 16 bits + // so we have room for the multiplication + // each 32 bits will be in the form 0x00AA00AA + // with A being the 1 - alpha + __m128i alphaChannel = _mm_srli_epi32(srcVector, 24); + alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); + alphaChannel = _mm_sub_epi16(one, alphaChannel); + + const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); + __m128i destMultipliedByOneMinusAlpha; + BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); + + // result = s + d * (1-alpha) + const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); + _mm_storeu_si128((__m128i *)&dst[x], result); + } + } + for (; x<w; ++x) { + uint s = src[x]; + if (s >= 0xff000000) + dst[x] = s; + else if (s != 0) + dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); + } + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } + } else if (const_alpha != 0) { + // dest = (s + d * sia) * ca + d * cia + // = s * ca + d * (sia * ca + cia) + // = s * ca + d * (1 - sa*ca) + const_alpha = (const_alpha * 255) >> 8; + const __m128i nullVector = _mm_set1_epi32(0); + const __m128i half = _mm_set1_epi16(0x80); + const __m128i one = _mm_set1_epi16(0xff); + const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); + const __m128i constAlphaVector = _mm_set1_epi16(const_alpha); + for (int y = 0; y < h; ++y) { + int x = 0; + for (; x < w-3; x += 4) { + __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]); + if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) { + BYTE_MUL_SSE2(srcVector, srcVector, constAlphaVector, colorMask, half); + + __m128i alphaChannel = _mm_srli_epi32(srcVector, 24); + alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); + alphaChannel = _mm_sub_epi16(one, alphaChannel); + + const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); + __m128i destMultipliedByOneMinusAlpha; + BYTE_MUL_SSE2(destMultipliedByOneMinusAlpha, dstVector, alphaChannel, colorMask, half); + + const __m128i result = _mm_add_epi8(srcVector, destMultipliedByOneMinusAlpha); + _mm_storeu_si128((__m128i *)&dst[x], result); + } + } + for (; x<w; ++x) { + quint32 s = src[x]; + if (s != 0) { + s = BYTE_MUL(s, const_alpha); + dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); + } + } + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } + } +} + +// qblendfunctions.cpp +void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); + +void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha) +{ + const quint32 *src = (const quint32 *) srcPixels; + quint32 *dst = (uint *) destPixels; + if (const_alpha != 256) { + if (const_alpha != 0) { + const __m128i nullVector = _mm_set1_epi32(0); + const __m128i half = _mm_set1_epi16(0x80); + const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); + + const_alpha = (const_alpha * 255) >> 8; + int one_minus_const_alpha = 255 - const_alpha; + const __m128i constAlphaVector = _mm_set1_epi16(const_alpha); + const __m128i oneMinusConstAlpha = _mm_set1_epi16(one_minus_const_alpha); + for (int y = 0; y < h; ++y) { + int x = 0; + for (; x < w-3; x += 4) { + __m128i srcVector = _mm_loadu_si128((__m128i *)&src[x]); + if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) { + const __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); + __m128i result; + INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, constAlphaVector, oneMinusConstAlpha, colorMask, half); + _mm_storeu_si128((__m128i *)&dst[x], result); + } + } + for (; x<w; ++x) { + quint32 s = src[x]; + s = BYTE_MUL(s, const_alpha); + dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha); + } + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } + } + } else { + qt_blend_rgb32_on_rgb32(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); + } +} + void qt_memfill32_sse2(quint32 *dest, quint32 value, int count) { if (count < 7) { diff --git a/src/gui/painting/qdrawhelper_x86_p.h b/src/gui/painting/qdrawhelper_x86_p.h index 30aadd0..d7282a7 100644 --- a/src/gui/painting/qdrawhelper_x86_p.h +++ b/src/gui/painting/qdrawhelper_x86_p.h @@ -114,6 +114,14 @@ void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y, void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y, quint32 color, const uchar *src, int width, int height, int stride); +void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); +void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, + const uchar *srcPixels, int sbpl, + int w, int h, + int const_alpha); #endif // QT_HAVE_SSE2 #ifdef QT_HAVE_IWMMXT diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index bc56ed0..4a4792a 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1827,6 +1827,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) } } +#ifndef FLOATING_POINT_BUGGY_OR_NO_FPU if (path.shape() == QVectorPath::EllipseHint) { if (!s->flags.antialiased && s->matrix.type() <= QTransform::TxScale) { const qreal *p = path.points(); @@ -1846,6 +1847,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush) } } } +#endif // ### Optimize for non transformed ellipses and rectangles... QRectF cpRect = path.controlPointRect(); @@ -3672,6 +3674,7 @@ void QRasterPaintEngine::drawLines(const QLineF *lines, int lineCount) */ void QRasterPaintEngine::drawEllipse(const QRectF &rect) { +#ifndef FLOATING_POINT_BUGGY_OR_NO_FPU Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); @@ -3679,9 +3682,6 @@ void QRasterPaintEngine::drawEllipse(const QRectF &rect) if (((qpen_style(s->lastPen) == Qt::SolidLine && s->flags.fast_pen) || (qpen_style(s->lastPen) == Qt::NoPen && !s->flags.antialiased)) && qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT -#ifdef FLOATING_POINT_BUGGY_OR_NO_FPU - && qMax(rect.width(), rect.height()) < 128 // integer math breakdown -#endif && s->matrix.type() <= QTransform::TxScale) // no shear { ensureBrush(); @@ -3697,6 +3697,7 @@ void QRasterPaintEngine::drawEllipse(const QRectF &rect) return; } } +#endif QPaintEngineEx::drawEllipse(rect); } @@ -6054,15 +6055,9 @@ static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip, ProcessSpans pen_func, ProcessSpans brush_func, QSpanData *pen_data, QSpanData *brush_data) { -#ifdef FLOATING_POINT_BUGGY_OR_NO_FPU // no fpu, so use fixed point - const QFixed a = QFixed(rect.width()) >> 1; - const QFixed b = QFixed(rect.height()) >> 1; - QFixed d = b*b - (a*a*b) + ((a*a) >> 2); -#else const qreal a = qreal(rect.width()) / 2; const qreal b = qreal(rect.height()) / 2; qreal d = b*b - (a*a*b) + 0.25*a*a; -#endif int x = 0; int y = (rect.height() + 1) / 2; @@ -6085,12 +6080,7 @@ static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip, pen_func, brush_func, pen_data, brush_data); // region 2 -#ifdef FLOATING_POINT_BUGGY_OR_NO_FPU - d = b*b*(x + (QFixed(1) >> 1))*(x + (QFixed(1) >> 1)) - + a*a*((y - 1)*(y - 1) - b*b); -#else d = b*b*(x + 0.5)*(x + 0.5) + a*a*((y - 1)*(y - 1) - b*b); -#endif const int miny = rect.height() & 0x1; while (y > miny) { if (d < 0) { // select SE diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 3bcaf8c..075c457 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -708,13 +708,14 @@ void QPainterPrivate::updateEmulationSpecifier(QPainterState *s) bool penTextureAlpha = false; if (penBrush.style() == Qt::TexturePattern) penTextureAlpha = qHasPixmapTexture(penBrush) - ? penBrush.texture().hasAlpha() + ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha() : penBrush.textureImage().hasAlphaChannel(); bool brushTextureAlpha = false; - if (s->brush.style() == Qt::TexturePattern) + if (s->brush.style() == Qt::TexturePattern) { brushTextureAlpha = qHasPixmapTexture(s->brush) - ? s->brush.texture().hasAlpha() + ? (s->brush.texture().depth() > 1) && s->brush.texture().hasAlpha() : s->brush.textureImage().hasAlphaChannel(); + } if (((penBrush.style() == Qt::TexturePattern && penTextureAlpha) || (s->brush.style() == Qt::TexturePattern && brushTextureAlpha)) && !engine->hasFeature(QPaintEngine::MaskedBrush)) diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp index 6cbf3d9..028ec48 100644 --- a/src/gui/painting/qwindowsurface_s60.cpp +++ b/src/gui/painting/qwindowsurface_s60.cpp @@ -149,11 +149,19 @@ void QS60WindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi Q_ASSERT(window); QTLWExtra *topExtra = window->d_func()->maybeTopData(); Q_ASSERT(topExtra); + QRect qr = region.boundingRect(); if (!topExtra->inExpose) { topExtra->inExpose = true; // Prevent DrawNow() from calling syncBackingStore() again - TRect tr = qt_QRect2TRect(region.boundingRect()); + TRect tr = qt_QRect2TRect(qr); widget->winId()->DrawNow(tr); topExtra->inExpose = false; + } else { + // This handles the case when syncBackingStore updates content outside of the + // original drawing rectangle. This might happen if there are pending update() + // events at the same time as we get a Draw() from Symbian. + QRect drawRect = qt_TRect2QRect(widget->winId()->DrawableWindow()->GetDrawRect()); + if (!drawRect.contains(qr)) + widget->winId()->DrawDeferred(); } } diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 9025e5b..ea7399f 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -289,6 +289,9 @@ void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, case SE_Editor: drawFrame(SF_FrameLineEdit, painter, rect, flags | SF_PointNorth); break; + case SE_DropArea: + drawPart(QS60StyleEnums::SP_QgnGrafOrgBgGrid, painter, rect, flags | SF_PointNorth); + break; default: break; } @@ -844,15 +847,18 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth)); break; - case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: - case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: case QS60StyleEnums::SP_QsnCpScrollBgBottom: - case QS60StyleEnums::SP_QsnCpScrollBgMiddle: case QS60StyleEnums::SP_QsnCpScrollBgTop: case QS60StyleEnums::SP_QsnCpScrollHandleBottom: - case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: case QS60StyleEnums::SP_QsnCpScrollHandleTop: + case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: + result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); + result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent)); + break; + case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: + case QS60StyleEnums::SP_QsnCpScrollBgMiddle: + case QS60StyleEnums::SP_QsnCpScrollHandleMiddle: result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent)); result.setWidth(pixelMetric(QStyle::PM_ScrollBarSliderMin)); break; @@ -2271,14 +2277,16 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti QS60StyleEnums::SkinParts skinPart = (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper; int minDimension = qMin(option->rect.width(), option->rect.height()); - const int resizeValue = minDimension >> 1; - minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension)); - int verticalMagic(0); - // magic values for positioning svg icon. - if (option->rect.width() <= option->rect.height()) - verticalMagic = 3; - iconRect.translate(3, verticalMagic - resizeValue); + const int magicTweak = 3; + int resizeValue = minDimension >> 1; + if (!QS60StylePrivate::isTouchSupported()) { + minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon. + iconRect.setSize(QSize(minDimension, minDimension)); + const int verticalMagic = (option->rect.width() <= option->rect.height()) ? magicTweak : 0; + resizeValue = verticalMagic - resizeValue; + } + iconRect.translate(magicTweak, resizeValue); QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); } } @@ -2302,7 +2310,12 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti break; case PE_PanelScrollAreaCorner: break; - + case PE_IndicatorItemViewItemDrop: + if (QS60StylePrivate::isTouchSupported()) + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_DropArea, painter, option->rect, flags); + else + commonStyleDraws = true; + break; // todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases case PE_FrameLineEdit: case PE_IndicatorDockWidgetResizeHandle: @@ -2323,7 +2336,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif //QT_NO_TOOLBAR #ifndef QT_NO_COLUMNVIEW case PE_IndicatorColumnViewArrow: - case PE_IndicatorItemViewItemDrop: #endif //QT_NO_COLUMNVIEW case PE_FrameTabBarBase: // since tabs are in S60 always in navipane, let's use common style for tab base in Qt. default: @@ -2481,6 +2493,9 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_FormLayoutWrapPolicy: retValue = QFormLayout::WrapLongRows; break; + case SH_ScrollBar_ContextMenu: + retValue = false; + break; default: retValue = QCommonStyle::styleHint(sh, opt, widget, hret); break; @@ -2559,11 +2574,11 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; const int buttonMargin = spinbox->frame ? 2 : 0; - const int buttonWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; + const int buttonContentWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; QSize buttonSize; buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness)); //width should at least be equal to height - buttonSize.setWidth(qMax(buttonSize.height(), buttonWidth)); + buttonSize.setWidth(qMax(buttonSize.height(), buttonContentWidth)); buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); const int y = frameThickness + spinbox->rect.y(); diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index eae2291..ea30b81 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -131,6 +131,7 @@ public: SP_QgnGrafBarFrameSideL, SP_QgnGrafBarFrameSideR, SP_QgnGrafBarProgress, + SP_QgnGrafOrgBgGrid, SP_QgnGrafScrollArrowDown, SP_QgnGrafScrollArrowLeft, SP_QgnGrafScrollArrowRight, @@ -428,6 +429,7 @@ public: SE_ScrollBarHandlePressedVertical, SE_ButtonInactive, SE_Editor, + SE_DropArea }; enum SkinFrameElements { diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 6d9ba05..cb49fbc 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -178,6 +178,8 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_All, -1,-1}, /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_All, -1,-1}, /* SP_QgnGrafBarProgress */ {KAknsIIDQgnGrafBarProgress, EDrawIcon, ES60_All, -1,-1}, + // No drop area for 3.x non-touch devices + /* SP_QgnGrafOrgBgGrid */ {KAknsIIDNone, EDrawIcon, ES60_3_X, EAknsMajorGeneric ,0x1eba}, //KAknsIIDQgnGrafOrgBgGrid /* SP_QgnGrafScrollArrowDown */ {KAknsIIDQgnGrafScrollArrowDown, EDrawGulIcon, ES60_All, -1,-1}, /* SP_QgnGrafScrollArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawGulIcon, ES60_All, -1,-1}, /* SP_QgnGrafScrollArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawGulIcon, ES60_All, -1,-1}, diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp index b30a6c3..c50d363 100644 --- a/src/gui/text/qfontdatabase_win.cpp +++ b/src/gui/text/qfontdatabase_win.cpp @@ -336,8 +336,18 @@ void addFontToDatabase(QString familyName, const QString &scriptName, signature->fsCsb[0], signature->fsCsb[1] }; QList<QFontDatabase::WritingSystem> systems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange); - for (int i = 0; i < systems.count(); ++i) - family->writingSystems[systems.at(i)] = QtFontFamily::Supported; + + for (int i = 0; i < systems.count(); ++i) { + QFontDatabase::WritingSystem writingSystem = systems.at(i); + + // ### Hack to work around problem with Thai text on Windows 7. Segoe UI contains + // the symbol for Baht, and Windows thus reports that it supports the Thai script. + // Since it's the default UI font on this platform, most widgets will be unable to + // display Thai text by default. As a temporary work around, we special case Segoe UI + // and remove the Thai script from its list of supported writing systems. + if (writingSystem != QFontDatabase::Thai || familyName != QLatin1String("Segoe UI")) + family->writingSystems[writingSystem] = QtFontFamily::Supported; + } } else if (!family->writingSystemCheck) { //qDebug("family='%s' script=%s", family->name.latin1(), script.latin1()); if (scriptName == QLatin1String("Western") diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index b0e632a..2a3036b 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -283,20 +283,17 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() // connection might be closed to signal the end of data if (socketState == QAbstractSocket::UnconnectedState) { - if (!socket->bytesAvailable()) { + if (socket->bytesAvailable() <= 0) { if (reply && reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingDataState) { + // finish this reply. this case happens when the server did not send a content length reply->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState; allDone(); } else { - // try to reconnect/resend before sending an error. - if (reconnectAttempts-- > 0) { - closeAndResendCurrentRequest(); - } else if (reply) { - reply->d_func()->errorString = connection->d_func()->errorDetail(QNetworkReply::RemoteHostClosedError, socket); - emit reply->finishedWithError(QNetworkReply::RemoteHostClosedError, reply->d_func()->errorString); - QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); - } + handleUnexpectedEOF(); + return; } + } else { + // socket not connected but still bytes for reading.. just continue in this function } } @@ -311,18 +308,10 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() } case QHttpNetworkReplyPrivate::ReadingStatusState: { qint64 statusBytes = reply->d_func()->readStatus(socket); - if (statusBytes == -1 && reconnectAttempts <= 0) { - // too many errors reading/receiving/parsing the status, close the socket and emit error - close(); - reply->d_func()->errorString = connection->d_func()->errorDetail(QNetworkReply::ProtocolFailure, socket); - emit reply->finishedWithError(QNetworkReply::ProtocolFailure, reply->d_func()->errorString); - QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); - break; - } else if (statusBytes == -1) { - reconnectAttempts--; - reply->d_func()->clear(); - closeAndResendCurrentRequest(); - break; + if (statusBytes == -1) { + // connection broke while reading status. also handled if later _q_disconnected is called + handleUnexpectedEOF(); + return; } bytes += statusBytes; lastStatus = reply->d_func()->statusCode; @@ -330,7 +319,13 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() } case QHttpNetworkReplyPrivate::ReadingHeaderState: { QHttpNetworkReplyPrivate *replyPrivate = reply->d_func(); - bytes += replyPrivate->readHeader(socket); + qint64 headerBytes = replyPrivate->readHeader(socket); + if (headerBytes == -1) { + // connection broke while reading headers. also handled if later _q_disconnected is called + handleUnexpectedEOF(); + return; + } + bytes += headerBytes; if (replyPrivate->state == QHttpNetworkReplyPrivate::ReadingDataState) { if (replyPrivate->isGzipped() && replyPrivate->autoDecompress) { // remove the Content-Length from header @@ -430,6 +425,23 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() } } +// called when unexpectedly reading a -1 or when data is expected but socket is closed +void QHttpNetworkConnectionChannel::handleUnexpectedEOF() +{ + if (reconnectAttempts <= 0) { + // too many errors reading/receiving/parsing the status, close the socket and emit error + requeueCurrentlyPipelinedRequests(); + close(); + reply->d_func()->errorString = connection->d_func()->errorDetail(QNetworkReply::RemoteHostClosedError, socket); + emit reply->finishedWithError(QNetworkReply::RemoteHostClosedError, reply->d_func()->errorString); + QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); + } else { + reconnectAttempts--; + reply->d_func()->clear(); + closeAndResendCurrentRequest(); + } +} + bool QHttpNetworkConnectionChannel::ensureConnection() { QAbstractSocket::SocketState socketState = socket->state(); @@ -799,9 +811,10 @@ void QHttpNetworkConnectionChannel::_q_disconnected() { // read the available data before closing if (isSocketWaiting() || isSocketReading()) { - state = QHttpNetworkConnectionChannel::ReadingState; - if (reply) + if (reply) { + state = QHttpNetworkConnectionChannel::ReadingState; _q_receiveReply(); + } } else if (state == QHttpNetworkConnectionChannel::IdleState && resendCurrent) { // re-sending request because the socket was in ClosingState QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h index 75ab50d..5032d2b 100644 --- a/src/network/access/qhttpnetworkconnectionchannel_p.h +++ b/src/network/access/qhttpnetworkconnectionchannel_p.h @@ -157,6 +157,7 @@ public: void requeueCurrentlyPipelinedRequests(); void detectPipeliningSupport(); + void handleUnexpectedEOF(); void closeAndResendCurrentRequest(); void eatWhitespace(); diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h index 081697b..0f1c23c 100644 --- a/src/network/socket/qlocalsocket_p.h +++ b/src/network/socket/qlocalsocket_p.h @@ -128,10 +128,8 @@ public: void _q_stateChanged(QAbstractSocket::SocketState newState); void _q_error(QAbstractSocket::SocketError newError); #elif defined(Q_OS_WIN) - ~QLocalSocketPrivate() { - CloseHandle(overlapped.hEvent); - } - + ~QLocalSocketPrivate(); + void destroyPipeHandles(); void setErrorString(const QString &function); void _q_notified(); void _q_canWrite(); diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 1f94df6..3283bf2 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -110,6 +110,20 @@ QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(), { } +QLocalSocketPrivate::~QLocalSocketPrivate() +{ + destroyPipeHandles(); + CloseHandle(overlapped.hEvent); +} + +void QLocalSocketPrivate::destroyPipeHandles() +{ + if (handle != INVALID_HANDLE_VALUE) { + DisconnectNamedPipe(handle); + CloseHandle(handle); + } +} + void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) { Q_D(QLocalSocket); @@ -388,8 +402,7 @@ void QLocalSocket::close() d->readSequenceStarted = false; d->pendingReadyRead = false; d->pipeClosed = false; - DisconnectNamedPipe(d->handle); - CloseHandle(d->handle); + d->destroyPipeHandles(); d->handle = INVALID_HANDLE_VALUE; ResetEvent(d->overlapped.hEvent); d->state = UnconnectedState; @@ -524,7 +537,10 @@ bool QLocalSocket::waitForDisconnected(int msecs) bool QLocalSocket::isValid() const { Q_D(const QLocalSocket); - return (d->handle != INVALID_HANDLE_VALUE); + if (d->handle == INVALID_HANDLE_VALUE) + return false; + + return PeekNamedPipe(d->handle, NULL, 0, NULL, NULL, NULL); } bool QLocalSocket::waitForReadyRead(int msecs) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index d2fb925..8468102 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1334,7 +1334,7 @@ void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) { - if (d->deviceHasAlpha || txtype > QTransform::TxTranslate + if (d->device->alphaRequested() || txtype > QTransform::TxTranslate || (state()->composition_mode != QPainter::CompositionMode_Source && state()->composition_mode != QPainter::CompositionMode_SourceOver)) { diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index cfcbbf8..5f5941b 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1692,18 +1692,18 @@ QGLTextureCache::QGLTextureCache() Q_ASSERT(qt_gl_texture_cache == 0); qt_gl_texture_cache = this; - QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(cleanupTextures); + QImagePixmapCleanupHooks::instance()->addPixmapDataModificationHook(cleanupTexturesForPixampData); QImagePixmapCleanupHooks::instance()->addPixmapDataDestructionHook(cleanupBeforePixmapDestruction); - QImagePixmapCleanupHooks::instance()->addImageHook(imageCleanupHook); + QImagePixmapCleanupHooks::instance()->addImageHook(cleanupTexturesForCacheKey); } QGLTextureCache::~QGLTextureCache() { qt_gl_texture_cache = 0; - QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTextures); + QImagePixmapCleanupHooks::instance()->removePixmapDataModificationHook(cleanupTexturesForPixampData); QImagePixmapCleanupHooks::instance()->removePixmapDataDestructionHook(cleanupBeforePixmapDestruction); - QImagePixmapCleanupHooks::instance()->removeImageHook(imageCleanupHook); + QImagePixmapCleanupHooks::instance()->removeImageHook(cleanupTexturesForCacheKey); } void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, int cost) @@ -1759,32 +1759,25 @@ QGLTextureCache* QGLTextureCache::instance() a hook that removes textures from the cache when a pixmap/image is deref'ed */ -void QGLTextureCache::imageCleanupHook(qint64 cacheKey) +void QGLTextureCache::cleanupTexturesForCacheKey(qint64 cacheKey) { // ### remove when the GL texture cache becomes thread-safe - if (qApp->thread() != QThread::currentThread()) - return; - QGLTexture *texture = instance()->getTexture(cacheKey); - if (texture && texture->options & QGLContext::MemoryManagedBindOption) + if (qApp->thread() == QThread::currentThread()) { instance()->remove(cacheKey); + Q_ASSERT(instance()->getTexture(cacheKey) == 0); + } } -void QGLTextureCache::cleanupTextures(QPixmapData* pmd) +void QGLTextureCache::cleanupTexturesForPixampData(QPixmapData* pmd) { - // ### remove when the GL texture cache becomes thread-safe - if (qApp->thread() == QThread::currentThread()) { - const qint64 cacheKey = pmd->cacheKey(); - QGLTexture *texture = instance()->getTexture(cacheKey); - if (texture && texture->options & QGLContext::MemoryManagedBindOption) - instance()->remove(cacheKey); - } + cleanupTexturesForCacheKey(pmd->cacheKey()); } void QGLTextureCache::cleanupBeforePixmapDestruction(QPixmapData* pmd) { // Remove any bound textures first: - cleanupTextures(pmd); + cleanupTexturesForPixampData(pmd); #if defined(Q_WS_X11) if (pmd->classId() == QPixmapData::X11Class) { @@ -2185,8 +2178,9 @@ QGLTexture *QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G // NOTE: bindTexture(const QImage&, GLenum, GLint, const qint64, bool) should never return null Q_ASSERT(texture); - if (texture->id > 0) - QImagePixmapCleanupHooks::enableCleanupHooks(image); + // Enable the cleanup hooks for this image so that the texture cache entry is removed when the + // image gets deleted: + QImagePixmapCleanupHooks::enableCleanupHooks(image); return texture; } @@ -2240,6 +2234,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G int tx_h = qt_next_power_of_two(image.height()); QImage img = image; + if (!(QGLExtensions::glExtensions() & QGLExtensions::NPOTTextures) && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0) && (target == GL_TEXTURE_2D && (tx_w != image.width() || tx_h != image.height()))) @@ -2408,6 +2403,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G int cost = img.width()*img.height()*4/1024; QGLTexture *texture = new QGLTexture(q, tx_id, target, options); QGLTextureCache::instance()->insert(q, key, texture, cost); + return texture; } @@ -2524,7 +2520,7 @@ GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format) return 0; Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(image, target, format, false, DefaultBindOption); + QGLTexture *texture = d->bindTexture(image, target, format, DefaultBindOption); return texture->id; } @@ -2664,11 +2660,13 @@ void QGLContext::deleteTexture(GLuint id) for (int i = 0; i < ddsKeys.size(); ++i) { GLuint texture = dds_cache->value(ddsKeys.at(i)); if (id == texture) { - glDeleteTextures(1, &texture); dds_cache->remove(ddsKeys.at(i)); - return; + break; } } + + // Finally, actually delete the texture ID + glDeleteTextures(1, &id); } #ifdef Q_MAC_COMPAT_GL_FUNCTIONS diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index efd2090..0491db9 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -538,8 +538,8 @@ public: static QGLTextureCache *instance(); static void deleteIfEmpty(); - static void imageCleanupHook(qint64 cacheKey); - static void cleanupTextures(QPixmapData* pixmap); + static void cleanupTexturesForCacheKey(qint64 cacheKey); + static void cleanupTexturesForPixampData(QPixmapData* pixmap); static void cleanupBeforePixmapDestruction(QPixmapData* pixmap); private: diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp index d4adc8b..fd17a27 100644 --- a/src/opengl/qgl_qws.cpp +++ b/src/opengl/qgl_qws.cpp @@ -198,11 +198,6 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) // Get the display and initialize it. d->eglContext = new QEglContext(); d->eglContext->setApi(QEgl::OpenGL); - if (!d->eglContext->openDisplay(device())) { - delete d->eglContext; - d->eglContext = 0; - return false; - } // Construct the configuration we need for this surface. QEglProperties configProps; diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp index 00a125a..f81115c 100644 --- a/src/opengl/qgl_wince.cpp +++ b/src/opengl/qgl_wince.cpp @@ -155,11 +155,6 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) // Get the display and initialize it. d->eglContext = new QEglContext(); d->eglContext->setApi(QEgl::OpenGL); - if (!d->eglContext->openDisplay(device())) { - delete d->eglContext; - d->eglContext = 0; - return false; - } // Construct the configuration we need for this surface. QEglProperties configProps; diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 61a16be..f0b06ef5 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -1656,8 +1656,11 @@ static bool qt_resolveTextureFromPixmap(QPaintDevice *paintDevice) Display *display = xinfo ? xinfo->display() : X11->display; int screen = xinfo ? xinfo->screen() : X11->defaultScreen; - QGLExtensionMatcher extensions(glXQueryExtensionsString(display, screen)); - if (extensions.match("GLX_EXT_texture_from_pixmap")) { + QGLExtensionMatcher serverExtensions(glXQueryExtensionsString(display, screen)); + QGLExtensionMatcher clientExtensions(glXGetClientString(display, GLX_EXTENSIONS)); + if (serverExtensions.match("GLX_EXT_texture_from_pixmap") + && clientExtensions.match("GLX_EXT_texture_from_pixmap")) + { glXBindTexImageEXT = (qt_glXBindTexImageEXT) qglx_getProcAddress("glXBindTexImageEXT"); glXReleaseTexImageEXT = (qt_glXReleaseTexImageEXT) qglx_getProcAddress("glXReleaseTexImageEXT"); } diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 572834b..3d183ee 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -190,11 +190,6 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) if (d->eglContext == 0) { d->eglContext = new QEglContext(); d->eglContext->setApi(QEgl::OpenGL); - if (!d->eglContext->openDisplay(device())) { - delete d->eglContext; - d->eglContext = 0; - return false; - } // Construct the configuration we need for this surface. QEglProperties configProps; @@ -614,7 +609,7 @@ EGLConfig Q_OPENGL_EXPORT qt_chooseEGLConfigForPixmap(bool hasAlpha, bool readOn EGLint configCount = 0; do { - eglChooseConfig(QEglContext::defaultDisplay(0), configAttribs.properties(), targetConfig, 1, &configCount); + eglChooseConfig(QEglContext::display(), configAttribs.properties(), targetConfig, 1, &configCount); if (configCount > 0) { // Got one qDebug() << "Found an" << (hasAlpha ? "ARGB" : "RGB") << (readOnly ? "readonly" : "target" ) @@ -653,7 +648,7 @@ bool Q_OPENGL_EXPORT qt_createEGLSurfaceForPixmap(QPixmapData* pmd, bool readOnl pixmapAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB); EGLSurface pixmapSurface; - pixmapSurface = eglCreatePixmapSurface(QEglContext::defaultDisplay(0), + pixmapSurface = eglCreatePixmapSurface(QEglContext::display(), pixmapConfig, (EGLNativePixmapType) pixmapData->handle(), pixmapAttribs.properties()); @@ -762,7 +757,7 @@ void QGLContextPrivate::destroyGlSurfaceForPixmap(QPixmapData* pmd) QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd); if (pixmapData->gl_surface) { EGLBoolean success; - success = eglDestroySurface(QEglContext::defaultDisplay(0), (EGLSurface)pixmapData->gl_surface); + success = eglDestroySurface(QEglContext::display(), (EGLSurface)pixmapData->gl_surface); if (success == EGL_FALSE) { qWarning() << "destroyGlSurfaceForPixmap() - Error deleting surface: " << QEglContext::errorString(eglGetError()); @@ -777,7 +772,7 @@ void QGLContextPrivate::unbindPixmapFromTexture(QPixmapData* pmd) QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd); if (pixmapData->gl_surface) { EGLBoolean success; - success = eglReleaseTexImage(QEglContext::defaultDisplay(0), + success = eglReleaseTexImage(QEglContext::display(), (EGLSurface)pixmapData->gl_surface, EGL_BACK_BUFFER); if (success == EGL_FALSE) { diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index f1d2325..2d0711b 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -325,6 +325,13 @@ void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f, } else if (attachment == QGLFramebufferObject::Depth) { fboFormat.setDepth(true); } + + GLenum format = f->format().internalTextureFormat(); + reqAlpha = (format != GL_RGB +#ifndef QT_OPENGL_ES + && format != GL_RGB5 && format != GL_RGB8 +#endif + ); } QGLContext *QGLFBOGLPaintDevice::context() const diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h index d7f96a5..d8ff012 100644 --- a/src/opengl/qglframebufferobject_p.h +++ b/src/opengl/qglframebufferobject_p.h @@ -111,14 +111,16 @@ public: virtual QSize size() const {return fbo->size();} virtual QGLContext* context() const; virtual QGLFormat format() const {return fboFormat;} + virtual bool alphaRequested() const { return reqAlpha; } void setFBO(QGLFramebufferObject* f, QGLFramebufferObject::Attachment attachment); private: - bool wasBound; QGLFramebufferObject* fbo; QGLFormat fboFormat; + bool wasBound; + bool reqAlpha; }; class QGLFramebufferObjectPrivate diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index a0b1a79..2d82222 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -124,6 +124,11 @@ QGLFormat QGLPaintDevice::format() const return context()->format(); } +bool QGLPaintDevice::alphaRequested() const +{ + return context()->d_func()->reqFormat.alpha(); +} + diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h index 9815467..3d669da 100644 --- a/src/opengl/qglpaintdevice_p.h +++ b/src/opengl/qglpaintdevice_p.h @@ -75,6 +75,7 @@ public: virtual QGLContext* context() const = 0; virtual QGLFormat format() const; virtual QSize size() const = 0; + virtual bool alphaRequested() const; // returns the QGLPaintDevice for the given QPaintDevice static QGLPaintDevice* getDevice(QPaintDevice*); diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp index 1e3223e..954049d 100644 --- a/src/opengl/qglpixelbuffer_egl.cpp +++ b/src/opengl/qglpixelbuffer_egl.cpp @@ -61,13 +61,6 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge ctx = new QEglContext(); ctx->setApi(QEgl::OpenGL); - // Open the EGL display. - if (!ctx->openDisplay(0)) { - delete ctx; - ctx = 0; - return false; - } - // Find the shared context. QEglContext *shareContext = 0; if (shareWidget && shareWidget->d_func()->glcx) @@ -211,7 +204,7 @@ GLuint QGLPixelBuffer::generateDynamicTexture() const bool QGLPixelBuffer::hasOpenGLPbuffers() { // See if we have at least 1 configuration that matches the default format. - EGLDisplay dpy = QEglContext::defaultDisplay(0); + EGLDisplay dpy = QEglContext::display(); if (dpy == EGL_NO_DISPLAY) return false; QEglProperties configProps; diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index aa80664..653e805 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -234,6 +234,11 @@ QSize QGLPixmapGLPaintDevice::size() const return data->size(); } +bool QGLPixmapGLPaintDevice::alphaRequested() const +{ + return data->m_hasAlpha; +} + void QGLPixmapGLPaintDevice::setPixmapData(QGLPixmapData* d) { data = d; diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h index e3ba5f8..c239bcb 100644 --- a/src/opengl/qpixmapdata_gl_p.h +++ b/src/opengl/qpixmapdata_gl_p.h @@ -88,6 +88,7 @@ public: void endPaint(); QGLContext* context() const; QSize size() const; + bool alphaRequested() const; void setPixmapData(QGLPixmapData*); private: diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp index edce56a..6a1d030 100644 --- a/src/opengl/qpixmapdata_x11gl_egl.cpp +++ b/src/opengl/qpixmapdata_x11gl_egl.cpp @@ -96,14 +96,14 @@ bool QX11GLPixmapData::hasX11GLPixmaps() #endif EGL_NONE }; - qPixmapARGBSharedEglContext = eglCreateContext(QEglContext::defaultDisplay(0), + qPixmapARGBSharedEglContext = eglCreateContext(QEglContext::display(), argbConfig, 0, contextAttribs); if (argbConfig == rgbConfig) { // If the configs are the same, we can re-use the same context. qPixmapRGBSharedEglContext = qPixmapARGBSharedEglContext; } else { - qPixmapRGBSharedEglContext = eglCreateContext(QEglContext::defaultDisplay(0), + qPixmapRGBSharedEglContext = eglCreateContext(QEglContext::display(), rgbConfig, 0, contextAttribs); } @@ -114,7 +114,7 @@ bool QX11GLPixmapData::hasX11GLPixmaps() if (!qt_createEGLSurfaceForPixmap(argbPixmapData, false)) break; - haveX11Pixmaps = eglMakeCurrent(QEglContext::defaultDisplay(0), + haveX11Pixmaps = eglMakeCurrent(QEglContext::display(), (EGLSurface)argbPixmapData->gl_surface, (EGLSurface)argbPixmapData->gl_surface, qPixmapARGBSharedEglContext); @@ -134,7 +134,7 @@ bool QX11GLPixmapData::hasX11GLPixmaps() if (!qt_createEGLSurfaceForPixmap(rgbPixmapData, false)) break; - haveX11Pixmaps = eglMakeCurrent(QEglContext::defaultDisplay(0), + haveX11Pixmaps = eglMakeCurrent(QEglContext::display(), (EGLSurface)rgbPixmapData->gl_surface, (EGLSurface)rgbPixmapData->gl_surface, qPixmapRGBSharedEglContext); @@ -147,7 +147,7 @@ bool QX11GLPixmapData::hasX11GLPixmaps() } while (0); if (qPixmapARGBSharedEglContext || qPixmapRGBSharedEglContext) { - eglMakeCurrent(QEglContext::defaultDisplay(0), + eglMakeCurrent(QEglContext::display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); } @@ -167,12 +167,12 @@ bool QX11GLPixmapData::hasX11GLPixmaps() if (!haveX11Pixmaps) { // Clean up the context(s) if we can't use X11GL pixmaps if (qPixmapARGBSharedEglContext != EGL_NO_CONTEXT) - eglDestroyContext(QEglContext::defaultDisplay(0), qPixmapARGBSharedEglContext); + eglDestroyContext(QEglContext::display(), qPixmapARGBSharedEglContext); if (qPixmapRGBSharedEglContext != qPixmapARGBSharedEglContext && qPixmapRGBSharedEglContext != EGL_NO_CONTEXT) { - eglDestroyContext(QEglContext::defaultDisplay(0), qPixmapRGBSharedEglContext); + eglDestroyContext(QEglContext::display(), qPixmapRGBSharedEglContext); } qPixmapRGBSharedEglContext = EGL_NO_CONTEXT; qPixmapARGBSharedEglContext = EGL_NO_CONTEXT; @@ -212,7 +212,6 @@ QPaintEngine* QX11GLPixmapData::paintEngine() const ctx = new QGLContext(glFormat()); if (ctx->d_func()->eglContext == 0) ctx->d_func()->eglContext = new QEglContext(); - ctx->d_func()->eglContext->openDisplay(0); // ;-) ctx->d_func()->eglContext->setApi(QEgl::OpenGL); ctx->d_func()->eglContext->setContext(hasAlphaChannel() ? qPixmapARGBSharedEglContext : qPixmapRGBSharedEglContext); diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index d92870f..9c44545 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -225,10 +225,6 @@ static QEglContext *createContext(QPaintDevice *device) // Create the context object and open the display. context = new QEglContext(); context->setApi(QEgl::OpenVG); - if (!context->openDisplay(device)) { - delete context; - return 0; - } // Set the swap interval for the display. QByteArray interval = qgetenv("QT_VG_SWAP_INTERVAL"); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 40daecb..ca10b01 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1123,6 +1123,14 @@ static void qParseArgs(int argc, char *argv[]) #endif } else if (strcmp(argv[i], "-qws") == 0) { // do nothing + } else if (strcmp(argv[i], "-graphicssystem") == 0) { + // do nothing + if (i + 1 >= argc) { + printf("-graphicssystem needs an extra parameter specifying the graphics system\n"); + exit(1); + } else { + ++i; + } } else if (argv[i][0] == '-') { printf("Unknown option: '%s'\n\n%s", argv[i], testOptions); exit(1); @@ -1308,11 +1316,23 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0) const int dataCount = table.dataCount(); QTestResult::setSkipCurrentTest(false); + // Data tag requested but none available? + if (data && !dataCount) { + // Let empty data tag through. + if (!*data) + data = 0; + else { + printf("Unknown testdata for function %s: '%s'\n", slotName, data); + printf("Function has no testdata.\n"); + return false; + } + } + /* For each entry in the data table, do: */ do { if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) { foundFunction = true; - QTestDataSetter s(table.isEmpty() ? static_cast<QTestData *>(0) + QTestDataSetter s(curDataIndex >= dataCount ? static_cast<QTestData *>(0) : table.testData(curDataIndex)); qInvokeTestMethodDataEntry(slot); |