| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICKIMAGEPROVIDER_H |
| 5 | #define QQUICKIMAGEPROVIDER_H |
| 6 | |
| 7 | #include <QtQuick/qtquickglobal.h> |
| 8 | #include <QtGui/qimage.h> |
| 9 | #include <QtGui/qpixmap.h> |
| 10 | #include <QtQml/qqmlengine.h> |
| 11 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | |
| 15 | class QQuickImageProviderPrivate; |
| 16 | class QQuickAsyncImageProviderPrivate; |
| 17 | class QQuickImageProviderOptionsPrivate; |
| 18 | class QSGTexture; |
| 19 | class QQuickWindow; |
| 20 | |
| 21 | class Q_QUICK_EXPORT QQuickTextureFactory : public QObject |
| 22 | { |
| 23 | Q_OBJECT |
| 24 | public: |
| 25 | QQuickTextureFactory(); |
| 26 | ~QQuickTextureFactory() override; |
| 27 | |
| 28 | virtual QSGTexture *createTexture(QQuickWindow *window) const = 0; |
| 29 | virtual QSize textureSize() const = 0; |
| 30 | virtual int textureByteCount() const = 0; |
| 31 | virtual QImage image() const; |
| 32 | |
| 33 | static QQuickTextureFactory *textureFactoryForImage(const QImage &image); |
| 34 | }; |
| 35 | |
| 36 | class QQuickImageResponsePrivate; |
| 37 | |
| 38 | class Q_QUICK_EXPORT QQuickImageResponse : public QObject |
| 39 | { |
| 40 | Q_OBJECT |
| 41 | public: |
| 42 | QQuickImageResponse(); |
| 43 | ~QQuickImageResponse() override; |
| 44 | |
| 45 | virtual QQuickTextureFactory *textureFactory() const = 0; |
| 46 | virtual QString errorString() const; |
| 47 | |
| 48 | public Q_SLOTS: |
| 49 | virtual void cancel(); |
| 50 | |
| 51 | Q_SIGNALS: |
| 52 | void finished(); |
| 53 | |
| 54 | private: |
| 55 | Q_DECLARE_PRIVATE(QQuickImageResponse) |
| 56 | Q_PRIVATE_SLOT(d_func(), void _q_finished()) |
| 57 | }; |
| 58 | |
| 59 | class QQuickImageProviderOptions; |
| 60 | |
| 61 | class Q_QUICK_EXPORT QQuickImageProvider : public QQmlImageProviderBase |
| 62 | { |
| 63 | friend class QQuickImageProviderWithOptions; |
| 64 | Q_OBJECT |
| 65 | public: |
| 66 | QQuickImageProvider(ImageType type, Flags flags = Flags()); |
| 67 | ~QQuickImageProvider() override; |
| 68 | |
| 69 | ImageType imageType() const override; |
| 70 | Flags flags() const override; |
| 71 | |
| 72 | virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize); |
| 73 | virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize); |
| 74 | virtual QQuickTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize); |
| 75 | |
| 76 | private: |
| 77 | QQuickImageProviderPrivate *d; |
| 78 | }; |
| 79 | |
| 80 | class Q_QUICK_EXPORT QQuickAsyncImageProvider : public QQuickImageProvider |
| 81 | { |
| 82 | public: |
| 83 | QQuickAsyncImageProvider(); |
| 84 | ~QQuickAsyncImageProvider() override; |
| 85 | |
| 86 | virtual QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) = 0; |
| 87 | |
| 88 | private: |
| 89 | QQuickAsyncImageProviderPrivate *d; |
| 90 | }; |
| 91 | |
| 92 | QT_END_NAMESPACE |
| 93 | |
| 94 | #endif // QQUICKIMAGEPROVIDER_H |
| 95 |
