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#include "qfbbackingstore_p.h"
5#include "qfbwindow_p.h"
6#include "qfbscreen_p.h"
7
8#include <qpa/qplatformwindow.h>
9#include <QtGui/qscreen.h>
10#include <QtGui/qpainter.h>
11
12QT_BEGIN_NAMESPACE
13
14QFbBackingStore::QFbBackingStore(QWindow *window)
15 : QPlatformBackingStore(window)
16{
17 if (window->handle())
18 (static_cast<QFbWindow *>(window->handle()))->setBackingStore(this);
19 else
20 (static_cast<QFbScreen *>(window->screen()->handle()))->addPendingBackingStore(bs: this);
21}
22
23QFbBackingStore::~QFbBackingStore()
24{
25}
26
27void QFbBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
28{
29 Q_UNUSED(window);
30 Q_UNUSED(offset);
31
32 (static_cast<QFbWindow *>(window->handle()))->repaint(region);
33}
34
35void QFbBackingStore::resize(const QSize &size, const QRegion &staticContents)
36{
37 Q_UNUSED(staticContents);
38
39 if (mImage.size() != size)
40 mImage = QImage(size, window()->screen()->handle()->format());
41}
42
43const QImage QFbBackingStore::image()
44{
45 return mImage;
46}
47
48
49QImage QFbBackingStore::toImage() const
50{
51 return mImage;
52}
53
54void QFbBackingStore::lock()
55{
56 mImageMutex.lock();
57}
58
59void QFbBackingStore::unlock()
60{
61 mImageMutex.unlock();
62}
63
64void QFbBackingStore::beginPaint(const QRegion &region)
65{
66 lock();
67
68 if (mImage.hasAlphaChannel()) {
69 QPainter p(&mImage);
70 p.setCompositionMode(QPainter::CompositionMode_Source);
71 for (const QRect &r : region)
72 p.fillRect(r, c: Qt::transparent);
73 }
74}
75
76void QFbBackingStore::endPaint()
77{
78 unlock();
79}
80
81QT_END_NAMESPACE
82

source code of qtbase/src/platformsupport/fbconvenience/qfbbackingstore.cpp