Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qrasterwindow.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
"qrasterwindow.h"
6
7
#
include
<
QtGui
/
private
/
qpaintdevicewindow_p
.
h
>
8
9
#
include
<
QtGui
/
QBackingStore
>
10
#
include
<
QtGui
/
QPainter
>
11
12
QT_BEGIN_NAMESPACE
13
14
/*!
15
\class QRasterWindow
16
\inmodule QtGui
17
\since 5.4
18
\brief QRasterWindow is a convenience class for using QPainter on a QWindow.
19
20
QRasterWindow is a QWindow with a raster-based, non-OpenGL surface. On top of
21
the functionality offered by QWindow, QRasterWindow adds a virtual
22
paintEvent() function and the possibility to open a QPainter on itself. The
23
underlying paint engine will be the raster one, meaning that all drawing will
24
happen on the CPU. For performing accelerated, OpenGL-based drawing, use
25
QOpenGLWindow instead.
26
27
Internally the class is thin wrapper for QWindow and QBackingStore
28
and is very similar to the \l{Raster Window Example}{Raster Window
29
Example} that uses these classes directly.
30
31
\sa QPaintDeviceWindow::paintEvent(), QPaintDeviceWindow::update()
32
*/
33
34
class
QRasterWindowPrivate
:
public
QPaintDeviceWindowPrivate
35
{
36
Q_DECLARE_PUBLIC(QRasterWindow)
37
public
:
38
void
handleResizeEvent
()
override
39
{
40
Q_Q
(
QRasterWindow
);
41
if
(
backingstore
->
size
() !=
q
->
size
())
42
markWindowAsDirty
();
43
}
44
45
void
beginPaint
(
const
QRegion
&
region
)
override
46
{
47
Q_Q
(
QRasterWindow
);
48
const
QSize
size
=
q
->
size
();
49
if
(
backingstore
->
size
() !=
size
)
50
backingstore
->
resize
(
size
);
51
52
backingstore
->
beginPaint
(
region
);
53
}
54
55
void
endPaint
()
override
56
{
57
backingstore
->
endPaint
();
58
}
59
60
void
flush
(
const
QRegion
&
region
)
override
61
{
62
Q_Q
(
QRasterWindow
);
63
backingstore
->
flush
(
region
,
q
);
64
}
65
66
QScopedPointer
<
QBackingStore
>
backingstore
;
67
};
68
69
/*!
70
Constructs a new QRasterWindow with \a parent.
71
*/
72
QRasterWindow::QRasterWindow(QWindow *parent)
73
: QPaintDeviceWindow(*(
new
QRasterWindowPrivate), parent)
74
{
75
setSurfaceType(QSurface::RasterSurface);
76
d_func()->backingstore.reset(
new
QBackingStore(
this
));
77
}
78
79
QRasterWindow::~QRasterWindow()
80
{
81
Q_D(QRasterWindow);
82
// Delete backingstore while window is still alive, as it
83
// might need to reference the window in the process
84
d->backingstore.reset(
nullptr
);
85
}
86
87
/*!
88
\internal
89
*/
90
int
QRasterWindow::metric(PaintDeviceMetric metric)
const
91
{
92
Q_D(
const
QRasterWindow);
93
94
switch
(metric) {
95
case
PdmDepth:
96
return
d->backingstore->paintDevice()->depth();
97
default
:
98
break
;
99
}
100
return
QPaintDeviceWindow::metric(metric);
101
}
102
103
/*!
104
\internal
105
*/
106
QPaintDevice *QRasterWindow::redirected(QPoint *)
const
107
{
108
Q_D(
const
QRasterWindow);
109
return
d->backingstore->paintDevice();
110
}
111
112
void
QRasterWindow::resizeEvent(QResizeEvent *)
113
{
114
}
115
116
QT_END_NAMESPACE
117
118
#
include
"moc_qrasterwindow.cpp"
QRasterWindowPrivate
Definition
qrasterwindow.cpp:35
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
qtbase
src
gui
kernel
qrasterwindow.cpp
Generated on
for Qt by
1.16.1