Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qrasterwindow.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
5 | ** | - | ||||||
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
9 | ** Commercial License Usage | - | ||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
16 | ** | - | ||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
24 | ** | - | ||||||
25 | ** GNU General Public License Usage | - | ||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
35 | ** | - | ||||||
36 | ** $QT_END_LICENSE$ | - | ||||||
37 | ** | - | ||||||
38 | ****************************************************************************/ | - | ||||||
39 | - | |||||||
40 | #include "qrasterwindow.h" | - | ||||||
41 | - | |||||||
42 | #include <QtGui/private/qpaintdevicewindow_p.h> | - | ||||||
43 | - | |||||||
44 | #include <QtGui/QBackingStore> | - | ||||||
45 | #include <QtGui/QPainter> | - | ||||||
46 | - | |||||||
47 | QT_BEGIN_NAMESPACE | - | ||||||
48 | - | |||||||
49 | /*! | - | ||||||
50 | \class QRasterWindow | - | ||||||
51 | \inmodule QtGui | - | ||||||
52 | \since 5.4 | - | ||||||
53 | \brief QRasterWindow is a convenience class for using QPainter on a QWindow | - | ||||||
54 | - | |||||||
55 | QRasterWindow is a QWindow with a raster-based, non-OpenGL surface. On top of | - | ||||||
56 | the functionality offered by QWindow, QRasterWindow adds a virtual | - | ||||||
57 | paintEvent() function and the possibility to open a QPainter on itself. The | - | ||||||
58 | underlying paint engine will be the raster one, meaning that all drawing will | - | ||||||
59 | happen on the CPU. For performing accelerated, OpenGL-based drawing, use | - | ||||||
60 | QOpenGLWindow instead. | - | ||||||
61 | - | |||||||
62 | Internally the class is thin wrapper for QWindow and QBackingStore | - | ||||||
63 | and is very similar to the \l{Raster Window Example}{Raster Window | - | ||||||
64 | Example} that uses these classes directly. | - | ||||||
65 | - | |||||||
66 | \sa QPaintDeviceWindow::paintEvent(), QPaintDeviceWindow::update() | - | ||||||
67 | */ | - | ||||||
68 | - | |||||||
69 | class QRasterWindowPrivate : public QPaintDeviceWindowPrivate | - | ||||||
70 | { | - | ||||||
71 | Q_DECLARE_PUBLIC(QRasterWindow) | - | ||||||
72 | public: | - | ||||||
73 | void beginPaint(const QRegion ®ion) Q_DECL_OVERRIDE | - | ||||||
74 | { | - | ||||||
75 | Q_Q(QRasterWindow); | - | ||||||
76 | const QSize size = q->size(); | - | ||||||
77 | if (backingstore->size() != size) {
| 0 | ||||||
78 | backingstore->resize(size); | - | ||||||
79 | markWindowAsDirty(); | - | ||||||
80 | } never executed: end of block | 0 | ||||||
81 | backingstore->beginPaint(region); | - | ||||||
82 | } never executed: end of block | 0 | ||||||
83 | - | |||||||
84 | void endPaint() Q_DECL_OVERRIDE | - | ||||||
85 | { | - | ||||||
86 | backingstore->endPaint(); | - | ||||||
87 | } never executed: end of block | 0 | ||||||
88 | - | |||||||
89 | void flush(const QRegion ®ion) Q_DECL_OVERRIDE | - | ||||||
90 | { | - | ||||||
91 | Q_Q(QRasterWindow); | - | ||||||
92 | backingstore->flush(region, q); | - | ||||||
93 | } never executed: end of block | 0 | ||||||
94 | - | |||||||
95 | QScopedPointer<QBackingStore> backingstore; | - | ||||||
96 | }; | - | ||||||
97 | - | |||||||
98 | /*! | - | ||||||
99 | Constructs a new QRasterWindow with \a parent. | - | ||||||
100 | */ | - | ||||||
101 | QRasterWindow::QRasterWindow(QWindow *parent) | - | ||||||
102 | : QPaintDeviceWindow(*(new QRasterWindowPrivate), parent) | - | ||||||
103 | { | - | ||||||
104 | setSurfaceType(QSurface::RasterSurface); | - | ||||||
105 | d_func()->backingstore.reset(new QBackingStore(this)); | - | ||||||
106 | } never executed: end of block | 0 | ||||||
107 | - | |||||||
108 | /*! | - | ||||||
109 | \internal | - | ||||||
110 | */ | - | ||||||
111 | int QRasterWindow::metric(PaintDeviceMetric metric) const | - | ||||||
112 | { | - | ||||||
113 | Q_D(const QRasterWindow); | - | ||||||
114 | - | |||||||
115 | switch (metric) { | - | ||||||
116 | case PdmDepth: never executed: case PdmDepth: | 0 | ||||||
117 | return d->backingstore->paintDevice()->depth(); never executed: return d->backingstore->paintDevice()->depth(); | 0 | ||||||
118 | default: never executed: default: | 0 | ||||||
119 | break; never executed: break; | 0 | ||||||
120 | } | - | ||||||
121 | return QPaintDeviceWindow::metric(metric); never executed: return QPaintDeviceWindow::metric(metric); | 0 | ||||||
122 | } | - | ||||||
123 | - | |||||||
124 | /*! | - | ||||||
125 | \internal | - | ||||||
126 | */ | - | ||||||
127 | QPaintDevice *QRasterWindow::redirected(QPoint *) const | - | ||||||
128 | { | - | ||||||
129 | Q_D(const QRasterWindow); | - | ||||||
130 | return d->backingstore->paintDevice(); never executed: return d->backingstore->paintDevice(); | 0 | ||||||
131 | } | - | ||||||
132 | - | |||||||
133 | QT_END_NAMESPACE | - | ||||||
Source code | Switch to Preprocessed file |