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#define IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT 8
40#define CACHE_EXPIRE_TIME 30
41#define CACHE_REMOVAL_FRACTION 4
43#define PIXMAP_PROFILE(Code) Q_QUICK_PROFILE(QQuickProfiler::ProfilePixmapCache, Code)
45#if QT_CONFIG(thread) && !defined(Q_OS_WASM)
46# define USE_THREADED_DOWNLOAD 1
48# define USE_THREADED_DOWNLOAD 0
53#if defined(QT_DEBUG) && QT_CONFIG(thread)
54class ThreadAffinityMarker
57 ThreadAffinityMarker() { attachToCurrentThread(); }
59 void assertOnAssignedThread()
62 if (!m_assignedThread)
63 attachToCurrentThread();
65 "Running on a wrong thread!");
68 void detachFromCurrentThread()
71 m_assignedThread =
nullptr;
80# define Q_THREAD_AFFINITY_MARKER(x) ThreadAffinityMarker x
81# define Q_ASSERT_CALLED_ON_VALID_THREAD(x) x.assertOnAssignedThread()
82# define Q_DETACH_THREAD_AFFINITY_MARKER(x) x.detachFromCurrentThread()
84# define Q_THREAD_AFFINITY_MARKER(x)
85# define Q_ASSERT_CALLED_ON_VALID_THREAD(x)
86# define Q_DETACH_THREAD_AFFINITY_MARKER(x)
120 QSGTexture *
t =
window->createTextureFromImage(im, QQuickWindow::TextureCanUseAtlas);
197 void networkRequestDone();
225#if QT_CONFIG(qml_network)
234#if QT_CONFIG(quick_pixmap_cache_threaded_download)
240 return runLoopReaderThreadExecutionEnforcer;
251 return ownedReaderThreadExecutionEnforcer.get();
253 std::unique_ptr<ReaderThreadExecutionEnforcer> ownedReaderThreadExecutionEnforcer;
256#if QT_CONFIG(qml_network)
266 static int replyDownloadProgressMethodIndex;
267 static int replyFinishedMethodIndex;
268 static int downloadProgressMethodIndex;
269 static int threadNetworkRequestDoneMethodIndex;
275#if QT_CONFIG(quick_pixmap_cache_threaded_download)
276# define PIXMAP_READER_LOCK() QMutexLocker locker(&mutex)
278# define PIXMAP_READER_LOCK()
347 referencer->d =
nullptr;
396int QQuickPixmapReader::replyDownloadProgressMethodIndex = -1;
397int QQuickPixmapReader::replyFinishedMethodIndex = -1;
398int QQuickPixmapReader::downloadProgressMethodIndex = -1;
399int QQuickPixmapReader::threadNetworkRequestDoneMethodIndex = -1;
415 delete textureFactory;
418#if QT_CONFIG(qml_network)
421 if (!accessManager) {
422 Q_ASSERT(readerThreadExecutionEnforcer());
424 readerThreadExecutionEnforcer());
426 return accessManager;
433 if (
image->hasAlphaChannel() &&
image->data_ptr()
434 && !
image->data_ptr()->checkForAlphaPixels()) {
435 switch (
image->format()) {
468 qreal devicePixelRatio = 1.0)
473 else if (appliedTransform)
489 <<
"requestRegion" <<
requestRegion <<
"QImageReader size" << originalSize <<
"-> scSize" << scSize;
492 *impsize = originalSize;
496 if (impsize && impsize->
width() < 0)
497 *impsize =
image->size();
499 if (
image->colorSpace().isValid())
507 *errorString = QQuickPixmap::tr(
"Error decoding: %1: %2").
arg(
url.
toString())
528 hasOpenGL = QQuickWindow::sceneGraphBackend().
isEmpty();
548 const int suffixIdx = localFile.
size() + 1;
549 for (
const QString &suffix : backendSupport()->fileSuffixes) {
550 tryFile.
replace(suffixIdx, 10, suffix);
564#if QT_CONFIG(quick_pixmap_cache_threaded_download)
565 eventLoopQuitHack =
new QObject;
587 reply->data->reply =
nullptr;
591#if QT_CONFIG(qml_network)
593 if (
reply->loading) {
595 reply->data =
nullptr;
599 for (
auto *
reply : std::as_const(networkJobs))
602 for (
auto *
reply : std::as_const(asyncResponses))
605#if !QT_CONFIG(quick_pixmap_cache_threaded_download)
611 if (readerThreadExecutionEnforcer())
616#if QT_CONFIG(quick_pixmap_cache_threaded_download)
625#if QT_CONFIG(qml_network)
631 reply->data->reply =
nullptr;
642 asyncResponses.
clear();
646#if QT_CONFIG(qml_network)
667 if (backendSupport()->hasOpenGL && texReader.isTexture()) {
670 readSize =
factory->textureSize();
741 reader->processJobs();
748void ReaderThreadExecutionEnforcer::networkRequestDone()
750#if QT_CONFIG(qml_network)
752 reader->networkRequestDone(
reply);
758 reader->asyncResponseFinished(response);
767void QQuickPixmapReader::processJobs()
777 if (!cancelledJobs.
isEmpty()) {
778 for (
int i = 0;
i < cancelledJobs.
size(); ++
i) {
780#if QT_CONFIG(qml_network)
783 networkJobs.remove(
reply);
791 asyncResponses.
remove(asyncResponse);
795 PIXMAP_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingError>(job->
url));
800 cancelledJobs.
clear();
805 bool usableJob =
false;
806 for (
int i = jobs.
size() - 1; !usableJob &&
i >= 0;
i--) {
817 imageType = provider->imageType();
822 usableJob = !localFile.
isEmpty()
823#if QT_CONFIG(qml_network)
836#if QT_CONFIG(quick_pixmap_cache_threaded_download)
842 processJob(job,
url, localFile, imageType, provider);
865 if (!cancelledJobs.
contains(runningJob))
890 if (
image.isNull()) {
892 errorStr = QQuickPixmap::tr(
"Failed to get image from provider: %1").
arg(
url.
toString());
895 if (!cancelledJobs.
contains(runningJob)) {
896 runningJob->
postReply(errorCode, errorStr, readSize,
914 errorStr = QQuickPixmap::tr(
"Failed to get image from provider: %1").
arg(
url.
toString());
918 if (!cancelledJobs.
contains(runningJob)) {
920 errorCode, errorStr, readSize,
938 errorStr = QQuickPixmap::tr(
"Failed to get texture from provider: %1").
arg(
url.
toString());
941 if (!cancelledJobs.
contains(runningJob))
942 runningJob->
postReply(errorCode, errorStr, readSize,
t);
963 auto provider_copy = provider;
978 asyncResponses.
insert(response, runningJob);
997 }
else if (runningJob->
data) {
1004 if (backendSupport()->hasOpenGL && texReader.isTexture()) {
1007 readSize =
factory->textureSize();
1009 errorStr = QQuickPixmap::tr(
"Error decoding: %1").
arg(
url.
toString());
1010 if (
f.fileName() != localFile)
1015 if (!cancelledJobs.
contains(runningJob))
1025 if (
f.fileName() != localFile)
1027 }
else if (runningJob->
data) {
1032 errorStr = QQuickPixmap::tr(
"Cannot open: %1").
arg(
url.
toString());
1037 if (!cancelledJobs.
contains(runningJob)) {
1038 runningJob->
postReply(errorCode, errorStr, readSize,
1042#if QT_CONFIG(qml_network)
1049 downloadProgressMethodIndex);
1051 threadNetworkRequestDoneMethodIndex);
1053 networkJobs.insert(
reply, runningJob);
1086 if (readerThreadExecutionEnforcer())
1094 if (
reply->loading) {
1096 reply->data =
nullptr;
1098 if (readerThreadExecutionEnforcer())
1114 if (replyDownloadProgressMethodIndex == -1) {
1115#if QT_CONFIG(qml_network)
1116 replyDownloadProgressMethodIndex =
1119 const QMetaObject *ir = &ReaderThreadExecutionEnforcer::staticMetaObject;
1120 threadNetworkRequestDoneMethodIndex = ir->
indexOfSlot(
"networkRequestDone()");
1122 downloadProgressMethodIndex =
1126#if QT_CONFIG(quick_pixmap_cache_threaded_download)
1130 delete runLoopReaderThreadExecutionEnforcer;
1131 runLoopReaderThreadExecutionEnforcer =
nullptr;
1136 Q_ASSERT(!runLoopReaderThreadExecutionEnforcer);
1143 ownedReaderThreadExecutionEnforcer = std::make_unique<ReaderThreadExecutionEnforcer>(
this);
1160 return *lhs.
url == *rhs.
url &&
1191 void shrinkCache(
int remove);
1196 int m_unreferencedCost;
1204 : m_unreferencedPixmaps(
nullptr), m_lastUnreferencedPixmap(
nullptr), m_unreferencedCost(0), m_timerId(-1), m_destroying(
false)
1210 m_destroying =
true;
1213 int leakedPixmaps = 0;
1223 int currRefCount =
pixmap->refCount;
1228 while (currRefCount > 0) {
1236 while (m_lastUnreferencedPixmap) {
1242 qDebug(
"Number of leaked pixmaps: %i", leakedPixmaps);
1252 data->nextUnreferenced = m_unreferencedPixmaps;
1255 m_unreferencedCost +=
data->cost();
1257 m_unreferencedPixmaps =
data;
1263 if (!m_lastUnreferencedPixmap)
1264 m_lastUnreferencedPixmap =
data;
1268 if (m_timerId == -1 && m_unreferencedPixmaps
1278 *
data->prevUnreferencedPtr =
data->nextUnreferenced;
1279 if (
data->nextUnreferenced) {
1280 data->nextUnreferenced->prevUnreferencedPtr =
data->prevUnreferencedPtr;
1281 data->nextUnreferenced->prevUnreferenced =
data->prevUnreferenced;
1283 if (m_lastUnreferencedPixmap ==
data)
1290 m_unreferencedCost -=
data->cost();
1293void QQuickPixmapStore::shrinkCache(
int remove)
1295 while ((
remove > 0 || m_unreferencedCost >
cache_limit) && m_lastUnreferencedPixmap) {
1299 *
data->prevUnreferencedPtr =
nullptr;
1304 if (!m_destroying) {
1306 m_unreferencedCost -=
data->cost();
1308 data->removeFromCache(
this);
1317 shrinkCache(removalCost);
1319 if (m_unreferencedPixmaps ==
nullptr) {
1327 shrinkCache(m_unreferencedCost);
1332 pixmapStore()->purgeCache();
1336 :
data(
d), engineForReader(
nullptr), requestRegion(
d->requestRegion), requestSize(
d->requestSize),
1337 url(
d->
url), loading(
false), providerOptions(
d->providerOptions)
1364 data->textureFactory !=
nullptr &&
data->textureFactory->textureSize().isValid() ?
1365 data->textureFactory->textureSize() :
1366 (
data->requestSize.isValid() ?
data->requestSize :
data->implicitSize)));
1370 data->removeFromCache();
1373 data->reply =
nullptr;
1398 pixmapStore()->referencePixmap(
this);
1414 reader->cancel(cancelReply);
1418 store = store ? store : pixmapStore();
1439 pixmapStore()->m_cache.insert(
key,
this);
1441 PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
1442 url, pixmapStore()->m_cache.size()));
1451 store = pixmapStore();
1455 PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>(
1461 const QRect &requestRegion,
const QSize &requestSize,
1463 qreal devicePixelRatio)
1474 imageType = provider->imageType();
1476 switch (imageType) {
1478 return new QQuickPixmapData(declarativePixmap,
url, requestRegion, requestSize, providerOptions,
1479 QQuickPixmap::tr(
"Invalid image provider: %1").
arg(
url.
toString()));
1483 : provider->requestTexture(
imageId(
url), &readSize, requestSize);
1494 QImage image = providerV2 ? providerV2->requestImage(
imageId(
url), &readSize, requestSize, providerOptions)
1495 : provider->requestImage(
imageId(
url), &readSize, requestSize);
1496 if (!
image.isNull()) {
1499 readSize, requestRegion, requestSize, providerOptions,
1506 QPixmap pixmap = providerV2 ? providerV2->requestPixmap(
imageId(
url), &readSize, requestSize, providerOptions)
1507 : provider->requestPixmap(
imageId(
url), &readSize, requestSize);
1511 readSize, requestRegion, requestSize, providerOptions,
1524 return new QQuickPixmapData(declarativePixmap,
url, requestRegion, requestSize, providerOptions,
1525 QQuickPixmap::tr(
"Failed to get image from provider: %1").
arg(
url.
toString()));
1538 if (backendSupport()->hasOpenGL && texReader.
isTexture()) {
1545 errorString = QQuickPixmap::tr(
"Error decoding: %1").
arg(
url.
toString());
1546 if (
f.fileName() != localFile)
1553 if (
readImage(
url, &
f, &
image, &errorString, &readSize, &frameCount, requestRegion, requestSize,
1554 providerOptions, &appliedTransform,
frame, devicePixelRatio)) {
1557 providerOptions, appliedTransform,
frame, frameCount);
1558 }
else if (
f.fileName() != localFile) {
1563 errorString = QQuickPixmap::tr(
"Cannot open: %1").
arg(
url.
toString());
1565 return new QQuickPixmapData(declarativePixmap,
url, requestRegion, requestSize, providerOptions, errorString);
1611 return d ==
nullptr;
1650 return nullPixmap()->
url;
1658 return nullPixmap()->size;
1666 return nullPixmap()->size;
1674 return nullPixmap()->region;
1772 qreal devicePixelRatio)
1786 QQuickPixmap::Options orgOptions = options;
1799 qWarning() <<
"Ignoring sourceSize request for image url that came from grabToImage. Use the targetSize parameter of the grabToImage() function instead.";
1868 const QRect &requestRegion,
const QSize &requestSize,
1931 if (!d || !d->
reply) {
1932 qWarning(
"QQuickPixmap: connectFinished() called when not loading.");
1941 if (!d || !d->
reply) {
1942 qWarning(
"QQuickPixmap: connectFinished() called when not loading.");
1951 if (!d || !d->
reply) {
1952 qWarning(
"QQuickPixmap: connectDownloadProgress() called when not loading.");
1962 if (!d || !d->
reply) {
1963 qWarning(
"QQuickPixmap: connectDownloadProgress() called when not loading.");
1980#include <qquickpixmapcache.moc>
1982#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.
\inmodule QtCore \reentrant
QString suffix() const
Returns the suffix (extension) of the file.
bool exists() const
Returns true if the file 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.
T value(const Key &key) const noexcept
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...
void setScaledClipRect(const QRect &rect)
Sets the scaled clip rect to rect.
QString errorString() const
Returns a human readable description of the last error that occurred.
int imageCount() const
For image formats that support animation, this function returns the total number of images in the ani...
bool autoTransform() const
void setScaledSize(const QSize &size)
Sets the scaled size of the image to size.
void setAutoTransform(bool enabled)
bool jumpToImage(int imageNumber)
For image formats that support animation, this function skips to the image whose sequence number is i...
QByteArray format() const
Returns the format QImageReader uses for reading images.
static QList< QByteArray > supportedImageFormats()
Returns the list of image formats supported by QImageReader.
QSize size() const
Returns the size of the image, without actually reading the image contents.
QImage read()
Reads an image from the device.
QColorSpace colorSpace() const
QSize size() const
Returns the size of the image, i.e.
@ Format_RGBA8888_Premultiplied
@ Format_A2BGR30_Premultiplied
@ Format_ARGB32_Premultiplied
@ Format_A2RGB30_Premultiplied
The QIntrusiveList class is a template class that provides a list of objects using static storage.
void insert(N *n)
Insert object into the list.
void remove(N *n)
Remove object from the list.
N * first() const
Returns the first entry in this list, or null if the list is empty.
qsizetype size() const noexcept
bool isEmpty() const noexcept
void removeAt(qsizetype i)
const_reference at(qsizetype i) const noexcept
qsizetype removeAll(const AT &t)
void append(parameter_type t)
void unlock() noexcept
Unlocks the mutex.
void lock() noexcept
Locks the mutex.
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...
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
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 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...
virtual QQuickImageResponse * requestImageResponse(const QString &id, const QSize &requestedSize)=0
Implement this method to return the job that will provide the texture with id.
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)
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override
Implement this method to return the pixmap with id.
QQuickTextureFactory * requestTexture(const QString &id, QSize *size, const QSize &requestedSize) override
Implement this method to return the texture with id.
QQuickImageResponse * requestImageResponse(const QString &id, const QSize &requestedSize) override
Implement this method to return the job that will provide the texture with id.
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.
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override
Implement this method to return the image with id.
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.
virtual void cancel()
This method is used to communicate that the response is no longer required by the engine.
QQuickPixmapReply * reply
QQuickImageProviderOptions::AutoTransform appliedTransform
QColorSpace targetColorSpace
void release(QQuickPixmapStore *store=nullptr)
QQuickPixmapData ** prevUnreferencedPtr
QQuickTextureFactory * textureFactory
QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QRect &r, const QSize &rs, const QQuickImageProviderOptions &po, const QString &e)
QQuickPixmapData(QQuickPixmap *pixmap, 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 * nextUnreferenced
void removeFromCache(QQuickPixmapStore *store=nullptr)
QQuickPixmap::Status pixmapStatus
QQuickPixmapData * prevUnreferenced
QIODevice * specialDevice
QQuickPixmapData(QQuickPixmap *pixmap, QQuickTextureFactory *texture)
QQuickImageProviderOptions providerOptions
QIntrusiveList< QQuickPixmap, &QQuickPixmap::dataListNode > declarativePixmaps
QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QRect &r, const QSize &s, const QQuickImageProviderOptions &po, QQuickImageProviderOptions::AutoTransform aTransform, int frame=0, int frameCount=1)
QQuickImageProviderOptions options
static QQuickPixmapReader * instance(QQmlEngine *engine)
QQuickPixmapReader(QQmlEngine *eng)
static QMutex readerMutex
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 *)
QHash< QQuickPixmapKey, QQuickPixmapData * > m_cache
void timerEvent(QTimerEvent *) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void referencePixmap(QQuickPixmapData *)
void unreferencePixmap(QQuickPixmapData *)
QColorSpace colorSpace() const
QQuickImageProviderOptions::AutoTransform autoTransform() const
bool connectDownloadProgress(QObject *, const char *)
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.
QQuickTextureFactory * read()
static QList< QByteArray > supportedFileFormats()
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString & replace(qsizetype i, qsizetype len, QChar after)
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype size() const
Returns the number of characters in this string.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void start(Priority=InheritPriority)
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.
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(QQuickImageResponse *response)
ReaderThreadExecutionEnforcer(QQuickPixmapReader *reader)
QCache< int, Employee > cache
[0]
Combined button and popup list for selecting options.
void all(std::vector< emscripten::val > promises, PromiseCallbacks callbacks)
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_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)
#define Q_DETACH_THREAD_AFFINITY_MARKER(x)
#define PIXMAP_PROFILE(Code)
static QQuickPixmapData * createPixmapDataSync(QQuickPixmap *declarativePixmap, QQmlEngine *engine, const QUrl &url, const QRect &requestRegion, const QSize &requestSize, const QQuickImageProviderOptions &providerOptions, int frame, bool *ok, qreal devicePixelRatio)
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]
QFileInfo fi("c:/temp/foo")
[newstuff]
settings remove("monkey")
QUrl url("example.com")
[constructor-url-reference]
QItemEditorFactory * factory
bool contains(const AT &t) const noexcept