painting/qbackingstore.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include <qbackingstore.h> -
43#include <qwindow.h> -
44#include <qpixmap.h> -
45#include <qpa/qplatformbackingstore.h> -
46#include <qpa/qplatformintegration.h> -
47#include <qscreen.h> -
48 -
49#include <private/qguiapplication_p.h> -
50#include <private/qwindow_p.h> -
51 -
52QT_BEGIN_NAMESPACE -
53 -
54class QBackingStorePrivate -
55{ -
56public: -
57 QBackingStorePrivate(QWindow *w) -
58 : window(w) -
59 { -
60 }
executed: }
Execution Count:2500
2500
61 -
62 QWindow *window; -
63 QPlatformBackingStore *platformBackingStore; -
64 QRegion staticContents; -
65 QSize size; -
66}; -
67 -
68/*! -
69 \class QBackingStore -
70 \since 5.0 -
71 \inmodule QtGui -
72 -
73 \brief The QBackingStore class provides a drawing area for QWindow. -
74 -
75 QBackingStore enables the use of QPainter to paint on a QWindow with type -
76 RasterSurface. The other way of rendering to a QWindow is through the use -
77 of OpenGL with QOpenGLContext. -
78 -
79 A QBackingStore contains a buffered representation of the window contents, -
80 and thus supports partial updates by using QPainter to only update a sub -
81 region of the window contents. -
82 -
83 QBackingStore might be used by an application that wants to use QPainter -
84 without OpenGL acceleration and without the extra overhead of using the -
85 QWidget or QGraphicsView UI stacks. For an example of how to use -
86 QBackingStore see the \l{gui/rasterwindow}{Raster Window} example. -
87*/ -
88 -
89/*! -
90 Flushes the given \a region from the specified window \a win onto the -
91 screen. -
92 -
93 Note that the \a offset parameter is currently unused. -
94*/ -
95void QBackingStore::flush(const QRegion &region, QWindow *win, const QPoint &offset) -
96{ -
97 if (!win)
evaluated: !win
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:8020
2-8020
98 win = window();
executed: win = window();
Execution Count:2
2
99 -
100 if (win && !qt_window_private(win)->receivedExpose)
partially evaluated: win
TRUEFALSE
yes
Evaluation Count:8022
no
Evaluation Count:0
evaluated: !qt_window_private(win)->receivedExpose
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:8013
0-8022
101 qWarning("QBackingStore::flush() called with non-exposed window, behavior is undefined");
executed: QMessageLogger("painting/qbackingstore.cpp", 101, __PRETTY_FUNCTION__).warning("QBackingStore::flush() called with non-exposed window, behavior is undefined");
Execution Count:9
9
102 -
103 d_ptr->platformBackingStore->flush(win, region, offset);
executed (the execution status of this line is deduced): d_ptr->platformBackingStore->flush(win, region, offset);
-
104}
executed: }
Execution Count:8022
8022
105 -
106/*! -
107 \fn QPaintDevice* QBackingStore::paintDevice() -
108 -
109 Implement this function to return the appropriate paint device. -
110*/ -
111QPaintDevice *QBackingStore::paintDevice() -
112{ -
113 return d_ptr->platformBackingStore->paintDevice();
executed: return d_ptr->platformBackingStore->paintDevice();
Execution Count:9395
9395
114} -
115 -
116/*! -
117 Constructs an empty surface for the given top-level \a window. -
118*/ -
119QBackingStore::QBackingStore(QWindow *window) -
120 : d_ptr(new QBackingStorePrivate(window)) -
121{ -
122 d_ptr->platformBackingStore = QGuiApplicationPrivate::platformIntegration()->createPlatformBackingStore(window);
executed (the execution status of this line is deduced): d_ptr->platformBackingStore = QGuiApplicationPrivate::platformIntegration()->createPlatformBackingStore(window);
-
123}
executed: }
Execution Count:2500
2500
124 -
125/*! -
126 Destroys this surface. -
127*/ -
128QBackingStore::~QBackingStore() -
129{ -
130 delete d_ptr->platformBackingStore;
executed (the execution status of this line is deduced): delete d_ptr->platformBackingStore;
-
131}
executed: }
Execution Count:2499
2499
132 -
133/*! -
134 Returns a pointer to the top-level window associated with this -
135 surface. -
136*/ -
137QWindow* QBackingStore::window() const -
138{ -
139 return d_ptr->window;
executed: return d_ptr->window;
Execution Count:2
2
140} -
141 -
142/*! -
143 This function is called before painting onto the surface begins, -
144 with the \a region in which the painting will occur. -
145 -
146 \sa endPaint(), paintDevice() -
147*/ -
148 -
149void QBackingStore::beginPaint(const QRegion &region) -
150{ -
151 d_ptr->platformBackingStore->beginPaint(region);
executed (the execution status of this line is deduced): d_ptr->platformBackingStore->beginPaint(region);
-
152}
executed: }
Execution Count:6185
6185
153 -
154/*! -
155 This function is called after painting onto the surface has ended. -
156 -
157 \sa beginPaint(), paintDevice() -
158*/ -
159void QBackingStore::endPaint() -
160{ -
161 d_ptr->platformBackingStore->endPaint();
executed (the execution status of this line is deduced): d_ptr->platformBackingStore->endPaint();
-
162}
executed: }
Execution Count:6185
6185
163 -
164/*! -
165 Sets the size of the windowsurface to be \a size. -
166 -
167 \sa size() -
168*/ -
169void QBackingStore::resize(const QSize &size) -
170{ -
171 d_ptr->size = size;
executed (the execution status of this line is deduced): d_ptr->size = size;
-
172 d_ptr->platformBackingStore->resize(size, d_ptr->staticContents);
executed (the execution status of this line is deduced): d_ptr->platformBackingStore->resize(size, d_ptr->staticContents);
-
173}
executed: }
Execution Count:2703
2703
174 -
175/*! -
176 Returns the current size of the windowsurface. -
177*/ -
178QSize QBackingStore::size() const -
179{ -
180 return d_ptr->size;
executed: return d_ptr->size;
Execution Count:9055
9055
181} -
182 -
183/*! -
184 Scrolls the given \a area \a dx pixels to the right and \a dy -
185 downward; both \a dx and \a dy may be negative. -
186 -
187 Returns true if the area was scrolled successfully; false otherwise. -
188*/ -
189bool QBackingStore::scroll(const QRegion &area, int dx, int dy) -
190{ -
191 Q_UNUSED(area);
executed (the execution status of this line is deduced): (void)area;;
-
192 Q_UNUSED(dx);
executed (the execution status of this line is deduced): (void)dx;;
-
193 Q_UNUSED(dy);
executed (the execution status of this line is deduced): (void)dy;;
-
194 -
195 return d_ptr->platformBackingStore->scroll(area, dx, dy);
executed: return d_ptr->platformBackingStore->scroll(area, dx, dy);
Execution Count:1975
1975
196} -
197 -
198void QBackingStore::setStaticContents(const QRegion &region) -
199{ -
200 d_ptr->staticContents = region;
never executed (the execution status of this line is deduced): d_ptr->staticContents = region;
-
201}
never executed: }
0
202 -
203QRegion QBackingStore::staticContents() const -
204{ -
205 return d_ptr->staticContents;
never executed: return d_ptr->staticContents;
0
206} -
207 -
208bool QBackingStore::hasStaticContents() const -
209{ -
210 return !d_ptr->staticContents.isEmpty();
never executed: return !d_ptr->staticContents.isEmpty();
0
211} -
212 -
213void Q_GUI_EXPORT qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset) -
214{ -
215 // make sure we don't detach -
216 uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits());
executed (the execution status of this line is deduced): uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits());
-
217 -
218 int lineskip = img.bytesPerLine();
executed (the execution status of this line is deduced): int lineskip = img.bytesPerLine();
-
219 int depth = img.depth() >> 3;
executed (the execution status of this line is deduced): int depth = img.depth() >> 3;
-
220 -
221 const QRect imageRect(0, 0, img.width(), img.height());
executed (the execution status of this line is deduced): const QRect imageRect(0, 0, img.width(), img.height());
-
222 const QRect r = rect & imageRect & imageRect.translated(-offset);
executed (the execution status of this line is deduced): const QRect r = rect & imageRect & imageRect.translated(-offset);
-
223 const QPoint p = rect.topLeft() + offset;
executed (the execution status of this line is deduced): const QPoint p = rect.topLeft() + offset;
-
224 -
225 if (r.isEmpty())
partially evaluated: r.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1903
0-1903
226 return;
never executed: return;
0
227 -
228 const uchar *src;
executed (the execution status of this line is deduced): const uchar *src;
-
229 uchar *dest;
executed (the execution status of this line is deduced): uchar *dest;
-
230 -
231 if (r.top() < p.y()) {
evaluated: r.top() < p.y()
TRUEFALSE
yes
Evaluation Count:377
yes
Evaluation Count:1526
377-1526
232 src = mem + r.bottom() * lineskip + r.left() * depth;
executed (the execution status of this line is deduced): src = mem + r.bottom() * lineskip + r.left() * depth;
-
233 dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth;
executed (the execution status of this line is deduced): dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth;
-
234 lineskip = -lineskip;
executed (the execution status of this line is deduced): lineskip = -lineskip;
-
235 } else {
executed: }
Execution Count:377
377
236 src = mem + r.top() * lineskip + r.left() * depth;
executed (the execution status of this line is deduced): src = mem + r.top() * lineskip + r.left() * depth;
-
237 dest = mem + p.y() * lineskip + p.x() * depth;
executed (the execution status of this line is deduced): dest = mem + p.y() * lineskip + p.x() * depth;
-
238 }
executed: }
Execution Count:1526
1526
239 -
240 const int w = r.width();
executed (the execution status of this line is deduced): const int w = r.width();
-
241 int h = r.height();
executed (the execution status of this line is deduced): int h = r.height();
-
242 const int bytes = w * depth;
executed (the execution status of this line is deduced): const int bytes = w * depth;
-
243 -
244 // overlapping segments? -
245 if (offset.y() == 0 && qAbs(offset.x()) < w) {
evaluated: offset.y() == 0
TRUEFALSE
yes
Evaluation Count:953
yes
Evaluation Count:950
evaluated: qAbs(offset.x()) < w
TRUEFALSE
yes
Evaluation Count:916
yes
Evaluation Count:37
37-953
246 do { -
247 ::memmove(dest, src, bytes);
executed (the execution status of this line is deduced): ::memmove(dest, src, bytes);
-
248 dest += lineskip;
executed (the execution status of this line is deduced): dest += lineskip;
-
249 src += lineskip;
executed (the execution status of this line is deduced): src += lineskip;
-
250 } while (--h);
executed: }
Execution Count:149976
evaluated: --h
TRUEFALSE
yes
Evaluation Count:149060
yes
Evaluation Count:916
916-149976
251 } else {
executed: }
Execution Count:916
916
252 do { -
253 ::memcpy(dest, src, bytes);
executed (the execution status of this line is deduced): ::memcpy(dest, src, bytes);
-
254 dest += lineskip;
executed (the execution status of this line is deduced): dest += lineskip;
-
255 src += lineskip;
executed (the execution status of this line is deduced): src += lineskip;
-
256 } while (--h);
executed: }
Execution Count:147620
evaluated: --h
TRUEFALSE
yes
Evaluation Count:146633
yes
Evaluation Count:987
987-147620
257 }
executed: }
Execution Count:987
987
258} -
259 -
260QPlatformBackingStore *QBackingStore::handle() const -
261{ -
262 return d_ptr->platformBackingStore;
never executed: return d_ptr->platformBackingStore;
0
263} -
264 -
265QT_END_NAMESPACE -
266 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial