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
12QT_BEGIN_NAMESPACE
13
14
15class QQuickImageProviderPrivate;
16class QQuickAsyncImageProviderPrivate;
17class QQuickImageProviderOptionsPrivate;
18class QSGTexture;
19class QQuickWindow;
20
21class Q_QUICK_EXPORT QQuickTextureFactory : public QObject
22{
23 Q_OBJECT
24public:
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
36class QQuickImageResponsePrivate;
37
38class Q_QUICK_EXPORT QQuickImageResponse : public QObject
39{
40Q_OBJECT
41public:
42 QQuickImageResponse();
43 ~QQuickImageResponse() override;
44
45 virtual QQuickTextureFactory *textureFactory() const = 0;
46 virtual QString errorString() const;
47
48public Q_SLOTS:
49 virtual void cancel();
50
51Q_SIGNALS:
52 void finished();
53
54private:
55 Q_DECLARE_PRIVATE(QQuickImageResponse)
56 Q_PRIVATE_SLOT(d_func(), void _q_finished())
57};
58
59class QQuickImageProviderOptions;
60
61class Q_QUICK_EXPORT QQuickImageProvider : public QQmlImageProviderBase
62{
63 friend class QQuickImageProviderWithOptions;
64 Q_OBJECT
65public:
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
76private:
77 QQuickImageProviderPrivate *d;
78};
79
80class Q_QUICK_EXPORT QQuickAsyncImageProvider : public QQuickImageProvider
81{
82public:
83 QQuickAsyncImageProvider();
84 ~QQuickAsyncImageProvider() override;
85
86 virtual QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) = 0;
87
88private:
89 QQuickAsyncImageProviderPrivate *d;
90};
91
92QT_END_NAMESPACE
93
94#endif // QQUICKIMAGEPROVIDER_H
95

source code of qtdeclarative/src/quick/util/qquickimageprovider.h