From: Lars Knoll Date: Wed, 7 Mar 2012 21:00:57 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/master' into api_changes X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=616bbd1988f3b92f7d980b6c9a1278f11b712573;p=konrad%2Fqtdeclarative.git Merge remote-tracking branch 'origin/master' into api_changes Change-Id: I121cb9c9316b5e47476dcb982bc28b6f3f358f78 --- 616bbd1988f3b92f7d980b6c9a1278f11b712573 diff --cc src/quick/util/qquickimageprovider.h index 153a4ba,da4d8c8..2a5d146 --- a/src/quick/util/qquickimageprovider.h +++ b/src/quick/util/qquickimageprovider.h @@@ -65,9 -64,10 +65,10 @@@ public virtual QSGTexture *createTexture(QQuickCanvas *canvas) const = 0; virtual QSize textureSize() const = 0; virtual int textureByteCount() const = 0; + virtual QImage image() const; }; -class Q_QML_EXPORT QQmlImageProvider +class Q_QUICK_EXPORT QQuickImageProvider : public QQmlImageProviderBase { public: enum ImageType { diff --cc src/quick/util/qquickpixmapcache.cpp index 350940c,6ebdf57..5c73e51 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@@ -538,10 -512,10 +526,10 @@@ void QQuickPixmapReader::processJob(QQu QImage image; mutex.lock(); if (!cancelled.contains(runningJob)) - runningJob->postReply(errorCode, errorStr, readSize, image); + runningJob->postReply(errorCode, errorStr, readSize, textureFactoryForImage(image)); mutex.unlock(); - } else if (imageType == QQmlImageProvider::Image) { - QImage image = ep->getImageFromProvider(url, &readSize, requestSize); + } else if (imageType == QQuickImageProvider::Image) { + QImage image = provider->requestImage(imageId(url), &readSize, requestSize); QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError; QString errorStr; if (image.isNull()) { @@@ -549,17 -523,11 +537,11 @@@ errorStr = QQuickPixmap::tr("Failed to get image from provider: %1").arg(url.toString()); } mutex.lock(); - if (!cancelled.contains(runningJob)) { - QQuickTextureFactory *factory = QSGContext::createTextureFactoryFromImage(image); - if (factory) - runningJob->postReply(errorCode, errorStr, readSize, factory, image); - else - runningJob->postReply(errorCode, errorStr, readSize, image); - } - + if (!cancelled.contains(runningJob)) + runningJob->postReply(errorCode, errorStr, readSize, textureFactoryForImage(image)); mutex.unlock(); } else { - QQuickTextureFactory *t = ep->getTextureFromProvider(url, &readSize, requestSize); + QQuickTextureFactory *t = provider->requestTexture(imageId(url), &readSize, requestSize); QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError; QString errorStr; if (!t) { @@@ -959,39 -919,36 +933,39 @@@ static QQuickPixmapData* createPixmapDa { if (url.scheme() == QLatin1String("image")) { QSize readSize; - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - QQmlImageProvider::ImageType imageType = ep->getImageProviderType(url); + + QQuickImageProvider::ImageType imageType = QQuickImageProvider::Invalid; + QQuickImageProvider *provider = static_cast(engine->imageProvider(imageProviderId(url))); + if (provider) + imageType = provider->imageType(); switch (imageType) { - case QQmlImageProvider::Invalid: + case QQuickImageProvider::Invalid: return new QQuickPixmapData(declarativePixmap, url, requestSize, QQuickPixmap::tr("Invalid image provider: %1").arg(url.toString())); - case QQmlImageProvider::Texture: + case QQuickImageProvider::Texture: { - QQuickTextureFactory *texture = ep->getTextureFromProvider(url, &readSize, requestSize); + QQuickTextureFactory *texture = provider->requestTexture(imageId(url), &readSize, requestSize); if (texture) { *ok = true; - return new QQuickPixmapData(declarativePixmap, url, texture, QImage(), readSize, requestSize); + return new QQuickPixmapData(declarativePixmap, url, texture, readSize, requestSize); } } - case QQmlImageProvider::Image: + case QQuickImageProvider::Image: { - QImage image = ep->getImageFromProvider(url, &readSize, requestSize); + QImage image = provider->requestImage(imageId(url), &readSize, requestSize); if (!image.isNull()) { *ok = true; - return new QQuickPixmapData(declarativePixmap, url, image, readSize, requestSize); + return new QQuickPixmapData(declarativePixmap, url, textureFactoryForImage(image), readSize, requestSize); } } - case QQmlImageProvider::Pixmap: + case QQuickImageProvider::Pixmap: { - QPixmap pixmap = ep->getPixmapFromProvider(url, &readSize, requestSize); + QPixmap pixmap = provider->requestPixmap(imageId(url), &readSize, requestSize); if (!pixmap.isNull()) { *ok = true; - return new QQuickPixmapData(declarativePixmap, url, pixmap.toImage(), readSize, requestSize); + return new QQuickPixmapData(declarativePixmap, url, textureFactoryForImage(pixmap.toImage()), readSize, requestSize); } } } diff --cc tests/auto/qml/qml.pro index d58a290,6892680..4d1644f --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@@ -31,7 -30,9 +30,8 @@@ PRIVATETESTS += animation \ qqmlcpputils \ qqmlecmascript \ + qqmlcontext \ qqmlexpression \ - qqmlimageprovider \ qqmlinstruction \ qqmllanguage \ qqmlproperty \