summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-09-10 17:48:41 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-09-11 19:47:10 +0200
commit9346760f5a173bd3b697b8f800b3c992db1019bd (patch)
tree4d60fd78c1e98d1606074ff092e90c28092cddc5 /src/gui/painting
parentac7e518a6465cae67c53604672c73d269bb07a9e (diff)
Minimal ABI necessary for future optimized QPixmap
Add virtual hooks that can make it possible in Qt6 to implement paint device specific pixmaps. Change-Id: Ib1d1d7b5e32d9430203f718534344b25c0ead744 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qpaintengine.cpp42
-rw-r--r--src/gui/painting/qpaintengine.h3
2 files changed, 44 insertions, 1 deletions
diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp
index fe6ddfaffe..075a802a6e 100644
--- a/src/gui/painting/qpaintengine.cpp
+++ b/src/gui/painting/qpaintengine.cpp
@@ -44,10 +44,13 @@
#include <qdebug.h>
#include <qmath.h>
#include <qguiapplication.h>
-#include <private/qtextengine_p.h>
#include <qvarlengtharray.h>
+#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformpixmap.h>
#include <private/qfontengine_p.h>
+#include <private/qguiapplication_p.h>
#include <private/qpaintengineex_p.h>
+#include <private/qtextengine_p.h>
QT_BEGIN_NAMESPACE
@@ -994,6 +997,43 @@ QRect QPaintEngine::systemRect() const
return d_func()->systemRect;
}
+/*!
+ \internal
+
+ Creates a QPixmap optimized for this paint engine and device.
+*/
+QPixmap QPaintEngine::createPixmap(QSize size)
+{
+ if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(QCoreApplication::instance()))) {
+ qWarning("QPaintEngine::createPixmap: QPixmap cannot be created without a QGuiApplication");
+ return QPixmap();
+ }
+
+ QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType));
+ data->resize(size.width(), size.height());
+ return QPixmap(data.take());
+}
+
+/*!
+ \internal
+
+ Creates a QPixmap optimized for this paint engine and device.
+*/
+QPixmap QPaintEngine::createPixmapFromImage(QImage image, Qt::ImageConversionFlags flags)
+{
+ if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(QCoreApplication::instance()))) {
+ qWarning("QPaintEngine::createPixmapFromImage: QPixmap cannot be created without a QGuiApplication");
+ return QPixmap();
+ }
+
+ QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType));
+ if (image.isDetached())
+ data->fromImageInPlace(image, flags);
+ else
+ data->fromImage(image, flags);
+ return QPixmap(data.take());
+}
+
QPaintEnginePrivate::~QPaintEnginePrivate()
{
}
diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h
index 2b876356be..64170c513e 100644
--- a/src/gui/painting/qpaintengine.h
+++ b/src/gui/painting/qpaintengine.h
@@ -225,6 +225,9 @@ public:
void syncState();
inline bool isExtended() const { return extended; }
+ virtual QPixmap createPixmap(QSize size);
+ virtual QPixmap createPixmapFromImage(QImage image, Qt::ImageConversionFlags flags = Qt::AutoColor);
+
protected:
QPaintEngine(QPaintEnginePrivate &data, PaintEngineFeatures devcaps=PaintEngineFeatures());