diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-03-28 22:57:03 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-03-28 22:57:03 (GMT) |
commit | a3868307c0e1584a1f694efc4a7b980b54c6e2b1 (patch) | |
tree | 54a19c5b8a357d057a8c9697b8429aed90973f60 /src | |
parent | 6b619af035a995cf16d977439995cf7c1c0d366e (diff) | |
download | Qt-a3868307c0e1584a1f694efc4a7b980b54c6e2b1.zip Qt-a3868307c0e1584a1f694efc4a7b980b54c6e2b1.tar.gz Qt-a3868307c0e1584a1f694efc4a7b980b54c6e2b1.tar.bz2 |
Source resizing for QDeclarativeImageProvider too.
(fixes test too)
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeimageprovider.cpp | 6 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeimageprovider.h | 2 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepixmapcache.cpp | 4 |
5 files changed, 12 insertions, 6 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index ad26650..dea5a40 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -580,13 +580,13 @@ void QDeclarativeEngine::removeImageProvider(const QString &providerId) delete d->imageProviders.take(providerId); } -QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url) +QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size) { QMutexLocker locker(&mutex); QImage image; QDeclarativeImageProvider *provider = imageProviders.value(url.host()); if (provider) - image = provider->request(url.path().mid(1)); + image = provider->request(url.path().mid(1), size, req_size); return image; } diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 06b5027..84bf061 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -225,7 +225,7 @@ public: mutable QDeclarativeNetworkAccessManagerFactory *networkAccessManagerFactory; QHash<QString,QDeclarativeImageProvider*> imageProviders; - QImage getImageFromProvider(const QUrl &url); + QImage getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size); mutable QMutex mutex; diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp index 9ef8545..b992b9f 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.cpp +++ b/src/declarative/qml/qdeclarativeimageprovider.cpp @@ -61,10 +61,14 @@ QDeclarativeImageProvider::~QDeclarativeImageProvider() } /*! - \fn QImage QDeclarativeImageProvider::request(const QString &id) + \fn QImage QDeclarativeImageProvider::request(const QString &id, QSize *size, const QSize& requested_size) Implement this method to return the image with \a id. + If \a requested_size is a valid size, resize the image to that size before returning. + + In any case, \a size must be set to the (original) size of the image. + Note: this method may be called by multiple threads, so ensure the implementation of this method is reentrant. */ diff --git a/src/declarative/qml/qdeclarativeimageprovider.h b/src/declarative/qml/qdeclarativeimageprovider.h index 6ee7bcf..50b73fe 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.h +++ b/src/declarative/qml/qdeclarativeimageprovider.h @@ -54,7 +54,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeImageProvider { public: virtual ~QDeclarativeImageProvider(); - virtual QImage request(const QString &id) = 0; + virtual QImage request(const QString &id, QSize *size, const QSize& requested_size) = 0; }; QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index 54dccce..1d90bf8 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -255,7 +255,9 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event) // fetch if (url.scheme() == QLatin1String("image")) { // Use QmlImageProvider - QImage image = QDeclarativeEnginePrivate::get(engine)->getImageFromProvider(url); + QSize read_impsize; + QImage image = QDeclarativeEnginePrivate::get(engine)->getImageFromProvider(url, &read_impsize, QSize(runningJob->forcedWidth(),runningJob->forcedHeight())); + qmlOriginalSizes()->insert(url, read_impsize); QDeclarativeImageReaderEvent::ReadError errorCode = QDeclarativeImageReaderEvent::NoError; QString errorStr; if (image.isNull()) { |