| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | |
| 5 | #include "qminimalbackingstore.h" |
| 6 | #include "qminimalintegration.h" |
| 7 | #include "qscreen.h" |
| 8 | #include <QtCore/qdebug.h> |
| 9 | #include <qpa/qplatformscreen.h> |
| 10 | #include <private/qguiapplication_p.h> |
| 11 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | using namespace Qt::StringLiterals; |
| 15 | |
| 16 | QMinimalBackingStore::QMinimalBackingStore(QWindow *window) |
| 17 | : QPlatformBackingStore(window) |
| 18 | , mDebug(QMinimalIntegration::instance()->options() & QMinimalIntegration::DebugBackingStore) |
| 19 | { |
| 20 | if (mDebug) |
| 21 | qDebug() << "QMinimalBackingStore::QMinimalBackingStore:"<< (quintptr)this; |
| 22 | } |
| 23 | |
| 24 | QMinimalBackingStore::~QMinimalBackingStore() |
| 25 | { |
| 26 | } |
| 27 | |
| 28 | QPaintDevice *QMinimalBackingStore::paintDevice() |
| 29 | { |
| 30 | if (mDebug) |
| 31 | qDebug(msg: "QMinimalBackingStore::paintDevice"); |
| 32 | |
| 33 | return &mImage; |
| 34 | } |
| 35 | |
| 36 | void QMinimalBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) |
| 37 | { |
| 38 | Q_UNUSED(window); |
| 39 | Q_UNUSED(region); |
| 40 | Q_UNUSED(offset); |
| 41 | |
| 42 | if (mDebug) { |
| 43 | static int c = 0; |
| 44 | QString filename = QString("output%1.png").arg(a: c++, fieldWidth: 4, base: 10, fillChar: QChar(u'0')); |
| 45 | qDebug() << "QMinimalBackingStore::flush() saving contents to"<< filename.toLocal8Bit().constData(); |
| 46 | mImage.save(fileName: filename); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | void QMinimalBackingStore::resize(const QSize &size, const QRegion &) |
| 51 | { |
| 52 | QImage::Format format = QGuiApplication::primaryScreen()->handle()->format(); |
| 53 | if (mImage.size() != size) |
| 54 | mImage = QImage(size, format); |
| 55 | } |
| 56 | |
| 57 | QT_END_NAMESPACE |
| 58 |
