5#include <private/qobject_p.h>
6#include <private/qimage_p.h>
7#include <QSharedMemory>
26#if QT_CONFIG(sharedmemory)
27struct SharedImageInfo {
36 SharedImageInfo *sii =
static_cast<SharedImageInfo *
>(cleanupInfo);
37 qCDebug(lcSharedImage) <<
"Cleanup called for" << sii->path;
38 if (sii->shmp.isNull()) {
39 qCDebug(lcSharedImage) <<
"shm is 0 for" << sii->path;
42 QSharedMemory *shm = sii->shmp.data();
77 h->width =
img.width();
78 h->height =
img.height();
79 h->bpl =
img.bytesPerLine();
80 h->format =
img.format();
83 memcpy(
p,
img.constBits(),
img.sizeInBytes());
105 if (
h->height *
h->bpl > availSize)
126#if QT_CONFIG(sharedmemory)
133 auto shm = std::make_unique<QSharedMemory>(QSharedMemory::legacyNativeKey(
q->key(
path,
params)));
136 if (!shm->attach(QSharedMemory::ReadOnly)) {
141 if (
size >
size_t(std::numeric_limits<int>::max())) {
142 qCDebug(lcSharedImage) <<
"Image" <<
path <<
"to large to load";
144 }
else if (shm->create(
int(
size))) {
145 qCDebug(lcSharedImage) <<
"Created new shm segment of size" <<
size <<
"for image" <<
path;
147 qCDebug(lcSharedImage) <<
"Lock1 failed!?" << shm->errorString();
152 }
else if (shm->error() == QSharedMemory::AlreadyExists) {
155 if (!shm->attach(QSharedMemory::ReadOnly)) {
156 qCDebug(lcSharedImage) <<
"Attach to existing failed?" << shm->errorString();
160 qCDebug(lcSharedImage) <<
"Create failed?" << shm->errorString();
169 qCDebug(lcSharedImage) <<
"Lock2 failed!?" << shm->errorString();
175 if (!
verifyMem(shm->constData(), shm->size())) {
176 qCDebug(lcSharedImage) <<
"Verifymem failed!?";
181 QSharedMemory *shmp = shm.release();
182 SharedImageInfo *sii =
new SharedImageInfo;
187 if (!shmp->unlock()) {
188 qCDebug(lcSharedImage) <<
"UnLock failed!?";
233#include "moc_qsharedimageloader_p.cpp"
qsizetype sizeInBytes() const
Format
The following image formats are available in Qt.
void storeImageToMem(void *data, const QImage &img)
bool verifyMem(const void *data, int size)
QImage createImageFromMem(const void *data, void *cleanupInfo)
QImage load(const QString &path, QSharedImageLoader::ImageParameters *params)
QSharedImageLoaderPrivate()
QSharedImageLoader(QObject *parent=nullptr)
virtual QString key(const QString &path, ImageParameters *params)
virtual QImage loadFile(const QString &path, ImageParameters *params)
QImage load(const QString &path, ImageParameters *params=nullptr)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
#define Q_STATIC_ASSERT(Condition)
int qt_depthForFormat(QImage::Format format)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
void cleanupSharedImage(void *)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent