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