4#include <QtQuick/private/qquickpixmapcache_p.h>
5#include <QtQuick/private/qquickimageprovider_p.h>
6#include <QtQuick/private/qquickprofiler_p.h>
7#include <QtQuick/private/qsgcontext_p.h>
8#include <QtQuick/private/qsgrenderer_p.h>
9#include <QtQuick/private/qsgtexturereader_p.h>
10#include <QtQuick/qquickwindow.h>
12#include <QtGui/private/qguiapplication_p.h>
13#include <QtGui/private/qimage_p.h>
14#include <QtGui/qpa/qplatformintegration.h>
15#include <QtGui/qimagereader.h>
16#include <QtGui/qpixmapcache.h>
18#include <QtQml/private/qqmlglobal_p.h>
19#include <QtQml/private/qqmlengine_p.h>
20#include <QtQml/qqmlfile.h>
22#include <QtCore/private/qobject_p.h>
23#include <QtCore/qcoreapplication.h>
24#include <QtCore/qhash.h>
25#include <QtCore/qfile.h>
26#include <QtCore/qthread.h>
27#include <QtCore/qmutex.h>
28#include <QtCore/qbuffer.h>
29#include <QtCore/qdebug.h>
30#include <QtCore/qmetaobject.h>
31#include <QtCore/qscopeguard.h>
33#if QT_CONFIG(qml_network)
34#include <QtQml/qqmlnetworkaccessmanagerfactory.h>
35#include <QtNetwork/qnetworkreply.h>
36#include <QtNetwork/qsslerror.h>
39#include <private/qdebug_p.h>
41#define IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT 8
44#define CACHE_EXPIRE_TIME 30
47#define CACHE_REMOVAL_FRACTION 4
49#define PIXMAP_PROFILE(Code) Q_QUICK_PROFILE(QQuickProfiler::ProfilePixmapCache, Code)
51#if QT_CONFIG(thread) && !defined(Q_OS_WASM)
52# define USE_THREADED_DOWNLOAD 1
54# define USE_THREADED_DOWNLOAD 0
63#if defined(QT_DEBUG) && QT_CONFIG(thread)
64class ThreadAffinityMarker
67 ThreadAffinityMarker() { attachToCurrentThread(); }
69 void assertOnAssignedThread()
72 if (!m_assignedThread)
73 attachToCurrentThread();
75 "Running on a wrong thread!");
78 void detachFromCurrentThread()
81 m_assignedThread =
nullptr;
90# define Q_THREAD_AFFINITY_MARKER(x) ThreadAffinityMarker x
91# define Q_ASSERT_CALLED_ON_VALID_THREAD(x) x.assertOnAssignedThread()
92# define Q_DETACH_THREAD_AFFINITY_MARKER(x) x.detachFromCurrentThread()
94# define Q_THREAD_AFFINITY_MARKER(x)
95# define Q_ASSERT_CALLED_ON_VALID_THREAD(x)
96# define Q_DETACH_THREAD_AFFINITY_MARKER(x)
133 QSGTexture *
t =
window->createTextureFromImage(im, QQuickWindow::TextureCanUseAtlas);
211 void networkRequestDone();
242#if QT_CONFIG(qml_network)
247 QList<QQuickPixmapReply*> jobs;
248 QList<QQuickPixmapReply *> cancelledJobs;
251#if QT_CONFIG(quick_pixmap_cache_threaded_download)
257 return runLoopReaderThreadExecutionEnforcer;
268 return ownedReaderThreadExecutionEnforcer.get();
270 std::unique_ptr<ReaderThreadExecutionEnforcer> ownedReaderThreadExecutionEnforcer;
273#if QT_CONFIG(qml_network)
276 QHash<QNetworkReply*,QQuickPixmapReply*> networkJobs;
278 QHash<QQuickImageResponse*,QQuickPixmapReply*> asyncResponses;
283 static int replyDownloadProgressMethodIndex;
284 static int replyFinishedMethodIndex;
285 static int downloadProgressMethodIndex;
286 static int threadNetworkRequestDoneMethodIndex;
287 static QHash<QQmlEngine *,QQuickPixmapReader*> readers;
292#if QT_CONFIG(quick_pixmap_cache_threaded_download)
293# define PIXMAP_READER_LOCK() QMutexLocker locker(&mutex)
295# define PIXMAP_READER_LOCK()
411QHash<QQmlEngine *,QQuickPixmapReader*> QQuickPixmapReader::readers;
414int QQuickPixmapReader::replyDownloadProgressMethodIndex = -1;
415int QQuickPixmapReader::replyFinishedMethodIndex = -1;
416int QQuickPixmapReader::downloadProgressMethodIndex = -1;
417int QQuickPixmapReader::threadNetworkRequestDoneMethodIndex = -1;
433 delete textureFactory;
436#if QT_CONFIG(qml_network)
439 if (!accessManager) {
440 Q_ASSERT(readerThreadExecutionEnforcer());
442 readerThreadExecutionEnforcer());
444 return accessManager;
451 if (
image->hasAlphaChannel() &&
image->data_ptr()
452 && !
image->data_ptr()->checkForAlphaPixels()) {
453 switch (
image->format()) {
486 qreal devicePixelRatio = 1.0)
491 else if (appliedTransform)
494 if (
frame < imgio.imageCount())
495 imgio.jumpToImage(
frame);
498 *frameCount = imgio.imageCount();
501 if (scSize.isValid())
502 imgio.setScaledSize(scSize);
505 const QSize originalSize = imgio.size();
506 qCDebug(lcImg) <<
url <<
"frame" <<
frame <<
"of" << imgio.imageCount()
507 <<
"requestRegion" <<
requestRegion <<
"QImageReader size" << originalSize <<
"-> scSize" << scSize;
510 *impsize = originalSize;
512 if (imgio.read(
image)) {
514 if (impsize && impsize->width() < 0)
515 *impsize =
image->size();
517 if (
image->colorSpace().isValid())
525 *errorString = QQuickPixmap::tr(
"Error decoding: %1: %2").arg(
url.
toString())
526 .arg(imgio.errorString());
546 hasOpenGL = QQuickWindow::sceneGraphBackend().isEmpty();
547 QList<QByteArray>
list;
564 if (!fi.suffix().isEmpty() || fi.exists())
568 const int suffixIdx = localFile.size() + 1;
569 for (
const QString &suffix : backendSupport()->fileSuffixes) {
570 tryFile.replace(suffixIdx, 10, suffix);
584#if QT_CONFIG(quick_pixmap_cache_threaded_download)
585 eventLoopQuitHack =
new QObject;
586 eventLoopQuitHack->moveToThread(
this);
607 reply->data->reply =
nullptr;
611#if QT_CONFIG(qml_network)
613 if (
reply->loading) {
614 cancelledJobs.append(
reply);
615 reply->data =
nullptr;
619 for (
auto *
reply : std::as_const(networkJobs))
622 for (
auto *
reply : std::as_const(asyncResponses))
625#if !QT_CONFIG(quick_pixmap_cache_threaded_download)
631 if (readerThreadExecutionEnforcer())
636#if QT_CONFIG(quick_pixmap_cache_threaded_download)
639 eventLoopQuitHack->deleteLater();
645#if QT_CONFIG(qml_network)
651 reply->data->reply =
nullptr;
662 asyncResponses.
clear();
666#if QT_CONFIG(qml_network)
687 if (backendSupport()->hasOpenGL && texReader.isTexture()) {
690 readSize =
factory->textureSize();
710 if (!cancelledJobs.contains(job))
738 if (!cancelledJobs.contains(job))
761 reader->processJobs();
768void ReaderThreadExecutionEnforcer::networkRequestDone()
770#if QT_CONFIG(qml_network)
772 reader->networkRequestDone(
reply);
778 reader->asyncResponseFinished(response);
787void QQuickPixmapReader::processJobs()
793 if (cancelledJobs.isEmpty() && jobs.isEmpty())
797 if (!cancelledJobs.isEmpty()) {
798 for (
int i = 0;
i < cancelledJobs.size(); ++
i) {
800#if QT_CONFIG(qml_network)
803 networkJobs.remove(
reply);
811 asyncResponses.
remove(asyncResponse);
812 asyncResponse->cancel();
815 PIXMAP_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingError>(job->
url));
820 cancelledJobs.clear();
823 if (!jobs.isEmpty()) {
825 bool usableJob =
false;
826 for (
int i = jobs.size() - 1; !usableJob &&
i >= 0;
i--) {
831 QSharedPointer<QQuickImageProvider> provider;
837 imageType = provider->imageType();
842 usableJob = !localFile.isEmpty()
843#if QT_CONFIG(qml_network)
856#if QT_CONFIG(quick_pixmap_cache_threaded_download)
862 processJob(job,
url, localFile, imageType, provider);
885 if (!cancelledJobs.contains(runningJob))
904 image = providerV2->requestImage(
imageId(
url), &readSize, runningJob->requestSize, runningJob->providerOptions);
906 image = provider->requestImage(
imageId(
url), &readSize, runningJob->requestSize);
910 if (
image.isNull()) {
915 if (!cancelledJobs.contains(runningJob)) {
916 runningJob->postReply(errorCode,
errorStr, readSize,
926 pixmap = providerV2->requestPixmap(
imageId(
url), &readSize, runningJob->requestSize, runningJob->providerOptions);
928 pixmap = provider->requestPixmap(
imageId(
url), &readSize, runningJob->requestSize);
938 if (!cancelledJobs.contains(runningJob)) {
939 runningJob->postReply(
950 t = providerV2->requestTexture(
imageId(
url), &readSize, runningJob->requestSize, runningJob->providerOptions);
952 t = provider->requestTexture(
imageId(
url), &readSize, runningJob->requestSize);
958 errorStr = QQuickPixmap::tr(
"Failed to get texture from provider: %1").arg(
url.
toString());
961 if (!cancelledJobs.contains(runningJob))
962 runningJob->postReply(errorCode,
errorStr, readSize,
t);
972 response = providerV2->requestImageResponse(
imageId(
url), runningJob->requestSize, runningJob->providerOptions);
975 response = asyncProvider->requestImageResponse(
imageId(
url), runningJob->requestSize);
983 auto provider_copy = provider;
998 asyncResponses.
insert(response, runningJob);
1004 if (!localFile.isEmpty()) {
1011 if (runningJob->data && runningJob->data->specialDevice) {
1014 runningJob->requestRegion, runningJob->requestSize,
1015 runningJob->providerOptions,
nullptr, runningJob->data->frame)) {
1017 }
else if (runningJob->data) {
1018 runningJob->data->frameCount = frameCount;
1024 if (backendSupport()->hasOpenGL && texReader.isTexture()) {
1027 readSize =
factory->textureSize();
1030 if (
f.fileName() != localFile)
1035 if (!cancelledJobs.contains(runningJob))
1040 int const frame = runningJob->data ? runningJob->data->frame : 0;
1042 runningJob->requestRegion, runningJob->requestSize,
1043 runningJob->providerOptions,
nullptr,
frame)) {
1045 if (
f.fileName() != localFile)
1047 }
else if (runningJob->data) {
1048 runningJob->data->frameCount = frameCount;
1057 if (!cancelledJobs.contains(runningJob)) {
1058 runningJob->postReply(errorCode,
errorStr, readSize,
1062#if QT_CONFIG(qml_network)
1069 downloadProgressMethodIndex);
1071 threadNetworkRequestDoneMethodIndex);
1073 networkJobs.insert(
reply, runningJob);
1087 readers.insert(
engine, reader);
1096 return readers.value(
engine, 0);
1110 if (readerThreadExecutionEnforcer())
1117 if (
reply->loading) {
1118 cancelledJobs.append(
reply);
1119 reply->data =
nullptr;
1121 if (readerThreadExecutionEnforcer())
1126 if (jobs.removeAll(
reply) == 0) {
1137 if (replyDownloadProgressMethodIndex == -1) {
1138#if QT_CONFIG(qml_network)
1139 replyDownloadProgressMethodIndex =
1142 const QMetaObject *ir = &ReaderThreadExecutionEnforcer::staticMetaObject;
1143 threadNetworkRequestDoneMethodIndex = ir->indexOfSlot(
"networkRequestDone()");
1145 downloadProgressMethodIndex =
1149#if QT_CONFIG(quick_pixmap_cache_threaded_download)
1153 delete runLoopReaderThreadExecutionEnforcer;
1154 runLoopReaderThreadExecutionEnforcer =
nullptr;
1159 Q_ASSERT(!runLoopReaderThreadExecutionEnforcer);
1166 ownedReaderThreadExecutionEnforcer = std::make_unique<ReaderThreadExecutionEnforcer>(
this);
1173 return *lhs.
url == *rhs.
url &&
1185#ifndef QT_NO_DEBUG_STREAM
1191 debug <<
"QQuickPixmapKey(0)";
1195 debug <<
"QQuickPixmapKey(" <<
key.url->toString() <<
" frame=" <<
key.frame;
1196 if (!
key.region->isEmpty()) {
1197 debug <<
" region=";
1200 if (!
key.size->isEmpty()) {
1228int QQuickPixmapCache::destroyCache()
1233 m_destroying =
true;
1241 int leakedPixmaps = 0;
1242 const auto cache = m_cache;
1244 auto currRefCount =
pixmap->refCount;
1248 <<
"size" <<
pixmap->requestSize <<
"region" <<
pixmap->requestRegion;
1249 while (currRefCount > 0) {
1257 while (m_lastUnreferencedPixmap)
1260 qCDebug(lcQsgLeak,
"Number of leaked pixmaps: %i", leakedPixmaps);
1261 return leakedPixmaps;
1264qsizetype QQuickPixmapCache::referencedCost()
const
1268 for (
const auto *
pixmap :
std::as_const(m_cache)) {
1285 data->nextUnreferenced = m_unreferencedPixmaps;
1287 if (!m_destroying) {
1288 m_unreferencedCost +=
data->cost();
1289 qCDebug(lcImg) <<
data->url <<
"had cost" <<
data->cost() <<
"of total unreferenced" << m_unreferencedCost;
1292 m_unreferencedPixmaps =
data;
1298 if (!m_lastUnreferencedPixmap)
1299 m_lastUnreferencedPixmap =
data;
1303 if (m_timerId == -1 && m_unreferencedPixmaps
1317 *
data->prevUnreferencedPtr =
data->nextUnreferenced;
1318 if (
data->nextUnreferenced) {
1319 data->nextUnreferenced->prevUnreferencedPtr =
data->prevUnreferencedPtr;
1320 data->nextUnreferenced->prevUnreferenced =
data->prevUnreferenced;
1322 if (m_lastUnreferencedPixmap ==
data)
1329 m_unreferencedCost -=
data->cost();
1330 qCDebug(lcImg) <<
data->url <<
"subtracts cost" <<
data->cost() <<
"of total" << m_unreferencedCost;
1337void QQuickPixmapCache::shrinkCache(
int remove)
1339 qCDebug(lcImg) <<
"reduce unreferenced cost" << m_unreferencedCost <<
"to less than limit" <<
cache_limit;
1340 while ((
remove > 0 || m_unreferencedCost >
cache_limit) && m_lastUnreferencedPixmap) {
1344 *
data->prevUnreferencedPtr =
nullptr;
1349 if (!m_destroying) {
1351 m_unreferencedCost -=
data->cost();
1353 data->removeFromCache(
this);
1362 shrinkCache(removalCost);
1364 if (m_unreferencedPixmaps ==
nullptr) {
1372 shrinkCache(m_unreferencedCost);
1381 :
data(
d), engineForReader(
nullptr), requestRegion(
d->requestRegion), requestSize(
d->requestSize),
1382 url(
d->
url), loading(
false), providerOptions(
d->providerOptions)
1405 data->textureFactory = de->textureFactory;
1406 de->textureFactory =
nullptr;
1407 data->implicitSize = de->implicitSize;
1409 data->textureFactory !=
nullptr &&
data->textureFactory->textureSize().isValid() ?
1410 data->textureFactory->textureSize() :
1411 (
data->requestSize.isValid() ?
data->requestSize :
data->implicitSize)));
1414 data->errorString = de->errorString;
1415 data->removeFromCache();
1418 data->reply =
nullptr;
1459 reader->cancel(cancelReply);
1496 if (lcImg().isDebugEnabled()) {
1500 qDebug(lcImg) <<
" similar pre-existing:" << *
it;
1505 PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
1520 PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
1526 const QRect &requestRegion,
const QSize &requestSize,
1528 qreal devicePixelRatio)
1539 imageType = provider->imageType();
1541 switch (imageType) {
1544 QQuickPixmap::tr(
"Invalid image provider: %1").
arg(
url.
toString()));
1548 : provider->requestTexture(
imageId(
url), &readSize, requestSize);
1559 QImage image = providerV2 ? providerV2->requestImage(
imageId(
url), &readSize, requestSize, providerOptions)
1560 : provider->requestImage(
imageId(
url), &readSize, requestSize);
1561 if (!
image.isNull()) {
1564 readSize, requestRegion, requestSize, providerOptions,
1571 QPixmap pixmap = providerV2 ? providerV2->requestPixmap(
imageId(
url), &readSize, requestSize, providerOptions)
1572 : provider->requestPixmap(
imageId(
url), &readSize, requestSize);
1576 readSize, requestRegion, requestSize, providerOptions,
1590 QQuickPixmap::tr(
"Failed to get image from provider: %1").
arg(
url.
toString()));
1594 if (localFile.isEmpty())
1603 if (backendSupport()->hasOpenGL && texReader.isTexture()) {
1610 errorString = QQuickPixmap::tr(
"Error decoding: %1").arg(
url.
toString());
1611 if (
f.fileName() != localFile)
1618 if (
readImage(
url, &
f, &
image, &errorString, &readSize, &frameCount, requestRegion, requestSize,
1619 providerOptions, &appliedTransform,
frame, devicePixelRatio)) {
1622 providerOptions, appliedTransform,
frame, frameCount);
1623 }
else if (
f.fileName() != localFile) {
1628 errorString = QQuickPixmap::tr(
"Cannot open: %1").arg(
url.
toString());
1630 return new QQuickPixmapData(
url, requestRegion, requestSize, providerOptions, errorString);
1681 return d ==
nullptr;
1720 return nullPixmap()->
url;
1728 return nullPixmap()->size;
1736 return nullPixmap()->size;
1744 return nullPixmap()->region;
1848 qreal devicePixelRatio)
1862 QQuickPixmap::Options orgOptions = options;
1875 qWarning() <<
"Ignoring sourceSize request for image url that came from grabToImage. Use the targetSize parameter of the grabToImage() function instead.";
1877 iter = store->m_cache.
find(grabberKey);
1881 if (
iter == store->m_cache.
end()) {
1929 d->
reply = reader->getImage(d);
1930 reader->startJob(d->
reply);
1947 const QRect &requestRegion,
const QSize &requestSize,
1956 if (
iter == store->m_cache.
end()) {
1968 d->
reply = reader->getImage(d);
1974 reader->startJob(d->
reply);
2019 return stringUrl.
endsWith(
"svg"_L1)
2020 || stringUrl.endsWith(
"svgz"_L1)
2021 || stringUrl.endsWith(
"pdf"_L1);
2026 if (!d || !d->
reply) {
2027 qWarning(
"QQuickPixmap: connectFinished() called when not loading.");
2036 if (!d || !d->
reply) {
2037 qWarning(
"QQuickPixmap: connectFinished() called when not loading.");
2046 if (!d || !d->
reply) {
2047 qWarning(
"QQuickPixmap: connectDownloadProgress() called when not loading.");
2057 if (!d || !d->
reply) {
2058 qWarning(
"QQuickPixmap: connectDownloadProgress() called when not loading.");
2075#include <qquickpixmapcache.moc>
2077#include "moc_qquickpixmapcache_p.cpp"
IOBluetoothDevice * device
\inmodule QtCore \reentrant
The QColorSpace class provides a color space abstraction.
bool isValid() const noexcept
Returns true if the color space is valid.
static bool closingDown()
Returns true if the application objects are being destroyed; otherwise returns false.
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
Type
This enum type defines the valid event types in Qt.
Type type() const
Returns the event type.
bool exists() const
Returns true if the file system entry this QFileInfo refers to exists; otherwise returns false.
static QPlatformIntegration * platformIntegration()
bool remove(const Key &key)
Removes the item that has the key from the hash.
qsizetype size() const noexcept
Returns the number of items in the hash.
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
Key key(const T &value) const noexcept
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
\inmodule QtCore \reentrant
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
The QImageReader class provides a format independent interface for reading images from files or other...
static QList< QByteArray > supportedImageFormats()
Returns the list of image formats supported by QImageReader.
QSize size() const
Returns the size of the image, i.e.
@ Format_RGBA8888_Premultiplied
@ Format_A2BGR30_Premultiplied
@ Format_ARGB32_Premultiplied
@ Format_A2RGB30_Premultiplied
qsizetype size() const noexcept
void append(parameter_type t)
void unlock() noexcept
Unlocks this mutex locker.
The QNetworkAccessManager class allows the application to send network requests and receive replies.
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
virtual void close() override
Closes this device for reading.
NetworkError error() const
Returns the error that was found during the processing of this request.
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
This signal is emitted to indicate the progress of the download part of this network request,...
void finished()
This signal is emitted when the reply has finished processing.
QUrl url() const
Returns the URL of the content downloaded or uploaded.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
@ HttpPipeliningAllowedAttribute
static QObjectPrivate * get(QObject *o)
int startTimer(int interval, Qt::TimerType timerType=Qt::CoarseTimer)
This is an overloaded function that will start a timer of type timerType and a timeout of interval mi...
Q_INVOKABLE QObject(QObject *parent=nullptr)
Constructs an object with parent object parent.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
void killTimer(int id)
Kills the timer with timer identifier, id.
void deleteLater()
\threadsafe
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\inmodule QtCore\reentrant
QSharedPointer< QQmlImageProviderBase > imageProvider(const QString &providerId) const
static QQmlEnginePrivate * get(QQmlEngine *e)
The QQmlEngine class provides an environment for instantiating QML components.
static QString urlToLocalFileOrQrc(const QString &)
If url is a local file returns a path suitable for passing to \l{QFile}.
@ ForceAsynchronousImageLoading
ImageType
Defines the type of image supported by this image provider.
The QQuickAsyncImageProvider class provides an interface for asynchronous control of QML image reques...
QImage image() const override
Returns an image version of this texture.
QQuickDefaultTextureFactory(const QImage &i)
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...
QColorSpace targetColorSpace() const
Returns the color space the image provider should return the image in.
AutoTransform
Whether the image provider should apply transformation metadata on read().
@ UsePluginDefaultTransform
AutoTransform autoTransform() const
Returns whether the image provider should apply transformation metadata on read().
static QQuickImageProviderWithOptions * checkedCast(QQuickImageProvider *provider)
static QSize loadSize(const QSize &originalSize, const QSize &requestedSize, const QByteArray &format, const QQuickImageProviderOptions &options, qreal devicePixelRatio=1.0)
Returns the recommended scaled image size for loading and storage.
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...
virtual QString errorString() const
Returns the error string for the job execution.
void finished()
Signals that the job execution has finished (be it successfully, because an error happened or because...
virtual QQuickTextureFactory * textureFactory() const =0
Returns the texture factory for the job.
static QQuickPixmapCache * instance()
void referencePixmap(QQuickPixmapData *)
void timerEvent(QTimerEvent *) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
~QQuickPixmapCache() override
void unreferencePixmap(QQuickPixmapData *)
QQuickPixmapReply * reply
QQuickPixmapData(const QUrl &u, const QRect &r, const QSize &rs, const QQuickImageProviderOptions &po, const QString &e)
QQuickImageProviderOptions::AutoTransform appliedTransform
QQuickPixmapData(const QUrl &u, const QRect &r, const QSize &s, const QQuickImageProviderOptions &po, QQuickImageProviderOptions::AutoTransform aTransform, int frame=0, int frameCount=1)
QColorSpace targetColorSpace
QQuickPixmapData ** prevUnreferencedPtr
QQuickTextureFactory * textureFactory
QQuickPixmapData(const QUrl &u, QQuickTextureFactory *texture, const QSize &s, const QRect &r, const QSize &rs, const QQuickImageProviderOptions &po, QQuickImageProviderOptions::AutoTransform aTransform, int frame=0, int frameCount=1)
QQuickPixmapData(QQuickTextureFactory *texture)
QQuickPixmapData * nextUnreferenced
void release(QQuickPixmapCache *store=nullptr)
QQuickPixmap::Status pixmapStatus
QQuickPixmapData * prevUnreferenced
QIODevice * specialDevice
QQuickImageProviderOptions providerOptions
void removeFromCache(QQuickPixmapCache *store=nullptr)
static QQuickPixmapReader * instance(QQmlEngine *engine)
QQuickPixmapReader(QQmlEngine *eng)
static QMutex readerMutex
void startJob(QQuickPixmapReply *job)
void cancel(QQuickPixmapReply *rep)
friend class ReaderThreadExecutionEnforcer
QQuickPixmapReply * getImage(QQuickPixmapData *)
static QQuickPixmapReader * existingInstance(QQmlEngine *engine)
QQuickTextureFactory * textureFactory
Event(ReadError, const QString &, const QSize &, QQuickTextureFactory *factory)
void downloadProgress(qint64, qint64)
QQmlEngine * engineForReader
static int downloadProgressMethodIndex
static int finishedMethodIndex
bool event(QEvent *event) override
This virtual function receives events to an object and should return true if the event e was recogniz...
void postReply(ReadError, const QString &, const QSize &, QQuickTextureFactory *factory)
QQuickImageProviderOptions providerOptions
QQuickPixmapReply(QQuickPixmapData *)
QColorSpace colorSpace() const
QQuickImageProviderOptions::AutoTransform autoTransform() const
bool connectDownloadProgress(QObject *, const char *)
static bool isScalableImageFormat(const QUrl &url)
QQuickTextureFactory * textureFactory() const
const QSize & requestSize() const
static bool isCached(const QUrl &url, const QRect &requestRegion, const QSize &requestSize, const int frame, const QQuickImageProviderOptions &options)
friend class QQuickPixmapData
void load(QQmlEngine *, const QUrl &)
void loadImageFromDevice(QQmlEngine *engine, QIODevice *device, const QUrl &url, const QRect &requestRegion, const QSize &requestSize, const QQuickImageProviderOptions &providerOptions, int frame=0, int frameCount=1)
const QRect & requestRegion() const
const QSize & implicitSize() const
void setImage(const QImage &)
void setPixmap(const QQuickPixmap &other)
static const QLatin1String itemGrabberScheme
bool connectFinished(QObject *, const char *)
The QQuickTextureFactory class provides an interface for loading custom textures from QML....
virtual QSize textureSize() const =0
Returns the size of the texture.
virtual int textureByteCount() const =0
Returns the number of bytes of memory the texture consumes.
virtual QImage image() const
Returns an image version of this texture.
static QQuickTextureFactory * textureFactoryForImage(const QImage &image)
Returns a QQuickTextureFactory holding the given image.
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
static QQuickTextureFactory * createTextureFactoryFromImage(const QImage &image)
Calls into the scene graph adaptation if available and creates a texture factory.
static QList< QByteArray > supportedFileFormats()
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString mid(qsizetype position, qsizetype n=-1) const &
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
static Qt::HANDLE currentThreadId() noexcept Q_DECL_PURE_FUNCTION
bool wait(QDeadlineTimer deadline=QDeadlineTimer(QDeadlineTimer::Forever))
void finished(QPrivateSignal)
QString url(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
QString fileName(ComponentFormattingOptions options=FullyDecoded) const
QString host(ComponentFormattingOptions=FullyDecoded) const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
QString scheme() const
Returns the scheme of the URL.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
void processJobsOnReaderThreadLater()
bool event(QEvent *e) override
This virtual function receives events to an object and should return true if the event e was recogniz...
void asyncResponseFinished()
ReaderThreadExecutionEnforcer(QQuickPixmapReader *reader)
QCache< int, Employee > cache
[0]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static void formatQRect(QDebug &debug, const Rect &rect)
static void formatQSize(QDebug &debug, const Size &size)
void all(std::vector< emscripten::val > promises, PromiseCallbacks callbacks)
#define Q_EVENT_DISABLE_COPY(Class)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter * iter
DBusConnection const char DBusError * error
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
constexpr QtPrivate::QHashMultiReturnType< T... > qHashMulti(size_t seed, const T &... args) noexcept(std::conjunction_v< QtPrivate::QNothrowHashable< T >... >)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
#define Q_ARG(Type, data)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
bool operator==(const QQuickPixmapKey &lhs, const QQuickPixmapKey &rhs)
#define CACHE_EXPIRE_TIME
static QString imageId(const QUrl &url)
#define Q_ASSERT_CALLED_ON_VALID_THREAD(x)
#define IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT
static QString existingImageFileForPath(const QString &localFile)
#define PIXMAP_READER_LOCK()
static void maybeRemoveAlpha(QImage *image)
static QQuickPixmapData * createPixmapDataSync(QQmlEngine *engine, const QUrl &url, const QRect &requestRegion, const QSize &requestSize, const QQuickImageProviderOptions &providerOptions, int frame, bool *ok, qreal devicePixelRatio)
#define Q_DETACH_THREAD_AFFINITY_MARKER(x)
#define PIXMAP_PROFILE(Code)
QDebug operator<<(QDebug debug, const QQuickPixmapKey &key)
static bool readImage(const QUrl &url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize, int *frameCount, const QRect &requestRegion, const QSize &requestSize, const QQuickImageProviderOptions &providerOptions, QQuickImageProviderOptions::AutoTransform *appliedTransform=nullptr, int frame=0, qreal devicePixelRatio=1.0)
size_t qHash(const QQuickPixmapKey &key, size_t seed) noexcept
#define Q_THREAD_AFFINITY_MARKER(x)
static QStringList fromLatin1List(const QList< QByteArray > &list)
#define CACHE_REMOVAL_FRACTION
static QString imageProviderId(const QUrl &url)
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
#define Q_ASSERT_X(cond, x, msg)
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
QLatin1StringView QLatin1String
#define QStringLiteral(str)
#define QT_CONFIG(feature)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
if(qFloatDistance(a, b)<(1<< 7))
[0]
settings remove("monkey")
QUrl url("example.com")
[constructor-url-reference]
QItemEditorFactory * factory
QQuickImageProviderOptions options