| 1 |
#include "headless_backingstore.h" |
| 2 |
#include "headless_integration.h" |
| 3 |
#include "qscreen.h" |
| 4 |
#include <QtCore/qdebug.h> |
| 5 |
#include <qpa/qplatformscreen.h> |
| 6 |
#include <private/qguiapplication_p.h> |
| 7 |
|
| 8 |
QT_BEGIN_NAMESPACE |
| 9 |
|
| 10 |
HeadlessBackingStore::HeadlessBackingStore(QWindow *window) : QPlatformBackingStore(window), mDebug(0) { |
| 11 |
if (mDebug) qDebug() << "HeadlessBackingStore::HeadlessBackingStore:" << (quintptr)this; |
| 12 |
} |
| 13 |
|
| 14 |
HeadlessBackingStore::~HeadlessBackingStore() {} |
| 15 |
|
| 16 |
QPaintDevice * |
| 17 |
HeadlessBackingStore::paintDevice() { |
| 18 |
if (mDebug) qDebug() << "HeadlessBackingStore::paintDevice"; |
| 19 |
|
| 20 |
return &mImage; |
| 21 |
} |
| 22 |
|
| 23 |
void |
| 24 |
HeadlessBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { |
| 25 |
Q_UNUSED(window); |
| 26 |
Q_UNUSED(region); |
| 27 |
Q_UNUSED(offset); |
| 28 |
|
| 29 |
if (mDebug) { |
| 30 |
static int c = 0; |
| 31 |
QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0')); |
| 32 |
qDebug() << "HeadlessBackingStore::flush() saving contents to" << filename.toLocal8Bit().constData(); |
| 33 |
mImage.save(filename); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
void |
| 38 |
HeadlessBackingStore::resize(const QSize &size, const QRegion &) { |
| 39 |
QImage::Format format = QGuiApplication::primaryScreen()->handle()->format(); |
| 40 |
if (mImage.size() != size) mImage = QImage(size, format); |
| 41 |
} |
| 42 |
|
| 43 |
QT_END_NAMESPACE |