Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickpixmapcache.cpp File Reference

(f8f42c929735dfb5a8f3202d4a4f3bf3f3d31d9a)

#include <QtQuick/private/qquickpixmapcache_p.h>
#include <QtQuick/private/qquickimageprovider_p.h>
#include <QtQuick/private/qquickprofiler_p.h>
#include <QtQuick/private/qsgcontext_p.h>
#include <QtQuick/private/qsgrenderer_p.h>
#include <QtQuick/private/qsgtexturereader_p.h>
#include <QtQuick/qquickwindow.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qimage_p.h>
#include <QtGui/qpa/qplatformintegration.h>
#include <QtGui/qimagereader.h>
#include <QtGui/qpixmapcache.h>
#include <QtQml/private/qqmlglobal_p.h>
#include <QtQml/private/qqmlengine_p.h>
#include <QtQml/qqmlfile.h>
#include <QtCore/private/qobject_p.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qhash.h>
#include <QtCore/qfile.h>
#include <QtCore/qthread.h>
#include <QtCore/qmutex.h>
#include <QtCore/qbuffer.h>
#include <QtCore/qdebug.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qscopeguard.h>
#include <private/qdebug_p.h>
#include <qquickpixmapcache.moc>
#include "moc_qquickpixmapcache_p.cpp"
+ Include dependency graph for qquickpixmapcache.cpp:

Go to the source code of this file.

Classes

class  QQuickPixmapReply
 
class  QQuickPixmapReply::Event
 
class  ReaderThreadExecutionEnforcer
 
class  QQuickPixmapReader
 
class  QQuickPixmapData
 
class  BackendSupport
 
struct  QQuickPixmapNull
 

Macros

#define IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT   8
 
#define CACHE_EXPIRE_TIME   30
 
#define CACHE_REMOVAL_FRACTION   4
 
#define PIXMAP_PROFILE(Code)   Q_QUICK_PROFILE(QQuickProfiler::ProfilePixmapCache, Code)
 
#define USE_THREADED_DOWNLOAD   0
 
#define Q_THREAD_AFFINITY_MARKER(x)
 
#define Q_ASSERT_CALLED_ON_VALID_THREAD(x)
 
#define Q_DETACH_THREAD_AFFINITY_MARKER(x)
 
#define PIXMAP_READER_LOCK()
 

Functions

static QString imageProviderId (const QUrl &url)
 
static QString imageId (const QUrl &url)
 
static void maybeRemoveAlpha (QImage *image)
 
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)
 
static QStringList fromLatin1List (const QList< QByteArray > &list)
 
 Q_GLOBAL_STATIC (BackendSupport, backendSupport)
 
static QString existingImageFileForPath (const QString &localFile)
 
bool operator== (const QQuickPixmapKey &lhs, const QQuickPixmapKey &rhs)
 
size_t qHash (const QQuickPixmapKey &key, size_t seed) noexcept
 
QDebug operator<< (QDebug debug, const QQuickPixmapKey &key)
 
static QQuickPixmapDatacreatePixmapDataSync (QQmlEngine *engine, const QUrl &url, const QRect &requestRegion, const QSize &requestSize, const QQuickImageProviderOptions &providerOptions, int frame, bool *ok, qreal devicePixelRatio)
 
 Q_GLOBAL_STATIC (QQuickPixmapNull, nullPixmap)
 

Variables

static int cache_limit = 2048 * 1024
 

Macro Definition Documentation

◆ CACHE_EXPIRE_TIME

#define CACHE_EXPIRE_TIME   30

Definition at line 44 of file qquickpixmapcache.cpp.

Referenced by QQuickPixmapCache::unreferencePixmap().

◆ CACHE_REMOVAL_FRACTION

#define CACHE_REMOVAL_FRACTION   4

Definition at line 47 of file qquickpixmapcache.cpp.

Referenced by QQuickPixmapCache::timerEvent().

◆ IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT

#define IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT   8

Definition at line 41 of file qquickpixmapcache.cpp.

◆ PIXMAP_PROFILE

◆ PIXMAP_READER_LOCK

◆ Q_ASSERT_CALLED_ON_VALID_THREAD

#define Q_ASSERT_CALLED_ON_VALID_THREAD ( x)

◆ Q_DETACH_THREAD_AFFINITY_MARKER

#define Q_DETACH_THREAD_AFFINITY_MARKER ( x)

Definition at line 96 of file qquickpixmapcache.cpp.

Referenced by QQuickPixmapReader::QQuickPixmapReader().

◆ Q_THREAD_AFFINITY_MARKER

#define Q_THREAD_AFFINITY_MARKER ( x)

Definition at line 94 of file qquickpixmapcache.cpp.

◆ USE_THREADED_DOWNLOAD

#define USE_THREADED_DOWNLOAD   0

Definition at line 54 of file qquickpixmapcache.cpp.

Function Documentation

◆ createPixmapDataSync()

static QQuickPixmapData * createPixmapDataSync ( QQmlEngine * engine,
const QUrl & url,
const QRect & requestRegion,
const QSize & requestSize,
const QQuickImageProviderOptions & providerOptions,
int frame,
bool * ok,
qreal devicePixelRatio )
static

◆ existingImageFileForPath()

static QString existingImageFileForPath ( const QString & localFile)
static

Definition at line 560 of file qquickpixmapcache.cpp.

References QFileInfo::exists(), and QStringLiteral.

Referenced by createPixmapDataSync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromLatin1List()

static QStringList fromLatin1List ( const QList< QByteArray > & list)
static

Definition at line 531 of file qquickpixmapcache.cpp.

References QString::fromLatin1(), item, list, and QList< T >::size().

Referenced by BackendSupport::BackendSupport().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imageId()

static QString imageId ( const QUrl & url)
inlinestatic

Definition at line 114 of file qquickpixmapcache.cpp.

References QString::mid(), QUrl::RemoveAuthority, QUrl::RemoveScheme, QUrl::toString(), and url.

Referenced by createPixmapDataSync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imageProviderId()

static QString imageProviderId ( const QUrl & url)
inlinestatic

Definition at line 109 of file qquickpixmapcache.cpp.

References QUrl::host(), and url.

Referenced by createPixmapDataSync(), and QQuickPixmap::load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maybeRemoveAlpha()

static void maybeRemoveAlpha ( QImage * image)
static

Definition at line 448 of file qquickpixmapcache.cpp.

References Qt::AutoColor, QImage::Format_A2BGR30_Premultiplied, QImage::Format_A2RGB30_Premultiplied, QImage::Format_BGR30, QImage::Format_RGB30, QImage::Format_RGB32, QImage::Format_RGBA8888, QImage::Format_RGBA8888_Premultiplied, and QImage::Format_RGBX8888.

Referenced by readImage().

+ Here is the caller graph for this function:

◆ operator<<()

QDebug operator<< ( QDebug debug,
const QQuickPixmapKey & key )
inline

Definition at line 1186 of file qquickpixmapcache.cpp.

References debug, QtDebugUtils::formatQRect(), and QtDebugUtils::formatQSize().

+ Here is the call graph for this function:

◆ operator==()

bool operator== ( const QQuickPixmapKey & lhs,
const QQuickPixmapKey & rhs )
inline

◆ Q_GLOBAL_STATIC() [1/2]

Q_GLOBAL_STATIC ( BackendSupport ,
backendSupport  )

◆ Q_GLOBAL_STATIC() [2/2]

Q_GLOBAL_STATIC ( QQuickPixmapNull ,
nullPixmap  )

◆ qHash()

size_t qHash ( const QQuickPixmapKey & key,
size_t seed )
inlinenoexcept

Definition at line 1180 of file qquickpixmapcache.cpp.

References qHashMulti(), and seed.

+ Here is the call graph for this function:

◆ readImage()

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 )
static

Definition at line 483 of file qquickpixmapcache.cpp.

References QQuickImageProviderOptions::ApplyTransform, QQuickImageProviderOptions::autoTransform(), QQuickImageProviderOptions::DoNotApplyTransform, frame, QRect::isNull(), QColorSpace::isValid(), QQuickImageProviderWithOptions::loadSize(), maybeRemoveAlpha(), QQuickPixmapReply::providerOptions, qCDebug, QQuickPixmapReply::requestRegion, QQuickPixmapReply::requestSize, QQuickImageProviderOptions::targetColorSpace(), QUrl::toString(), QQuickPixmapReply::url, and QQuickImageProviderOptions::UsePluginDefaultTransform.

Referenced by createPixmapDataSync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ cache_limit

int cache_limit = 2048 * 1024
static

The maximum currently-unused image data that can be stored for potential later reuse, in bytes. See QQuickPixmapCache::shrinkCache()

Definition at line 107 of file qquickpixmapcache.cpp.