Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquickpixmapcache_p.h
Go to the documentation of this file.
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 QQUICKPIXMAPCACHE_H
5#define QQUICKPIXMAPCACHE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qcoreapplication.h>
19#include <QtCore/qstring.h>
20#include <QtGui/qpixmap.h>
21#include <QtCore/qurl.h>
22#include <private/qtquickglobal_p.h>
23#include <QtQuick/qquickimageprovider.h>
24
25#include <private/qintrusivelist_p.h>
26
28
29class QQmlEngine;
33
35{
37public:
40 QSize textureSize() const override { return size; }
41 int textureByteCount() const override { return size.width() * size.height() * 4; }
42 QImage image() const override { return im; }
43
44private:
45 QImage im;
46 QSize size;
47};
48
50{
51public:
53 QQuickImageProvider::Flags flags;
55};
56
57// ### Qt 6: Make public moving to qquickimageprovider.h
58class Q_QUICK_PRIVATE_EXPORT QQuickImageProviderOptions
59{
60public:
62 UsePluginDefaultTransform = -1,
63 ApplyTransform = 0,
64 DoNotApplyTransform = 1
65 };
66
69
72
73 bool operator==(const QQuickImageProviderOptions&) const;
74
75 AutoTransform autoTransform() const;
76 void setAutoTransform(AutoTransform autoTransform);
77
78 bool preserveAspectRatioCrop() const;
79 void setPreserveAspectRatioCrop(bool preserveAspectRatioCrop);
80
81 bool preserveAspectRatioFit() const;
82 void setPreserveAspectRatioFit(bool preserveAspectRatioFit);
83
84 QColorSpace targetColorSpace() const;
85 void setTargetColorSpace(const QColorSpace &colorSpace);
86
87private:
89};
90
91class Q_QUICK_PRIVATE_EXPORT QQuickPixmap
92{
94public:
96 QQuickPixmap(QQmlEngine *, const QUrl &);
97 QQuickPixmap(QQmlEngine *, const QUrl &, const QRect &region, const QSize &);
98 QQuickPixmap(const QUrl &, const QImage &image);
100
101 enum Status { Null, Ready, Error, Loading };
102
103 enum Option {
104 Asynchronous = 0x00000001,
105 Cache = 0x00000002
106 };
108
109 bool isNull() const;
110 bool isReady() const;
111 bool isError() const;
112 bool isLoading() const;
113
114 Status status() const;
115 QString error() const;
116 const QUrl &url() const;
117 const QSize &implicitSize() const;
118 const QRect &requestRegion() const;
119 const QSize &requestSize() const;
120 QQuickImageProviderOptions::AutoTransform autoTransform() const;
121 int frameCount() const;
122 QImage image() const;
123 void setImage(const QImage &);
124 void setPixmap(const QQuickPixmap &other);
125
126 QColorSpace colorSpace() const;
127
128 QQuickTextureFactory *textureFactory() const;
129
130 QRect rect() const;
131 int width() const;
132 int height() const;
133
134 void load(QQmlEngine *, const QUrl &);
135 void load(QQmlEngine *, const QUrl &, QQuickPixmap::Options options);
136 void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize);
137 void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize, QQuickPixmap::Options options);
138 void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize,
139 QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions, int frame = 0, int frameCount = 1,
140 qreal devicePixelRatio = 1.0);
141 void loadImageFromDevice(QQmlEngine *engine, QIODevice *device, const QUrl &url,
142 const QRect &requestRegion, const QSize &requestSize,
143 const QQuickImageProviderOptions &providerOptions, int frame = 0, int frameCount = 1);
144
145 void clear();
146 void clear(QObject *);
147
148 bool connectFinished(QObject *, const char *);
149 bool connectFinished(QObject *, int);
150 bool connectDownloadProgress(QObject *, const char *);
151 bool connectDownloadProgress(QObject *, int);
152
153 static void purgeCache();
154 static bool isCached(const QUrl &url, const QRect &requestRegion, const QSize &requestSize,
155 const int frame, const QQuickImageProviderOptions &options);
156
158
159private:
160 Q_DISABLE_COPY(QQuickPixmap)
162 QIntrusiveListNode dataListNode;
163 friend class QQuickPixmapData;
164};
165
166Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPixmap::Options)
167
168// ### Qt 6: This should be made public in Qt 6. It's functionality can't be merged into
169// QQuickImageProvider without breaking source compatibility.
170class Q_QUICK_PRIVATE_EXPORT QQuickImageProviderWithOptions : public QQuickAsyncImageProvider
171{
172public:
174
175 QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) override;
176 QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) override;
177 QQuickTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize) override;
178 QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override;
179
180 virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize, const QQuickImageProviderOptions &options);
181 virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize, const QQuickImageProviderOptions &options);
182 virtual QQuickTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize, const QQuickImageProviderOptions &options);
183 virtual QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize, const QQuickImageProviderOptions &options);
184
185 static QSize loadSize(const QSize &originalSize, const QSize &requestedSize, const QByteArray &format, const QQuickImageProviderOptions &options,
186 qreal devicePixelRatio = 1.0);
187 static QQuickImageProviderWithOptions *checkedCast(QQuickImageProvider *provider);
188};
189
191
192#endif // QQUICKPIXMAPCACHE_H
IOBluetoothDevice * device
[qjs-as-container]
\inmodule QtCore
Definition qbytearray.h:57
The QColorSpace class provides a color space abstraction.
Definition qcolorspace.h:21
\inmodule QtCore \reentrant
Definition qiodevice.h:34
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qobject.h:90
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
ImageType
Defines the type of image supported by this image provider.
Definition qqmlengine.h:21
The QQuickAsyncImageProvider class provides an interface for asynchronous control of QML image reques...
QImage image() const override
Returns an image version of this texture.
QSize textureSize() const override
Returns the size of the texture.
int textureByteCount() const override
Returns the number of bytes of memory the texture consumes.
QSGTexture * createTexture(QQuickWindow *window) const override
This function is called on the scene graph rendering thread to create a QSGTexture instance from the ...
The QQuickImageProviderOptions class provides options for QQuickImageProviderWithOptions image reques...
AutoTransform
Whether the image provider should apply transformation metadata on read().
QQuickImageProvider::ImageType type
QQuickImageProvider::Flags flags
The QQuickImageProvider class provides an interface for supporting pixmaps and threaded image request...
The QQuickImageResponse class provides an interface for asynchronous image loading in QQuickAsyncImag...
static const QLatin1String itemGrabberScheme
The QQuickTextureFactory class provides an interface for loading custom textures from QML....
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtQuick
Definition qsgtexture.h:20
\inmodule QtCore
Definition qshareddata.h:35
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qurl.h:94
b clear()
p1 load("image.bmp")
rect
[4]
Combined button and popup list for selecting options.
Definition image.cpp:4
#define Q_DECLARE_TR_FUNCTIONS(context)
DBusConnection const char DBusError * error
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
Flags
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei width
GLenum type
GLbitfield flags
GLint GLsizei GLsizei GLenum format
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1219
#define Q_OBJECT
double qreal
Definition qtypes.h:92
QUrl url("example.com")
[constructor-url-reference]
QSharedPointer< T > other(t)
[5]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QFrame frame
[0]
imageLabel setPixmap(QPixmap::fromImage(image))
QJSEngine engine
[0]