Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qrasterbackingstore.cpp
Go to the documentation of this file.
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
// Qt-Security score:significant reason:default
4
5
#
include
"qrasterbackingstore_p.h"
6
7
#
include
<
QtGui
/
qbackingstore
.
h
>
8
#
include
<
QtGui
/
qpainter
.
h
>
9
10
#
include
<
qpa
/
qplatformwindow
.
h
>
11
12
QT_BEGIN_NAMESPACE
13
14
QRasterBackingStore::QRasterBackingStore(QWindow *window)
15
: QPlatformBackingStore(window)
16
{
17
}
18
19
QRasterBackingStore::~QRasterBackingStore()
20
{
21
}
22
23
void
QRasterBackingStore::resize(
const
QSize &size,
const
QRegion &staticContents)
24
{
25
Q_UNUSED(staticContents);
26
m_requestedSize = size;
27
}
28
29
QImage::Format QRasterBackingStore::format()
const
30
{
31
if
(window()->format().hasAlpha())
32
return
QImage::Format_ARGB32_Premultiplied;
33
else
34
return
QImage::Format_RGB32;
35
}
36
37
QPaintDevice *QRasterBackingStore::paintDevice()
38
{
39
return
&m_image;
40
}
41
42
QImage QRasterBackingStore::toImage()
const
43
{
44
return
m_image;
45
}
46
47
bool
QRasterBackingStore::scroll(
const
QRegion ®ion,
int
dx,
int
dy)
48
{
49
if
(window()->surfaceType() != QSurface::RasterSurface)
50
return
false
;
51
52
extern
void
qt_scrollRectInImage(QImage &,
const
QRect &,
const
QPoint &);
53
54
const
qreal devicePixelRatio = m_image.devicePixelRatio();
55
const
QPoint delta(dx * devicePixelRatio, dy * devicePixelRatio);
56
57
const
QRect rect = region.boundingRect();
58
qt_scrollRectInImage(m_image, QRect(rect.topLeft() * devicePixelRatio, rect.size() * devicePixelRatio), delta);
59
60
return
true
;
61
}
62
63
void
QRasterBackingStore::beginPaint(
const
QRegion ®ion)
64
{
65
qreal nativeWindowDevicePixelRatio = window()->handle()->devicePixelRatio();
66
QSize effectiveBufferSize = m_requestedSize * nativeWindowDevicePixelRatio;
67
if
(m_image.devicePixelRatio() != nativeWindowDevicePixelRatio || m_image.size() != effectiveBufferSize) {
68
m_image = QImage(effectiveBufferSize, format());
69
m_image.setDevicePixelRatio(nativeWindowDevicePixelRatio);
70
if
(m_image.hasAlphaChannel())
71
m_image.fill(Qt::transparent);
72
}
73
74
if
(!m_image.hasAlphaChannel())
75
return
;
76
77
QPainter painter(&m_image);
78
painter.setCompositionMode(QPainter::CompositionMode_Source);
79
for
(
const
QRect &rect : region)
80
painter.fillRect(rect, Qt::transparent);
81
}
82
83
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
gui
painting
qrasterbackingstore.cpp
Generated on
for Qt by
1.18.0