summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/image.pri2
-rw-r--r--src/gui/image/qbitmap.cpp4
-rw-r--r--src/gui/image/qimage.cpp4
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks.cpp2
-rw-r--r--src/gui/image/qimagereader.cpp59
-rw-r--r--src/gui/image/qimagewriter.cpp54
-rw-r--r--src/gui/image/qnativeimage.cpp2
-rw-r--r--src/gui/image/qpicture.cpp14
-rw-r--r--src/gui/image/qpixmap.cpp4
-rw-r--r--src/gui/image/qpixmap_blitter_p.h2
-rw-r--r--src/gui/image/qpixmap_raster_p.h2
-rw-r--r--src/gui/image/qpixmap_win.cpp2
-rw-r--r--src/gui/image/qplatformpixmap.cpp4
-rw-r--r--src/gui/image/qplatformpixmap.h (renamed from src/gui/image/qplatformpixmap_qpa.h)0
14 files changed, 99 insertions, 56 deletions
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri
index 34a33aa0f0..737b7fcbd4 100644
--- a/src/gui/image/image.pri
+++ b/src/gui/image/image.pri
@@ -21,7 +21,7 @@ HEADERS += \
image/qpixmap_blitter_p.h \
image/qpixmapcache.h \
image/qpixmapcache_p.h \
- image/qplatformpixmap_qpa.h \
+ image/qplatformpixmap.h \
image/qimagepixmapcleanuphooks_p.h \
SOURCES += \
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp
index f3c26dd5b2..499f9f48f2 100644
--- a/src/gui/image/qbitmap.cpp
+++ b/src/gui/image/qbitmap.cpp
@@ -40,8 +40,8 @@
****************************************************************************/
#include "qbitmap.h"
-#include "qplatformpixmap_qpa.h"
-#include "qplatformintegration_qpa.h"
+#include <qpa/qplatformpixmap.h>
+#include <qpa/qplatformintegration.h>
#include "qimage.h"
#include "qscreen.h"
#include "qvariant.h"
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 64decd0fd7..89060cfbb4 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -50,13 +50,13 @@
#include "qstringlist.h"
#include "qvariant.h"
#include "qimagepixmapcleanuphooks_p.h"
-#include "qplatformintegration_qpa.h"
+#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
#include <ctype.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
-#include <qplatformpixmap_qpa.h>
+#include <qpa/qplatformpixmap.h>
#include <private/qdrawhelper_p.h>
#include <private/qmemrotate_p.h>
#include <private/qimagescale_p.h>
diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp
index b118f5f856..548934829e 100644
--- a/src/gui/image/qimagepixmapcleanuphooks.cpp
+++ b/src/gui/image/qimagepixmapcleanuphooks.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include "qimagepixmapcleanuphooks_p.h"
-#include "qplatformpixmap_qpa.h"
+#include <qpa/qplatformpixmap.h>
#include "private/qimage_p.h"
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index c08ac0593b..4cda7304ac 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -224,15 +224,18 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
QImageIOHandler *handler = 0;
#ifndef QT_NO_LIBRARY
+ typedef QMultiMap<int, QString> PluginKeyMap;
+ typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
+
// check if we have plugins that support the image format
QFactoryLoader *l = loader();
- QStringList keys = l->keys();
+ const PluginKeyMap keyMap = l->keyMap();
#endif
QByteArray suffix;
#ifdef QIMAGEREADER_DEBUG
qDebug() << "QImageReader::createReadHandler( device =" << (void *)device << ", format =" << format << "),"
- << keys.size() << "plugins available: " << keys;
+ << keyMap.values().size() << "plugins available: " << keyMap.values();
#endif
#ifndef QT_NO_LIBRARY
@@ -246,7 +249,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
qDebug() << "QImageReader::createReadHandler: device is a file:" << file->fileName();
#endif
if (!(suffix = QFileInfo(file->fileName()).suffix().toLower().toLatin1()).isEmpty()) {
- int index = keys.indexOf(QString::fromLatin1(suffix));
+ const int index = keyMap.key(QString::fromLatin1(suffix), -1);
if (index != -1) {
#ifdef QIMAGEREADER_DEBUG
qDebug() << "QImageReader::createReadHandler: suffix recognized; the"
@@ -269,13 +272,16 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
// check if the plugin that claims support for this format can load
// from this device with this format.
const qint64 pos = device ? device->pos() : 0;
- QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(QString::fromLatin1(suffix)));
- if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) {
- handler = plugin->create(device, testFormat);
+ const int index = keyMap.key(QString::fromLatin1(suffix), -1);
+ if (index != -1) {
+ QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(index));
+ if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) {
+ handler = plugin->create(device, testFormat);
#ifdef QIMAGEREADER_DEBUG
- qDebug() << "QImageReader::createReadHandler: using the" << suffix
- << "plugin";
+ qDebug() << "QImageReader::createReadHandler: using the" << suffix
+ << "plugin";
#endif
+ }
}
if (device && !device->isSequential())
device->seek(pos);
@@ -287,9 +293,10 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
const qint64 pos = device ? device->pos() : 0;
if (autoDetectImageFormat) {
- for (int i = 0; i < keys.size(); ++i) {
+ const int keyCount = keyMap.keys().size();
+ for (int i = 0; i < keyCount; ++i) {
if (i != suffixPluginIndex) {
- QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i)));
+ QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(i));
if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) {
#ifdef QIMAGEREADER_DEBUG
qDebug() << "QImageReader::createReadHandler: the" << keys.at(i) << "plugin can read this format";
@@ -300,12 +307,15 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
}
}
} else {
- QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(QLatin1String(testFormat)));
- if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) {
+ const int testIndex = keyMap.key(QLatin1String(testFormat), -1);
+ if (testIndex != -1) {
+ QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(testIndex));
+ if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) {
#ifdef QIMAGEREADER_DEBUG
- qDebug() << "QImageReader::createReadHandler: the" << testFormat << "plugin can read this format";
+ qDebug() << "QImageReader::createReadHandler: the" << testFormat << "plugin can read this format";
#endif
- handler = plugin->create(device, testFormat);
+ handler = plugin->create(device, testFormat);
+ }
}
}
if (device && !device->isSequential())
@@ -363,9 +373,10 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
if (!handler && (autoDetectImageFormat || ignoresFormatAndExtension)) {
// check if any of our plugins recognize the file from its contents.
const qint64 pos = device ? device->pos() : 0;
- for (int i = 0; i < keys.size(); ++i) {
+ const int keyCount = keyMap.keys().size();
+ for (int i = 0; i < keyCount; ++i) {
if (i != suffixPluginIndex) {
- QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i)));
+ QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(i));
if (plugin && plugin->capabilities(device, QByteArray()) & QImageIOPlugin::CanRead) {
handler = plugin->create(device, testFormat);
#ifdef QIMAGEREADER_DEBUG
@@ -1413,6 +1424,12 @@ QByteArray QImageReader::imageFormat(QIODevice *device)
return format;
}
+#ifndef QT_NO_LIBRARY
+void supportedImageHandlerFormats(QFactoryLoader *loader,
+ QImageIOPlugin::Capability cap,
+ QSet<QByteArray> *result);
+#endif
+
/*!
Returns the list of image formats supported by QImageReader.
@@ -1442,6 +1459,7 @@ QByteArray QImageReader::imageFormat(QIODevice *device)
\sa setFormat(), QImageWriter::supportedImageFormats(), QImageIOPlugin
*/
+
QList<QByteArray> QImageReader::supportedImageFormats()
{
QSet<QByteArray> formats;
@@ -1449,14 +1467,7 @@ QList<QByteArray> QImageReader::supportedImageFormats()
formats << _qt_BuiltInFormats[i].extension;
#ifndef QT_NO_LIBRARY
- QFactoryLoader *l = loader();
- QStringList keys = l->keys();
-
- for (int i = 0; i < keys.count(); ++i) {
- QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i)));
- if (plugin && plugin->capabilities(0, keys.at(i).toLatin1()) & QImageIOPlugin::CanRead)
- formats << keys.at(i).toLatin1();
- }
+ supportedImageHandlerFormats(loader(), QImageIOPlugin::CanRead, &formats);
#endif // QT_NO_LIBRARY
QList<QByteArray> sortedFormats;
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index 56c459ee4d..c1b7a6459a 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -136,9 +136,12 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device,
QImageIOHandler *handler = 0;
#ifndef QT_NO_LIBRARY
+ typedef QMultiMap<int, QString> PluginKeyMap;
+ typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
+
// check if any plugins can write the image
QFactoryLoader *l = loader();
- QStringList keys = l->keys();
+ const PluginKeyMap keyMap = l->keyMap();
int suffixPluginIndex = -1;
#endif
@@ -149,7 +152,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device,
if (QFile *file = qobject_cast<QFile *>(device)) {
if (!(suffix = QFileInfo(file->fileName()).suffix().toLower().toLatin1()).isEmpty()) {
#ifndef QT_NO_LIBRARY
- int index = keys.indexOf(QString::fromLatin1(suffix));
+ const int index = keyMap.key(QString::fromLatin1(suffix), -1);
if (index != -1)
suffixPluginIndex = index;
#endif
@@ -163,9 +166,12 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device,
if (suffixPluginIndex != -1) {
// when format is missing, check if we can find a plugin for the
// suffix.
- QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(QString::fromLatin1(suffix)));
- if (plugin && (plugin->capabilities(device, suffix) & QImageIOPlugin::CanWrite))
- handler = plugin->create(device, suffix);
+ const int index = keyMap.key(QString::fromLatin1(suffix), -1);
+ if (index != -1) {
+ QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(index));
+ if (plugin && (plugin->capabilities(device, suffix) & QImageIOPlugin::CanWrite))
+ handler = plugin->create(device, suffix);
+ }
}
#endif // QT_NO_LIBRARY
@@ -210,8 +216,9 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device,
#ifndef QT_NO_LIBRARY
if (!testFormat.isEmpty()) {
- for (int i = 0; i < keys.size(); ++i) {
- QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i)));
+ const int keyCount = keyMap.keys().size();
+ for (int i = 0; i < keyCount; ++i) {
+ QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(i));
if (plugin && (plugin->capabilities(device, testFormat) & QImageIOPlugin::CanWrite)) {
delete handler;
handler = plugin->create(device, testFormat);
@@ -647,6 +654,31 @@ bool QImageWriter::supportsOption(QImageIOHandler::ImageOption option) const
return d->handler->supportsOption(option);
}
+
+#ifndef QT_NO_LIBRARY
+void supportedImageHandlerFormats(QFactoryLoader *loader,
+ QImageIOPlugin::Capability cap,
+ QSet<QByteArray> *result)
+{
+ typedef QMultiMap<int, QString> PluginKeyMap;
+ typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
+
+ const PluginKeyMap keyMap = loader->keyMap();
+ const PluginKeyMapConstIterator cend = keyMap.constEnd();
+ int i = -1;
+ QImageIOPlugin *plugin = 0;
+ for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) {
+ if (it.key() != i) {
+ i = it.key();
+ plugin = qobject_cast<QImageIOPlugin *>(loader->instance(i));
+ }
+ const QByteArray key = it.value().toLatin1();
+ if (plugin && (plugin->capabilities(0, key) & cap) != 0)
+ result->insert(key);
+ }
+}
+#endif // QT_NO_LIBRARY
+
/*!
Returns the list of image formats supported by QImageWriter.
@@ -696,13 +728,7 @@ QList<QByteArray> QImageWriter::supportedImageFormats()
#endif
#ifndef QT_NO_LIBRARY
- QFactoryLoader *l = loader();
- QStringList keys = l->keys();
- for (int i = 0; i < keys.count(); ++i) {
- QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i)));
- if (plugin && (plugin->capabilities(0, keys.at(i).toLatin1()) & QImageIOPlugin::CanWrite) != 0)
- formats << keys.at(i).toLatin1();
- }
+ supportedImageHandlerFormats(loader(), QImageIOPlugin::CanWrite, &formats);
#endif // QT_NO_LIBRARY
QList<QByteArray> sortedFormats;
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index 96d7a0487b..c562b0bd6d 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -41,7 +41,7 @@
#include <qdebug.h>
#include "qnativeimage_p.h"
-#include "qplatformscreen_qpa.h"
+#include <qpa/qplatformscreen.h>
#include "private/qguiapplication_p.h"
#include "qscreen.h"
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 283002b1d3..34ca077e5b 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -1400,14 +1400,20 @@ Q_GLOBAL_STATIC(QPHList, pictureHandlers)
void qt_init_picture_plugins()
{
#ifndef QT_NO_LIBRARY
+ typedef QMultiMap<int, QString> PluginKeyMap;
+ typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
+
static QBasicMutex mutex;
QMutexLocker locker(&mutex);
static QFactoryLoader loader(QPictureFormatInterface_iid,
QStringLiteral("/pictureformats"));
- QStringList keys = loader.keys();
- for (int i = 0; i < keys.count(); ++i)
- if (QPictureFormatInterface *format = qobject_cast<QPictureFormatInterface*>(loader.instance(keys.at(i))))
- format->installIOHandler(keys.at(i));
+
+ const PluginKeyMap keyMap = loader.keyMap();
+ const PluginKeyMapConstIterator cend = keyMap.constEnd();
+ for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) {
+ if (QPictureFormatInterface *format = qobject_cast<QPictureFormatInterface*>(loader.instance(it.key())))
+ format->installIOHandler(it.value());
+ }
#endif
}
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 377d7e036a..4cdf61138c 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -42,7 +42,7 @@
#include <qglobal.h>
#include "qpixmap.h"
-#include "qplatformpixmap_qpa.h"
+#include <qpa/qplatformpixmap.h>
#include "qimagepixmapcleanuphooks_p.h"
#include "qbitmap.h"
@@ -63,7 +63,7 @@
#include "qthread.h"
#include "qdebug.h"
-# include "qplatformintegration_qpa.h"
+#include <qpa/qplatformintegration.h>
#include "qpixmap_raster_p.h"
#include "private/qhexstring_p.h"
diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h
index 95397374c6..174277f9eb 100644
--- a/src/gui/image/qpixmap_blitter_p.h
+++ b/src/gui/image/qpixmap_blitter_p.h
@@ -42,7 +42,7 @@
#ifndef QPIXMAP_BLITTER_P_H
#define QPIXMAP_BLITTER_P_H
-#include <qplatformpixmap_qpa.h>
+#include <qpa/qplatformpixmap.h>
#include <private/qpaintengine_blitter_p.h>
#ifndef QT_NO_BLITTABLE
diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h
index 864fad42ec..8e1a8ccc03 100644
--- a/src/gui/image/qpixmap_raster_p.h
+++ b/src/gui/image/qpixmap_raster_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include <QtGui/qplatformpixmap_qpa.h>
+#include <qpa/qplatformpixmap.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index 66a829f5de..c25393c72e 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include "qpixmap.h"
-#include "qplatformpixmap_qpa.h"
+#include <qpa/qplatformpixmap.h>
#include "qpixmap_raster_p.h"
#include <qglobal.h>
diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp
index 073c267fbe..769cf5f90b 100644
--- a/src/gui/image/qplatformpixmap.cpp
+++ b/src/gui/image/qplatformpixmap.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include "qplatformpixmap_qpa.h"
-#include "qplatformintegration_qpa.h"
+#include "qplatformpixmap.h"
+#include <qpa/qplatformintegration.h>
#include <QtCore/qbuffer.h>
#include <QtGui/qbitmap.h>
#include <QtGui/qimagereader.h>
diff --git a/src/gui/image/qplatformpixmap_qpa.h b/src/gui/image/qplatformpixmap.h
index 154c5079a7..154c5079a7 100644
--- a/src/gui/image/qplatformpixmap_qpa.h
+++ b/src/gui/image/qplatformpixmap.h