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>
This commit is contained in:
parent
ac7e518a64
commit
9346760f5a
@ -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()
|
||||
{
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user