Line | Source Code | Coverage |
---|
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 <private/qemulationpaintengine_p.h> | - |
43 | #include <private/qpainter_p.h> | - |
44 | #include <private/qtextengine_p.h> | - |
45 | #include <qdebug.h> | - |
46 | | - |
47 | QT_BEGIN_NAMESPACE | - |
48 | | - |
49 | QEmulationPaintEngine::QEmulationPaintEngine(QPaintEngineEx *engine) | - |
50 | : real_engine(engine) | - |
51 | { | - |
52 | QPaintEngine::state = real_engine->state(); executed (the execution status of this line is deduced): QPaintEngine::state = real_engine->state(); | - |
53 | } executed: } Execution Count:2942 | 2942 |
54 | | - |
55 | | - |
56 | QPaintEngine::Type QEmulationPaintEngine::type() const | - |
57 | { | - |
58 | return real_engine->type(); never executed: return real_engine->type(); | 0 |
59 | } | - |
60 | | - |
61 | bool QEmulationPaintEngine::begin(QPaintDevice *) | - |
62 | { | - |
63 | return true; never executed: return true; | 0 |
64 | } | - |
65 | | - |
66 | bool QEmulationPaintEngine::end() | - |
67 | { | - |
68 | return true; never executed: return true; | 0 |
69 | } | - |
70 | | - |
71 | | - |
72 | QPainterState *QEmulationPaintEngine::createState(QPainterState *orig) const | - |
73 | { | - |
74 | return real_engine->createState(orig); executed: return real_engine->createState(orig); Execution Count:12 | 12 |
75 | } | - |
76 | | - |
77 | void QEmulationPaintEngine::fill(const QVectorPath &path, const QBrush &brush) | - |
78 | { | - |
79 | QPainterState *s = state(); executed (the execution status of this line is deduced): QPainterState *s = state(); | - |
80 | | - |
81 | if (s->bgMode == Qt::OpaqueMode) { evaluated: s->bgMode == Qt::OpaqueMode yes Evaluation Count:5169 | yes Evaluation Count:2797 |
| 2797-5169 |
82 | Qt::BrushStyle style = brush.style(); executed (the execution status of this line is deduced): Qt::BrushStyle style = brush.style(); | - |
83 | if ((style >= Qt::Dense1Pattern && style <= Qt::DiagCrossPattern) || (style == Qt::TexturePattern )) evaluated: style >= Qt::Dense1Pattern yes Evaluation Count:5165 | yes Evaluation Count:4 |
partially evaluated: style <= Qt::DiagCrossPattern yes Evaluation Count:5165 | no Evaluation Count:0 |
partially evaluated: (style == Qt::TexturePattern ) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-5165 |
84 | real_engine->fill(path, s->bgBrush); executed: real_engine->fill(path, s->bgBrush); Execution Count:5165 | 5165 |
85 | } executed: } Execution Count:5169 | 5169 |
86 | | - |
87 | Qt::BrushStyle style = qbrush_style(brush); executed (the execution status of this line is deduced): Qt::BrushStyle style = qbrush_style(brush); | - |
88 | if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) { evaluated: style >= Qt::LinearGradientPattern yes Evaluation Count:6 | yes Evaluation Count:7960 |
partially evaluated: style <= Qt::ConicalGradientPattern yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-7960 |
89 | const QGradient *g = brush.gradient(); executed (the execution status of this line is deduced): const QGradient *g = brush.gradient(); | - |
90 | | - |
91 | if (g->coordinateMode() > QGradient::LogicalMode) { evaluated: g->coordinateMode() > QGradient::LogicalMode yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
92 | if (g->coordinateMode() == QGradient::StretchToDeviceMode) { evaluated: g->coordinateMode() == QGradient::StretchToDeviceMode yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
93 | QBrush copy = brush; executed (the execution status of this line is deduced): QBrush copy = brush; | - |
94 | QTransform mat = copy.transform(); executed (the execution status of this line is deduced): QTransform mat = copy.transform(); | - |
95 | mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); executed (the execution status of this line is deduced): mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); | - |
96 | copy.setTransform(mat); executed (the execution status of this line is deduced): copy.setTransform(mat); | - |
97 | real_engine->fill(path, copy); executed (the execution status of this line is deduced): real_engine->fill(path, copy); | - |
98 | return; executed: return; Execution Count:1 | 1 |
99 | } else if (g->coordinateMode() == QGradient::ObjectBoundingMode) { partially evaluated: g->coordinateMode() == QGradient::ObjectBoundingMode yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
100 | QBrush copy = brush; executed (the execution status of this line is deduced): QBrush copy = brush; | - |
101 | QTransform mat = copy.transform(); executed (the execution status of this line is deduced): QTransform mat = copy.transform(); | - |
102 | QRectF r = path.controlPointRect(); executed (the execution status of this line is deduced): QRectF r = path.controlPointRect(); | - |
103 | mat.translate(r.x(), r.y()); executed (the execution status of this line is deduced): mat.translate(r.x(), r.y()); | - |
104 | mat.scale(r.width(), r.height()); executed (the execution status of this line is deduced): mat.scale(r.width(), r.height()); | - |
105 | copy.setTransform(mat); executed (the execution status of this line is deduced): copy.setTransform(mat); | - |
106 | real_engine->fill(path, copy); executed (the execution status of this line is deduced): real_engine->fill(path, copy); | - |
107 | return; executed: return; Execution Count:2 | 2 |
108 | } | - |
109 | } | - |
110 | } executed: } Execution Count:3 | 3 |
111 | | - |
112 | real_engine->fill(path, brush); executed (the execution status of this line is deduced): real_engine->fill(path, brush); | - |
113 | } executed: } Execution Count:7963 | 7963 |
114 | | - |
115 | void QEmulationPaintEngine::stroke(const QVectorPath &path, const QPen &pen) | - |
116 | { | - |
117 | QPainterState *s = state(); executed (the execution status of this line is deduced): QPainterState *s = state(); | - |
118 | | - |
119 | if (s->bgMode == Qt::OpaqueMode && pen.style() > Qt::SolidLine) { evaluated: s->bgMode == Qt::OpaqueMode yes Evaluation Count:16 | yes Evaluation Count:11170 |
partially evaluated: pen.style() > Qt::SolidLine no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-11170 |
120 | QPen bgPen = pen; never executed (the execution status of this line is deduced): QPen bgPen = pen; | - |
121 | bgPen.setBrush(s->bgBrush); never executed (the execution status of this line is deduced): bgPen.setBrush(s->bgBrush); | - |
122 | bgPen.setStyle(Qt::SolidLine); never executed (the execution status of this line is deduced): bgPen.setStyle(Qt::SolidLine); | - |
123 | real_engine->stroke(path, bgPen); never executed (the execution status of this line is deduced): real_engine->stroke(path, bgPen); | - |
124 | } | 0 |
125 | | - |
126 | QBrush brush = pen.brush(); executed (the execution status of this line is deduced): QBrush brush = pen.brush(); | - |
127 | QPen copy = pen; executed (the execution status of this line is deduced): QPen copy = pen; | - |
128 | Qt::BrushStyle style = qbrush_style(brush); executed (the execution status of this line is deduced): Qt::BrushStyle style = qbrush_style(brush); | - |
129 | if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) { partially evaluated: style >= Qt::LinearGradientPattern no Evaluation Count:0 | yes Evaluation Count:11186 |
never evaluated: style <= Qt::ConicalGradientPattern | 0-11186 |
130 | const QGradient *g = brush.gradient(); never executed (the execution status of this line is deduced): const QGradient *g = brush.gradient(); | - |
131 | | - |
132 | if (g->coordinateMode() > QGradient::LogicalMode) { never evaluated: g->coordinateMode() > QGradient::LogicalMode | 0 |
133 | if (g->coordinateMode() == QGradient::StretchToDeviceMode) { never evaluated: g->coordinateMode() == QGradient::StretchToDeviceMode | 0 |
134 | QTransform mat = brush.transform(); never executed (the execution status of this line is deduced): QTransform mat = brush.transform(); | - |
135 | mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); never executed (the execution status of this line is deduced): mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); | - |
136 | brush.setTransform(mat); never executed (the execution status of this line is deduced): brush.setTransform(mat); | - |
137 | copy.setBrush(brush); never executed (the execution status of this line is deduced): copy.setBrush(brush); | - |
138 | real_engine->stroke(path, copy); never executed (the execution status of this line is deduced): real_engine->stroke(path, copy); | - |
139 | return; | 0 |
140 | } else if (g->coordinateMode() == QGradient::ObjectBoundingMode) { never evaluated: g->coordinateMode() == QGradient::ObjectBoundingMode | 0 |
141 | QTransform mat = brush.transform(); never executed (the execution status of this line is deduced): QTransform mat = brush.transform(); | - |
142 | QRectF r = path.controlPointRect(); never executed (the execution status of this line is deduced): QRectF r = path.controlPointRect(); | - |
143 | mat.translate(r.x(), r.y()); never executed (the execution status of this line is deduced): mat.translate(r.x(), r.y()); | - |
144 | mat.scale(r.width(), r.height()); never executed (the execution status of this line is deduced): mat.scale(r.width(), r.height()); | - |
145 | brush.setTransform(mat); never executed (the execution status of this line is deduced): brush.setTransform(mat); | - |
146 | copy.setBrush(brush); never executed (the execution status of this line is deduced): copy.setBrush(brush); | - |
147 | real_engine->stroke(path, copy); never executed (the execution status of this line is deduced): real_engine->stroke(path, copy); | - |
148 | return; | 0 |
149 | } | - |
150 | } | - |
151 | } | 0 |
152 | | - |
153 | real_engine->stroke(path, pen); executed (the execution status of this line is deduced): real_engine->stroke(path, pen); | - |
154 | } executed: } Execution Count:11186 | 11186 |
155 | | - |
156 | void QEmulationPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) | - |
157 | { | - |
158 | real_engine->clip(path, op); executed (the execution status of this line is deduced): real_engine->clip(path, op); | - |
159 | } executed: } Execution Count:6 | 6 |
160 | | - |
161 | void QEmulationPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) | - |
162 | { | - |
163 | if (state()->bgMode == Qt::OpaqueMode && pm.isQBitmap()) partially evaluated: state()->bgMode == Qt::OpaqueMode no Evaluation Count:0 | yes Evaluation Count:3 |
never evaluated: pm.isQBitmap() | 0-3 |
164 | fillBGRect(r); never executed: fillBGRect(r); | 0 |
165 | real_engine->drawPixmap(r, pm, sr); executed (the execution status of this line is deduced): real_engine->drawPixmap(r, pm, sr); | - |
166 | } executed: } Execution Count:3 | 3 |
167 | | - |
168 | void QEmulationPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) | - |
169 | { | - |
170 | if (state()->bgMode == Qt::OpaqueMode) { never evaluated: state()->bgMode == Qt::OpaqueMode | 0 |
171 | const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); never executed (the execution status of this line is deduced): const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); | - |
172 | QRectF rect(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent + 1).toReal()); never executed (the execution status of this line is deduced): QRectF rect(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent + 1).toReal()); | - |
173 | fillBGRect(rect); never executed (the execution status of this line is deduced): fillBGRect(rect); | - |
174 | } | 0 |
175 | | - |
176 | QPainterState *s = state(); never executed (the execution status of this line is deduced): QPainterState *s = state(); | - |
177 | Qt::BrushStyle style = qbrush_style(s->pen.brush()); never executed (the execution status of this line is deduced): Qt::BrushStyle style = qbrush_style(s->pen.brush()); | - |
178 | if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) never evaluated: style >= Qt::LinearGradientPattern never evaluated: style <= Qt::ConicalGradientPattern | 0 |
179 | { | - |
180 | QPen savedPen = s->pen; never executed (the execution status of this line is deduced): QPen savedPen = s->pen; | - |
181 | QGradient g = *s->pen.brush().gradient(); never executed (the execution status of this line is deduced): QGradient g = *s->pen.brush().gradient(); | - |
182 | | - |
183 | if (g.coordinateMode() > QGradient::LogicalMode) { never evaluated: g.coordinateMode() > QGradient::LogicalMode | 0 |
184 | QTransform mat = s->pen.brush().transform(); never executed (the execution status of this line is deduced): QTransform mat = s->pen.brush().transform(); | - |
185 | if (g.coordinateMode() == QGradient::StretchToDeviceMode) { never evaluated: g.coordinateMode() == QGradient::StretchToDeviceMode | 0 |
186 | mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); never executed (the execution status of this line is deduced): mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); | - |
187 | } else if (g.coordinateMode() == QGradient::ObjectBoundingMode) { never executed: } never evaluated: g.coordinateMode() == QGradient::ObjectBoundingMode | 0 |
188 | const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); never executed (the execution status of this line is deduced): const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); | - |
189 | QRectF r(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent + 1).toReal()); never executed (the execution status of this line is deduced): QRectF r(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent + 1).toReal()); | - |
190 | mat.translate(r.x(), r.y()); never executed (the execution status of this line is deduced): mat.translate(r.x(), r.y()); | - |
191 | mat.scale(r.width(), r.height()); never executed (the execution status of this line is deduced): mat.scale(r.width(), r.height()); | - |
192 | } | 0 |
193 | g.setCoordinateMode(QGradient::LogicalMode); never executed (the execution status of this line is deduced): g.setCoordinateMode(QGradient::LogicalMode); | - |
194 | QBrush brush(g); never executed (the execution status of this line is deduced): QBrush brush(g); | - |
195 | brush.setTransform(mat); never executed (the execution status of this line is deduced): brush.setTransform(mat); | - |
196 | s->pen.setBrush(brush); never executed (the execution status of this line is deduced): s->pen.setBrush(brush); | - |
197 | penChanged(); never executed (the execution status of this line is deduced): penChanged(); | - |
198 | real_engine->drawTextItem(p, textItem); never executed (the execution status of this line is deduced): real_engine->drawTextItem(p, textItem); | - |
199 | s->pen = savedPen; never executed (the execution status of this line is deduced): s->pen = savedPen; | - |
200 | penChanged(); never executed (the execution status of this line is deduced): penChanged(); | - |
201 | return; | 0 |
202 | } | - |
203 | } | 0 |
204 | | - |
205 | real_engine->drawTextItem(p, textItem); never executed (the execution status of this line is deduced): real_engine->drawTextItem(p, textItem); | - |
206 | } | 0 |
207 | | - |
208 | void QEmulationPaintEngine::drawStaticTextItem(QStaticTextItem *item) | - |
209 | { | - |
210 | real_engine->drawStaticTextItem(item); never executed (the execution status of this line is deduced): real_engine->drawStaticTextItem(item); | - |
211 | } | 0 |
212 | | - |
213 | void QEmulationPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) | - |
214 | { | - |
215 | if (state()->bgMode == Qt::OpaqueMode && pixmap.isQBitmap()) never evaluated: state()->bgMode == Qt::OpaqueMode never evaluated: pixmap.isQBitmap() | 0 |
216 | fillBGRect(r); never executed: fillBGRect(r); | 0 |
217 | real_engine->drawTiledPixmap(r, pixmap, s); never executed (the execution status of this line is deduced): real_engine->drawTiledPixmap(r, pixmap, s); | - |
218 | } | 0 |
219 | | - |
220 | void QEmulationPaintEngine::drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags) | - |
221 | { | - |
222 | real_engine->drawImage(r, pm, sr, flags); never executed (the execution status of this line is deduced): real_engine->drawImage(r, pm, sr, flags); | - |
223 | } | 0 |
224 | | - |
225 | void QEmulationPaintEngine::clipEnabledChanged() | - |
226 | { | - |
227 | real_engine->clipEnabledChanged(); never executed (the execution status of this line is deduced): real_engine->clipEnabledChanged(); | - |
228 | } | 0 |
229 | | - |
230 | void QEmulationPaintEngine::penChanged() | - |
231 | { | - |
232 | real_engine->penChanged(); executed (the execution status of this line is deduced): real_engine->penChanged(); | - |
233 | } executed: } Execution Count:13996 | 13996 |
234 | | - |
235 | void QEmulationPaintEngine::brushChanged() | - |
236 | { | - |
237 | real_engine->brushChanged(); executed (the execution status of this line is deduced): real_engine->brushChanged(); | - |
238 | } executed: } Execution Count:5033 | 5033 |
239 | | - |
240 | void QEmulationPaintEngine::brushOriginChanged() | - |
241 | { | - |
242 | real_engine->brushOriginChanged(); never executed (the execution status of this line is deduced): real_engine->brushOriginChanged(); | - |
243 | } | 0 |
244 | | - |
245 | void QEmulationPaintEngine::opacityChanged() | - |
246 | { | - |
247 | real_engine->opacityChanged(); never executed (the execution status of this line is deduced): real_engine->opacityChanged(); | - |
248 | } | 0 |
249 | | - |
250 | void QEmulationPaintEngine::compositionModeChanged() | - |
251 | { | - |
252 | real_engine->compositionModeChanged(); never executed (the execution status of this line is deduced): real_engine->compositionModeChanged(); | - |
253 | } | 0 |
254 | | - |
255 | void QEmulationPaintEngine::renderHintsChanged() | - |
256 | { | - |
257 | real_engine->renderHintsChanged(); executed (the execution status of this line is deduced): real_engine->renderHintsChanged(); | - |
258 | } executed: } Execution Count:6 | 6 |
259 | | - |
260 | void QEmulationPaintEngine::transformChanged() | - |
261 | { | - |
262 | real_engine->transformChanged(); executed (the execution status of this line is deduced): real_engine->transformChanged(); | - |
263 | } executed: } Execution Count:3 | 3 |
264 | | - |
265 | void QEmulationPaintEngine::setState(QPainterState *s) | - |
266 | { | - |
267 | QPaintEngine::state = s; executed (the execution status of this line is deduced): QPaintEngine::state = s; | - |
268 | real_engine->setState(s); executed (the execution status of this line is deduced): real_engine->setState(s); | - |
269 | } executed: } Execution Count:2966 | 2966 |
270 | | - |
271 | void QEmulationPaintEngine::beginNativePainting() | - |
272 | { | - |
273 | real_engine->beginNativePainting(); never executed (the execution status of this line is deduced): real_engine->beginNativePainting(); | - |
274 | } | 0 |
275 | | - |
276 | void QEmulationPaintEngine::endNativePainting() | - |
277 | { | - |
278 | real_engine->endNativePainting(); never executed (the execution status of this line is deduced): real_engine->endNativePainting(); | - |
279 | } | 0 |
280 | | - |
281 | void QEmulationPaintEngine::fillBGRect(const QRectF &r) | - |
282 | { | - |
283 | qreal pts[] = { r.x(), r.y(), r.x() + r.width(), r.y(), never executed (the execution status of this line is deduced): qreal pts[] = { r.x(), r.y(), r.x() + r.width(), r.y(), | - |
284 | r.x() + r.width(), r.y() + r.height(), r.x(), r.y() + r.height() }; never executed (the execution status of this line is deduced): r.x() + r.width(), r.y() + r.height(), r.x(), r.y() + r.height() }; | - |
285 | QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); never executed (the execution status of this line is deduced): QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); | - |
286 | real_engine->fill(vp, state()->bgBrush); never executed (the execution status of this line is deduced): real_engine->fill(vp, state()->bgBrush); | - |
287 | } | 0 |
288 | | - |
289 | QT_END_NAMESPACE | - |
290 | | - |
| | |