Merge remote-tracking branch 'origin/master' into api_changes
authorLars Knoll <lars.knoll@nokia.com>
Wed, 7 Mar 2012 21:00:57 +0000 (22:00 +0100)
committerLars Knoll <lars.knoll@nokia.com>
Wed, 7 Mar 2012 21:01:11 +0000 (22:01 +0100)
Change-Id: I121cb9c9316b5e47476dcb982bc28b6f3f358f78

12 files changed:
1  2 
doc/src/qml/basictypes.qdoc
src/qml/qml/qqmlengine.cpp
src/qml/qml/v8/qqmlbuiltinfunctions.cpp
src/quick/items/qquickcanvas.cpp
src/quick/scenegraph/qsgcontext.cpp
src/quick/scenegraph/qsgcontextplugin_p.h
src/quick/util/qquickimageprovider.cpp
src/quick/util/qquickimageprovider.h
src/quick/util/qquickpixmapcache.cpp
src/quick/util/qquickpixmapcache_p.h
tests/auto/qml/qml.pro
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp

Simple merge
Simple merge
Simple merge
Simple merge
@@@ -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 {
@@@ -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()) {
                  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<QQuickImageProvider *>(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);
                  }
              }
          }
Simple merge
@@@ -31,7 -30,9 +30,8 @@@ PRIVATETESTS += 
      animation \
      qqmlcpputils \
      qqmlecmascript \
+     qqmlcontext \
      qqmlexpression \
 -    qqmlimageprovider \
      qqmlinstruction \
      qqmllanguage \
      qqmlproperty \